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