Package ptolemy.vergil.basic.export.web
Class Script
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable
,HasTypeConstraints
,Typeable
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
,Settable
,ValueListener
,WebExportable
- Direct Known Subclasses:
IconScript
public abstract class Script extends WebContent implements WebExportable
A parameter for associating a script (such as Javascript) with an object in a model.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee, Elizabeth Latronico
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.data.expr.Variable
Variable.CircularDependencyError, Variable.VariableScope
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
Nested classes/interfaces inherited from interface ptolemy.kernel.util.Settable
Settable.Visibility
-
-
Field Summary
Fields Modifier and Type Field Description Parameter
evaluateScript
Parameter indicating whether the script text's expression should be evaluated or not.AreaEventType
eventType
Event type to respond to by executing the command given by the value of this Script parameter.StringParameter
script
Script to insert in the head section of the web page.-
Fields inherited from class ptolemy.vergil.basic.export.web.WebContent
_icon, displayText, height, width
-
Fields inherited from class ptolemy.data.expr.Variable
_currentExpression, _needsEvaluation, _parserScope, _parseTreeValid, _suppressVariableSubstitution, _valueListeners
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.kernel.util.Settable
EXPERT, FULL, NONE, NOT_EDITABLE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMimeType()
Script is of type text/javascript for backwards compatibility.boolean
isOverwriteable()
Return true, since new scripts and method calls should overwrite old.-
Methods inherited from class ptolemy.vergil.basic.export.web.WebContent
_provideAttributes, _provideElements, attributeChanged, clone, provideContent
-
Methods inherited from class ptolemy.data.expr.StringParameter
stringValue
-
Methods inherited from class ptolemy.data.expr.Parameter
addChoice, exportMoML, getChoices, removeAllChoices, removeChoice
-
Methods inherited from class ptolemy.data.expr.Variable
_description, _evaluate, _getCurrentExpression, _notifyValueListeners, _parseIfNecessary, _propagate, _propagateToValueListeners, _propagateValue, _setToken, _setTokenAndNotify, addValueListener, getDeclaredType, getExpression, getFreeIdentifiers, getParserScope, getScope, getScope, getToken, getType, getTypeTerm, getValueAsString, getVariable, getVisibility, invalidate, isKnown, isLazy, isStringMode, isSuppressVariableSubstitution, isTypeAcceptable, removeValueListener, reset, setContainer, setExpression, setLazy, setName, setParseTreeEvaluator, setStringMode, setSuppressVariableSubstitution, setToken, setToken, setTypeAtLeast, setTypeAtLeast, setTypeAtMost, setTypeEquals, setTypeSameAs, setUnknown, setValueListenerAsWeakDependency, setVisibility, stringRepresentation, toString, typeConstraintList, typeConstraints, validate, valueChanged
-
Methods inherited from class ptolemy.kernel.util.AbstractSettableAttribute
getDefaultExpression
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.kernel.util.Settable
getDisplayName
-
Methods inherited from interface ptolemy.vergil.basic.export.web.WebExportable
provideContent
-
-
-
-
Field Detail
-
evaluateScript
public Parameter evaluateScript
Parameter indicating whether the script text's expression should be evaluated or not. Ptolemy interprets the dollar sign to indicate that the value of a parameter should be inserted; for example, $pi and a variable pi=3.14 would evaluate to 3.14. However, many scripting languages such as jQuery use a dollar sign as part of the script itself (to refer to jQuery variables). In this case, we want to insert the exact plain text into the web page, not the evaluated text.
-
eventType
public AreaEventType eventType
Event type to respond to by executing the command given by the value of this Script parameter. The script will be run when the icon corresponding to the container of this parameter gets one of the following events:- onblur: Command to be run when an element loses focus.
- onclick: Command to be run on a mouse click.
- ondblclick: Command to be run on a mouse double-click.
- onfocus: Command to be run when an element gets focus.
- onmousedown: Command to be run when mouse button is pressed.
- onmousemove: Command to be run when mouse pointer moves.
- onmouseout: Command to be run when mouse pointer moves out of an element.
- onmouseover: Command to be run when mouse pointer moves over an element.
- onmouseup: Command to be run when mouse button is released.
- onkeydown: Command to be run when a key is pressed.
- onkeypress: Command to be run when a key is pressed and released.
- onkeyup: Command to be run when a key is released.
-
script
public StringParameter script
Script to insert in the head section of the web page. This will normally define a JavaScript function that will be invoked when the UI event specified by eventType occurs. By default, this is blank. For example, if the value of this parameter is the stringfunction writeText(text) { document.getElementById("xyz").innerHTML = text; };
and the value of this parameter is "writeText('hello world')", then the HTML element with ID xyz will be populated with the string 'hello world' when the UI action eventType occurs.
-
-
Constructor Detail
-
Script
public Script(NamedObj container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create an instance of this parameter.- Parameters:
container
- The container.name
- The name.- Throws:
IllegalActionException
- If the superclass throws it.NameDuplicationException
- If the superclass throws it.
-
-
Method Detail
-
getMimeType
public java.lang.String getMimeType()
Script is of type text/javascript for backwards compatibility. return string text/javascript- Specified by:
getMimeType
in interfaceWebExportable
- Returns:
- The Mime type of the content (for example, text/html)
-
isOverwriteable
public boolean isOverwriteable()
Return true, since new scripts and method calls should overwrite old.- Specified by:
isOverwriteable
in interfaceWebExportable
- Returns:
- True, since new scripts and method calls should overwrite old
-
-