--- a/tools/JavaSettingsApplication.st Fri Feb 14 14:27:26 2014 +0100
+++ b/tools/JavaSettingsApplication.st Wed Jan 28 03:12:08 2015 +0100
@@ -1,9 +1,7 @@
"{ Package: 'stx:libjava/tools' }"
AbstractSettingsApplication subclass:#JavaSettingsApplication
- instanceVariableNames:'javaReleaseHolder javaReleaseList javaHomeHolder
- javaReleaseIsCustomHolder infoPanel jdkBundleHolder
- environmentBundleHolder packageBundleHolder userBundleHolder'
+ instanceVariableNames:'javaHomeHolder infoPanel javaHomeInfoHolder'
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Tools'
@@ -24,10 +22,12 @@
Smalltalk addStartBlock:[
AbstractLauncherApplication
addSettingsApplicationByClass:self name withName:'Java' icon:self defaultIcon
+"/ AbstractLauncherApplication settingsList
+"/ addLast:(Array with:'Java' with:self name)
]
"Created: / 23-06-2005 / 09:27:10 / masca"
- "Modified: / 19-07-2012 / 11:26:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-09-2013 / 01:08:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSettingsApplication class methodsFor:'image specs'!
@@ -377,160 +377,107 @@
<resource: #canvas>
^
- #(FullSpec
- name: windowSpec
- window:
- (WindowSpec
- label: 'Java Settings'
- name: 'Java Settings'
- min: (Point 10 10)
- bounds: (Rectangle 0 0 695 627)
- )
- component:
- (SpecCollection
- collection: (
- (LabelSpec
- label: ' Java Settings'
- name: 'SubVersiSettingsTitle'
- layout: (LayoutFrame 0 0 0 0 0 1 66 0)
- style: (FontDescription helvetica medium roman 18 #'iso10646-1')
- backgroundColor: (Color 100.0 100.0 100.0)
- translateLabel: true
- adjust: left
- )
- (LabelSpec
- label: 'Icon'
- name: 'JavaIcon'
- layout: (LayoutFrame -75 1 0 0 0 1 66 0)
- hasCharacterOrientedLabel: false
- backgroundColor: (Color 100.0 100.0 100.0)
- translateLabel: true
- labelChannel: libjavaCupIcon
- )
- (SubCanvasSpec
- name: 'InfoPanel'
- layout: (LayoutFrame 0 0 67 0 0 1 107 0)
- level: 0
- initiallyInvisible: true
- hasHorizontalScrollBar: false
- hasVerticalScrollBar: false
- clientKey: infoPanel
- createNewBuilder: false
- )
- (VerticalPanelViewSpec
- name: 'Controls'
- layout: (LayoutFrame 0 0 70 0 0 1 0 1)
- horizontalLayout: fit
- verticalLayout: topFit
- horizontalSpace: 3
- verticalSpace: 3
- component:
- (SpecCollection
- collection: (
- (FramedBoxSpec
- label: 'Basic Settings'
- name: 'JavaReleasePanel'
- labelPosition: topLeft
- translateLabel: true
- component:
- (SpecCollection
- collection: (
- (ComboListSpec
- name: 'ReleaseList'
- layout: (LayoutFrame 100 0 0 0 0 1 25 0)
- model: javaReleaseHolder
- comboList: javaReleaseList
- useIndex: false
- )
- (LabelSpec
- label: 'Release:'
- name: 'ReleaseLabel'
- layout: (LayoutFrame 0 0 0 0 100 0 25 0)
- translateLabel: true
- adjust: left
- )
- (LabelSpec
- label: 'JAVA_HOME'
- name: 'JAVA_HOME_Label'
- layout: (LayoutFrame 0 0 30 0 100 0 55 0)
- translateLabel: true
- adjust: left
- )
- (FilenameInputFieldSpec
- name: 'JAVA_HOME'
- layout: (LayoutFrame 100 0 30 0 -55 1 55 0)
- enableChannel: javaReleaseIsCustomHolder
- model: javaHomeHolder
- immediateAccept: true
- acceptOnPointerLeave: true
- )
- (ActionButtonSpec
- label: 'Browse'
- name: 'JAVA_HOME_Browse'
- layout: (LayoutFrame -50 1 30 0 0 1 55 0)
- translateLabel: true
- model: doBrowseJavaHome
- enableChannel: javaReleaseIsCustomHolder
- )
+ #(FullSpec
+ name: windowSpec
+ window:
+ (WindowSpec
+ label: 'Java Settings'
+ name: 'Java Settings'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 695 627)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: ' Java Settings'
+ name: 'SubVersiSettingsTitle'
+ layout: (LayoutFrame 0 0 0 0 0 1 66 0)
+ style: (FontDescription helvetica medium roman 18 #'iso10646-1')
+ backgroundColor: (Color 100.0 100.0 100.0)
+ translateLabel: true
+ adjust: left
+ )
+ (LabelSpec
+ label: 'Icon'
+ name: 'JavaIcon'
+ layout: (LayoutFrame -75 1 0 0 0 1 66 0)
+ hasCharacterOrientedLabel: false
+ backgroundColor: (Color 100.0 100.0 100.0)
+ translateLabel: true
+ labelChannel: libjavaCupIcon
+ )
+ (SubCanvasSpec
+ name: 'InfoPanel'
+ layout: (LayoutFrame 0 0 67 0 0 1 107 0)
+ level: 0
+ initiallyInvisible: true
+ hasHorizontalScrollBar: false
+ hasVerticalScrollBar: false
+ clientKey: infoPanel
+ createNewBuilder: false
+ )
+ (VerticalPanelViewSpec
+ name: 'Controls'
+ layout: (LayoutFrame 0 0 70 0 0 1 0 1)
+ horizontalLayout: fit
+ verticalLayout: top
+ horizontalSpace: 3
+ verticalSpace: 3
+ component:
+ (SpecCollection
+ collection: (
+ (FramedBoxSpec
+ label: 'Java'
+ name: 'JavaReleasePanel'
+ labelPosition: topLeft
+ translateLabel: true
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Java Home:'
+ name: 'JavaHomeLabel'
+ layout: (LayoutFrame 0 0 0 0 100 0 25 0)
+ translateLabel: true
+ adjust: left
)
-
- )
- extent: (Point 695 95)
- )
- (VariableVerticalPanelSpec
- name: 'VariableVerticalPanel1'
- component:
- (SpecCollection
- collection: (
- (NoteBookViewSpec
- name: 'Notebook'
- menu: tabList
- )
+ (ComboBoxSpec
+ name: 'JavaHomeField'
+ layout: (LayoutFrame 100 0.0 0 0 -61 1.0 25 0)
+ model: javaHomeHolder
+ acceptOnPointerLeave: false
+ comboList: javaHomeList
+ postBuildCallback: postBuildJavaHomeFIeld:
+ )
+ (ActionButtonSpec
+ label: 'Browse'
+ name: 'Button1'
+ layout: (LayoutFrame -60 1 0 0 0 1 25 0)
+ translateLabel: true
+ model: doBrowseJavaHome
)
-
- )
- extent: (Point 695 459)
- handles: (Any 1.0)
- )
+ (LabelSpec
+ label: 'Label'
+ name: 'Label1'
+ layout: (LayoutFrame 100 0 30 0 0 1 55 0)
+ translateLabel: true
+ labelChannel: javaHomeInfoHolder
+ adjust: left
+ )
+ )
+
+ )
+ extent: (Point 695 85)
)
-
- )
- )
+ )
+
+ )
)
-
- )
- )
-! !
-
-!JavaSettingsApplication class methodsFor:'list specs'!
-
-tabList
- "This resource specification was automatically generated
- by the TabListEditor of ST/X."
-
- "Do not manually edit this!! If it is corrupted,
- the TabListEditor may not be able to read the specification."
-
- "
- TabListEditor new openOnClass: self andSelector:#tabList
- "
-
- <resource: #tabList>
-
- ^ #(
- (TabItem
- label: 'Package Libraries'
- minorKey: packageBundleTabSpec
- )
- (TabItem
- label: 'User Libraries'
- minorKey: userBundleTabSpec
- )
+ )
+
)
-
- collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]
-
- "Modified: / 28-01-2013 / 20:33:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ )
! !
!JavaSettingsApplication methodsFor:'actions'!
@@ -540,37 +487,42 @@
| java_home |
- java_home := Dialog requestDirectoryName:(resources string:'JAVA_HOME directory').
+ java_home := Dialog requestDirectoryName:(resources string:'Java Installation Directory').
java_home notEmptyOrNil ifTrue:[
self javaHomeHolder value: java_home
]
- "Modified: / 27-07-2012 / 00:20:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 11:11:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateJavaHomeInfo
+ | home release info |
+
+ home := self javaHomeHolder value.
+ info := ''.
+ home isEmptyOrNil ifTrue:[
+ release := JavaRelease default.
+ ] ifFalse:[
+ home asFilename isDirectory ifTrue:[
+ release := JavaRelease inDirectory: home.
+ ]
+ ].
+ release notNil ifTrue:[
+ info :='%1 (%2%3) ' bindWith: release name
+ with: (release jdkHome notNil ifTrue:[ 'JDK' ] ifFalse:[ 'JRE' ])
+ with: (release isSystem ifTrue:[ ', system' ] ifFalse:[ '' ]).
+ release isSystem ifTrue:[
+ info := info asText allUnderlined.
+ ].
+ ].
+ self javaHomeInfoHolder value: info
+
+ "Created: / 09-12-2014 / 12:56:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 14:08:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSettingsApplication methodsFor:'aspects'!
-environmentBundleHolder
- "return/create the 'environmentBundleHolder' value holder (automatically generated)"
-
- environmentBundleHolder isNil ifTrue:[
- environmentBundleHolder := ValueHolder new.
- ].
- ^ environmentBundleHolder
-!
-
-environmentBundleHolder:something
- "set the 'environmentBundleHolder' value holder (automatically generated)"
-
- environmentBundleHolder := something.
-!
-
-falseHolder
- ^false
-
- "Created: / 28-01-2013 / 20:34:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
infoPanel
infoPanel isNil ifTrue:[
infoPanel := Tools::InlineMessageDialog new.
@@ -584,141 +536,90 @@
<resource: #uiAspect>
javaHomeHolder isNil ifTrue:[
- javaHomeHolder := AspectAdaptor forAspect: #javaHome.
- javaHomeHolder subjectChannel: self javaReleaseHolder.
- javaHomeHolder onChangeSend:#updateModifiedChannel to:self
+ javaHomeHolder := ValueHolder with: Java release javaHome.
+ javaHomeHolder onChangeSend: #updateModifiedChannel to: self.
+ javaHomeHolder onChangeSend: #updateJavaHomeInfo to: self.
].
^ javaHomeHolder.
"Created: / 27-07-2012 / 00:06:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-javaReleaseHolder
- <resource: #uiAspect>
-
- javaReleaseHolder isNil ifTrue:[
- javaReleaseHolder := Java release asValue.
- javaReleaseHolder onChangeSend:#updateModifiedChannel to:self.
- ].
- ^ javaReleaseHolder.
-
- "Modified: / 27-07-2012 / 18:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 06-02-2013 / 08:30:00 / jv"
-!
-
-javaReleaseIsCustomHolder
- <resource: #uiAspect>
-
- javaReleaseIsCustomHolder isNil ifTrue:[
- javaReleaseIsCustomHolder := AspectAdaptor forAspect: #isCustom.
- javaReleaseIsCustomHolder subjectChannel: self javaReleaseHolder
- ].
- ^ javaReleaseIsCustomHolder.
-
- "Created: / 27-07-2012 / 00:07:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-javaReleaseList
- <resource: #uiAspect>
-
-
- javaReleaseList isNil ifTrue:[
- javaReleaseList := JavaRelease all asList
- ].
- ^ javaReleaseList.
-
- "Modified: / 27-07-2012 / 00:13:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 12:57:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-jdkBundleHolder
- "return/create the 'jdkBundleHolder' value holder (automatically generated)"
+javaHomeInfoHolder
+ <resource: #uiAspect>
+
+ "automatically generated by UIPainter ..."
- jdkBundleHolder isNil ifTrue:[
- jdkBundleHolder := ValueHolder new.
+ "*** the code below creates a default model when invoked."
+ "*** (which may not be the one you wanted)"
+ "*** Please change as required and accept it in the browser."
+ "*** (and replace this comment by something more useful ;-)"
+
+ javaHomeInfoHolder isNil ifTrue:[
+ javaHomeInfoHolder := ValueHolder new.
+"/ if your app needs to be notified of changes, uncomment one of the lines below:
+"/ javaHomeInfoHolder addDependent:self.
+"/ javaHomeInfoHolder onChangeSend:#javaHomeInfoHolderChanged to:self.
].
- ^ jdkBundleHolder
-!
-
-jdkBundleHolder:something
- "set the 'jdkBundleHolder' value holder (automatically generated)"
-
- jdkBundleHolder := something.
+ ^ javaHomeInfoHolder.
!
-packageBundleHolder
- "return/create the 'packageBundleHolder' value holder (automatically generated)"
+javaHomeList
+ <resource: #uiAspect>
- packageBundleHolder isNil ifTrue:[
- packageBundleHolder := ValueHolder new.
- ].
- ^ packageBundleHolder
-!
-
-packageBundleHolder:something
- "set the 'packageBundleHolder' value holder (automatically generated)"
+ ^ [
+ | homesAndReleases |
- packageBundleHolder := something.
-!
-
-tabList
- "Generated by the TabListEditor"
+ homesAndReleases := OrderedCollection withAll: JavaRelease available .
+ (homesAndReleases includesIdentical: JavaRelease system) ifFalse:[
+ homesAndReleases add: JavaRelease system.
+ ].
+ (homesAndReleases anySatisfy: [:release | release javaHome = self javaHomeHolder value ]) ifFalse:[
+ homesAndReleases addFirst: self javaHomeHolder value.
+ ].
+ homesAndReleases addLast: ((resources string:'Autodetect') asText colorizeAllWith: Color gray).
+ homesAndReleases.
+ ]
- |list|
-
- (list := builder bindingAt:#tabList) isNil ifTrue:[
- builder aspectAt:#tabList put:(list := self class tabList).
- ].
- ^ list
+ "Created: / 09-12-2014 / 11:22:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 14:06:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
trueHolder
^true
"Created: / 28-01-2013 / 20:34:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+! !
+
+!JavaSettingsApplication methodsFor:'hooks'!
-userBundleHolder
- "return/create the 'userBundleHolder' value holder (automatically generated)"
-
- userBundleHolder isNil ifTrue:[
- userBundleHolder := ValueHolder new.
+postBuildJavaHomeFIeld: aComboBox
+ aComboBox menuSelectAction: [ :value |
+ value = (resources string:'Autodetect') ifTrue:[
+ aComboBox field contents: ''
+ ] ifFalse:[
+ aComboBox field contents: (value isString ifTrue:[ value ] ifFalse:[ value javaHome ])
+ ]
].
- ^ userBundleHolder
-!
+ aComboBox field emptyFieldReplacementText: (resources string:'Autodetect')
-userBundleHolder:something
- "set the 'userBundleHolder' value holder (automatically generated)"
-
- userBundleHolder := something.
+ "Modified: / 09-12-2014 / 14:04:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSettingsApplication methodsFor:'protocol'!
basicReadSettings
- | rel cpb |
+ self javaHomeHolder value: currentUserPrefs javaHome.
+ self updateJavaHomeInfo.
- rel := currentUserPrefs javaRelease.
- (rel isNil and:[Java notNil]) ifTrue:[
- rel := Java release
- ].
-
- self javaReleaseHolder value: rel.
- cpb := Java classPathBundle.
- self userBundleHolder value: cpb user deepCopy.
- self packageBundleHolder value: cpb packages.
- self environmentBundleHolder value: cpb environment.
-
- "Modified: / 28-01-2013 / 20:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 09-12-2014 / 14:53:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
basicSaveSettings
- self javaReleaseHolder value notNil ifTrue:[
- currentUserPrefs javaReleaseSelector: self javaReleaseHolder value selector.
- ] ifFalse:[
- currentUserPrefs javaReleaseSelector: nil.
- ].
+ currentUserPrefs javaHome:self javaHomeHolder value
- "Modified: / 25-01-2013 / 22:25:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 12:43:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
helpFilename
@@ -734,38 +635,76 @@
!JavaSettingsApplication methodsFor:'queries'!
hasUnsavedChanges
- "superclass AbstractSettingsApplication says that I am responsible to implement this method"
- | prefRel setRel |
-
- prefRel := currentUserPrefs javaRelease.
- setRel := self javaReleaseHolder value.
-
- (setRel validateJavaHome: self javaHomeHolder value) ifFalse:[
- self infoPanel
- reset;
- beWarning;
- message: (resources string: 'JAVA_HOME is not valid');
- show.
- ^ false "/ Hack, this effectively disables the "Apply" button...
- ] ifTrue:[
- self infoPanel hide.
+ self validate ifFalse:[
+ ^ false "/ Effectively disables the 'Apply' button.
].
- prefRel ~~ setRel ifTrue:[ ^ true ].
+ self javaHomeHolder value ~= currentUserPrefs javaHome ifTrue:[ ^ true ].
+
+ ^ false
+
+ "Modified: / 09-12-2014 / 12:42:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaSettingsApplication methodsFor:'validation'!
+validate
+ self validateJavaHome ifFalse:[ ^ false ].
+ self validationOK.
+ ^ true
+ "Created: / 09-12-2014 / 12:27:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+validateJavaHome
+ | javaHome javaRelease |
+ javaHome := self javaHomeHolder value.
+ javaHome isEmptyOrNil ifTrue:[
+ ^ true.
+ ].
+ javaHome asFilename exists ifFalse:[
+ self validationError: (resources string: 'Java home does not exist').
+ ^ false.
+ ].
+ javaHome asFilename isDirectory ifFalse:[
+ self validationError: (resources string: 'Java home is not a directory').
+ ^ false.
+ ].
+ javaRelease := JavaRelease inDirectory: javaHome.
+ javaRelease isNil ifTrue:[
+ self validationError: (resources string: 'Cannot find JDK or JRE in specified java home').
+ ^ false
+ ].
+ ^ true
- ^false
+ "Created: / 09-12-2014 / 12:19:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 09-12-2014 / 14:06:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
- "Modified: / 16-01-2013 / 13:44:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+validationError:message
+ self infoPanel
+ reset;
+ beWarning;
+ message: message;
+ show.
+
+ "Created: / 09-12-2014 / 12:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+validationOK
+ self infoPanel
+ reset;
+ hide.
+
+ "Created: / 09-12-2014 / 12:26:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!JavaSettingsApplication class methodsFor:'documentation'!
version_CVS
- ^ '$Header: /cvs/stx/stx/libjava/tools/JavaSettingsApplication.st,v 1.3 2013-09-06 00:45:28 vrany Exp $'
+ ^ '$Header: /cvs/stx/stx/libjava/tools/JavaSettingsApplication.st,v 1.4 2015-01-28 02:12:02 vrany Exp $'
!
version_HG
@@ -774,7 +713,7 @@
!
version_SVN
- ^ '§Id:: §'
+ ^ 'Id:: '
! !