--- a/tools/JavaCodeBundleEditor.st Mon Mar 02 17:50:49 2015 +0100
+++ b/tools/JavaCodeBundleEditor.st Fri Mar 20 14:29:53 2015 +0100
@@ -1,5 +1,9 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:libjava/tools' }"
+"{ NameSpace: Smalltalk }"
+
ApplicationModel subclass:#JavaCodeBundleEditor
instanceVariableNames:'bundleHolder readonlyHolder bundleTree bundleTreeSelectionHolder'
classVariableNames:''
@@ -7,8 +11,15 @@
category:'Languages-Java-Tools'
!
-HierarchicalItem subclass:#Item
- instanceVariableNames:'libraryOrBundle'
+HierarchicalItem subclass:#BundleItem
+ instanceVariableNames:'bundle'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:JavaCodeBundleEditor
+!
+
+HierarchicalItem subclass:#LibraryItem
+ instanceVariableNames:'library warnings label'
classVariableNames:''
poolDictionaries:''
privateIn:JavaCodeBundleEditor
@@ -372,13 +383,15 @@
updateTree
self bundleTree root notNil ifTrue:[
- self bundleTree removeAll; root: nil.
+ (self bundleTree)
+ removeAll;
+ root:nil.
].
- self bundleTree root: (Item libraryOrBundle: self bundleHolder value parent: nil).
+ self bundleTree root:(BundleItem bundle:self bundleHolder value parent:nil).
self bundleTree root expand.
"Created: / 25-01-2013 / 21:40:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 22-02-2013 / 14:01:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 19-03-2015 / 13:14:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaCodeBundleEditor methodsFor:'hooks'!
@@ -447,15 +460,19 @@
!
doEdit
- | bundleOrLibrary dialog name |
+ | bundleOrLibraryItem bundleOrLibrary dialog name |
- bundleOrLibrary := self bundleTreeSelectionHolder value.
- bundleOrLibrary isNil ifTrue:[ ^ self ].
- bundleOrLibrary := bundleOrLibrary libraryOrBundle.
+ bundleOrLibraryItem := self bundleTreeSelectionHolder value.
+ bundleOrLibraryItem isNil ifTrue:[ ^ self ].
+ bundleOrLibrary := bundleOrLibraryItem libraryOrBundle.
bundleOrLibrary isLibrary ifTrue:[
dialog := JavaCodeLibraryEditor new.
dialog library: bundleOrLibrary.
dialog open.
+ bundleOrLibrary isLibrary ifTrue:[
+ "/ To get rid ow warnings if fixed or revalidate
+ bundleOrLibraryItem updateWarnings.
+ ].
] ifFalse:[
name := Dialog request: (resources string: 'Enter new name') initialAnswer:bundleOrLibrary name.
name isNil ifTrue:[^self].
@@ -463,7 +480,7 @@
]
- "Modified: / 21-02-2013 / 23:41:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 16:27:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
doRemove
@@ -498,17 +515,15 @@
"Created: / 22-02-2013 / 15:36:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!JavaCodeBundleEditor::Item class methodsFor:'instance creation'!
+!JavaCodeBundleEditor::BundleItem class methodsFor:'instance creation'!
-libraryOrBundle: model parent: parent
- ^self new
- libraryOrBundle: model;
- parent: parent
+bundle: bundle parent: parent
+ ^self new setBundle: bundle parent: parent
- "Created: / 25-01-2013 / 21:53:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 19-03-2015 / 13:04:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!JavaCodeBundleEditor::Item methodsFor:'accessing'!
+!JavaCodeBundleEditor::BundleItem methodsFor:'accessing'!
icon
^nil
@@ -517,34 +532,24 @@
!
label
- ^libraryOrBundle displayString
+ ^bundle displayString
"Created: / 25-01-2013 / 21:41:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-04-2014 / 18:57:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
libraryOrBundle
- ^ libraryOrBundle
-!
+ ^ bundle
-libraryOrBundle:aJavaCodeLibraryOrBundle
- libraryOrBundle notNil ifTrue:[
- libraryOrBundle removeDependent: self
- ].
- libraryOrBundle := aJavaCodeLibraryOrBundle.
- libraryOrBundle notNil ifTrue:[
- libraryOrBundle addDependent: self
- ].
-
- "Modified: / 22-02-2013 / 15:19:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 19-03-2015 / 13:15:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!JavaCodeBundleEditor::Item methodsFor:'change & update'!
+!JavaCodeBundleEditor::BundleItem methodsFor:'change & update'!
update:aspect with: parameter from:changedObject
"Invoked when an object that I depend upon sends a change notification."
- changedObject == libraryOrBundle ifTrue:[
+ changedObject == bundle ifTrue:[
self updateChildren.
^ self.
].
@@ -560,40 +565,134 @@
self children: self fetchChildren.
^self.
].
- libraryOrBundle isLibrary ifTrue:[ ^ self ].
+ bundle isLibrary ifTrue:[ ^ self ].
oldChildren := children copy.
newChildren := OrderedCollection new.
- libraryOrBundle libraries do:[:e|
+ bundle libraries do:[:each|
| item |
item := oldChildren
- detect:[:item|item libraryOrBundle == e]
- ifNone:[self class libraryOrBundle:e parent: self].
+ detect:[:item|item libraryOrBundle == each]
+ ifNone:[each isLibrary
+ ifTrue:[ JavaCodeBundleEditor::LibraryItem library:each parent: self]
+ ifFalse: [ JavaCodeBundleEditor::BundleItem bundle:each parent: self] ].
newChildren add: item.
].
self children: newChildren
"Created: / 22-02-2013 / 15:20:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 16:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
-!JavaCodeBundleEditor::Item methodsFor:'protocol-accessing'!
+!JavaCodeBundleEditor::BundleItem methodsFor:'initialization'!
+
+setBundle: aJavaCodeBundle parent: aBundleItem
+ bundle := aJavaCodeBundle.
+ bundle addDependent: self.
+ parent := aBundleItem.
+
+ "Created: / 19-03-2015 / 13:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::BundleItem methodsFor:'protocol-accessing'!
fetchChildren
- ^libraryOrBundle isBundle ifTrue:[
- libraryOrBundle libraries collect:[:each|self class libraryOrBundle:each parent: self].
- ] ifFalse:[
- #()
+ ^ bundle libraries collect:[:each|
+ each isLibrary
+ ifTrue:[ JavaCodeBundleEditor::LibraryItem library:each parent: self]
+ ifFalse: [ JavaCodeBundleEditor::BundleItem bundle:each parent: self]
]
"Created: / 25-01-2013 / 21:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 16:26:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::LibraryItem class methodsFor:'instance creation'!
+
+library: model parent: parent
+ ^self new setLibrary: model parent: parent
+
+ "Created: / 19-03-2015 / 13:06:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::LibraryItem methodsFor:'accessing'!
+
+icon
+ ^nil
+
+ "Created: / 25-01-2013 / 21:51:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+label
+ | resources |
+
+ label isNil ifTrue:[
+ resources := self class classResources.
+ warnings isNil ifTrue:[ self updateWarnings ].
+
+ label := library name.
+ warnings isEmpty ifTrue:[
+ library sources isNil ifTrue:[
+ label := label , ((' (', (resources string: 'no sources') , ')') asText colorizeAllWith: Color gray)
+ ].
+ ] ifFalse:[
+ label := label , (' (', (warnings size == 1 ifTrue:[resources string: '1 warning'] ifFalse:[resources string: '%1 warnings' with: warnings size]) , ')').
+ label := label colorizeAllWith: Color red.
+ ].
+ ].
+ ^ label
+
+ "Created: / 25-01-2013 / 21:41:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 16:22:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+libraryOrBundle
+ ^ library
+
+ "Created: / 19-03-2015 / 13:15:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::LibraryItem methodsFor:'initialization'!
+
+setLibrary: aJavaCodeLibrary parent: aBundleItem
+ library := aJavaCodeLibrary.
+ parent := aBundleItem.
+
+ "Created: / 19-03-2015 / 13:06:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 16:20:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::LibraryItem methodsFor:'private'!
+
+updateWarnings
+
+ warnings := OrderedCollection new.
+ [
+ library validate
+ ] on: JavaCodeLibraryValidationWarning do:[:warning |
+ warnings add: warning.
+ warning proceed.
+ ].
+ label := nil.
+
+ "Created: / 19-03-2015 / 16:20:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaCodeBundleEditor::LibraryItem methodsFor:'protocol-accessing'!
+
+fetchChildren
+ ^ #()
+
+ "Created: / 25-01-2013 / 21:52:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-03-2015 / 13:07:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaCodeBundleEditor class methodsFor:'documentation'!
version_CVS
- ^ '$Header: /cvs/stx/stx/libjava/tools/JavaCodeBundleEditor.st,v 1.4 2015-01-28 02:11:52 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libjava/tools/JavaCodeBundleEditor.st,v 1.5 2015-03-20 13:29:52 vrany Exp $'
!
version_HG