UISpecificationTool.st
author Stefan Vogel <sv@exept.de>
Fri, 06 Feb 1998 15:10:15 +0100
changeset 610 c6dc33689c6a
parent 584 351914fcc5a4
child 752 2dc82cdfdd90
permissions -rw-r--r--
Add help for subSpec GUI Painter opening.

"
 COPYRIGHT (c) 1995 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"




ApplicationModel subclass:#UISpecificationTool
	instanceVariableNames:'modifiedHolder aspects specification selection specChannel'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-UIPainter'
!

!UISpecificationTool class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"



!

documentation
"
    used by the UIPainter to manipulate the specifications of the selected component

    [author:]
        Claus Atzkern

    [see also:]
        UIPainter
        UILayoutTool
        UIHelpTool
"
! !

!UISpecificationTool class methodsFor:'help specs'!

helpSpec
    "return a dictionary filled with helpKey -> helptext associations.
     These are used by the activeHelp tool."

    "
    UIHelpTool openOnClass:UISpecificationTool    
    "

  ^ super helpSpec addPairsFrom:#(

#acceptChannel
'acceptChannel for the view. This field specifies the name of the aspect (-method or binding) in your application, which is supposed to return a valueHolder on to the boolean accept-flag.\ If the holder changed its value to true, the contents will be accepted and the modifiaction flag is set to false.'

#acceptImmediate
'input will we sent to the model immediately (every key)'

#acceptOnLeave
'input will we sent to the model when the field is left via cursor keys'

#acceptOnLostFocus
'input will we sent to the model when the mouse leaves the field, or its tabbed'

#acceptOnReturn
'input will we sent to the model when the return key is pressed'

#acceptOnTab
'input will we sent to the model when the tab key is pressed'

#action
'action selector sent to the application when the button is activated. (either on-press or on-release; this depends on the setting of triggerOnDown flag). The selector may be for a one-arg message; in this case, the argument is passed (a string).'

#actionArg
'action argument passed to action method, if action selector is a one-arg selector (i.e. ends with '':''). The arg is passed as a string.'

#appletParamText
'Paste the complete appletTAGs HTML text here (i.e. all from <applet> up to and including the </applet>). Press parse to extract all parameters from it.'

#appletTextParse
'Parse the appletTAG and fill the parameters directory from it.'

#arbitraryView
'the class of the arbitrary component or an aspect selector which provides a widget class.'

#archiveEntry
'The name of a zip-file archive, if the class(es) are to be loaded from a zip-archive.'

#arrowButtonDirection
'the direction of the arrow.'

#autoRepeat
'repeat the action as long as the button is pressed; to have this behavior the ''isTriggerOnDown'' state must be enabled.'

#backgroundChannel
'a holder, which provides the widgets backgroundColor. Useful if the labels bg color is to be changed dynamically (alerts).'

#backgroundColor
'set the background color if the color-checkBox is turned on. Otherwise, the widget uses its default background color (which is specified in the styleSheet).'

#beDefault
'show/dont show a return-key image after the label'

#beDependentOfRows
'make each row in the list dependant. Thus, whenever a row raises a change notification, the row will be redrawn (if visible on the screen).'

#booleanHolder
'aspect of a boolean holder which keeps the state'

#borderWidth
'width of the border'

#canvas
'gets a widget placed into the notebook'

#canvasArgument
'the argument to the selector or none'

#canvasSelector
'after opening the application as specified by the clientKey,  this message will be sent'

#clientHolder
'holder which provides the sub application to be opened'

#clientKey
'returns an application which provides the builder. By default the application itself is used.'

#codeBaseHolder
'The URL of the directory, where the classFile-file resides. If the classFile is located on the local machine, use\     file:/<fullPath>\ where fullPath is an absolute pathname. If its to be accessed via http, use\     http:/<host>/<relativePath>\ where relativePath is the path relative to the http''s top diretory on that host.'

#codeFileEntry
'The name of the java classFile  which contains the applets code.  For example: ''ArcTest.class'''

#columnButton
'open the dataset builder'

#columnHolder
'valuHolder, which provides a list of column descriptions.'

#defaultLabel
'the default label  (used, if nothing selected).'

#document
'a holder which keeps the document name.'

#doubleClickSelector
'double click action which is evaluated on double click in case of a non-nil selection. \ If the selector ends with '':'' the method is invoked with the current selection as argument.'

#downAction
'action selector sent to the application when the down button is activated. The selector may be for a one-arg message; in this case, the argument is passed.'

#enableChannel
'enableHolder for the view. This field specifies the name of the aspect (-method or binding) in your application, which is supposed to return a valueHolder on to the boolean enable-flag. This is convenient, if many widgets are to be enabled/disabled depending on the setting of a single flag, because the application can change them all with a single setting of the enableHolders value.'

#fileSelectionFilterClas
'the name of the Item class used to create the entries into the hierarchical list. The class is oblegated to provide the whole interface of the FileSelectionItem class. If no class is specified, the FileSelectionItem class is used. \ Thus you can define your own filter operations, icons, ....'

#fileSelectionTreeRoot
'a holder, which keeps the pathname of the root directory (first entry in the list).'

#fitLastRow
'fit rows to tab horizontal or vertical extent'

#fontMenu
'set the font for the widget if the font-checkBox is turned on. Otherwise, the widget uses its default font (which is specified in the viewStyle).'

#forceRecursiveBackground
'also change all subcomponents viewBackground (recursively).'

#foregroundChannel
'a holder, which provides the widgets foregroundColor. Useful if the labels fg color is to be changed dynamically (alerts).'

#foregroundColor
'set the foreground color if the color-checkBox is turned on. Otherwise, the widget uses its default foreground color (which is specified in the styleSheet).'

#galleryLabels
'a list of tab labels'

#galleryModel
'a holder, which keeps the label of the current selected tab or nil.'

#gallerySelection
'a holder, which keeps the specification of the current selected widget or nil.'

#gallerySelectors
'the list of selectors specify which interface specification should be used dependent on the tab pressed. Each selector must return an interfaceSpec. On default the #windowSpec method is used'

#has3Dsepartors
'show all the column and row separators in a 3D-look'

#hasBorder
'currently ignored - kept to avoid loosing information of imported VW window specs'

#hierarchicalList
'gets a hierarchical list or a holder which keeps a hierarchical list entry; the value must understand the TreeItem protocol.'

#hierarchicalListButton
'opens the hierarchical list editor, which can be used to generate and install a hierarchical list.'

#horizontalLayout
'specifies how components are to be arranged horizontally'

#horizontalMiniScroller
'use a mini-horizontalScroller'

#horizontalScroller
'make the view horizontally scrollable'

#horizontalSpace
'horizontal space between elements on pixels'

#id
'the symbolic name of the component.  This ID can be used by the application to access components, using #componentAt:<ID>'

#initiallyDisabled
'if on, the widget is initially disabled (to be enabled programatically with "(self componentAt:<ID>) enable").'

#initiallyInvisible
'if on, the widget is initially invisible (to be made visible programatically with "(self componentAt:<ID>) beVisible")).'

#inputFieldGroup
'symbolic ID of the input group - fields within a group can be reached via cursor up/down.'

#isMultiSelect
'enable/disable multiple selections.'

#isOpaque
'define how the widget is displayed; opaque or not opaque'

#isTriggerOnDown
'if true, the action is evaluated when the button is pressed; otherwise, when released.'

#label
'the label of the widget. If ''label is image'' is off, this is the label string. Otherwise, it specifies the applications selector, which returns the label - either a string or a bitmap image.'

#labelChannel
'a holder, which provides the widgets label. Useful if the label is to be changed dynamically.'

#labelIsImage
'if ''label is image'' is off (the default), the widgets label is the string as entered in the label aspect. Otherwise, its the name of the message sent to the application - this should return a string or bitmap image, which is used as logo in the widget.'

#labelPositionList
'define the position of the label'

#lampColor
'set the lamp color if the color-checkBox is turned on. Otherwise, the widget uses its default lamp color (which is specified in the styleSheet).'

#level
'the 3D-level relative to its superView. If left blank, the components default is used.'

#listHolder
'a list or a list holders aspect'

#majorKey
'name of the class which provides the window specification. If left blank, the application itself is used.'

#maxChars
'maximum number of characters that are allowed in the editfield.  If left blank, no limit is set.'

#maxSize
'Those two fields specify the windows maximum size. The user will not be allowed to resize it to a larger size.'

#maxXField
'the maximum width - the user will not be allowed to resize the topView to a larger width.'

#maxYField
'the maximum height - the user will not be allowed to resize the topView to a larger height.'

#menuButton
'open a menu editor on the specified menu selector.'

#menuHolder
'aspect selector or holder which provides the middle button menu'

#menuId
'the aspect of the menu. The application may respond to this message by returning a menu.'

#menuPerformer
'aspect providing an object which gets the menu messages. If left blank, the menu sends its menuMessages to the application.'

#middleButtonPressed
'called if the middle button is pressed; you can open a menu'

#minSize
'Those two fields specify the windows minimum size. The user will not be allowed to resize it to a smaller size.'

#minXField
'the minimum width - the user will not be allowed to resize the topView to a smaller width.'

#minYField
'the minimum height - the user will not be allowed to resize the topView to a smaller height.'

#minorKey
'the selector specifies which interface specification to be used. The selector must return an interfaceSpec. By default the #windowSpec method is used.'

#modifiedChannel
'modifiedHolder for the view. This field specifies the name of the aspect (-method or binding) in your application, which is supposed to return a valueHolder on to the boolean modified-flag. \ The holder is set dependant on the modification state of the view contents.'

#monitoring
'start or stop a background process, which will update the list dependant on any directory change.\ Between each check cycle, there is a defined delay time measured in seconds.'

#monitoringDelayTime
'delay time of the monitoring task in seconds'

#moveSelectedRow
'move selected row always to view'

#oneTabPerLine
'draw only one tab per line'

#openSubSpecGuiHelp
'Start a GUI Builder for this subspecification.'

#orientation
'define the orientation of the widget; horizontal or vertical.'

#paramAdd
'Adds a name-value pair to the parameters collection.'

#paramList
'Lists defined parameters.'

#paramNameField
'The name of the appletParameter.'

#paramRemove
'Removes the definition of the current name.'

#paramValueField
'The value of the appletParameter.'

#parameNameField
''

#radioButtonGroup
'the aspect of the valueHolder which holds the selection of a radioButtonGroup. When clicked, each button writes its value into that aspect; vice versa, if the groupValue is changed to the value of one of the buttons, that button turns itself on.'

#radioButtonValue
'the value associated with that radioButton. When clicked, this will be stored into the group-model. If left empty, buttons are numbered sequentially, starting with 1.'

#readOnly
'the field is readOnly - its contents cannot be modified by the user (however, the program can)'

#regionType
'define the shape of the widget'

#resizeForLabel
'if on, the widget is allowed to resize itself to fit the labelString - if off, the size is frozen.'

#rowIfAbsent
'name of a method in the application which is invoked whenever an empty list entry is detected. The method is called with the index into the list and should return a valid row instance. \ Thus, you are able to define a list with all elements set to nil.'

#selectConditionSelector
'name of a method in the application which is invoked before the selection changed. The selection will not be done, if the method returns false. \ If the selector ends with '':'' the method is invoked with the selection-line-number as argument.'

#selectionHolder
'the aspect of the valueHolder which holds the selection or input value.'

#setMaxExtent
'set the maximum size from the topViews current size.'

#setMinExtent
'set the minumum size from the topViews current size.'

#showDirectoryIndicator
'enable/disable directory indicator (+/-) for none empty directories'

#showDirectoryIndicatorForRoot
'disable the directory indicator for the first element of the hierarchical list in case that the global directory indication is set to true.'

#showFrame
'show the frame'

#showLamp
'enable/disable display of the toggles lamp.'

#showLines
'show or hide lines'

#showPercentage
'define if the percentage is to be shown numerically'

#showRoot
'show or hide the first element of the hierarchical list.'

#showSeparatingLines
'seperate each menu item by a vertical or horizontal line dependant on its vertical layout'

#sizeAsDefault
'let the widget compute its size to include space for the default (return) image. Useful for buttons which are not default buttons initially, but may become a default button dynamically.'

#specHolder
'holder which provides the selector to access the windowspec used to open the sub application derived from the application holder. If no selector is defined, the #windowSpec selector is used.'

#start
'define the scroller/slider''s range minimum'

#step
'define the scroller/slider''s range step'

#stop
'define the scroller/slider''s range maximum'

#tabLabels
'a list or list holder which provides the labels assigned to the tabs.'

#tabOrientation
'where to place the tabs'

#tabWidget
'select the tab style (windows- or mac look)'

#tabable
'if on, the widget can be reached by tabbing.'

#translateLabel
'if on, the labelString is translated via the resource mechanism to a national language string (if a translation for that string is present in the resource file of the application).'

#typeConverter
'convert the fields string value to some other object. Needed if the aspectValue is not a string (typically numbers).'

#upAction
'action selector sent to the application when the up button is activated. The selector may be for a one-arg message; in this case, the argument is passed.'

#useIndex
'set/clear the useIndex flag. If set, the index of the selection is stored into the model; otherwise the selected string.'

#usePreferredExtent
'Take the top components preferredExtent as extent of the topView. Only possible if there is exactly one top component (typically: a panel).'

#validateDoubleClickSelector
'name of a method in the application which is invoked before a not empty directory is opened by a double click. If the method returns false, the directory will not be opened.\ If the selector ends with '':'' the method is invoked with the selection-line-number as argument.'

#valueChangeSelector
'name of a method in the application which is invoked whenever the selection changed. If the selector ends with '':'' the method is invoked with the current selection.'

#verticalLayout
'specifies how components are to be arranged vertically'

#verticalMiniScroller
'use a mini-verticalScroller'

#verticalScroller
'make the view vertically scrollable'

#verticalSpace
'the vertical space between elements on pixels'

#windowIcon
'aspect of the windows icon. This is supposed to provide a bitmap image, which is displayed by the windowManager if your applications gets iconified.'

#windowIconLabel
'the windows icon label. This will be displayed by most windowManagers in the icon if the topView is iconified.'

#windowLabel
'the windows label. This will be displayed by the windowManager in the windows frame.'

)

    "Modified: / 6.2.1998 / 14:08:44 / stefan"
! !

!UISpecificationTool class methodsFor:'interface specs'!

windowSpec
    "this window spec was automatically generated by the ST/X UIPainter"

    "do not manually edit this - the painter/builder may not be able to
     handle the specification if its corrupted."

    "
     UIPainter new openOnClass:UISpecificationTool andSelector:#windowSpec
     UISpecificationTool new openInterface:#windowSpec
    "
    "UISpecificationTool open"

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'uIPainterView'
              #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
              #'label:' 'unnamed canvas'
              #'bounds:' #(#Rectangle 0 0 300 300)
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#ViewSpec
                    #'name:' 'Frame'
                    #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                )
              )
          )
      )
! !

!UISpecificationTool methodsFor:'accessing'!

specification
    "gets current edit specification
    "
    ^ specification


!

specification:aSpec
    "sets current edit specification
    "
    self releaseResources.

    aSpec isNil ifTrue:[
        specChannel notNil ifTrue:[ specChannel release ].
        aspects     notNil ifTrue:[ aspects     release ].

        specChannel   := nil.
        specification := nil.
        aspects       := nil.
    ] ifFalse:[
        specification class == aSpec class ifTrue:[
            specification := aSpec.
          ^ specChannel value:specification.
        ].
        specChannel notNil ifTrue:[ specChannel release ].
        aspects     notNil ifTrue:[ aspects     release ].

        specification  := aSpec.
        
        "/ some tricky specs need the builder
        "/ during the addBindings phase.
        "/ This is passed down in a special UIBindingsDictionary
        "/ (remain backward compatible)

        aspects        := UISpecification newBindingsDictionary.
        aspects builder:builder.

        specChannel    := specification asValue.
        specification class addBindingsTo:aspects for:specification channel:specChannel.
        aspects do:[:el| el addDependent:self ].
    ].

    selection notNil ifTrue:[
        (builder componentAt:#Frame) destroySubViews.
        selection := nil.
    ].

    "Modified: / 30.1.1998 / 13:50:51 / cg"
! !

!UISpecificationTool methodsFor:'accessing channels'!

modifiedHolder:aValueHolder
    "set the value holder set to true in case of modifying attributes
    "
    modifiedHolder notNil ifTrue:[
        modifiedHolder removeDependent:self. 
    ].

    (modifiedHolder := aValueHolder) notNil ifTrue:[
        modifiedHolder addDependent:self.
    ].

! !

!UISpecificationTool methodsFor:'actions'!

setMaxExtent
    "set the windows maxExtent from its current extent"

    |canvas currentExtent|

    canvas := self masterApplication painter topView.
    currentExtent := canvas extent.
    (self aspectFor:#maxX) value:currentExtent x.
    (self aspectFor:#maxY) value:currentExtent y.

    "Modified: / 29.10.1997 / 18:29:17 / cg"
!

setMinExtent
    "set the windows minExtent from its current extent"

    |canvas currentExtent|

    canvas := self masterApplication painter topView.
    currentExtent := canvas extent.
    (self aspectFor:#minX) value:currentExtent x.
    (self aspectFor:#minY) value:currentExtent y.

    "Created: / 29.10.1997 / 18:17:55 / cg"
    "Modified: / 29.10.1997 / 18:28:53 / cg"
! !

!UISpecificationTool methodsFor:'bindings'!

aspectFor:aKey
    "returns aspect for a key or nil
    "
    aspects notNil ifTrue:[
        ^ aspects at:aKey ifAbsent:nil
    ].
    ^ super aspectFor:aKey

!

releaseResources
    "release resources
    "
    |frame appl|

    frame := builder componentAt:#Frame.
    appl  := builder application.
    builder := UIBuilder new.
    builder application:appl.
    builder componentAt:#Frame put:frame.

!

specificationFor:aKey
    "this is called if our current specification contains 
     subspecifications or subcanvases.
     Get the subspecification from the current specification"

    |cls|

    cls := specification class.
    (cls respondsTo:aKey) ifTrue:[
        ^ cls perform:aKey
    ].
    ^ nil

    "Created: / 4.2.1998 / 23:52:39 / stefan"
    "Modified: / 4.2.1998 / 23:58:23 / stefan"
! !

!UISpecificationTool methodsFor:'change & update'!

update
    "reload specification
    "
    specChannel notNil ifTrue:[
        specChannel value:specification.
    ]


!

update:something with:someArgument from:someone
    "any attribute changed its state in the current specification
    "
    someone ~~ modifiedHolder ifTrue:[
        modifiedHolder value ~~ true ifTrue:[
            modifiedHolder value:true
        ]
    ]


! !

!UISpecificationTool methodsFor:'selection'!

selection:something
    "selection changed
    "
    |slices idx spec frame|

    specification notNil ifTrue:[
        slices := specification class slices.
        idx:= slices findFirst:[:aSlice| aSlice first = something ].

        idx ~~ 0 ifTrue:[
            spec := specification class perform:((slices at:idx) last).
        ]
    ].

    spec ~= selection ifTrue:[
        self releaseResources.
        frame := builder componentAt:#Frame.
        frame destroySubViews.

        spec notNil ifTrue:[
            builder buildFromSpec:spec in:frame.
            frame allViewBackground:(frame viewBackground).
            frame realizeAllSubViews.
        ]
    ].
    selection := spec.
! !

!UISpecificationTool class methodsFor:'documentation'!

version
    ^ '$Header$'
! !