Helios-Core.st 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  1. Smalltalk current createPackage: 'Helios-Core'!
  2. Object subclass: #HLModel
  3. instanceVariableNames: 'announcer environment'
  4. package: 'Helios-Core'!
  5. !HLModel commentStamp!
  6. I am the abstract superclass of all models of Helios.
  7. I am the "Model" part of the MVC pattern implementation in Helios.
  8. I provide access to an `Environment` object and both a local (model-specific) and global (system-specific) announcer.
  9. The `#withChangesDo:` method is handy for performing model changes ensuring that all widgets are aware of the change and can prevent it from happening.
  10. Modifications of the system should be done via commands (see `HLCommand` and subclasses).!
  11. !HLModel methodsFor: 'accessing'!
  12. announcer
  13. ^ announcer ifNil: [ announcer := Announcer new ]
  14. !
  15. environment
  16. ^ environment ifNil: [ self manager environment ]
  17. !
  18. environment: anEnvironment
  19. environment := anEnvironment
  20. !
  21. manager
  22. ^ HLManager current
  23. !
  24. systemAnnouncer
  25. ^ self environment systemAnnouncer
  26. ! !
  27. !HLModel methodsFor: 'error handling'!
  28. withChangesDo: aBlock
  29. [
  30. self announcer announce: (HLAboutToChange new
  31. actionBlock: aBlock).
  32. aBlock value.
  33. ]
  34. on: HLChangeForbidden
  35. do: [ :ex | ]
  36. ! !
  37. !HLModel methodsFor: 'testing'!
  38. isBrowserModel
  39. ^ false
  40. !
  41. isReferencesModel
  42. ^ false
  43. !
  44. isToolModel
  45. ^ false
  46. ! !
  47. HLModel subclass: #HLToolModel
  48. instanceVariableNames: 'selectedClass selectedPackage selectedProtocol selectedSelector'
  49. package: 'Helios-Core'!
  50. !HLToolModel commentStamp!
  51. I am a model specific to package and class manipulation. All browsers should either use me or a subclass as their model.
  52. I provide methods for package, class, protocol and method manipulation and access, forwarding to my environment.
  53. I also handle compilation of classes and methods as well as compilation and parsing errors.!
  54. !HLToolModel methodsFor: 'accessing'!
  55. allSelectors
  56. ^ self environment allSelectors
  57. !
  58. availableClassNames
  59. ^ self environment availableClassNames
  60. !
  61. availablePackageNames
  62. ^ self environment availablePackageNames
  63. !
  64. availablePackages
  65. ^ self environment availablePackageNames
  66. !
  67. availableProtocols
  68. ^ self environment availableProtocolsFor: self selectedClass
  69. !
  70. packages
  71. ^ self environment packages
  72. !
  73. selectedClass
  74. ^ selectedClass
  75. !
  76. selectedClass: aClass
  77. (self selectedClass = aClass and: [ aClass isNil ])
  78. ifTrue: [ ^ self ].
  79. self withChangesDo: [
  80. selectedClass = aClass ifTrue: [
  81. self selectedProtocol: nil ].
  82. aClass
  83. ifNil: [ selectedClass := nil ]
  84. ifNotNil: [
  85. self selectedPackage: aClass theNonMetaClass package.
  86. self showInstance
  87. ifTrue: [ selectedClass := aClass theNonMetaClass ]
  88. ifFalse: [ selectedClass := aClass theMetaClass ] ].
  89. self selectedProtocol: nil.
  90. self announcer announce: (HLClassSelected on: self selectedClass) ]
  91. !
  92. selectedMethod
  93. ^ self selectedClass ifNotNil: [
  94. self selectedClass methodDictionary
  95. at: selectedSelector
  96. ifAbsent: [ nil ] ]
  97. !
  98. selectedMethod: aCompiledMethod
  99. selectedSelector = aCompiledMethod ifTrue: [ ^ self ].
  100. self withChangesDo: [
  101. aCompiledMethod
  102. ifNil: [ selectedSelector := nil ]
  103. ifNotNil: [
  104. selectedClass := aCompiledMethod methodClass.
  105. selectedPackage := selectedClass theNonMetaClass package.
  106. selectedSelector := aCompiledMethod selector ].
  107. self announcer announce: (HLMethodSelected on: aCompiledMethod) ]
  108. !
  109. selectedPackage
  110. ^ selectedPackage
  111. !
  112. selectedPackage: aPackage
  113. selectedPackage = aPackage ifTrue: [ ^ self ].
  114. self withChangesDo: [
  115. selectedPackage := aPackage.
  116. self selectedClass: nil.
  117. self announcer announce: (HLPackageSelected on: aPackage) ]
  118. !
  119. selectedProtocol
  120. ^ selectedProtocol
  121. !
  122. selectedProtocol: aString
  123. selectedProtocol = aString ifTrue: [ ^ self ].
  124. self withChangesDo: [
  125. selectedProtocol := aString.
  126. self selectedMethod: nil.
  127. self announcer announce: (HLProtocolSelected on: aString) ]
  128. ! !
  129. !HLToolModel methodsFor: 'actions'!
  130. addInstVarNamed: aString
  131. self environment addInstVarNamed: aString to: self selectedClass.
  132. self announcer announce: (HLInstVarAdded new
  133. theClass: self selectedClass;
  134. variableName: aString;
  135. yourself)
  136. !
  137. save: aString
  138. self announcer announce: HLSourceCodeSaved new.
  139. (self shouldCompileClassDefinition: aString)
  140. ifTrue: [ self compileClassDefinition: aString ]
  141. ifFalse: [ self compileMethod: aString ]
  142. !
  143. saveSourceCode
  144. self announcer announce: HLSaveSourceCode new
  145. ! !
  146. !HLToolModel methodsFor: 'commands actions'!
  147. commitPackage
  148. "self
  149. withHelperLabelled: 'Committing package ', self selectedPackage name, '...'
  150. do: [ "self environment commitPackage: self selectedPackage" ]"
  151. !
  152. copyClassTo: aClassName
  153. self withChangesDo: [
  154. self environment
  155. copyClass: self selectedClass theNonMetaClass
  156. to: aClassName ]
  157. !
  158. moveClassToPackage: aPackageName
  159. self withChangesDo: [
  160. self environment
  161. moveClass: self selectedClass theNonMetaClass
  162. toPackage: aPackageName ]
  163. !
  164. moveMethodToClass: aClassName
  165. self withChangesDo: [
  166. self environment
  167. moveMethod: self selectedMethod
  168. toClass: aClassName ]
  169. !
  170. moveMethodToProtocol: aProtocol
  171. self withChangesDo: [
  172. self environment
  173. moveMethod: self selectedMethod
  174. toProtocol: aProtocol ]
  175. !
  176. openClassNamed: aString
  177. | class |
  178. self withChangesDo: [
  179. class := self environment classNamed: aString.
  180. self selectedPackage: class package.
  181. self selectedClass: class ]
  182. !
  183. removeClass
  184. self withChangesDo: [
  185. self manager
  186. confirm: 'Do you REALLY want to remove class ', self selectedClass name
  187. ifTrue: [ self environment removeClass: self selectedClass ] ]
  188. !
  189. removeMethod
  190. self withChangesDo: [
  191. self manager
  192. confirm: 'Do you REALLY want to remove method ', self selectedMethod methodClass name,' >> #', self selectedMethod selector
  193. ifTrue: [ self environment removeMethod: self selectedMethod ] ]
  194. !
  195. removeProtocol
  196. self withChangesDo: [
  197. self manager
  198. confirm: 'Do you REALLY want to remove protocol ', self selectedProtocol
  199. ifTrue: [ self environment
  200. removeProtocol: self selectedProtocol
  201. from: self selectedClass ] ]
  202. !
  203. renameClassTo: aClassName
  204. self withChangesDo: [
  205. self environment
  206. renameClass: self selectedClass theNonMetaClass
  207. to: aClassName ]
  208. !
  209. renameProtocolTo: aString
  210. self withChangesDo: [
  211. self environment
  212. renameProtocol: self selectedProtocol
  213. to: aString
  214. in: self selectedClass ]
  215. ! !
  216. !HLToolModel methodsFor: 'compiling'!
  217. compileClassComment: aString
  218. self environment
  219. compileClassComment: aString
  220. for: self selectedClass
  221. !
  222. compileClassDefinition: aString
  223. self environment compileClassDefinition: aString
  224. !
  225. compileMethod: aString
  226. | method |
  227. self withCompileErrorHandling: [
  228. method := self environment
  229. compileMethod: aString
  230. for: self selectedClass
  231. protocol: self compilationProtocol.
  232. self selectedMethod: method ]
  233. ! !
  234. !HLToolModel methodsFor: 'defaults'!
  235. allProtocol
  236. ^ '-- all --'
  237. !
  238. unclassifiedProtocol
  239. ^ 'as yet unclassified'
  240. ! !
  241. !HLToolModel methodsFor: 'error handling'!
  242. handleCompileError: anError
  243. self announcer announce: (HLCompileErrorRaised new
  244. error: anError;
  245. yourself)
  246. !
  247. handleParseError: anError
  248. | split line column messageToInsert |
  249. split := anError messageText tokenize: ' : '.
  250. messageToInsert := split second.
  251. "21 = 'Parse error on line ' size + 1"
  252. split := split first copyFrom: 21 to: split first size.
  253. split := split tokenize: ' column '.
  254. line := split first.
  255. column := split second.
  256. self announcer announce: (HLParseErrorRaised new
  257. line: line asNumber;
  258. column: column asNumber;
  259. message: messageToInsert;
  260. error: anError;
  261. yourself)
  262. !
  263. handleUnkownVariableError: anError
  264. self announcer announce: (HLUnknownVariableErrorRaised new
  265. error: anError;
  266. yourself)
  267. !
  268. withCompileErrorHandling: aBlock
  269. self environment
  270. evaluate: [
  271. self environment
  272. evaluate: [
  273. self environment
  274. evaluate: aBlock
  275. on: ParseError
  276. do: [:ex | self handleParseError: ex ] ]
  277. on: UnknownVariableError
  278. do: [ :ex | self handleUnkownVariableError: ex ] ]
  279. on: CompilerError
  280. do: [ :ex | self handleCompileError: ex ]
  281. ! !
  282. !HLToolModel methodsFor: 'private'!
  283. compilationProtocol
  284. | currentProtocol |
  285. currentProtocol := self selectedProtocol.
  286. currentProtocol ifNil: [ currentProtocol := self unclassifiedProtocol ].
  287. self selectedMethod ifNotNil: [ currentProtocol := self selectedMethod protocol ].
  288. ^ currentProtocol = self allProtocol
  289. ifTrue: [ self unclassifiedProtocol ]
  290. ifFalse: [ currentProtocol ]
  291. !
  292. withHelperLabelled: aString do: aBlock
  293. "TODO: doesn't belong here"
  294. (window jQuery: '#helper') remove.
  295. [ :html |
  296. html div
  297. id: 'helper';
  298. with: aString ] appendToJQuery: 'body' asJQuery.
  299. [
  300. aBlock value.
  301. (window jQuery: '#helper') remove
  302. ]
  303. valueWithTimeout: 10
  304. ! !
  305. !HLToolModel methodsFor: 'testing'!
  306. isToolModel
  307. ^ true
  308. !
  309. shouldCompileClassDefinition: aString
  310. ^ self selectedClass isNil or: [
  311. aString match: '^[A-Z]' ]
  312. ! !
  313. !HLToolModel class methodsFor: 'actions'!
  314. on: anEnvironment
  315. ^ self new
  316. environment: anEnvironment;
  317. yourself
  318. ! !
  319. ProgressHandler subclass: #HLProgressHandler
  320. instanceVariableNames: ''
  321. package: 'Helios-Core'!
  322. !HLProgressHandler commentStamp!
  323. I am a specific progress handler for Helios, displaying progresses in a modal window.!
  324. !HLProgressHandler methodsFor: 'progress handling'!
  325. do: aBlock on: aCollection displaying: aString
  326. HLProgressWidget default
  327. do: aBlock
  328. on: aCollection
  329. displaying: aString
  330. ! !
  331. Widget subclass: #HLTabWidget
  332. instanceVariableNames: 'widget label root'
  333. package: 'Helios-Core'!
  334. !HLTabWidget commentStamp!
  335. I am a widget specialized into building another widget as an Helios tab.
  336. I should not be used directly, `HLWidget class >> #openAsTab` should be used instead.
  337. ## Example
  338. HLWorkspace openAsTab!
  339. !HLTabWidget methodsFor: 'accessing'!
  340. activate
  341. self manager activate: self
  342. !
  343. add
  344. self manager addTab: self
  345. !
  346. cssClass
  347. ^ self widget tabClass
  348. !
  349. displayLabel
  350. ^ self label size > 20
  351. ifTrue: [ (self label first: 20), '...' ]
  352. ifFalse: [ self label ]
  353. !
  354. focus
  355. self widget canHaveFocus ifTrue: [
  356. self widget focus ]
  357. !
  358. label
  359. ^ label ifNil: [ '' ]
  360. !
  361. label: aString
  362. label := aString
  363. !
  364. manager
  365. ^ HLManager current
  366. !
  367. widget
  368. ^ widget
  369. !
  370. widget: aWidget
  371. widget := aWidget
  372. ! !
  373. !HLTabWidget methodsFor: 'actions'!
  374. hide
  375. root ifNotNil: [ root asJQuery css: 'visibility' put: 'hidden' ]
  376. !
  377. registerBindings
  378. self widget registerBindings
  379. !
  380. remove
  381. self widget unregister.
  382. root ifNotNil: [ root asJQuery remove ]
  383. !
  384. show
  385. root
  386. ifNil: [ self appendToJQuery: 'body' asJQuery ]
  387. ifNotNil: [ root asJQuery css: 'visibility' put: 'visible' ]
  388. ! !
  389. !HLTabWidget methodsFor: 'rendering'!
  390. renderOn: html
  391. root := html div
  392. class: 'tab';
  393. yourself.
  394. self renderTab
  395. !
  396. renderTab
  397. root contents: [ :html |
  398. html div
  399. class: 'amber_box';
  400. with: [ self widget renderOn: html ] ]
  401. ! !
  402. !HLTabWidget methodsFor: 'testing'!
  403. isActive
  404. ^ self manager activeTab = self
  405. ! !
  406. !HLTabWidget class methodsFor: 'instance creation'!
  407. on: aWidget labelled: aString
  408. ^ self new
  409. widget: aWidget;
  410. label: aString;
  411. yourself
  412. ! !
  413. Widget subclass: #HLWidget
  414. instanceVariableNames: 'wrapper'
  415. package: 'Helios-Core'!
  416. !HLWidget commentStamp!
  417. I am the abstract superclass of all Helios widgets.
  418. I provide common methods, additional behavior to widgets useful for Helios, like dialog creation, command execution and tab creation.
  419. ## API
  420. 1. Rendering
  421. Instead of overriding `#renderOn:` as with other Widget subclasses, my subclasses should override `#renderContentOn:`.
  422. 2. Refreshing
  423. To re-render a widget, use `#refresh`.
  424. 3. Key bindings registration and tabs
  425. When displayed as a tab, the widget has a chance to register keybindings with the `#registerBindingsOn:` hook method.
  426. 4. Unregistration
  427. When a widget has subscribed to announcements or other actions that need to be cleared when closing the tab, the hook method `#unregister` will be called by helios.
  428. 5. Tabs
  429. To enable a widget class to be open as a tab, override the class-side `#canBeOpenAsTab` method to answer `true`. `#tabClass` and `#tabPriority` can be overridden too to respectively change the css class of the tab and the order of tabs in the main menu.
  430. 6. Command execution
  431. An helios command (instance of `HLCommand` or one of its subclass) can be executed with `#execute:`.!
  432. !HLWidget methodsFor: 'accessing'!
  433. manager
  434. ^ HLManager current
  435. !
  436. tabClass
  437. ^ self class tabClass
  438. !
  439. wrapper
  440. ^ wrapper
  441. ! !
  442. !HLWidget methodsFor: 'actions'!
  443. alert: aString
  444. window alert: aString
  445. !
  446. confirm: aString ifTrue: aBlock
  447. self manager confirm: aString ifTrue: aBlock
  448. !
  449. execute: aCommand
  450. HLManager current keyBinder
  451. activate;
  452. applyBinding: aCommand asBinding
  453. !
  454. openAsTab
  455. HLManager current addTab: (HLTabWidget on: self labelled: self class tabLabel)
  456. !
  457. request: aString do: aBlock
  458. self manager request: aString do: aBlock
  459. !
  460. request: aString value: valueString do: aBlock
  461. self manager
  462. request: aString
  463. value: valueString
  464. do: aBlock
  465. !
  466. unregister
  467. "This method is called whenever the receiver is closed (as a tab).
  468. Widgets subscribing to announcements should unregister there"
  469. ! !
  470. !HLWidget methodsFor: 'keybindings'!
  471. registerBindings
  472. self registerBindingsOn: self manager keyBinder bindings
  473. !
  474. registerBindingsOn: aBindingGroup
  475. ! !
  476. !HLWidget methodsFor: 'rendering'!
  477. renderContentOn: html
  478. !
  479. renderOn: html
  480. wrapper := html div.
  481. [ :renderer | self renderContentOn: renderer ] appendToJQuery: wrapper asJQuery
  482. ! !
  483. !HLWidget methodsFor: 'testing'!
  484. canHaveFocus
  485. ^ false
  486. ! !
  487. !HLWidget methodsFor: 'updating'!
  488. refresh
  489. self wrapper ifNil: [ ^ self ].
  490. self wrapper asJQuery empty.
  491. [ :html | self renderContentOn: html ] appendToJQuery: self wrapper asJQuery
  492. ! !
  493. !HLWidget class methodsFor: 'accessing'!
  494. openAsTab
  495. HLManager current addTab: (HLTabWidget on: self new labelled: self tabLabel)
  496. !
  497. tabClass
  498. ^ ''
  499. !
  500. tabLabel
  501. ^ 'Tab'
  502. !
  503. tabPriority
  504. ^ 500
  505. ! !
  506. !HLWidget class methodsFor: 'testing'!
  507. canBeOpenAsTab
  508. ^ false
  509. ! !
  510. HLWidget subclass: #HLFocusableWidget
  511. instanceVariableNames: ''
  512. package: 'Helios-Core'!
  513. !HLFocusableWidget commentStamp!
  514. I am a widget that can be focused.
  515. ## API
  516. Instead of overriding `#renderOn:` as with other `Widget` subclasses, my subclasses should override `#renderContentOn:`.
  517. To bring the focus to the widget, use the `#focus` method.!
  518. !HLFocusableWidget methodsFor: 'accessing'!
  519. focusClass
  520. ^ 'focused'
  521. ! !
  522. !HLFocusableWidget methodsFor: 'events'!
  523. blur
  524. self wrapper asJQuery blur
  525. !
  526. focus
  527. self wrapper asJQuery focus
  528. !
  529. hasFocus
  530. ^ self wrapper notNil and: [ self wrapper asJQuery is: ':focus' ]
  531. ! !
  532. !HLFocusableWidget methodsFor: 'rendering'!
  533. renderContentOn: html
  534. !
  535. renderOn: html
  536. wrapper := html div
  537. class: 'hl_widget';
  538. yourself.
  539. wrapper with: [ self renderContentOn: html ].
  540. wrapper
  541. at: 'tabindex' put: '0';
  542. onBlur: [ self wrapper asJQuery removeClass: self focusClass ];
  543. onFocus: [ self wrapper asJQuery addClass: self focusClass ]
  544. ! !
  545. !HLFocusableWidget methodsFor: 'testing'!
  546. canHaveFocus
  547. ^ true
  548. ! !
  549. HLFocusableWidget subclass: #HLListWidget
  550. instanceVariableNames: 'items selectedItem mapping'
  551. package: 'Helios-Core'!
  552. !HLListWidget methodsFor: 'accessing'!
  553. cssClassForItem: anObject
  554. ^ ''
  555. !
  556. items
  557. ^ items ifNil: [ items := self defaultItems ]
  558. !
  559. items: aCollection
  560. items := aCollection
  561. !
  562. listCssClassForItem: anObject
  563. ^ self selectedItem = anObject
  564. ifTrue: [ 'active' ]
  565. ifFalse: [ 'inactive' ]
  566. !
  567. positionOf: aListItem
  568. <
  569. return aListItem.parent().children().get().indexOf(aListItem.get(0)) + 1
  570. >
  571. !
  572. selectedItem
  573. ^ selectedItem
  574. !
  575. selectedItem: anObject
  576. selectedItem := anObject
  577. ! !
  578. !HLListWidget methodsFor: 'actions'!
  579. activateFirstListItem
  580. self activateListItem: (window jQuery: ((wrapper asJQuery find: 'li.inactive') get: 0))
  581. !
  582. activateItem: anObject
  583. self activateListItem: (mapping
  584. at: anObject
  585. ifAbsent: [ ^ self ]) asJQuery
  586. !
  587. activateListItem: aListItem
  588. | item |
  589. (aListItem get: 0) ifNil: [ ^self ].
  590. aListItem parent children removeClass: 'active'.
  591. aListItem addClass: 'active'.
  592. self ensureVisible: aListItem.
  593. "Activate the corresponding item"
  594. item := (self items at: (aListItem attr: 'list-data') asNumber).
  595. self selectedItem == item ifFalse: [
  596. self selectItem: item ]
  597. !
  598. activateNextListItem
  599. self activateListItem: (self wrapper asJQuery find: 'li.active') next.
  600. "select the first item if none is selected"
  601. (self wrapper asJQuery find: ' .active') get ifEmpty: [
  602. self activateFirstListItem ]
  603. !
  604. activatePreviousListItem
  605. self activateListItem: (self wrapper asJQuery find: 'li.active') prev
  606. !
  607. ensureVisible: aListItem
  608. "Move the scrollbar to show the active element"
  609. | perent position |
  610. position := self positionOf: aListItem.
  611. parent := aListItem parent.
  612. aListItem position top < 0 ifTrue: [
  613. (parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem position top - 10) ].
  614. aListItem position top + aListItem height > parent height ifTrue: [
  615. (parent get: 0) scrollTop: ((parent get: 0) scrollTop + aListItem height - (parent height - aListItem position top)) +10 ]
  616. !
  617. focus
  618. super focus.
  619. self items isEmpty ifFalse: [
  620. self selectedItem ifNil: [ self activateFirstListItem ] ]
  621. !
  622. refresh
  623. super refresh.
  624. self ensureVisible: (mapping
  625. at: self selectedItem
  626. ifAbsent: [ ^ self ]) asJQuery
  627. !
  628. selectItem: anObject
  629. self selectedItem: anObject
  630. ! !
  631. !HLListWidget methodsFor: 'defaults'!
  632. defaultItems
  633. ^ #()
  634. ! !
  635. !HLListWidget methodsFor: 'events'!
  636. setupKeyBindings
  637. "TODO: refactor this!!"
  638. | active interval delay repeatInterval |
  639. active := false.
  640. repeatInterval := 70.
  641. self wrapper asJQuery unbind: 'keydown'.
  642. self wrapper asJQuery keydown: [ :e |
  643. (e which = 38 and: [ active = false ]) ifTrue: [
  644. active := true.
  645. e preventDefault.
  646. self activatePreviousListItem.
  647. delay := [
  648. interval := [
  649. (self wrapper asJQuery hasClass: self focusClass)
  650. ifTrue: [
  651. self activatePreviousListItem ]
  652. ifFalse: [
  653. active := false.
  654. interval ifNotNil: [ interval clearInterval ].
  655. delay ifNotNil: [ delay clearTimeout] ] ]
  656. valueWithInterval: repeatInterval ]
  657. valueWithTimeout: 300.
  658. false ].
  659. (e which = 40 and: [ active = false ]) ifTrue: [
  660. active := true.
  661. e preventDefault.
  662. self activateNextListItem.
  663. delay := [
  664. interval := [
  665. (self wrapper asJQuery hasClass: self focusClass)
  666. ifTrue: [
  667. self activateNextListItem ]
  668. ifFalse: [
  669. active := false.
  670. interval ifNotNil: [ interval clearInterval ].
  671. delay ifNotNil: [ delay clearTimeout] ] ]
  672. valueWithInterval: repeatInterval ]
  673. valueWithTimeout: 300 ].
  674. false ].
  675. self wrapper asJQuery keyup: [ :e |
  676. active ifTrue: [
  677. active := false.
  678. interval ifNotNil: [ interval clearInterval ].
  679. delay ifNotNil: [ delay clearTimeout] ] ]
  680. ! !
  681. !HLListWidget methodsFor: 'initialization'!
  682. initialize
  683. super initialize.
  684. mapping := Dictionary new.
  685. ! !
  686. !HLListWidget methodsFor: 'private'!
  687. registerMappingFrom: anObject to: aTag
  688. mapping at: anObject put: aTag
  689. ! !
  690. !HLListWidget methodsFor: 'rendering'!
  691. renderButtonsOn: html
  692. !
  693. renderContentOn: html
  694. html ul
  695. class: 'nav nav-pills nav-stacked';
  696. with: [ self renderListOn: html ].
  697. html div class: 'pane_actions form-actions'; with: [
  698. self renderButtonsOn: html ].
  699. self setupKeyBindings
  700. !
  701. renderItem: anObject on: html
  702. | li |
  703. li := html li.
  704. self registerMappingFrom: anObject to: li.
  705. li
  706. at: 'list-data' put: (self items indexOf: anObject) asString;
  707. class: (self listCssClassForItem: anObject);
  708. with: [
  709. html a
  710. with: [
  711. (html tag: 'i') class: (self cssClassForItem: anObject).
  712. self renderItemLabel: anObject on: html ];
  713. onClick: [
  714. self activateListItem: li asJQuery ] ]
  715. !
  716. renderItemLabel: anObject on: html
  717. html with: anObject asString
  718. !
  719. renderListOn: html
  720. mapping := Dictionary new.
  721. self items do: [ :each |
  722. self renderItem: each on: html ]
  723. ! !
  724. HLListWidget subclass: #HLNavigationListWidget
  725. instanceVariableNames: 'previous next'
  726. package: 'Helios-Core'!
  727. !HLNavigationListWidget methodsFor: 'accessing'!
  728. next
  729. ^ next
  730. !
  731. next: aWidget
  732. next := aWidget.
  733. aWidget previous = self ifFalse: [ aWidget previous: self ]
  734. !
  735. previous
  736. ^ previous
  737. !
  738. previous: aWidget
  739. previous := aWidget.
  740. aWidget next = self ifFalse: [ aWidget next: self ]
  741. ! !
  742. !HLNavigationListWidget methodsFor: 'actions'!
  743. nextFocus
  744. self next ifNotNil: [ self next focus ]
  745. !
  746. previousFocus
  747. self previous ifNotNil: [ self previous focus ]
  748. ! !
  749. !HLNavigationListWidget methodsFor: 'events'!
  750. setupKeyBindings
  751. super setupKeyBindings.
  752. self wrapper asJQuery keydown: [ :e |
  753. e which = 39 ifTrue: [
  754. self nextFocus ].
  755. e which = 37 ifTrue: [
  756. self previousFocus ] ]
  757. ! !
  758. HLNavigationListWidget subclass: #HLToolListWidget
  759. instanceVariableNames: 'model'
  760. package: 'Helios-Core'!
  761. !HLToolListWidget methodsFor: 'accessing'!
  762. commandCategory
  763. ^ self label
  764. !
  765. label
  766. ^ 'List'
  767. !
  768. menuCommands
  769. "Answer a collection of commands to be put in the cog menu"
  770. ^ ((HLToolCommand concreteClasses
  771. select: [ :each | each isValidFor: self model ])
  772. collect: [ :each | each for: self model ])
  773. select: [ :each |
  774. each category = self commandCategory and: [
  775. each isAction and: [ each isActive ] ] ]
  776. !
  777. model
  778. ^ model
  779. !
  780. model: aBrowserModel
  781. model := aBrowserModel.
  782. self
  783. observeSystem;
  784. observeModel
  785. !
  786. selectedItem: anItem
  787. "Selection changed, update the cog menu"
  788. super selectedItem: anItem.
  789. self updateMenu
  790. ! !
  791. !HLToolListWidget methodsFor: 'actions'!
  792. activateListItem: anItem
  793. self model withChangesDo: [ super activateListItem: anItem ]
  794. !
  795. activateNextListItem
  796. self model withChangesDo: [ super activateNextListItem ]
  797. !
  798. activatePreviousListItem
  799. self model withChangesDo: [ super activatePreviousListItem ]
  800. !
  801. observeModel
  802. !
  803. observeSystem
  804. !
  805. unregister
  806. super unregister.
  807. self model announcer unsubscribe: self.
  808. self model systemAnnouncer unsubscribe: self
  809. ! !
  810. !HLToolListWidget methodsFor: 'rendering'!
  811. renderContentOn: html
  812. self renderHeadOn: html.
  813. super renderContentOn: html
  814. !
  815. renderHeadOn: html
  816. html div
  817. class: 'list-label';
  818. with: [
  819. html with: self label.
  820. self renderMenuOn: html ]
  821. !
  822. renderMenuOn: html
  823. | commands |
  824. commands := self menuCommands.
  825. commands isEmpty ifTrue: [ ^ self ].
  826. html div
  827. class: 'btn-group cog';
  828. with: [
  829. html a
  830. class: 'btn dropdown-toggle';
  831. at: 'data-toggle' put: 'dropdown';
  832. with: [ (html tag: 'i') class: 'icon-cog' ].
  833. html ul
  834. class: 'dropdown-menu pull-right';
  835. with: [
  836. self menuCommands do: [ :each |
  837. html li with: [ html a
  838. with: each menuLabel;
  839. onClick: [ self execute: each ] ] ] ] ]
  840. ! !
  841. !HLToolListWidget methodsFor: 'updating'!
  842. updateMenu
  843. (self wrapper asJQuery find: '.cog') remove.
  844. [ :html | self renderMenuOn: html ]
  845. appendToJQuery: (self wrapper asJQuery find: '.list-label')
  846. ! !
  847. !HLToolListWidget class methodsFor: 'instance creation'!
  848. on: aModel
  849. ^ self new
  850. model: aModel;
  851. yourself
  852. ! !
  853. HLWidget subclass: #HLManager
  854. instanceVariableNames: 'tabs activeTab keyBinder environment history'
  855. package: 'Helios-Core'!
  856. !HLManager methodsFor: 'accessing'!
  857. activeTab
  858. ^ activeTab
  859. !
  860. environment
  861. "The default environment used by all Helios objects"
  862. ^ environment ifNil: [ environment := self defaultEnvironment ]
  863. !
  864. environment: anEnvironment
  865. environment := anEnvironment
  866. !
  867. history
  868. ^ history ifNil: [ history := OrderedCollection new ]
  869. !
  870. history: aCollection
  871. history := aCollection
  872. !
  873. keyBinder
  874. ^ keyBinder ifNil: [ keyBinder := HLKeyBinder new ]
  875. !
  876. tabs
  877. ^ tabs ifNil: [ tabs := OrderedCollection new ]
  878. ! !
  879. !HLManager methodsFor: 'actions'!
  880. activate: aTab
  881. self keyBinder flushBindings.
  882. aTab registerBindings.
  883. activeTab := aTab.
  884. self
  885. refresh;
  886. addToHistory: aTab;
  887. show: aTab
  888. !
  889. addTab: aTab
  890. self tabs add: aTab.
  891. self activate: aTab
  892. !
  893. addToHistory: aTab
  894. self removeFromHistory: aTab.
  895. self history add: aTab
  896. !
  897. confirm: aString ifFalse: aBlock
  898. (HLConfirmationWidget new
  899. confirmationString: aString;
  900. cancelBlock: aBlock;
  901. yourself)
  902. appendToJQuery: 'body' asJQuery
  903. !
  904. confirm: aString ifTrue: aBlock
  905. (HLConfirmationWidget new
  906. confirmationString: aString;
  907. actionBlock: aBlock;
  908. yourself)
  909. appendToJQuery: 'body' asJQuery
  910. !
  911. registerErrorHandler: anErrorHandler
  912. self environment registerErrorHandler: anErrorHandler
  913. !
  914. registerInspector: anInspector
  915. self environment registerInspector: anInspector
  916. !
  917. registerProgressHandler: aProgressHandler
  918. self environment registerProgressHandler: aProgressHandler
  919. !
  920. removeActiveTab
  921. self removeTab: self activeTab
  922. !
  923. removeFromHistory: aTab
  924. self history: (self history reject: [ :each | each == aTab ])
  925. !
  926. removeTab: aTab
  927. (self tabs includes: aTab) ifFalse: [ ^ self ].
  928. self removeFromHistory: aTab.
  929. self tabs remove: aTab.
  930. self keyBinder flushBindings.
  931. aTab remove.
  932. self refresh.
  933. self history ifNotEmpty: [
  934. self history last activate ]
  935. !
  936. request: aString do: aBlock
  937. self
  938. request: aString
  939. value: ''
  940. do: aBlock
  941. !
  942. request: aString value: valueString do: aBlock
  943. (HLRequestWidget new
  944. confirmationString: aString;
  945. actionBlock: aBlock;
  946. value: valueString;
  947. yourself)
  948. appendToJQuery: 'body' asJQuery
  949. ! !
  950. !HLManager methodsFor: 'defaults'!
  951. defaultEnvironment
  952. "If helios is loaded from within a frame, answer the parent window environment"
  953. | parent |
  954. parent := window opener ifNil: [ window parent ].
  955. parent ifNil: [ ^ Environment new ].
  956. ^ ((parent at: 'smalltalk')
  957. at: 'Environment') new
  958. ! !
  959. !HLManager methodsFor: 'initialization'!
  960. initialize
  961. super initialize.
  962. HLErrorHandler register.
  963. HLProgressHandler register.
  964. self registerInspector: HLInspector.
  965. self registerErrorHandler: ErrorHandler current.
  966. self registerProgressHandler: ProgressHandler current.
  967. self keyBinder setupEvents
  968. ! !
  969. !HLManager methodsFor: 'rendering'!
  970. refresh
  971. (window jQuery: '.navbar') remove.
  972. self appendToJQuery: 'body' asJQuery
  973. !
  974. renderAddOn: html
  975. html li
  976. class: 'dropdown';
  977. with: [
  978. html a
  979. class: 'dropdown-toggle';
  980. at: 'data-toggle' put: 'dropdown';
  981. with: [
  982. html with: 'Open...'.
  983. (html tag: 'b') class: 'caret' ].
  984. html ul
  985. class: 'dropdown-menu';
  986. with: [
  987. ((HLWidget withAllSubclasses
  988. select: [ :each | each canBeOpenAsTab ])
  989. sorted: [ :a :b | a tabPriority < b tabPriority ])
  990. do: [ :each |
  991. html li with: [
  992. html a
  993. with: each tabLabel;
  994. onClick: [ each openAsTab ] ] ] ] ]
  995. !
  996. renderContentOn: html
  997. html div
  998. class: 'navbar navbar-fixed-top';
  999. with: [ html div
  1000. class: 'navbar-inner';
  1001. with: [ self renderTabsOn: html ] ]
  1002. !
  1003. renderTabsOn: html
  1004. html ul
  1005. class: 'nav';
  1006. with: [
  1007. self tabs do: [ :each |
  1008. html li
  1009. class: (each isActive ifTrue: [ 'active' ] ifFalse: [ 'inactive' ]);
  1010. with: [
  1011. html a
  1012. with: [
  1013. ((html tag: 'i') class: 'close')
  1014. onClick: [ self removeTab: each ].
  1015. html span
  1016. class: each cssClass;
  1017. with: each displayLabel ];
  1018. onClick: [ each activate ] ] ].
  1019. self renderAddOn: html ]
  1020. !
  1021. show: aTab
  1022. self tabs do: [ :each | each hide ].
  1023. aTab show; focus
  1024. ! !
  1025. HLManager class instanceVariableNames: 'current'!
  1026. !HLManager class methodsFor: 'accessing'!
  1027. current
  1028. ^ current ifNil: [ current := self basicNew initialize ]
  1029. ! !
  1030. !HLManager class methodsFor: 'initialization'!
  1031. initialize
  1032. self current appendToJQuery: 'body' asJQuery
  1033. ! !
  1034. !HLManager class methodsFor: 'instance creation'!
  1035. new
  1036. "Use current instead"
  1037. self shouldNotImplement
  1038. ! !
  1039. HLWidget subclass: #HLModalWidget
  1040. instanceVariableNames: ''
  1041. package: 'Helios-Core'!
  1042. !HLModalWidget commentStamp!
  1043. I implement an abstract modal widget.!
  1044. !HLModalWidget methodsFor: 'accessing'!
  1045. cssClass
  1046. ^ ''
  1047. ! !
  1048. !HLModalWidget methodsFor: 'actions'!
  1049. cancel
  1050. self remove
  1051. !
  1052. remove
  1053. (window jQuery: '.dialog') removeClass: 'active'.
  1054. [
  1055. (window jQuery: '#overlay') remove.
  1056. (window jQuery: '.dialog') remove
  1057. ] valueWithTimeout: 300
  1058. ! !
  1059. !HLModalWidget methodsFor: 'rendering'!
  1060. renderButtonsOn: html
  1061. !
  1062. renderContentOn: html
  1063. | confirmButton |
  1064. html div id: 'overlay'.
  1065. html div
  1066. class: 'dialog ', self cssClass;
  1067. with: [
  1068. self
  1069. renderMainOn: html;
  1070. renderButtonsOn: html ].
  1071. (window jQuery: '.dialog') addClass: 'active'.
  1072. self setupKeyBindings
  1073. !
  1074. renderMainOn: html
  1075. !
  1076. setupKeyBindings
  1077. (window jQuery: '.dialog') keyup: [ :e |
  1078. e keyCode = 27 ifTrue: [ self cancel ] ]
  1079. ! !
  1080. HLModalWidget subclass: #HLConfirmationWidget
  1081. instanceVariableNames: 'confirmationString actionBlock cancelBlock'
  1082. package: 'Helios-Core'!
  1083. !HLConfirmationWidget commentStamp!
  1084. I display confirmation messages.
  1085. Instead of creating an instance directly, use `HLWidget >> #confirm:ifTrue:`.!
  1086. !HLConfirmationWidget methodsFor: 'accessing'!
  1087. actionBlock
  1088. ^ actionBlock ifNil: [ [] ]
  1089. !
  1090. actionBlock: aBlock
  1091. actionBlock := aBlock
  1092. !
  1093. cancelBlock
  1094. ^ cancelBlock ifNil: [ [] ]
  1095. !
  1096. cancelBlock: aBlock
  1097. cancelBlock := aBlock
  1098. !
  1099. confirmationString
  1100. ^ confirmationString ifNil: [ 'Confirm' ]
  1101. !
  1102. confirmationString: aString
  1103. confirmationString := aString
  1104. ! !
  1105. !HLConfirmationWidget methodsFor: 'actions'!
  1106. cancel
  1107. self cancelBlock value.
  1108. self remove
  1109. !
  1110. confirm
  1111. self actionBlock value.
  1112. self remove
  1113. !
  1114. remove
  1115. (window jQuery: '.dialog') removeClass: 'active'.
  1116. [
  1117. (window jQuery: '#overlay') remove.
  1118. (window jQuery: '.dialog') remove
  1119. ] valueWithTimeout: 300
  1120. ! !
  1121. !HLConfirmationWidget methodsFor: 'rendering'!
  1122. renderButtonsOn: html
  1123. | confirmButton |
  1124. html div
  1125. class: 'buttons';
  1126. with: [
  1127. html button
  1128. class: 'button';
  1129. with: 'Cancel';
  1130. onClick: [ self cancel ].
  1131. confirmButton := html button
  1132. class: 'button default';
  1133. with: 'Confirm';
  1134. onClick: [ self confirm ] ].
  1135. confirmButton asJQuery focus
  1136. !
  1137. renderMainOn: html
  1138. html span with: self confirmationString
  1139. ! !
  1140. HLConfirmationWidget subclass: #HLRequestWidget
  1141. instanceVariableNames: 'input value'
  1142. package: 'Helios-Core'!
  1143. !HLRequestWidget commentStamp!
  1144. I display a modal window requesting user input.
  1145. Instead of creating instances manually, use `HLWidget >> #request:do:` and `#request:value:do:`.!
  1146. !HLRequestWidget methodsFor: 'accessing'!
  1147. cssClass
  1148. ^ 'large'
  1149. !
  1150. value
  1151. ^ value ifNil: [ '' ]
  1152. !
  1153. value: aString
  1154. value := aString
  1155. ! !
  1156. !HLRequestWidget methodsFor: 'actions'!
  1157. confirm
  1158. self actionBlock value: input asJQuery val.
  1159. self remove
  1160. ! !
  1161. !HLRequestWidget methodsFor: 'rendering'!
  1162. renderMainOn: html
  1163. super renderMainOn: html.
  1164. input := html textarea.
  1165. input asJQuery val: self value
  1166. ! !
  1167. HLModalWidget subclass: #HLProgressWidget
  1168. instanceVariableNames: 'progressBars visible'
  1169. package: 'Helios-Core'!
  1170. !HLProgressWidget commentStamp!
  1171. I am a widget used to display progress modal dialogs.
  1172. My default instance is accessed with `HLProgressWidget class >> #default`.
  1173. See `HLProgressHandler` for usage.!
  1174. !HLProgressWidget methodsFor: 'accessing'!
  1175. progressBars
  1176. ^ progressBars ifNil: [ progressBars := OrderedCollection new ]
  1177. ! !
  1178. !HLProgressWidget methodsFor: 'actions'!
  1179. addProgressBar: aProgressBar
  1180. self show.
  1181. self progressBars add: aProgressBar.
  1182. aProgressBar appendToJQuery: (self wrapper asJQuery find: '.dialog')
  1183. !
  1184. do: aBlock on: aCollection displaying: aString
  1185. | progressBar |
  1186. progressBar := HLProgressBarWidget new
  1187. parent: self;
  1188. label: aString;
  1189. workBlock: aBlock;
  1190. collection: aCollection;
  1191. yourself.
  1192. self addProgressBar: progressBar.
  1193. progressBar start
  1194. !
  1195. remove
  1196. self isVisible ifTrue: [
  1197. visible := false.
  1198. super remove ]
  1199. !
  1200. removeProgressBar: aProgressBar
  1201. self progressBars remove: aProgressBar ifAbsent: [].
  1202. aProgressBar wrapper asJQuery remove.
  1203. self progressBars ifEmpty: [ self remove ]
  1204. !
  1205. show
  1206. self isVisible ifFalse: [
  1207. visible := true.
  1208. self appendToJQuery: 'body' asJQuery ]
  1209. ! !
  1210. !HLProgressWidget methodsFor: 'rendering'!
  1211. renderButtonsOn: html
  1212. !
  1213. renderMainOn: html
  1214. self progressBars do: [ :each |
  1215. html with: each ]
  1216. ! !
  1217. !HLProgressWidget methodsFor: 'testing'!
  1218. isVisible
  1219. ^ visible ifNil: [ false ]
  1220. ! !
  1221. HLProgressWidget class instanceVariableNames: 'default'!
  1222. !HLProgressWidget class methodsFor: 'accessing'!
  1223. default
  1224. ^ default ifNil: [ default := self new ]
  1225. ! !
  1226. HLWidget subclass: #HLProgressBarWidget
  1227. instanceVariableNames: 'label parent workBlock collection bar'
  1228. package: 'Helios-Core'!
  1229. !HLProgressBarWidget commentStamp!
  1230. I am a widget used to display a progress bar while iterating over a collection.!
  1231. !HLProgressBarWidget methodsFor: 'accessing'!
  1232. collection
  1233. ^ collection
  1234. !
  1235. collection: aCollection
  1236. collection := aCollection
  1237. !
  1238. label
  1239. ^ label
  1240. !
  1241. label: aString
  1242. label := aString
  1243. !
  1244. parent
  1245. ^ parent
  1246. !
  1247. parent: aProgress
  1248. parent := aProgress
  1249. !
  1250. workBlock
  1251. ^ workBlock
  1252. !
  1253. workBlock: aBlock
  1254. workBlock := aBlock
  1255. ! !
  1256. !HLProgressBarWidget methodsFor: 'actions'!
  1257. evaluateAt: anInteger
  1258. self updateProgress: (anInteger / self collection size) * 100.
  1259. anInteger <= self collection size
  1260. ifTrue: [
  1261. [
  1262. self workBlock value: (self collection at: anInteger).
  1263. self evaluateAt: anInteger + 1 ] valueWithTimeout: 10 ]
  1264. ifFalse: [ [ self remove ] valueWithTimeout: 500 ]
  1265. !
  1266. remove
  1267. self parent removeProgressBar: self
  1268. !
  1269. start
  1270. "Make sure the UI has some time to update itself between each iteration"
  1271. self evaluateAt: 1
  1272. !
  1273. updateProgress: anInteger
  1274. bar asJQuery css: 'width' put: anInteger asString, '%'
  1275. ! !
  1276. !HLProgressBarWidget methodsFor: 'rendering'!
  1277. renderContentOn: html
  1278. html span with: self label.
  1279. html div
  1280. class: 'progress';
  1281. with: [
  1282. bar := html div
  1283. class: 'bar';
  1284. style: 'width: 0%' ]
  1285. ! !
  1286. HLProgressBarWidget class instanceVariableNames: 'default'!
  1287. !HLProgressBarWidget class methodsFor: 'accessing'!
  1288. default
  1289. ^ default ifNil: [ default := self new ]
  1290. ! !
  1291. HLWidget subclass: #HLSUnit
  1292. instanceVariableNames: ''
  1293. package: 'Helios-Core'!
  1294. !HLSUnit class methodsFor: 'accessing'!
  1295. tabClass
  1296. ^ 'sunit'
  1297. !
  1298. tabLabel
  1299. ^ 'SUnit'
  1300. !
  1301. tabPriority
  1302. ^ 1000
  1303. ! !
  1304. !HLSUnit class methodsFor: 'testing'!
  1305. canBeOpenAsTab
  1306. ^ true
  1307. ! !