"
COPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libjava' }"
NamedSpec subclass:#JavaAppletComponentSpec
instanceVariableNames:'codeURL codeBaseURL documentURL archiveURL parameterDictionary'
classVariableNames:''
poolDictionaries:''
category:'Languages-Java-Views-Support'
!
!JavaAppletComponentSpec class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1997 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
"
[Author:]
Claus Gittinger
"
! !
!JavaAppletComponentSpec class methodsFor:'interface specs'!
addBindingsTo:env for:inst channel:aChannel
|nameStringHolder valueStringHolder
paramNameListHolder selectionInParameters
indexHolder
appletTextHolder textAcceptChannel|
super addBindingsTo:env for:inst channel:aChannel.
self
adaptApects:
#(
codeURL
codeBaseURL
archiveURL
parameterDictionary
)
to:env
for:inst
channel:aChannel.
"/
"/ tricky setup for the parameter section
"/ (a bit complicated to avoid the need for defining
"/ new methods in my application (the GUI-painter)
"/ instead, everything is done via blocks.)
"/
selectionInParameters := SelectionInList new.
env at:#paramNameListHolder put:selectionInParameters.
env at:#paramNameString put:(nameStringHolder := '' asValue).
env at:#paramValueString put:(valueStringHolder := '' asValue).
aChannel onChangeSend:#value to:[
|parameterListHolder inst|
inst := aChannel value.
parameterListHolder := env at:#paramNameListHolder.
inst parameterDictionary notNil ifTrue:[
parameterListHolder list:(inst parameterDictionary keys asSortedCollection)
] ifFalse:[
parameterListHolder list:SortedCollection new
].
].
inst parameterDictionary notNil ifTrue:[
paramNameListHolder := (inst parameterDictionary keys asSortedCollection) asValue
] ifFalse:[
paramNameListHolder := SortedCollection new asValue
].
selectionInParameters listHolder:paramNameListHolder.
indexHolder := selectionInParameters indexHolder.
indexHolder
onChangeSend:#value
to:[
|selectedName selectedValue index inst|
inst := aChannel value.
index := indexHolder value.
index ~~ 0 ifTrue:[
selectedName := paramNameListHolder value at:index.
selectedValue := inst parameterDictionary at:selectedName ifAbsent:''.
nameStringHolder value:selectedName.
valueStringHolder value:selectedValue
]
].
env at:#addParam put:[
|newName inst|
inst := aChannel value.
newName := nameStringHolder value.
newName notEmpty ifTrue:[
inst
addParameter:newName
value:valueStringHolder value.
paramNameListHolder
value:(inst parameterDictionary keys asSortedCollection)
]
].
env at:#removeParam put:[
|nameToRemove inst|
inst := aChannel value.
nameToRemove := nameStringHolder value.
nameToRemove notEmpty ifTrue:[
inst removeParameter:nameToRemove.
paramNameListHolder
value:(inst parameterDictionary keys asSortedCollection).
indexHolder value:0.
]
].
"/
"/ tricky setup for the appletText section
"/
env at:#textAcceptChannel put:(textAcceptChannel := false asValue).
appletTextHolder := '' asValue.
env at:#appletText put:appletTextHolder.
env at:#parseText put:[
|appletTagText builder editor inst|
inst := aChannel value.
"/ force accept ...
textAcceptChannel setValue:false.
textAcceptChannel value:true.
appletTagText := appletTextHolder value.
appletTagText notEmpty ifTrue:[
inst parseParametersFromAppletTag:appletTagText.
].
paramNameListHolder value:(inst parameterDictionary keys asSortedCollection)
].
env at:#browseForURL put:[
|path|
path := FileSelectionBrowser
request: 'CodeFile'
fileName: 'classFile.class'
inDirectory: Filename currentDirectory name
withFileFilters: #('*.class' '*.cls').
path notNil ifTrue:[
(env at:#codeURL) value:(path asFilename baseName).
(env at:#codeBaseURL) value:('file:' , path asFilename directoryName).
]
].
"Created: / 29.1.1998 / 14:17:39 / cg"
"Modified: / 5.2.1998 / 13:46:00 / cg"
!
appletTagEditSpec
"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:JavaAppletComponentSpec andSelector:#appletTagEditSpec
JavaAppletComponentSpec new openInterface:#appletTagEditSpec
"
<resource: #canvas>
^
#(#FullSpec
#'window:'
#(#WindowSpec
#'name:' 'ArbitraryComponent Detail'
#'layout:' #(#LayoutFrame 24 0 161 0 299 0 456 0)
#'label:' 'ArbitraryComponent Detail'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1160 870)
#'bounds:' #(#Rectangle 24 161 300 457)
#'usePreferredExtent:' false
)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#LabelSpec
#'name:' 'label3'
#'layout:' #(#LayoutFrame 2 0 7 0 198 0 29 0)
#'label:' 'Applet Tag (HTML):'
#'adjust:' #left
)
#(#TextEditorSpec
#'name:' 'textEditor1'
#'layout:' #(#LayoutFrame 0 0.0 32 0 0 1.0 -40 1.0)
#'activeHelpKey:' #appletParamText
#'model:' #appletText
#'hasHorizontalScrollBar:' true
#'hasVerticalScrollBar:' true
#'miniScrollerHorizontal:' true
#'acceptChannel:' #textAcceptChannel
)
#(#HorizontalPanelViewSpec
#'name:' 'horizontalPanelView1'
#'layout:' #(#LayoutFrame 0 0.0 -39 1.0 0 1.0 -2 1.0)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#ButtonSpec
#'name:' 'parseButton'
#'activeHelpKey:' #appletTextParse
#'label:' 'Parse'
#'model:' #parseText
#'extent:' #(#Point 99 28)
)
)
)
#'horizontalLayout:' #center
#'verticalLayout:' #center
#'horizontalSpace:' 3
#'verticalSpace:' 3
)
)
)
)
"Modified: / 1.2.1998 / 15:04:33 / cg"
!
basicsEditSpec
"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:JavaAppletComponentSpec andSelector:#basicsEditSpec
JavaAppletComponentSpec new openInterface:#basicsEditSpec
"
<resource: #canvas>
^
#(#FullSpec
#'window:'
#(#WindowSpec
#'name:' 'ArbitraryComponent Basic'
#'layout:' #(#LayoutFrame 190 0 437 0 496 0 727 0)
#'label:' 'ArbitraryComponent Basic'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1280 1024)
#'bounds:' #(#Rectangle 190 437 497 728)
#'usePreferredExtent:' false
)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#LabelSpec
#'name:' 'idLabel'
#'layout:' #(#AlignmentOrigin 72 0 30 0 1 0.5)
#'label:' 'ID:'
#'resizeForLabel:' true
)
#(#InputFieldSpec
#'name:' 'idField'
#'layout:' #(#LayoutFrame 75 0 20 0 -2 1 45 0)
#'activeHelpKey:' #id
#'model:' #name
)
#(#LabelSpec
#'name:' 'codeURLLabel'
#'layout:' #(#AlignmentOrigin 85 0 106 0 1 0.5)
#'label:' 'CodeFile:'
#'resizeForLabel:' true
)
#(#InputFieldSpec
#'name:' 'codeURLField'
#'layout:' #(#LayoutFrame 87 0 95 0 -83 1 120 0)
#'activeHelpKey:' #codeFileEntry
#'model:' #codeURL
)
#(#LabelSpec
#'name:' 'codeBaseURLLabel'
#'layout:' #(#AlignmentOrigin 85 0 177 0 1 0.5)
#'label:' 'CodeBase:'
#'adjust:' #right
#'resizeForLabel:' true
)
#(#InputFieldSpec
#'name:' 'codeBaseURLField'
#'layout:' #(#LayoutFrame 87 0 166 0 -2 1.0 191 0)
#'activeHelpKey:' #codeBaseHolder
#'model:' #codeBaseURL
)
#(#LabelSpec
#'name:' 'archiveURLLabel'
#'layout:' #(#AlignmentOrigin 85 0 206 0 1 0.5)
#'label:' 'Archive:'
#'adjust:' #right
#'resizeForLabel:' true
)
#(#InputFieldSpec
#'name:' 'archiveURLField1'
#'layout:' #(#LayoutFrame 87 0 195 0 -2 1.0 220 0)
#'activeHelpKey:' #archiveEntry
#'model:' #archiveURL
)
#(#LabelSpec
#'name:' 'label1'
#'layout:' #(#LayoutFrame 2 0 139 0 198 0 161 0)
#'label:' 'URLS:'
#'adjust:' #left
)
#(#ButtonSpec
#'name:' 'browseButton'
#'layout:' #(#LayoutFrame -80 1.0 95 0 -2 1.0 119 0)
#'label:' 'Browse...'
#'model:' #browseForURL
)
)
)
)
"Modified: / 5.2.1998 / 13:29:45 / cg"
!
detailsEditSpec
"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:JavaAppletComponentSpec andSelector:#detailsEditSpec
JavaAppletComponentSpec new openInterface:#detailsEditSpec
"
<resource: #canvas>
^
#(#FullSpec
#'window:'
#(#WindowSpec
#'name:' 'ArbitraryComponent Detail'
#'layout:' #(#LayoutFrame 197 0 172 0 472 0 444 0)
#'label:' 'ArbitraryComponent Detail'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1160 870)
#'bounds:' #(#Rectangle 197 172 473 445)
)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#CheckBoxSpec
#'name:' 'hasBorder'
#'layout:' #(#LayoutOrigin 20 0 50 0)
#'tabable:' true
#'model:' #hasBorder
#'activeHelpKey:' #hasBorder
#'label:' 'Bordered'
)
#(#UISubSpecification
#'name:' 'detailsInitSubSpec'
#'layout:' #(#LayoutFrame 0 0.0 182 0 0 1.0 264 0)
#'minorKey:' #detailsInitSubSpec
)
)
)
)
"Created: / 29.1.1998 / 14:17:29 / cg"
"Modified: / 29.1.1998 / 14:28:46 / cg"
!
icon
"ImageEditor openOnClass:self andSelector:#icon"
<resource: #image>
^(Depth4Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[0 0 0 0 0 0 0 0 0 1 17 17 17 17 17 17 17 48 1 0 0 0 0 0 0 0 32 1 2 34 34 34 34 34 48 32 1 2 51 51 51 51 51 16 32 1 2 48 0 0 0 3 16 32 1 2 48 34 34 35 3 16 32 1 2 48 40 136 129 3 16 32 1 2 48 40 136 129 3 16 32 1 2 48 49 17 17 3 16 32 1 2 48 0 0 0 3 16 32 1 2 51 51 51 51 51 16 32 1 3 17 17 17 17 17 16 32 1 0 0 0 0 0 0 0 32 3 34 34 34 34 34 34 34 32 0 0 0 0 0 0 0 0 0]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color grey:49.9962); add:(Color grey:66.9978); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9992 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9992 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9992); add:(Color red:0.0 green:49.9992 blue:49.9992); add:(Color red:49.9992 green:49.9992 blue:0.0); add:(Color red:49.9992 green:0.0 blue:49.9992); yourself)); mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[127 255 128 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 255 255 192 127 255 128]) ; yourself); yourself
"Created: / 29.1.1998 / 14:17:49 / cg"
!
parameterEditSpec
"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:JavaAppletComponentSpec andSelector:#parameterEditSpec
JavaAppletComponentSpec new openInterface:#parameterEditSpec
"
<resource: #canvas>
^
#(#FullSpec
#'window:'
#(#WindowSpec
#'name:' 'ArbitraryComponent Detail'
#'layout:' #(#LayoutFrame 216 0 173 0 491 0 595 0)
#'label:' 'ArbitraryComponent Detail'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1160 870)
#'bounds:' #(#Rectangle 216 173 492 596)
#'usePreferredExtent:' false
)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#InputFieldSpec
#'name:' 'inputField1'
#'layout:' #(#LayoutFrame 80 0 -100 1.0 -2 1 -78 1.0)
#'activeHelpKey:' #paramNameField
#'model:' #paramNameString
)
#(#InputFieldSpec
#'name:' 'inputField2'
#'layout:' #(#LayoutFrame 80 0 -71 1.0 -2 1.0 -49 1.0)
#'activeHelpKey:' #paramValueField
#'model:' #paramValueString
)
#(#LabelSpec
#'name:' 'label1'
#'layout:' #(#AlignmentOrigin 77 0 -89 1.0 1 0.5)
#'label:' 'Name:'
#'adjust:' #right
)
#(#LabelSpec
#'name:' 'label2'
#'layout:' #(#AlignmentOrigin 77 0 -60 1.0 1 0.5)
#'label:' 'Value:'
#'adjust:' #right
)
#(#SequenceViewSpec
#'name:' 'sequenceView1'
#'layout:' #(#LayoutFrame 0 0.0 32 0.0 0 1.0 -120 1.0)
#'activeHelpKey:' #paramList
#'model:' #paramNameListHolder
#'hasHorizontalScrollBar:' true
#'hasVerticalScrollBar:' true
#'miniScrollerVertical:' true
#'useIndex:' false
)
#(#LabelSpec
#'name:' 'label3'
#'layout:' #(#LayoutFrame 2 0 7 0 198 0 29 0)
#'label:' 'Applet Parameters:'
#'adjust:' #left
)
#(#HorizontalPanelViewSpec
#'name:' 'horizontalPanelView1'
#'layout:' #(#LayoutFrame 79 0 -39 1.0 276 0 -2 1.0)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#ButtonSpec
#'name:' 'addButton'
#'activeHelpKey:' #paramAdd
#'label:' 'Add'
#'model:' #addParam
#'extent:' #(#Point 88 28)
)
#(#ButtonSpec
#'name:' 'removeButton'
#'activeHelpKey:' #paramRemove
#'label:' 'Remove'
#'model:' #removeParam
#'extent:' #(#Point 88 28)
)
)
)
#'horizontalLayout:' #left
#'verticalLayout:' #center
#'horizontalSpace:' 3
#'verticalSpace:' 3
)
)
)
)
"Modified: / 1.2.1998 / 15:13:54 / cg"
!
slices
^#(
(Basics basicsEditSpec)
(Details detailsEditSpec)
(Parameter parameterEditSpec)
(AppletTag appletTagEditSpec)
)
"Created: / 29.1.1998 / 14:17:34 / cg"
"Modified: / 30.1.1998 / 12:51:10 / cg"
! !
!JavaAppletComponentSpec methodsFor:'accessing'!
archiveURL
"return the value of the instance variable 'archiveURL' (automatically generated)"
^ archiveURL
"Created: / 29.1.1998 / 14:15:47 / cg"
!
archiveURL:something
"set the value of the instance variable 'archiveURL' (automatically generated)"
archiveURL := something.
"Created: / 29.1.1998 / 14:15:47 / cg"
!
codeBaseURL
"return the value of the instance variable 'codeBaseURL' (automatically generated)"
^ codeBaseURL
"Created: / 29.1.1998 / 14:15:43 / cg"
!
codeBaseURL:something
"set the value of the instance variable 'codeBaseURL' (automatically generated)"
codeBaseURL := something.
"Created: / 29.1.1998 / 14:15:43 / cg"
!
codeURL
"return the value of the instance variable 'codeURL' (automatically generated)"
^ codeURL
"Created: / 29.1.1998 / 14:15:41 / cg"
!
codeURL:something
"set the value of the instance variable 'codeURL' (automatically generated)"
codeURL := something.
"Created: / 29.1.1998 / 14:15:41 / cg"
!
documentURL
"return the value of the instance variable 'documentURL' (automatically generated)"
^ documentURL
"Created: / 29.1.1998 / 14:15:45 / cg"
!
documentURL:something
"set the value of the instance variable 'documentURL' (automatically generated)"
documentURL := something.
"Created: / 29.1.1998 / 14:15:45 / cg"
!
parameterDictionary
"return the value of the instance variable 'parameterDictionary' (automatically generated)"
^ parameterDictionary
"Created: / 29.1.1998 / 14:15:48 / cg"
!
parameterDictionary:something
"set the value of the instance variable 'parameterDictionary' (automatically generated)"
parameterDictionary := something.
"Created: / 29.1.1998 / 14:15:49 / cg"
! !
!JavaAppletComponentSpec methodsFor:'building'!
setAttributesIn:anAppletView with:aBuilder
|fullCode|
super setAttributesIn:anAppletView with:aBuilder.
(codeURL notNil and:[codeBaseURL notNil]) ifTrue:[
fullCode := (codeBaseURL asFilename construct:codeURL) name.
anAppletView codeURL:codeURL.
anAppletView codeBaseURL:fullCode.
"/ anAppletView codeBaseURL:codeBaseURL.
documentURL notNil ifTrue:[
anAppletView documentURL:documentURL
].
archiveURL notNil ifTrue:[
anAppletView archiveURL:archiveURL
].
parameterDictionary notNil ifTrue:[
anAppletView parameterDictionary:parameterDictionary
].
aBuilder isEditing ifTrue:[
anAppletView autoSetupApplet:false.
] ifFalse:[
anAppletView autoSetupApplet:true.
anAppletView autoStartApplet:true.
anAppletView autoDestroyApplet:true.
]
]
"Created: / 29.1.1998 / 15:17:38 / cg"
"Modified: / 23.12.1999 / 19:51:46 / cg"
!
viewClass
^ JavaEmbeddedFrameView
"Modified: / 29.1.1998 / 15:07:00 / cg"
! !
!JavaAppletComponentSpec methodsFor:'converting'!
fromLiteralArrayEncoding:aSpecArray
"initialize my values from a specArray"
super fromLiteralArrayEncoding:aSpecArray.
parameterDictionary notNil ifTrue:[
parameterDictionary := parameterDictionary decodeAsLiteralArray.
].
"Created: / 30.1.1998 / 04:58:41 / cg"
!
skippedInLiteralEncoding
"redefined to skip flags with default values"
|l|
l := super skippedInLiteralEncoding asOrderedCollection.
codeURL isNil ifTrue:[
l add:#codeURL
].
codeBaseURL isNil ifTrue:[
l add:#codeBaseURL
].
archiveURL isNil ifTrue:[
l add:#archiveURL
].
documentURL isNil ifTrue:[
l add:#documentURL
].
(parameterDictionary isNil
or:[parameterDictionary isEmpty]) ifTrue:[
l add:#parameterDictionary
].
level isNil ifTrue:[
l add:#level
].
^ l
"Created: / 29.1.1998 / 20:31:32 / cg"
"Modified: / 30.1.1998 / 05:03:22 / cg"
! !
!JavaAppletComponentSpec methodsFor:'spec actions'!
addParameter:nameString value:valueString
parameterDictionary isNil ifTrue:[
parameterDictionary := Dictionary new
].
parameterDictionary at:nameString put:valueString
"Created: / 30.1.1998 / 04:16:44 / cg"
"Modified: / 30.1.1998 / 04:21:58 / cg"
!
parseParametersFromAppletTag:appletTagText
"given some appletTAG text (i.e. <applet> ... </applet>),
extract values from it."
|html name value|
parameterDictionary isNil ifTrue:[
parameterDictionary := Dictionary new
].
html := HTMLParser new parseText:appletTagText.
[html notNil] whileTrue:[
html type == #param ifTrue:[
name := html nameString.
name notNil ifTrue:[
value := html valueString.
value notNil ifTrue:[
parameterDictionary at:name put:value
]
].
].
html := html next.
].
"Created: / 30.1.1998 / 15:47:52 / cg"
"Modified: / 30.1.1998 / 15:53:51 / cg"
!
removeParameter:nameString
parameterDictionary removeKey:nameString ifAbsent:nil
"Created: / 30.1.1998 / 04:16:55 / cg"
"Modified: / 9.2.1998 / 12:02:08 / cg"
! !
!JavaAppletComponentSpec class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libjava/Attic/JavaAppletComponentSpec.st,v 1.14 2002-11-22 20:13:57 cg Exp $'
! !