Package ptolemy.actor.lib.gui
Class InteractiveDialog
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.gui.InteractiveDialog
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Placeable
,Initializable
,UsesInvokeAndWait
,TypedActor
,ShellInterpreter
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class InteractiveDialog extends TypedAtomicActor implements Placeable, ShellInterpreter, UsesInvokeAndWait
This actor creates a window on the screen with a command entry box and a results display box. When the user types a command and terminates it with a return, this actor will emit an output with the value of that command and also display the command in the results display box. Any input that it receives it displays in the results display box.
- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- Edward A. Lee
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
InteractiveDialog.DialogFrame
The frame that is created by an instance of ShellTableau.class
InteractiveDialog.DialogTableau
Version of ExpressionShellTableau that records the size of the display when it is closed.-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description TypedIOPort
input
The input port.TypedIOPort
output
The output port.Parameter
terminateWithNewline
If true, append a newline to each output string.UserDialog
userDialog
The dialog window object.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description InteractiveDialog(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<Inequality>
_customTypeConstraints()
Set the input port greater than or equal toBaseType.GENERAL
in case backward type inference is enabled and the input port has no type declared.protected void
_exportMoMLContents(java.io.Writer output, int depth)
Write a MoML description of the contents of this object.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.java.lang.String
evaluateCommand(java.lang.String command)
Record the specified command and request a firing to send it to the output.void
fire()
Read and display any input, then if a new command is available, display it and produce it on the output.void
initialize()
If the shell has not already been created, create it.boolean
isCommandComplete(java.lang.String command)
Return true if the specified command is complete (ready to be interpreted).void
place(java.awt.Container container)
Specify the container into which this shell should be placed.void
setContainer(CompositeEntity container)
Override the base class to remove the shell from its graphical container if the argument is null.void
setDisplayName(java.lang.String name)
Set a name to present to the user.void
setName(java.lang.String name)
Set or change the name.void
stop()
Override the base class to call notifyAll() to get out of any waiting.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName
-
-
-
-
Field Detail
-
input
public TypedIOPort input
The input port. By default, this has undeclared type. If backward type inference is enabled, then it has type general. In either case, it can receive any data type. If it receives token of type string, it strips off the surrounding double quotes before displaying the value.
-
terminateWithNewline
public Parameter terminateWithNewline
If true, append a newline to each output string. This is a boolean that defaults to false.
-
output
public TypedIOPort output
The output port.
-
userDialog
public UserDialog userDialog
The dialog window object.
-
-
Constructor Detail
-
InteractiveDialog
public InteractiveDialog(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class has an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
evaluateCommand
public java.lang.String evaluateCommand(java.lang.String command) throws java.lang.Exception
Record the specified command and request a firing to send it to the output.- Specified by:
evaluateCommand
in interfaceShellInterpreter
- Parameters:
command
- The command.- Returns:
- Null to indicate that the command evaluation is not complete.
- Throws:
java.lang.Exception
- If something goes wrong processing the command.- See Also:
ShellTextArea.returnResult(String)
-
fire
public void fire() throws IllegalActionException
Read and display any input, then if a new command is available, display it and produce it on the output.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If producing the output causes an exception.
-
initialize
public void initialize() throws IllegalActionException
If the shell has not already been created, create it. Then wait for user input and produce it on the output.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the parent class throws it.
-
isCommandComplete
public boolean isCommandComplete(java.lang.String command)
Return true if the specified command is complete (ready to be interpreted).- Specified by:
isCommandComplete
in interfaceShellInterpreter
- Parameters:
command
- The command.- Returns:
- True.
-
place
public void place(java.awt.Container container)
Specify the container into which this shell should be placed. This method needs to be called before the first call to initialize(). Otherwise, the shell will be placed in its own frame. The background of the plot is set equal to that of the container (unless it is null).
-
setContainer
public void setContainer(CompositeEntity container) throws IllegalActionException, NameDuplicationException
Override the base class to remove the shell from its graphical container if the argument is null.- Overrides:
setContainer
in classAtomicActor<TypedIOPort>
- Parameters:
container
- The proposed container.- Throws:
IllegalActionException
- If the base class throws it.NameDuplicationException
- If the base class throws it.- See Also:
ComponentEntity.getContainer()
-
setDisplayName
public void setDisplayName(java.lang.String name)
Set a name to present to the user.If the Plot window has been rendered, then the title of the Plot window will be updated to the value of the name parameter.
- Overrides:
setDisplayName
in classNamedObj
- Parameters:
name
- A name to present to the user.- See Also:
NamedObj.getDisplayName()
-
setName
public void setName(java.lang.String name) throws IllegalActionException, NameDuplicationException
Set or change the name. If a null argument is given the name is set to an empty string. Increment the version of the workspace. This method is write-synchronized on the workspace.If the Plot window has been rendered, then the title of the Plot window will be updated to the value of the name parameter.
- Specified by:
setName
in interfaceNameable
- Overrides:
setName
in classComponentEntity<TypedIOPort>
- Parameters:
name
- The new name.- Throws:
IllegalActionException
- If the name contains a period or if the object is a derived object and the name argument does not match the current name.NameDuplicationException
- Not thrown in this base class. May be thrown by derived classes if the container already contains an object with this name.- See Also:
NamedObj.getName()
,NamedObj.getName(NamedObj)
-
stop
public void stop()
Override the base class to call notifyAll() to get out of any waiting.- Specified by:
stop
in interfaceExecutable
- Overrides:
stop
in classAtomicActor<TypedIOPort>
-
_customTypeConstraints
protected java.util.Set<Inequality> _customTypeConstraints()
Set the input port greater than or equal toBaseType.GENERAL
in case backward type inference is enabled and the input port has no type declared.- Overrides:
_customTypeConstraints
in classTypedAtomicActor
- Returns:
- A set of inequalities.
-
_exportMoMLContents
protected void _exportMoMLContents(java.io.Writer output, int depth) throws java.io.IOException
Write a MoML description of the contents of this object. This overrides the base class to make sure that the current frame properties, if there is a frame, are recorded.- Overrides:
_exportMoMLContents
in classEntity<TypedIOPort>
- Parameters:
output
- The output stream to write to.depth
- The depth in the hierarchy, to determine indenting.- Throws:
java.io.IOException
- If an I/O error occurs.- See Also:
NamedObj.exportMoML(Writer, int)
-
-