1
0

Helios.st 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. Smalltalk current createPackage: 'Helios' properties: #{}!
  2. Widget subclass: #HLBrowser
  3. instanceVariableNames: ''
  4. package: 'Helios'!
  5. Widget subclass: #HLDebugger
  6. instanceVariableNames: ''
  7. package: 'Helios'!
  8. Widget subclass: #HLInspector
  9. instanceVariableNames: ''
  10. package: 'Helios'!
  11. Widget subclass: #HLSUnit
  12. instanceVariableNames: ''
  13. package: 'Helios'!
  14. Object subclass: #HLTab
  15. instanceVariableNames: 'widget label'
  16. package: 'Helios'!
  17. !HLTab methodsFor: 'accessing'!
  18. activate
  19. self manager activate: self
  20. !
  21. add
  22. self manager addTab: self
  23. !
  24. label
  25. ^ label ifNil: [ '' ]
  26. !
  27. label: aString
  28. label := aString
  29. !
  30. manager
  31. ^ HLTabManager current
  32. !
  33. widget
  34. ^ widget
  35. !
  36. widget: aWidget
  37. widget := aWidget
  38. ! !
  39. !HLTab methodsFor: 'testing'!
  40. isActive
  41. ^ self manager activeTab = self
  42. ! !
  43. !HLTab class methodsFor: 'instance creation'!
  44. on: aWidget labelled: aString
  45. ^ self new
  46. widget: aWidget;
  47. label: aString;
  48. yourself
  49. ! !
  50. Widget subclass: #HLTabManager
  51. instanceVariableNames: 'tabs activeTab'
  52. package: 'Helios'!
  53. !HLTabManager methodsFor: 'accessing'!
  54. activate: aTab
  55. activeTab := aTab.
  56. self
  57. refresh;
  58. show: aTab
  59. !
  60. activeTab
  61. ^ activeTab
  62. !
  63. addTab: aTab
  64. self tabs add: aTab.
  65. self refresh
  66. !
  67. removeTab: aTab
  68. "Todo: activate the previously activated tab. Keep a history of tabs selection"
  69. (self tabs includes: aTab) ifFalse: [ ^ self ].
  70. self tabs remove: aTab.
  71. self refresh
  72. !
  73. tabs
  74. ^ tabs ifNil: [ tabs := OrderedCollection new ]
  75. ! !
  76. !HLTabManager methodsFor: 'rendering'!
  77. refresh
  78. (window jQuery: '.navbar') remove.
  79. (window jQuery: '#container') remove.
  80. self appendToJQuery: 'body' asJQuery
  81. !
  82. renderOn: html
  83. html div
  84. class: 'navbar navbar-fixed-top';
  85. with: [ html div
  86. class: 'navbar-inner';
  87. with: [ self renderTabsOn: html ] ].
  88. html div id: 'container'
  89. !
  90. renderTabsOn: html
  91. html ul
  92. class: 'nav';
  93. with: [ self tabs do: [ :each |
  94. html li
  95. class: (each isActive ifTrue: [ 'active' ] ifFalse: [ 'inactive' ]);
  96. with: [
  97. html a
  98. with: each label;
  99. onClick: [ each activate ] ] ] ]
  100. !
  101. show: aTab
  102. (window jQuery: '#container') empty.
  103. aTab widget appendToJQuery: '#container' asJQuery
  104. ! !
  105. HLTabManager class instanceVariableNames: 'current'!
  106. !HLTabManager class methodsFor: 'accessing'!
  107. current
  108. ^ current ifNil: [ current := self basicNew initialize ]
  109. ! !
  110. !HLTabManager class methodsFor: 'initialization'!
  111. initialize
  112. self current appendToJQuery: 'body' asJQuery
  113. ! !
  114. !HLTabManager class methodsFor: 'instance creation'!
  115. new
  116. "Use current instead"
  117. self shouldNotImplement
  118. ! !
  119. Widget subclass: #HLTranscript
  120. instanceVariableNames: ''
  121. package: 'Helios'!
  122. Widget subclass: #HLWorkspace
  123. instanceVariableNames: ''
  124. package: 'Helios'!