--- a/mercurial/HGSourceCodeManagementSettingsAppl.st Wed Jan 14 10:02:24 2015 +0100
+++ b/mercurial/HGSourceCodeManagementSettingsAppl.st Fri Jan 16 15:42:08 2015 +0100
@@ -1,6 +1,6 @@
"
stx:libscm - a new source code management library for Smalltalk/X
-Copyright (C) 2012-2013 Jan Vrany
+Copyright (C) 2012-2015 Jan Vrany
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -19,8 +19,9 @@
"{ Package: 'stx:libscm/mercurial' }"
AbstractSourceCodeManagementSettingsAppl subclass:#HGSourceCodeManagementSettingsAppl
- instanceVariableNames:'defaultLogo hgCommand hgDiff2Command hgDiff3Command hgAutopush'
- classVariableNames:''
+ instanceVariableNames:'defaultLogo hgCommand hgDiff2Command hgDiff3Command hgAutopush
+ infoPanel hgrcAspect'
+ classVariableNames:'IgnoreCheckUsername IgnoreCheckMenuLayout'
poolDictionaries:''
category:'SCM-Mercurial-StX-Interface'
!
@@ -30,7 +31,7 @@
copyright
"
stx:libscm - a new source code management library for Smalltalk/X
-Copyright (C) 2012-2013 Jan Vrany
+Copyright (C) 2012-2015 Jan Vrany
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -48,6 +49,19 @@
"
! !
+!HGSourceCodeManagementSettingsAppl class methodsFor:'initialization'!
+
+initialize
+ "Invoked at system start or when the class is dynamically loaded."
+
+ "/ please change as required (and remove this comment)
+
+ IgnoreCheckUsername := false.
+ IgnoreCheckMenuLayout := false.
+
+ "Modified: / 18-02-2014 / 11:46:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGSourceCodeManagementSettingsAppl class methodsFor:'image specs'!
defaultIcon
@@ -232,119 +246,44 @@
translateLabel: true
labelChannel: defaultLogo
)
- (CheckBoxSpec
- label: 'Show in Menus'
- name: 'CheckBox1'
- layout: (LayoutFrame 0 0 73 0 0 1 103 0)
- activeHelpKey: shownInBrowserMenus
- model: shownInBrowserMenusHolder
- translateLabel: true
- )
(ViewSpec
- name: 'Settings'
- layout: (LayoutFrame 0 0 105 0 0 1 0 1)
+ name: 'OuterPanel'
+ layout: (LayoutFrame 0 0 67 0 0 1 0 1)
component:
(SpecCollection
collection: (
- (VerticalPanelViewSpec
- name: 'GeneralSettingsPanel'
+ (SubCanvasSpec
+ name: 'InfoPanel'
+ layout: (LayoutFrame 0 0 0 0 0 1 40 0)
+ level: 0
+ initiallyInvisible: true
+ hasHorizontalScrollBar: false
+ hasVerticalScrollBar: false
+ clientKey: infoPanel
+ createNewBuilder: false
+ )
+ (ViewSpec
+ name: 'InnerPanel'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
- horizontalLayout: fit
- verticalLayout: top
- horizontalSpace: 3
- verticalSpace: 3
component:
(SpecCollection
collection: (
- (ViewSpec
- name: 'Panel1'
- component:
- (SpecCollection
- collection: (
- (LabelSpec
- label: '''hg'' command:'
- name: 'CommandLabel'
- layout: (LayoutFrame 5 0 0 0 150 0 30 0)
- translateLabel: true
- adjust: right
- )
- (FilenameInputFieldSpec
- name: 'HGCommand'
- layout: (LayoutFrame 150 0 0 0 -100 1 0 1)
- model: hgCommand
- acceptOnPointerLeave: true
- emptyFieldReplacementText: 'Autodetect'
- )
- (ActionButtonSpec
- label: 'Test'
- name: 'HGCommandTest'
- layout: (LayoutFrame -100 1 0 0 -8 1 0 1)
- translateLabel: true
- model: doTestHGCommand
- enableChannel: svnEnabled
- )
- )
-
- )
- extent: (Point 695 30)
+ (CheckBoxSpec
+ label: 'Show in Menus'
+ name: 'CheckBox1'
+ layout: (LayoutFrame 0 0 0 0 0 1 30 0)
+ activeHelpKey: shownInBrowserMenus
+ model: shownInBrowserMenusHolder
+ translateLabel: true
)
(ViewSpec
- name: 'Spacer'
- extent: (Point 695 15)
- )
- (FramedBoxSpec
- label: 'External Tools'
- name: 'ToolsSettings'
- initiallyInvisible: true
- labelPosition: topLeft
- translateLabel: true
- component:
- (SpecCollection
- collection: (
- (LabelSpec
- label: 'Diff2:'
- name: 'Label1'
- layout: (LayoutFrame 0 0 0 0 80 0 30 0)
- translateLabel: true
- adjust: left
- )
- (FilenameInputFieldSpec
- name: 'FilenameEntryField1'
- layout: (LayoutFrame 80 0 3 0 0 1 28 0)
- enableChannel: svnEnabled
- model: hgDiff2Command
- acceptOnPointerLeave: true
- )
- (LabelSpec
- label: 'Diff3:'
- name: 'Label2'
- layout: (LayoutFrame 0 0 30 0 80 0 0 1.0)
- translateLabel: true
- adjust: left
- )
- (FilenameInputFieldSpec
- name: 'FilenameEntryField2'
- layout: (LayoutFrame 80 0 33 0 0 1 58 0)
- enableChannel: svnEnabled
- model: hgDiff3Command
- acceptOnPointerLeave: true
- )
- )
-
- )
- extent: (Point 695 95)
- )
- (FramedBoxSpec
- label: 'Debugging'
- name: 'DebugSettings'
- initiallyInvisible: true
- labelPosition: topLeft
- translateLabel: true
+ name: 'Settings'
+ layout: (LayoutFrame 0 0 40 0 0 1 0 1)
component:
(SpecCollection
collection: (
(VerticalPanelViewSpec
- name: 'VerticalPanel1'
+ name: 'GeneralSettingsPanel'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
horizontalLayout: fit
verticalLayout: top
@@ -353,13 +292,98 @@
component:
(SpecCollection
collection: (
+ (ViewSpec
+ name: 'Panel1'
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: '''hg'' command:'
+ name: 'CommandLabel'
+ layout: (LayoutFrame 5 0 0 0 120 0 30 0)
+ translateLabel: true
+ adjust: left
+ )
+ (FilenameInputFieldSpec
+ name: 'HGCommand'
+ layout: (LayoutFrame 125 0 0 0 -100 1 0 1)
+ enableChannel: hgEnabled
+ model: hgCommand
+ acceptOnPointerLeave: true
+ emptyFieldReplacementText: 'Autodetect'
+ )
+ (ActionButtonSpec
+ label: 'Test'
+ name: 'HGCommandTest'
+ layout: (LayoutFrame -100 1 0 0 -8 1 0 1)
+ visibilityChannel: false
+ translateLabel: true
+ model: doTestHGCommand
+ )
+ (ActionButtonSpec
+ label: 'Browse'
+ name: 'BrowseButton'
+ layout: (LayoutFrame -100 1 0 0 -8 1 0 1)
+ translateLabel: true
+ model: doSelectHGCommand
+ enableChannel: hgEnabled
+ )
+ )
+
+ )
+ extent: (Point 695 25)
+ )
+ (ViewSpec
+ name: 'Spacer1'
+ extent: (Point 695 15)
+ )
(CheckBoxSpec
- label: 'Verbose (Traces svn commands to Transcript)'
- name: 'Verbose'
- enableChannel: svnEnabled
- model: svnVerbose
+ label: 'Automatically push changes to upstream repository'
+ name: 'CheckBox2'
+ enableChannel: hgEnabled
+ model: hgAutopush
translateLabel: true
- useDefaultExtent: true
+ extent: (Point 695 22)
+ )
+ (ViewSpec
+ name: 'Spacer2'
+ extent: (Point 695 14)
+ )
+ (ViewSpec
+ name: 'SettingsFile'
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Mercurial user configuration file:'
+ name: 'Label1'
+ layout: (LayoutFrame 25 0 -1 0 0 1 24 0)
+ translateLabel: true
+ adjust: left
+ )
+ (LinkButtonSpec
+ label: 'LinkButton'
+ name: 'EditPreferences'
+ layout: (LayoutFrame 25 0 28 0 -100 1 58 0)
+ foregroundColor: (Color 0.0 0.0 100.0)
+ translateLabel: true
+ labelChannel: hgrcAspect
+ adjust: left
+ model: doEditHGRC
+ enableChannel: hgEnabled
+ )
+ (ActionButtonSpec
+ label: 'Edit'
+ name: 'Button1'
+ layout: (LayoutFrame -106 1 -17 0.5 -6 1 8 0.5)
+ translateLabel: true
+ model: doEditHGRC
+ enableChannel: hgEnabled
+ )
+ )
+
+ )
+ extent: (Point 695 92)
)
)
@@ -368,14 +392,6 @@
)
)
- extent: (Point 695 70)
- )
- (CheckBoxSpec
- label: 'Automatically push changes to upstream repository'
- name: 'CheckBox2'
- model: hgAutopush
- translateLabel: true
- extent: (Point 695 30)
)
)
@@ -404,6 +420,53 @@
!HGSourceCodeManagementSettingsAppl methodsFor:'actions'!
+doCheckSettings
+ "Perform some sanity check on current configuration"
+
+ self doCheckUsername ifFalse:[ ^ self ].
+ self doCheckMenuLayout ifFalse:[ ^ self ].
+ self doCheckCommand ifFalse:[ ^ self ].
+ self infoPanel hide.
+
+ "Created: / 18-02-2014 / 10:04:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 21-02-2014 / 10:32:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doEditHGRC
+ <resource: #uiCallback>
+
+ | hgrc editor |
+
+ hgrc := self hgrcAspect value asString string asFilename.
+ hgrc exists ifFalse:[
+ hgrc writingFileDo:[ :s |
+ s nextPutAll: HGConfig userConfigFileTemplate
+ ].
+ ].
+ editor := WorkspaceApplication new.
+ editor open.
+ editor enqueueDelayedAction:[
+ editor loadFile: hgrc.
+ editor syntaxHolder value: nil.
+ ]
+
+ "Modified: / 18-02-2014 / 10:43:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doSelectHGCommand
+ | guess executable |
+
+ guess := OperatingSystem pathOfCommand: 'hg'.
+ executable := Dialog requestFileName:(resources string:'Select hg command') default: guess ifFail:[ ^ self ].
+ (executable includes: Character space) ifTrue:[
+ executable := '"' , executable , '"'.
+ ].
+ self hgCommand value: executable
+
+ "Created: / 21-02-2014 / 10:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 17-07-2014 / 19:39:31 / jv"
+!
+
doTestHGCommand
self hgCommand value isEmptyOrNil ifTrue:[
@@ -441,6 +504,111 @@
"Modified: / 21-01-2013 / 05:12:39 / jv"
! !
+!HGSourceCodeManagementSettingsAppl methodsFor:'actions-checks'!
+
+doCheckCommand
+ "Check `hg` command. Return true if `hg` command exists
+ and of supported version, false otherwise."
+
+ | command |
+
+ command := self hgCommand value.
+ command isEmptyOrNil ifTrue:[
+ command := OperatingSystem pathOfCommand:'hg'.
+ command isNil ifTrue:[
+ self infoPanel
+ reset;
+ beWarning;
+ message: (resources string:'Cannot find path to `hg` command');
+ addButtonWithLabel: (self resources string:'Browse') action: [self infoPanel hide. self doSelectHGCommand ];
+ show.
+ ^ false
+ ].
+ ].
+ [
+ HGCommand hgCommandValidate: command
+ ] on: HGInvalidVersionError do:[:ex |
+ self infoPanel
+ reset;
+ beWarning;
+ message: (resources string:'Unssuported Mercurial version %1' with: (ex parameter asStringWith: $.));
+ addButtonWithLabel: (self resources string:'Browse') action: [self infoPanel hide. self doSelectHGCommand ];
+ show.
+ ^ false
+ ] on: HGCommandError do:[:ex |
+ self infoPanel
+ reset;
+ beWarning;
+ message: (resources string:ex description);
+ addButtonWithLabel: (self resources string:'Browse') action: [self infoPanel hide. self doSelectHGCommand ];
+ show.
+ ^ false
+ ].
+ ^ true.
+
+ "Created: / 21-02-2014 / 09:58:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doCheckMenuLayout
+ "Check if browser SCM menu layouyt is not #old. Return true, if yes,
+ false otherwise. As a sideffect, show message in info panel"
+
+ IgnoreCheckUsername ifTrue:[ ^ true ].
+ (UserPreferences current sourceCodeManagementMenuLayout = #old) ifTrue:[
+ self infoPanel
+ reset;
+ beWarning;
+ message: (resources string:'SCM menu layout in set to ''old'' which does not support HG');
+ addButtonWithLabel: (self resources string:'Use ''Compact''') action: [
+ UserPreferences current sourceCodeManagementMenuLayout: #compact.
+ (Dialog confirm: (resources string: 'Settings changed to ''Compact''\\Save settings?') withCRs) ifTrue:[
+ SettingsDialog saveSettingsWithoutAskingForFile
+ ].
+ self doCheckCommand
+ ];
+ addButtonWithLabel: (self resources string:'Use ''Inline''') action: [
+ UserPreferences current sourceCodeManagementMenuLayout: #inline.
+ (Dialog confirm: (resources string: 'Settings changed to ''Compact''\\Save settings?') withCRs) ifTrue:[
+ SettingsDialog saveSettingsWithoutAskingForFile
+ ].
+ self doCheckCommand
+ ];
+ addButtonWithLabel: (resources string:'Ignore') action: [IgnoreCheckUsername := true. self infoPanel hide.];
+ show.
+ ^ false
+ ].
+ ^ true.
+
+ "Created: / 18-02-2014 / 11:46:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 21-02-2014 / 10:32:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+doCheckUsername
+ "Check if username is configured. Return true, if yes,
+ false otherwise. As a sideffect, show message in info panel"
+
+ | username |
+
+ IgnoreCheckUsername ifTrue:[ ^ true ].
+ username := HGConfig userConfig ui_username.
+ "/ Check for lazy users which only uncomment the line and
+ "/ does not bother with filling in proper values. See
+ "/ HGConfig userConfigFileTemplate
+ (username isNil or:[username = 'FirstName LastName <Email>']) ifTrue:[
+ self infoPanel
+ reset;
+ beWarning;
+ message: (resources string:'Commit author signature not configured');
+ addButtonWithLabel: (self resources string:'Edit') action: [self doEditHGRC. self doCheckMenuLayout];
+ addButtonWithLabel: (resources string:'Ignore') action: [IgnoreCheckUsername := true. self doCheckMenuLayout];
+ show.
+ ^ false
+ ].
+ ^ true.
+
+ "Created: / 18-02-2014 / 11:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGSourceCodeManagementSettingsAppl methodsFor:'aspects'!
hgAutopush
@@ -456,11 +624,12 @@
hgCommand
hgCommand isNil ifTrue:[
- hgCommand := self settingsAspectFor: #hgCommand
+ hgCommand := self settingsAspectFor: #hgCommand.
+ hgCommand onChangeSend: #doCheckCommand to: self.
].
^ hgCommand
- "Modified: / 19-11-2012 / 21:30:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 21-02-2014 / 10:33:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
hgDiff2Command
@@ -483,10 +652,54 @@
"Created: / 19-11-2012 / 21:30:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+hgrcAspect
+ <resource: #uiAspect>
+
+ hgrcAspect isNil ifTrue:[
+ | hgrc |
+
+ hgrc := HGConfig userConfigFile asString asText.
+ hgrc actionForAll:[ self doEditHGRC ].
+ hgrcAspect := hgrc asValue.
+ ].
+ ^ hgrcAspect.
+
+ "Modified: / 18-02-2014 / 10:40:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+infoPanel
+ infoPanel isNil ifTrue:[
+ infoPanel := Tools::InlineMessageDialog new
+ ].
+ ^ infoPanel
+
+ "Created: / 09-02-2012 / 19:23:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 18-02-2014 / 10:02:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
settings
^#(hgCommand hgAutopush)
"Created: / 10-12-2012 / 02:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+shownInBrowserMenusHolder
+ shownInBrowserMenusHolder isNil ifTrue:[
+ shownInBrowserMenusHolder := true asValue.
+ shownInBrowserMenusHolder onChangeSend:#updateModifiedChannel to:self.
+ shownInBrowserMenusHolder onChangeSend:#doCheckSettings to:self.
+ ].
+ ^ shownInBrowserMenusHolder.
+
+ "Created: / 18-02-2014 / 10:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!HGSourceCodeManagementSettingsAppl methodsFor:'aspects-queries'!
+
+hgEnabled
+ ^ self shownInBrowserMenusHolder
+
+ "Created: / 21-02-2014 / 10:37:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!HGSourceCodeManagementSettingsAppl methodsFor:'help'!
@@ -516,6 +729,14 @@
"Modified: / 22-12-2011 / 15:13:37 / cg"
! !
+!HGSourceCodeManagementSettingsAppl methodsFor:'hooks'!
+
+commonPostOpen
+ self doCheckSettings
+
+ "Created: / 18-02-2014 / 10:05:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!HGSourceCodeManagementSettingsAppl methodsFor:'protocol'!
basicReadSettings
@@ -588,11 +809,11 @@
!HGSourceCodeManagementSettingsAppl class methodsFor:'documentation'!
version
- ^ '$Header$'
+ ^ '$Header: /cvs/stx/stx/libscm/mercurial/HGSourceCodeManagementSettingsAppl.st,v 1.6 2015-01-16 14:42:08 vrany Exp $'
!
version_CVS
- ^ '$Header$'
+ ^ '$Header: /cvs/stx/stx/libscm/mercurial/HGSourceCodeManagementSettingsAppl.st,v 1.6 2015-01-16 14:42:08 vrany Exp $'
!
version_HG
@@ -601,6 +822,8 @@
!
version_SVN
- ^ '$Id$'
+ ^ '$Id: HGSourceCodeManagementSettingsAppl.st,v 1.6 2015-01-16 14:42:08 vrany Exp $'
! !
+
+HGSourceCodeManagementSettingsAppl initialize!