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