--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomCodeGeneratorOrRefactoring.st Sun Dec 01 00:31:23 2013 +0000
@@ -0,0 +1,607 @@
+"
+ COPYRIGHT (c) 2002 by eXept Software AG
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+"{ Package: 'jn:refactoring_custom' }"
+
+CodeGeneratorTool subclass:#CustomCodeGeneratorOrRefactoring
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Refactoring-Custom'
+!
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 2002 by eXept Software AG
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+documentation
+"
+
+"
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'instance creation'!
+
+new
+ ^ self subclassResponsibility.
+
+ "Modified: / 23-08-2013 / 22:19:23 / user"
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'compilation'!
+
+compile:theCode forClass:aClass inCategory:cat
+ "install some code for a class.
+ If refactory browser stuff is avaliable the refactory tools are used to support undo"
+
+ ^ self new compile:theCode forClass:aClass inCategory:cat
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'interface specs'!
+
+initialMenuSpecForApplications
+ "return a menuSpec with typical stuff in it"
+
+ "This resource specification was automatically generated by the CustomCodeGeneratorAbstract."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+ "
+ MenuEditor new openOnClass:self andSelector:#initialMenuSpecForApplications
+ "
+
+ <resource: #menu>
+
+ ^ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'File'
+ #translateLabel: true
+ #submenu:
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'New'
+ #translateLabel: true
+ #value: #menuNew
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Open...'
+ #translateLabel: true
+ #value: #menuOpen
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Save'
+ #translateLabel: true
+ #value: #menuSave
+ )
+ #(#MenuItem
+ #label: 'Save As...'
+ #translateLabel: true
+ #value: #menuSaveAs
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Exit'
+ #translateLabel: true
+ #value: #closeRequest
+ )
+ ) nil
+ nil
+ )
+ )
+ #(#MenuItem
+ #label: 'Help'
+ #translateLabel: true
+ #startGroup: #right
+ #submenu:
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'Documentation'
+ #translateLabel: true
+ #value: #openDocumentation
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'About this Application...'
+ #translateLabel: true
+ #value: #openAboutThisApplication
+ )
+ ) nil
+ nil
+ )
+ )
+ ) nil
+ nil
+ )
+!
+
+initialPageMenuSpecForWebApplications
+ "return a menuSpec with typical stuff in it"
+
+ "This resource specification was automatically generated by the CustomCodeGeneratorAbstract."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+ "
+ MenuEditor new openOnClass:self andSelector:#initialPageMenuSpecForWebApplications
+ "
+
+ <resource: #menu>
+
+ ^ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'File'
+ #translateLabel: true
+ #submenu:
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'New'
+ #translateLabel: true
+ #value: #menuNew
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Open...'
+ #translateLabel: true
+ #value: #menuOpen
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Save'
+ #translateLabel: true
+ #value: #menuSave
+ )
+ #(#MenuItem
+ #label: 'Save As...'
+ #translateLabel: true
+ #value: #menuSaveAs
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'Exit'
+ #translateLabel: true
+ #value: #closeRequest
+ )
+ ) nil
+ nil
+ )
+ )
+ #(#MenuItem
+ #label: 'Help'
+ #translateLabel: true
+ #startGroup: #right
+ #submenu:
+ #(#Menu
+ #(
+ #(#MenuItem
+ #label: 'Documentation'
+ #translateLabel: true
+ #value: #openDocumentation
+ )
+ #(#MenuItem
+ #label: '-'
+ )
+ #(#MenuItem
+ #label: 'About this Application...'
+ #translateLabel: true
+ #value: #openAboutThisApplication
+ )
+ ) nil
+ nil
+ )
+ )
+ ) nil
+ nil
+ )
+!
+
+initialPageSpecForWebApplications
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:self andSelector:#initialPageSpecForWebApplications
+ "
+
+ <resource: #canvas>
+
+ ^ #(#FullSpec
+ #window:
+ #(#WindowSpec
+ #name: '%1'
+ #layout: #(#LayoutFrame 204 0 162 0 503 0 461 0)
+ #label: '%1'
+ #min: #(#Point 10 10)
+ #max: #(#Point 1024 768)
+ #bounds: #(#Rectangle 204 162 504 462)
+ #menu: #pageMenu
+ #usePreferredExtent: false
+ )
+ #component:
+ #(#SpecCollection
+ #collection: #()
+ )
+ )
+
+ "Modified: / 14-07-2011 / 16:44:20 / cg"
+!
+
+initialToolbarMenuSpec
+ "This resource specification was automatically generated
+ by the MenuEditor of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the MenuEditor may not be able to read the specification."
+
+
+ "
+ MenuEditor new openOnClass:CustomCodeGeneratorAbstract andSelector:#initialToolbarMenuSpec
+ (Menu new fromLiteralArrayEncoding:(CustomCodeGeneratorAbstract initialToolbarMenuSpec)) startUp
+ "
+
+ <resource: #menu>
+
+ ^
+ #(Menu
+ (
+ (MenuItem
+ label: 'Reload'
+ itemValue: menuReload
+ translateLabel: true
+ isButton: true
+ labelImage: (ResourceRetriever ToolbarIconLibrary reload24x24Icon)
+ )
+ )
+ nil
+ nil
+ )
+!
+
+initialWindowSpecForApplications
+ "This resource specification was automatically generated
+ by the UIPainter of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:CustomCodeGeneratorAbstract andSelector:#initialWindowSpecForApplications
+ "
+
+ <resource: #canvas>
+
+ ^
+ #(FullSpec
+ name: initialWindowSpecForApplications
+ window:
+ (WindowSpec
+ label: '%1'
+ name: '%1'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 300 300)
+ menu: mainMenu
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Hello World'
+ name: 'Label1'
+ layout: (LayoutFrame 0 0.0 60 0 0 1.0 219 0)
+ translateLabel: true
+ )
+ )
+
+ )
+ )
+
+ "Modified: / 07-05-2010 / 14:21:48 / cg"
+!
+
+initialWindowSpecForApplications2
+ "This resource specification was automatically generated
+ by the UIPainter of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:CustomCodeGeneratorAbstract andSelector:#initialWindowSpecForApplications2
+ "
+
+ <resource: #canvas>
+
+ ^
+ #(FullSpec
+ name: initialWindowSpecForApplications2
+ window:
+ (WindowSpec
+ label: '%1'
+ name: '%1'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 300 300)
+ menu: mainMenu
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (MenuPanelSpec
+ name: 'ToolBar1'
+ layout: (LayoutFrame 0 0.0 0 0 0 1.0 36 0)
+ menu: toolbarMenu
+ textDefault: true
+ )
+ (ViewSpec
+ name: 'Box1'
+ layout: (LayoutFrame 1 0 36 0 0 1 -26 1)
+ level: 1
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Hello World'
+ name: 'Contents'
+ layout: (LayoutFrame 0 0 0 0 0 1 0 1)
+ translateLabel: true
+ )
+ )
+
+ )
+ )
+ (ViewSpec
+ name: 'Box2'
+ layout: (LayoutFrame 0 0 -26 1 0 1 0 1)
+ level: 1
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'InfoLabel'
+ name: 'Label2'
+ layout: (LayoutFrame 0 0 -26 1 -1 1 0 1)
+ level: -1
+ translateLabel: true
+ labelChannel: infoLabelHolder
+ adjust: left
+ )
+ )
+
+ )
+ )
+ )
+
+ )
+ )
+!
+
+initialWindowSpecForDialogs
+ "This resource specification was automatically generated
+ by the UIPainter of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:CustomCodeGeneratorAbstract andSelector:#initialWindowSpecForDialogs
+ "
+
+ <resource: #canvas>
+
+ ^
+ #(FullSpec
+ name: initialWindowSpecForDialogs
+ window:
+ (WindowSpec
+ label: '%1'
+ name: '%1'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 300 300)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (HorizontalPanelViewSpec
+ name: 'buttonPanel'
+ layout: (LayoutFrame 0 0.0 -40 1 0 1.0 0 1.0)
+ horizontalLayout: spreadSpaceMax
+ verticalLayout: center
+ horizontalSpace: 3
+ verticalSpace: 3
+ reverseOrderIfOKAtLeft: true
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'Cancel'
+ name: 'cancelButton'
+ translateLabel: true
+ tabable: true
+ model: cancel
+ extent: (Point 125 22)
+ )
+ (ActionButtonSpec
+ label: 'OK'
+ name: 'okButton'
+ translateLabel: true
+ tabable: true
+ model: accept
+ isDefault: true
+ extent: (Point 125 22)
+ )
+ )
+
+ )
+ )
+ )
+
+ )
+ )
+
+ "Modified: / 07-05-2010 / 14:21:55 / cg"
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'private'!
+
+canUseRefactoringSupport
+ "check if refactory browser stuff is avaliable"
+
+ ^ RefactoryChangeManager notNil
+ and:[RefactoryChangeManager isLoaded
+ and:[UserPreferences current useRefactoringSupport]]
+!
+
+methodNameTemplateFor:aSelector
+ self subclassResponsibility
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'utilities'!
+
+missingRequiredProtocolFor:aClass
+ "return the missing required protocol;
+ that is the set of selectors which send #subclassResponsibility in a superclass and
+ have no implementation in aClass or in any class between aClass and that superclass"
+
+ |requiredSelectors implementedSelectors|
+
+ requiredSelectors := IdentitySet new.
+ implementedSelectors := IdentitySet withAll:(aClass methodDictionary keys).
+
+ aClass allSuperclassesDo:[:eachSuperClass |
+ eachSuperClass methodDictionary keysAndValuesDo:[:eachSelector :eachMethod |
+ (eachMethod sends:#subclassResponsibility or:#subclassResponsibility:) ifTrue:[
+ (implementedSelectors includes:eachSelector) ifFalse:[
+ requiredSelectors add:eachSelector.
+ ]
+ ] ifFalse:[
+ (requiredSelectors includes:eachSelector) ifFalse:[
+ implementedSelectors add:eachSelector.
+ ].
+ ].
+ ]
+ ].
+ ^ requiredSelectors
+
+ "Modified: / 08-08-2011 / 18:44:58 / cg"
+! !
+
+!CustomCodeGeneratorOrRefactoring methodsFor:'accessing-presentation'!
+
+description
+ "Returns more detailed description of the receiver"
+
+ ^ self subclassResponsibility
+
+ "Created: / 01-12-2013 / 00:18:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+group
+ "Returns a collection strings describing a group to which
+ receiver belongs. A groups may be nested hence the array of
+ strings. For example for subgroup 'accessors' in group 'generate'
+ this method should return #('generate' 'accessors')."
+
+ "/ By default return an empty array which means the item will appear
+ "/ in top-level group.
+ ^ #()
+
+ "Created: / 01-12-2013 / 00:21:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+label
+ "Returns show label describing the receiver. This label
+ is used in UI as menu item/tree item label."
+
+ ^ self subclassResponsibility
+
+ "Created: / 01-12-2013 / 00:18:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CustomCodeGeneratorOrRefactoring methodsFor:'executing'!
+
+executeInContext: aCustomContext
+ "Generates the code or perform the refactoring. This method
+ is guaranteed to be called only if #availableInContext: returns
+ true.
+
+ Called by the UI when user want to perform the task"
+
+ self subclassResponsibility
+
+ "Created: / 01-12-2013 / 00:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CustomCodeGeneratorOrRefactoring methodsFor:'queries'!
+
+availableInContext: aCustomContext
+ "Returns true if the generator/refactoring is available in given
+ context, false otherwise.
+
+ Called by the UI to figure out what generators / refactorings
+ are available at given point. See class CustomContext for details."
+
+ ^ self subclassResponsibility
+
+ "Created: / 01-12-2013 / 00:13:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!CustomCodeGeneratorOrRefactoring class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libtool/CustomCodeGeneratorAbstract.st,v 1.100 2012-10-15 20:17:19 cg Exp $'
+!
+
+version_CVS
+ ^ '$Header: /cvs/stx/stx/libtool/CustomCodeGeneratorAbstract.st,v 1.100 2012-10-15 20:17:19 cg Exp $'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+!
+
+version_SVN
+ ^ '$Id: CustomCodeGeneratorAbstract.st 8074 2012-11-30 17:23:39Z vranyj1 $'
+! !
+