ResourceSpecEditor.st
author Claus Gittinger <cg@exept.de>
Mon, 13 Feb 2006 09:50:23 +0100
changeset 2097 7f078c4af09d
parent 2037 a99b25a83641
child 2102 ef76fea01343
permissions -rw-r--r--
code cleanup & refactoring
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     1
"
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
     2
 COPYRIGHT (c) 1997-1998 by eXept Software AG
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     3
              All Rights Reserved
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     4
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     5
 This software is furnished under a license and may be used
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     7
 inclusion of the above copyright notice. This software may not
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    10
 hereby transferred.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    11
"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    12
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    13
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    14
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    15
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    16
1390
35f90684be49 browserClass from preferences
Claus Gittinger <cg@exept.de>
parents: 1201
diff changeset
    17
"{ Package: 'stx:libview2' }"
35f90684be49 browserClass from preferences
Claus Gittinger <cg@exept.de>
parents: 1201
diff changeset
    18
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    19
ToolApplicationModel subclass:#ResourceSpecEditor
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
    20
	instanceVariableNames:'specClass specClassName specSelector aspects modified hasSaved
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
    21
		tabSelection'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    22
	classVariableNames:''
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    23
	poolDictionaries:''
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    24
	category:'Interface-Framework'
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    25
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    26
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    27
!ResourceSpecEditor class methodsFor:'documentation'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    28
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    29
copyright
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    30
"
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    31
 COPYRIGHT (c) 1997-1998 by eXept Software AG
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    32
              All Rights Reserved
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    33
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    34
 This software is furnished under a license and may be used
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    35
 only in accordance with the terms of that license and with the
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    36
 inclusion of the above copyright notice. This software may not
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    37
 be provided or otherwise made available to, or used by, any
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    38
 other person.  No title to or ownership of the software is
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    39
 hereby transferred.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    40
"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    41
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    42
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    43
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    44
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    45
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    46
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    47
documentation
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    48
"
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    49
    Abstract super class for the MenuEditor, HierarchicalListEditor, 
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    50
    and the TabListEditor.
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    51
    It provides common behavior for initializing, loading, saving, and
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    52
    asking for modifications of the resource specs (#menu, #hierarchicalList, 
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    53
    #tabList) for the concrete subclasses.
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    54
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    55
    [instance variables:]
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    56
        specClass       <Symbol>                class implementing the resource spec
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    57
        specSelector    <Symbol>                selector returning the resource spec
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    58
        aspects         <IdentityDictionary>    dictionary with the attributes of the resource spec
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    59
        modified        <Boolean>               flag whether the resource spec was modified
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    60
        hasSaved        <Boolean>               flag whether the resource spec was saved
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    61
        tabSelection    <Integer>               index of the tab selection
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    62
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    63
    [see also:]
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    64
        MenuEditor
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    65
        HierarchicalListEditor
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    66
        TabListEditor
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    67
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    68
    [author:]
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
    69
         Thomas Zwick, eXept Software AG
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    70
"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    71
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    72
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    73
!ResourceSpecEditor class methodsFor:'instance creation'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    74
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    75
openModalOnClass:aClass andSelector:aSelector
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    76
    "opens modal the Resource Spec Editor on aClass and aSelector"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    77
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    78
    ^self new openModalOnClass:aClass andSelector:aSelector
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    79
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    80
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    81
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    82
openOnClass:aClass andSelector:aSelector
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    83
    "opens the Resource Spec Editor on aClass and aSelector"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    84
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
    85
    ^ self new openOnClass:aClass theNonMetaclass andSelector:aSelector
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    86
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    87
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    88
!ResourceSpecEditor class methodsFor:'accessing'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    89
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    90
codeGenerationComment
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
    91
    "returns a comment for the method code generated by myself"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    92
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    93
    ^self codeGenerationCommentForClass: self
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    94
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    95
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    96
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    97
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    98
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
    99
1994
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   100
codeGenerationCommentForClass: generatingClass
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   101
    "returns a comment for the method code generated by generatingClass"
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   102
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   103
    |generatingClassName|
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   104
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   105
    generatingClassName := generatingClass name.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   106
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   107
    ^'    "This resource specification was automatically generated\',
1994
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   108
     '     by the ', generatingClassName, ' of ST/X."\\',
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   109
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   110
     '    "Do not manually edit this!! If it is corrupted,\',
1994
0747926cfd33 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1967
diff changeset
   111
     '     the ', generatingClassName, ' may not be able to read the specification."'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   112
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   113
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   114
resourceType
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   115
    "returns the type of resource of the method generated by the Resource Spec Editor;
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   116
     concrete subclasses has to reimplement this method"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   117
868
f35e6c622a98 subclassResponsibility
tz
parents: 867
diff changeset
   118
    ^self subclassResponsibility
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   119
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   120
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   121
!ResourceSpecEditor class methodsFor:'aspects'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   122
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   123
aspects
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   124
    "returns the aspects for the attributes of the resource spec components;
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   125
     concrete subclasses might reimplement this method in order to return an array"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   126
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   127
    ^#()
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   128
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   129
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   130
!ResourceSpecEditor class methodsFor:'queries'!
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   131
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   132
isVisualStartable
1427
b3e355574ccf comment only
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   133
    "return true, if this application can be started via #open.
b3e355574ccf comment only
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
   134
     (to allow start of a change browser via double-click in the browser)"
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   135
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   136
    self == ResourceSpecEditor ifTrue:[^false].
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   137
    ^super isVisualStartable
1967
815ac59338e1 resource package
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   138
!
815ac59338e1 resource package
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   139
815ac59338e1 resource package
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   140
resourcePackage
815ac59338e1 resource package
Claus Gittinger <cg@exept.de>
parents: 1874
diff changeset
   141
    ^ #'stx:libtool2'
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   142
! !
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   143
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   144
!ResourceSpecEditor class methodsFor:'startup / release'!
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   145
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   146
preSnapshot
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   147
    "before a snapshot; updates the channels,
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   148
     because the clipboard has removed"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   149
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   150
    super preSnapshot.
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   151
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   152
    instances notNil ifTrue:[
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   153
        instances do:[:inst |
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   154
            inst updateChannels. 
1147
bbaa243ddd1c accept & modifiedChannels
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
   155
            inst valueOfEnablingCommitButtons value: false.
bbaa243ddd1c accept & modifiedChannels
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
   156
            inst modifiedChannel value: false. 
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   157
        ]
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   158
    ]
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   159
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   160
    "Modified: / 4.2.1999 / 15:32:17 / cg"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   161
! !
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   162
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   163
!ResourceSpecEditor methodsFor:'accessing'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   164
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   165
clearModified       
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   166
    modified := false
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   167
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   168
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   169
modified       
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   170
    "returns whether the resource spec was modified"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   171
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   172
    ^modified
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   173
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   174
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   175
modified: aBoolean         
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   176
    "sets the resource spec modified as aBoolean"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   177
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   178
    modified := aBoolean
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   179
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   180
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   181
setModified       
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   182
    modified := true
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   183
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   184
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   185
specClass
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   186
    "returns the class where the resource spec is implemented"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   187
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   188
self halt.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   189
    ^ specClass
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   190
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   191
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   192
specClass:aClassOrClassName
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   193
    "sets the class (or name) where the resource spec is (or should be) implemented"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   194
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   195
    aClassOrClassName isBehavior 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   196
        ifTrue: [ specClass := aClassOrClassName ]
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   197
        ifFalse:[ specClass := Smalltalk classNamed:aClassOrClassName ]
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   198
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   199
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   200
specClassName
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   201
    "returns the classes name where the resource spec is implemented"
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   202
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   203
self halt.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   204
    ^ specClass name
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   205
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   206
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   207
specSelector
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   208
    "returns the method selector of the resource spec"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   209
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   210
    ^specSelector
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   211
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   212
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   213
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   214
specSelector:aSelector
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   215
    "sets the method selector of the resource spec"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   216
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   217
    specSelector := aSelector
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   218
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   219
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   220
!ResourceSpecEditor methodsFor:'aspects'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   221
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   222
aspectFor:aKey
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   223
    "returns the aspect for a aKey or nil"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   224
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   225
    ^aspects at: aKey ifAbsent: [super aspectFor:aKey]
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   226
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   227
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   228
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   229
tabModel
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   230
    "returns the value holder for the tab selection"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   231
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   232
    |holder|
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   233
    (holder := builder bindingAt:#tabModel) isNil ifTrue:[
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   234
        holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   235
        builder aspectAt:#tabModel put:holder.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   236
    ].
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   237
    ^ holder
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   238
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   239
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   240
valueOfCanPaste
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   241
    "returns whether the application can paste; as value holder"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   242
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   243
    |holder|
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   244
    holder := super valueOfCanPaste.
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   245
    holder value: self class clipboard notNil.
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   246
    ^ holder
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   247
!
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   248
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   249
valueOfEnableMovingIn
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   250
    "returns whether the selected item can move into next item as child; as value holder"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   251
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   252
    ^builder booleanValueAspectFor: #valueOfEnableMovingIn
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   253
!
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   254
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   255
valueOfEnableMovingInAbove
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   256
    "returns whether the selected item can move into the previous item as child;
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   257
     as a value holder"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   258
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   259
    ^builder booleanValueAspectFor: #valueOfEnableMovingInAbove
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   260
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   261
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   262
valueOfEnableMovingOut
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   263
    "returns whether the selected item can move out from its parent item; as value holder"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   264
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   265
    ^builder booleanValueAspectFor: #valueOfEnableMovingOut
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   266
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   267
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   268
valueOfEnableMovingUpOrDown
1470
1ac79214af0f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1427
diff changeset
   269
    "returns whether the selected item can move up or down; as value holder"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   270
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   271
    ^builder booleanValueAspectFor: #valueOfEnableMovingUpOrDown
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   272
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   273
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   274
!ResourceSpecEditor methodsFor:'building'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   275
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   276
buildFromClass: aClass andSelector: aSelector
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   277
    ^ self loadFromClass: aClass andSelector: aSelector
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   278
!
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   279
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   280
buildFromResourceSpec: aResourceSpec
868
f35e6c622a98 subclassResponsibility
tz
parents: 867
diff changeset
   281
    "concrete subclass has to reimplement this method
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   282
     in order to build its resource spec from aResourceSpec"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   283
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   284
    ^ self loadFromResourceSpec:aResourceSpec
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   285
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   286
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   287
loadFromClass: aClass andSelector: aSelector
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   288
    ^ self subclassResponsibility
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   289
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   290
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   291
loadFromResourceSpec: aResourceSpec
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   292
    "concrete subclass has to reimplement this method
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   293
     in order to build its resource spec from aResourceSpec"
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   294
868
f35e6c622a98 subclassResponsibility
tz
parents: 867
diff changeset
   295
    ^self subclassResponsibility
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   296
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   297
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   298
!ResourceSpecEditor methodsFor:'change & update'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   299
1874
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   300
update:something with:aParameter from:changedObject
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   301
    "one of my aspects has changed; update modified channel for the commit buttons"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   302
1874
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   303
    |enableCommitButtonsHolder|
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   304
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   305
    enableCommitButtonsHolder := self valueOfEnablingCommitButtons.
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   306
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   307
    changedObject ~~ enableCommitButtonsHolder ifTrue:[ 
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   308
        enableCommitButtonsHolder value: true 
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   309
    ]
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   310
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   311
!
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   312
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   313
updateAllToolInstances
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   314
    "updates the channels of all other instances of my class"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   315
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   316
    self allToolInstances do: [:inst| inst updateChannels]
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   317
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   318
!
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   319
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   320
updateChannels
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   321
    "updates my channels"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   322
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   323
    self valueOfCanPaste
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   324
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   325
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   326
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   327
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   328
!ResourceSpecEditor methodsFor:'help'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   329
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   330
defaultInfoLabel
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   331
    "returns the default label for the info bar"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   332
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   333
    specClass isBehavior ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   334
        (specClass respondsTo:specSelector) ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   335
            ^ specClass name, ' >> ', specSelector
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   336
        ].
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   337
        specSelector isNil ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   338
            ^ specClass name, ' >> ? (no selector defined)'
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   339
        ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   340
        ^ specClass name, ' >> ', specSelector, ' (not implemented)'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   341
    ].
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   342
    ^ 'No class and selector defined.'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   343
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   344
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   345
!ResourceSpecEditor methodsFor:'initialization'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   346
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   347
initialize
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   348
    "initialize the flags and the aspects"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   349
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   350
    super initialize.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   351
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   352
    hasSaved     := modified := false.
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   353
    aspects      := IdentityDictionary new.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   354
    tabSelection := 0.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   355
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   356
    self class aspects do:
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   357
    [:aKey|
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   358
        |holder|
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   359
        aspects at:aKey put: (holder := ValueHolder new).
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   360
        holder addDependent: self
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   361
    ]
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   362
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   363
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   364
!ResourceSpecEditor methodsFor:'private'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   365
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   366
askForItemModification
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   367
    "asks for resource item modification"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   368
1524
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   369
    |anythingChangedHolder anythingChanged answer|
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   370
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   371
    anythingChangedHolder := self valueOfEnablingCommitButtons.
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   372
    anythingChanged := anythingChangedHolder value.
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   373
    anythingChanged ifTrue:[          
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   374
"/        answer := ((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs)        
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   375
"/                        noText:'No';
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   376
"/                        yesText:'Yes';
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   377
"/                        showAtPointer;
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   378
"/                        accepted). 
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   379
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   380
        answer := Dialog 
1645
5d3552cd029b dialog text
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   381
                        confirmWithCancel:(resources string:'Item was modified !!\Save it ?\' withCRs)
5d3552cd029b dialog text
Claus Gittinger <cg@exept.de>
parents: 1554
diff changeset
   382
                        labels:(resources array:#('Cancel' 'No' 'Yes'))
1524
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   383
                        default:3.
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   384
        answer isNil ifTrue:[
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   385
            ^ false
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   386
        ].
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   387
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   388
        answer ifTrue:[
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   389
            self accept
1874
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   390
        ] ifFalse:[
1524
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   391
            anythingChangedHolder value: false. 
1201
d8c4b4f52e7e code cleanup
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   392
            self clearModifiedFlag. 
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   393
            self clearModified.
1874
4bd4f25fdada oops - modified flag was always re-turned on
Claus Gittinger <cg@exept.de>
parents: 1870
diff changeset
   394
        ].
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   395
    ].
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   396
    ^true
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   397
1524
6a0a84872e73 added cancel to ask-if-modified dialog
Claus Gittinger <cg@exept.de>
parents: 1504
diff changeset
   398
    "Modified: / 30.10.2001 / 18:38:34 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   399
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   400
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   401
askForListModification
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   402
    "asks for resource modification"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   403
1870
c0475972bf3e Use 'Discard Changes and Exit' instead of 'Forget it...'
Stefan Vogel <sv@exept.de>
parents: 1767
diff changeset
   404
    self modified ifTrue:
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   405
    [
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   406
        ((YesNoBox title:(resources string:'%1 spec was modified. Proceed?' with:self class resourceType asUppercaseFirst))        
929
7dfcaf12d7df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
   407
            noText:(resources string:'Cancel');
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   408
            yesText:(resources string:'Discard Changes and Proceed');
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   409
            showAtPointer;
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   410
            accepted) ifFalse: [^ false].
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   411
        self clearModified
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   412
    ].
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   413
    ^ true
929
7dfcaf12d7df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
   414
7dfcaf12d7df checkin from browser
Claus Gittinger <cg@exept.de>
parents: 896
diff changeset
   415
    "Modified: / 20.5.1998 / 03:40:26 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   416
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   417
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   418
askForModification
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   419
    "asks first for item and then for resource modification"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   420
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   421
    ^self askForItemModification and: [self askForListModification]
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   422
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   423
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   424
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   425
extractClassAndSelectorFrom:aString
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   426
    "extracts class and selector from a resource string. On success
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   427
     an association with the key a class and the selector as value
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   428
     is returned. Otherwise nil is returned
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   429
    "
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   430
    |words newClass newSel|
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   431
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   432
    aString size ~~ 0 ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   433
        words := aString asCollectionOfWords.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   434
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   435
        words size == 2 ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   436
            newClass := self resolveName:(words first).
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   437
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   438
            (newClass isClass and:[newClass isLoaded]) ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   439
                newSel := words last asSymbol.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   440
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   441
                (newClass class includesSelector:newSel) ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   442
                    ^ Association key:newClass value:newSel            
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   443
                ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   444
            ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   445
        ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   446
    ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   447
    ^ nil
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   448
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   449
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   450
updateHistory
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   451
    "updates the history, if there was loaded a resource spec"
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   452
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   453
    specClass notNil ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   454
        self addHistoryEntryForClass:specClass selector:specSelector
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   455
    ]
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   456
!
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   457
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   458
xxresourceMessage:aString
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   459
    "extracts the specClass and the specSelector from aString "
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   460
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   461
    |msg cls|
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   462
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   463
    (aString notNil and:[self askForModification]) ifTrue:[            
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   464
        msg := aString asCollectionOfWords.
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   465
        (msg size == 2 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   466
        and: [ (cls := self resolveName:(msg at:1)) notNil ])
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   467
        ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   468
            specClass := cls.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   469
            specSelector := (msg at: 2) asSymbol.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   470
            ^true
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   471
        ]
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   472
    ].
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   473
    ^false
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   474
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   475
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   476
!ResourceSpecEditor methodsFor:'queries'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   477
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   478
hasSaved
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   479
    "returns true if resource spec has saved"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   480
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   481
    ^hasSaved
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   482
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   483
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   484
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   485
isNotStandAlone
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   486
    "returns true if the editor was not started from or in another tool"
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   487
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   488
    ^self masterApplication notNil
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   489
!
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   490
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   491
isStandAlone
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   492
    "returns true if the editor was started from or in another tool"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   493
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   494
    ^self masterApplication isNil
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   495
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   496
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   497
!ResourceSpecEditor methodsFor:'selection'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   498
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   499
tabSelection
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   500
    "returns selected tab index or 0"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   501
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   502
    ^tabSelection
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   503
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   504
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   505
1767
f94850ee9885 method category rename
Claus Gittinger <cg@exept.de>
parents: 1735
diff changeset
   506
!ResourceSpecEditor methodsFor:'startup & release'!
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   507
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   508
closeRequest
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   509
    "asks first for modification, then sends close request to super"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   510
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   511
    self askForModification ifTrue: [super closeRequest]
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   512
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   513
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   514
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   515
loadFromMessage:classAndSelector
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   516
    "builds by evaluating aString the resource spec for editing"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   517
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   518
    |cls sel|
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   519
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   520
    self askForModification ifFalse:[ ^ false].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   521
    classAndSelector isNil ifTrue:[^ false].
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   522
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   523
    cls := classAndSelector methodClass.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   524
    sel := classAndSelector methodSelector.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   525
    self isStandAlone 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   526
        ifFalse: [self loadFromResourceSpec: (cls perform: sel).]
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   527
        ifTrue:  [self loadFromClass:cls andSelector:sel ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   528
    ^ true
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   529
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   530
    "Modified: / 21.5.1998 / 02:56:46 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   531
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   532
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   533
openModalOnClass:aClass andSelector:aSelector
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   534
    "sets the specClass and specSelector and opens modal the interface"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   535
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   536
    specClass    := aClass isClass ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass].
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   537
    specSelector := aSelector.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   538
1735
4cc63484a29a allButOpen must have been invoked
penk
parents: 1645
diff changeset
   539
    self openInterfaceModal.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   540
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   541
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   542
openModalOnResourceSpec: aListSpec
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   543
    "builds first from specClass and specSelector the resource spec for editing,
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   544
     then opens modal the interface"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   545
1735
4cc63484a29a allButOpen must have been invoked
penk
parents: 1645
diff changeset
   546
    self allButOpen.
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   547
    self loadFromResourceSpec:aListSpec.
1735
4cc63484a29a allButOpen must have been invoked
penk
parents: 1645
diff changeset
   548
    self openWindowModal.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   549
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   550
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   551
openOnClass:aClass andSelector:aSelector
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   552
    "sets the specClass and specSelector and opens the interface"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   553
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   554
    specClass    := aClass isBehavior ifTrue: [aClass] ifFalse: [ Smalltalk classNamed:aClass].
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   555
    specSelector := aSelector.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   556
1735
4cc63484a29a allButOpen must have been invoked
penk
parents: 1645
diff changeset
   557
    self openInterface.
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   558
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   559
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   560
postBuildWith:aBuilder
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   561
    "after creating the views and before opening,
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   562
     adds myself to the instances dictionary in the settings"
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   563
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   564
    super postBuildWith:aBuilder.
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   565
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   566
    self class rememberInstance:self
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   567
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   568
    "Modified: / 4.2.1999 / 15:33:23 / cg"
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   569
!
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   570
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   571
postOpenWith:aBuilder
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   572
    "after opening, builds from specClass and specSelector the resource spec for editing"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   573
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   574
    super postOpenWith:aBuilder.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   575
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   576
    specClass notNil ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   577
        self loadFromClass: specClass andSelector: specSelector 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   578
    ]
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   579
!
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   580
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   581
uninitialize
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   582
    "uninitializes; removes myself from the instances dictionary in the settings"
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   583
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   584
    super uninitialize.
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   585
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   586
    self class forgetInstance:self
876
585929b1fec2 some cleans
tz
parents: 868
diff changeset
   587
1090
d7738a06b696 fixing Thomas's code
Claus Gittinger <cg@exept.de>
parents: 1003
diff changeset
   588
    "Modified: / 4.2.1999 / 15:34:25 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   589
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   590
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   591
!ResourceSpecEditor methodsFor:'user actions'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   592
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   593
accept
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   594
    "invoked by the OK button; disables the commit buttons and sets myself modified"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   595
1157
feeae3138d3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1147
diff changeset
   596
    self acceptChannel 
1158
fe67c8fdf68b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   597
        value:false;    
1157
feeae3138d3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1147
diff changeset
   598
        value:true;      "/ toggle to force inputFields to accept
feeae3138d3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1147
diff changeset
   599
        value:false.    
feeae3138d3d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1147
diff changeset
   600
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   601
    self valueOfEnablingCommitButtons value: false.
1201
d8c4b4f52e7e code cleanup
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   602
    self clearModifiedFlag.
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   603
    self setModified
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   604
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   605
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   606
doBrowseClass
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   607
    "opens a System Browser on the specClass and specSelector"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   608
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   609
    specClass notNil 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   610
        ifTrue: [UserPreferences systemBrowserClass openInClass:specClass class selector: specSelector] 
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   611
        ifFalse:[self information:'No class defined!!']
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   612
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   613
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   614
doEditImage
896
6e23150974d0 comments + docu
tz
parents: 889
diff changeset
   615
    "opens a Image Editor on the resource retriever and the icon selector"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   616
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   617
    |resourceClass resourceSelector classAndSelector retrieverName|
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   618
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   619
    resourceSelector := (aspects at:#icon) value.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   620
    resourceSelector isEmptyOrNil ifTrue:[ resourceSelector := #icon ].
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   621
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   622
    retrieverName := (aspects at:#retriever) value.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   623
    retrieverName notEmptyOrNil ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   624
        resourceClass := Smalltalk classNamed:retrieverName
1147
bbaa243ddd1c accept & modifiedChannels
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
   625
    ] ifFalse:[
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   626
        specClass notNil ifTrue:[
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   627
            resourceClass := specClass withAllSuperclasses 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   628
                                detect:[:cls| cls class includesSelector: resourceSelector] 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   629
                                ifNone:[specClass]
1003
3f728982d7d9 opens an Image Editor in any case
tz
parents: 991
diff changeset
   630
        ]
3f728982d7d9 opens an Image Editor in any case
tz
parents: 991
diff changeset
   631
    ].
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   632
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   633
    (classAndSelector := ImageEditor openModalOnClass: resourceClass andSelector: resourceSelector) notNil
1147
bbaa243ddd1c accept & modifiedChannels
Claus Gittinger <cg@exept.de>
parents: 1090
diff changeset
   634
    ifTrue: [
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   635
        resourceClass := classAndSelector at:1.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   636
        resourceSelector := classAndSelector at:2.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   637
        (aspects at:#retriever) value: resourceClass name.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   638
        (aspects at:#icon) value: resourceSelector. 
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   639
        self valueOfEnablingCommitButtons value: true
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   640
    ]
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   641
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   642
    "Modified: / 21.5.1998 / 02:44:04 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   643
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   644
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   645
doLoad
889
85b7aa0e79e4 comments
tz
parents: 877
diff changeset
   646
    "opens a Resource Selection Browser in order to get a resource message"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   647
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   648
    |myResourceType classAndSelector|
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   649
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   650
    myResourceType := self class resourceType.
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   651
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   652
    classAndSelector := ResourceSelectionBrowser
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   653
            request: 'Load ', myResourceType asUppercaseFirst, ' Spec From Class'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   654
            onSuperclass: nil
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   655
            andClass: specClass
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   656
            andSelector: specSelector ? myResourceType
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   657
            withResourceTypes: (Array with: myResourceType).
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   658
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   659
    classAndSelector isNil ifTrue:[ ^ self ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   660
    ^ self loadFromClass:(classAndSelector methodClass) andSelector:(classAndSelector methodSelector) 
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   661
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   662
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   663
doNew
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   664
    "first ask for modification; then clean specClass and specSelector,
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   665
     but only, if the editor is opened as stand alone;
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   666
     finally make a build of a resource spec containing no items"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   667
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   668
    self askForModification ifTrue:[
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   669
        self isStandAlone ifTrue: [specClass := specSelector := nil].
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   670
        self loadFromClass:nil andSelector:(self class resourceType).
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   671
        ^ true
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   672
    ].
2037
a99b25a83641 askForListModification for modal views too
penk
parents: 1994
diff changeset
   673
    ^ false
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   674
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   675
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   676
doSave
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   677
    "before saving ask for modification; if no specClass and specSelector
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   678
     is defined, do save as"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   679
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   680
    self askForItemModification.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   681
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   682
    (specClass isNil or:[specSelector isNil]) ifTrue:[
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   683
        self doSaveAs.
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   684
        ^ false
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   685
    ].
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   686
    ^ true
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   687
!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   688
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   689
doSaveAs
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   690
    "first ask for modification; 
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   691
     then open a ResourceSelectionBrowser; 
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   692
     after that extract the resource message;
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   693
     finally do save and make a new build"
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   694
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   695
    |resourceMessage myResourceType|  
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   696
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   697
    self askForItemModification.
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   698
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   699
    myResourceType := self class resourceType.
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   700
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   701
    resourceMessage := ResourceSelectionBrowser
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   702
            request: 'Save ', myResourceType asUppercaseFirst, ' Spec In Class'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   703
            onSuperclass: #Object
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   704
            andClass: specClass name
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   705
            andSelector: specSelector ? myResourceType
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   706
            withResourceTypes: (Array with: myResourceType).
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   707
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   708
    resourceMessage isNil ifTrue:[ ^ false ].
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   709
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   710
    self clearModified.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   711
    specClass := resourceMessage methodClass.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   712
    specSelector := resourceMessage methodSelector.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   713
    self doSave.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   714
    self loadFromClass: specClass andSelector: specSelector.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   715
self halt.
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   716
    ^ true
934
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   717
c32a44c8913e should not redefine AllButOpenInterface;
Claus Gittinger <cg@exept.de>
parents: 929
diff changeset
   718
    "Modified: / 21.5.1998 / 02:59:46 / cg"
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   719
! !
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   720
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   721
!ResourceSpecEditor class methodsFor:'documentation'!
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   722
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   723
version
2097
7f078c4af09d code cleanup & refactoring
Claus Gittinger <cg@exept.de>
parents: 2037
diff changeset
   724
    ^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.31 2006-02-13 08:50:23 cg Exp $'
867
9da1ff2ac50d initial checkin
tz
parents:
diff changeset
   725
! !