com.nwoods.jgo
Class JGoTextEdit

java.lang.Object
  extended bycom.nwoods.jgo.JGoObject
      extended bycom.nwoods.jgo.JGoControl
          extended bycom.nwoods.jgo.JGoTextEdit
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.FocusListener, JGoXMLSaveRestore, org.eclipse.swt.events.KeyListener, java.io.Serializable, org.eclipse.swt.internal.SWTEventListener

public class JGoTextEdit
extends JGoControl
implements org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.FocusListener

JGoTextEdit displays an SWT Text Control to allow end-user editing of the text in the associated JGoText object.

This class is normally only used by JGoView to implement in-place text editing for JGoText. Only one instance of this class will exist at a time per view, and then only in a view (not in a document).

Note that, like all other JGoControls, the SWT Controls created to be displayed as the representation of these JGoObjects, will appear in front of (on top of) all other JGoObjects. Thus it is wise to either use these objects as view objects or make sure they don't overlap with other document objects.

See Also:
JGoText, Serialized Form

Field Summary
 
Fields inherited from class com.nwoods.jgo.JGoObject
Bottom, BottomCenter, BottomLeft, BottomMiddle, BottomRight, Center, CenterLeft, CenterRight, Changed4ResizeHandles, ChangedAutoRescale, ChangedBrush, ChangedDraggable, ChangedDragsNode, ChangedGeometry, ChangedGrabChildSelection, ChangedInitializing, ChangedPen, ChangedResizable, ChangedSelectable, ChangedUpdatePartner, ChangedVisible, ChangedZOrder, LastChangedHint, Left, LeftCenter, NoHandle, NoSpot, NumReservedHandles, RepaintAll, Right, RightCenter, SideLeft, SideRight, Top, TopCenter, TopLeft, TopMiddle, TopRight
 
Constructor Summary
JGoTextEdit()
          Create a standard JGoObject/JGoControl corresponding to an SWT Text Control.
JGoTextEdit(org.eclipse.swt.graphics.Point location, Dimension size, java.lang.String origText, boolean multiline, JGoText obj)
          Create a text editor object associated with a JGoText object.
JGoTextEdit(org.eclipse.swt.graphics.Rectangle rect, java.lang.String origText, boolean multiline, JGoText obj)
          Create a text editor object associated with a JGoText object.
 
Method Summary
 JGoObject copyObject(JGoCopyEnvironment env)
          Called during the first phase of the copy process to produce a copy of this object within the given copy dictionary.
 org.eclipse.swt.widgets.Control createControl(JGoView view)
          Create an SWT Text Control that implements the text editor.
 void doEndEdit()
          Convenience routine to stop user editing of the JGoText object.
 void focusGained(org.eclipse.swt.events.FocusEvent e)
           
 void focusLost(org.eclipse.swt.events.FocusEvent e)
           
 JGoText getTextObject()
          Return the JGoText object that this control object is an editor for.
 void keyPressed(org.eclipse.swt.events.KeyEvent e)
           
 void keyReleased(org.eclipse.swt.events.KeyEvent e)
           
 void paint(Graphics2D g, JGoView view)
          Draw the Control associated with this JGoTextEdit.
 boolean setEditedText(java.lang.String newtext, JGoView view)
          Convenience routine to commit user editing of the JGoText object.
 void setTextObject(JGoText obj)
          Set the JGoText object that this JGoControl is supposed to be an editor for.
 
Methods inherited from class com.nwoods.jgo.JGoControl
geometryChange, getControl, getIterator, ownerChange, setVisible
 
Methods inherited from class com.nwoods.jgo.JGoObject
canView, changeValue, computeBoundingRect, computeMove, computeResize, copy, copyNewValueForRedo, copyObjectDelayed, copyOldValueForUndo, copyRect, doMouseClick, doMouseDblClick, doUncapturedMouseMove, expandRectByPenWidth, findCommonParent, foredate, gainedSelection, geometryChangeChild, getBoundingRect, getDocument, getDraggingObject, getFlags, getHeight, getLayer, getLeft, getLocation, getLocation, getNearestIntersectionPoint, getParent, getParentJGoNode, getParentNode, getPartner, getRectangleSpotLocation, getSize, getSize, getSpotLocation, getSpotLocation, getToolTipText, getTop, getTopLeft, getTopLeft, getTopLevelObject, getView, getWidth, growRect, handleMove, handleResize, hideSelectionHandles, is4ResizeHandles, isAutoRescale, isBoundingRectInvalid, isChildOf, isDraggable, isDragsNode, isInitializing, isPointInObj, isResizable, isSelectable, isSkipsUndoManager, isSuspendUpdates, isTopLevel, isUpdatePartner, isVisible, lostSelection, partnerUpdate, pick, redirectSelection, remove, set4ResizeHandles, setAutoRescale, setBoundingRect, setBoundingRect, setBoundingRect, setBoundingRectInvalid, setBoundsRect, setDraggable, setDragsNode, setFlags, setHeight, setInitializing, setLeft, setLocation, setLocation, setLocationOffset, setLocationOffset, setParent, setPartner, setRectangleSpotLocation, setResizable, setSelectable, setSize, setSize, setSizeKeepingLocation, setSkipsUndoManager, setSpotLocation, setSpotLocation, setSpotLocation, setSpotLocationOffset, setSuspendUpdates, setTop, setTopLeft, setTopLeft, setUpdatePartner, setWidth, showSelectionHandles, spotOpposite, SVGReadAttributes, SVGReadObject, SVGUpdateReference, SVGWriteAttributes, SVGWriteObject, update, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGoTextEdit

public JGoTextEdit()
Create a standard JGoObject/JGoControl corresponding to an SWT Text Control.

The TextObject property must be set to a valid JGoText before this JGoControl can be used, even for painting.


JGoTextEdit

public JGoTextEdit(org.eclipse.swt.graphics.Point location,
                   Dimension size,
                   java.lang.String origText,
                   boolean multiline,
                   JGoText obj)
Create a text editor object associated with a JGoText object.

Parameters:
location - the top-left position, in document coordinates
size - the width and height, in document coordinates
origText - the initial text string
multiline - whether more than one line of text is allowed
obj - the JGoText object for which this object represents the editor

JGoTextEdit

public JGoTextEdit(org.eclipse.swt.graphics.Rectangle rect,
                   java.lang.String origText,
                   boolean multiline,
                   JGoText obj)
Create a text editor object associated with a JGoText object.

Parameters:
rect - the initial bounding rectangle, in document coordinates
origText - the initial text string
multiline - whether more than one line of text is allowed
obj - the JGoText object for which this object represents the editor
Method Detail

copyObject

public JGoObject copyObject(JGoCopyEnvironment env)
Description copied from class: JGoObject
Called during the first phase of the copy process to produce a copy of this object within the given copy dictionary. If you just need to make a copy of a JGoObject, call JGoObject.copy(), or JGoDocument.addCopy, or JGoDocument.copyFromCollection if you have more than one object to copy.

You should override this method in your derived classes when it has some fields that have reference objects that need to be copied. Your override method should first call super.copyObject(env) to get the newly copied object. The standard implementation of this method for JGoObject is to do a shallow copy, by Object.getClass().newInstance(). This depends on the existence of a zero-argument constructor. The result should be the object you return, after performing any other deeper copying of referenced objects that you deem necessary, and after removing references that should not be shared (such as to cached data structures). If super.copyObject(env) returns null, it's either already copied, or mapped to an existing object in this document, or shouldn't be copied at all.

The copied object does not belong to any layer or any group, nor does it have any observers; the ultimate caller (i.e. JGoDocument.copyFromCollection) is responsible for adding it to the appropriate collection and copyObjectDelayed is responsible for adding the appropriate observers.

You probably should not be calling this method for any reason but the initial super.copyObject(env) call in an override of this method; normally only JGoCopyEnvironment.copy is the caller. Within an override of this method, if you need to make a copy of another object, call JGoCopyEnvironment.copy instead.

Overrides:
copyObject in class JGoObject
Parameters:
env - the environment for the copy operation - keeps track of copied objects.
Returns:
a newly allocated copy of this object, or null

getTextObject

public JGoText getTextObject()
Return the JGoText object that this control object is an editor for.


setTextObject

public void setTextObject(JGoText obj)
Set the JGoText object that this JGoControl is supposed to be an editor for.


keyPressed

public void keyPressed(org.eclipse.swt.events.KeyEvent e)
Specified by:
keyPressed in interface org.eclipse.swt.events.KeyListener

keyReleased

public void keyReleased(org.eclipse.swt.events.KeyEvent e)
Specified by:
keyReleased in interface org.eclipse.swt.events.KeyListener

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent e)
Specified by:
focusGained in interface org.eclipse.swt.events.FocusListener

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent e)
Specified by:
focusLost in interface org.eclipse.swt.events.FocusListener

createControl

public org.eclipse.swt.widgets.Control createControl(JGoView view)
Create an SWT Text Control that implements the text editor.

Specified by:
createControl in class JGoControl
Parameters:
view - the view for which this control should be created
Returns:
a Control

paint

public void paint(Graphics2D g,
                  JGoView view)
Draw the Control associated with this JGoTextEdit.

Overrides:
paint in class JGoControl
Parameters:
g - this Graphics should be ignored, because it is transformed
view - the view in which this control should be drawn

setEditedText

public boolean setEditedText(java.lang.String newtext,
                             JGoView view)
Convenience routine to commit user editing of the JGoText object.


doEndEdit

public void doEndEdit()
Convenience routine to stop user editing of the JGoText object.