Runtime

org.eclipse.gmf.runtime.diagram.ui.editparts
Class LabelEditPart

java.lang.Object
  extended byorg.eclipse.gef.editparts.AbstractEditPart
      extended byorg.eclipse.gef.editparts.AbstractGraphicalEditPart
          extended byorg.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart
              extended byorg.eclipse.gmf.runtime.diagram.ui.editparts.TopGraphicEditPart
                  extended byorg.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart
All Implemented Interfaces:
EditPart, GraphicalEditPart, IAdaptable, IAdaptableSelection, org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IContainedEditPart, org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IEditableEditPart, IGraphicalEditPart, NotificationListener, RequestConstants

public class LabelEditPart
extends TopGraphicEditPart

Controller for all label that deals with interactions bewteen the label figure the underline editpart


Nested Class Summary
 
Nested classes inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart
AbstractGraphicalEditPart.AccessibleGraphicalEditPart, AbstractGraphicalEditPart.DefaultAccessibleAnchorProvider
 
Nested classes inherited from class org.eclipse.gef.editparts.AbstractEditPart
AbstractEditPart.EditPolicyIterator
 
Field Summary
 
Fields inherited from class org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart
accessibleEP, elementGuid
 
Fields inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart
figure, sourceConnections, targetConnections
 
Fields inherited from class org.eclipse.gef.editparts.AbstractEditPart
children, FLAG_ACTIVE, FLAG_FOCUS, MAX_FLAG
 
Fields inherited from interface org.eclipse.gef.EditPart
SELECTED, SELECTED_NONE, SELECTED_PRIMARY
 
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER
 
Constructor Summary
LabelEditPart(View view)
          constructor
 
Method Summary
protected  void addNotationalListeners()
          This method adds all listeners to the notational world (views, figures, editpart...etc) Override this method to add more notational listeners down the hierarchy
protected  void createDefaultEditPolicies()
          Should be overridden to install editpolicies programmatically.
protected  IFigure createFigure()
           
protected  AccessibleEditPart getAccessibleEditPart()
           
protected  java.lang.String getAccessibleText()
          Concatenates the text of all the text compartment children of this editpart to be used as the accessible text.
 java.lang.Object getAdapter(java.lang.Class key)
          Returns an object which is an instance of the given class associated with this object.
 DragTracker getDragTracker(Request request)
          Return a DragTracker instance.
 int getKeyPoint()
          Returns a ConnectionLocator.MIDDLE as the key point.
 Point getReferencePoint()
          Returns a Point located on the parent which is used by the LabelEditPart to orient itself.
protected  java.lang.String getSemanticType()
          Returns the model's semantic hint.
static Point getSnapBackPosition(java.lang.String propertyName)
          Retrieves the default snap back position for this label that was registered using using the LabelEditPart.registerSnapBackPosition(String, Point) method.
protected  void handleNotificationEvent(Notification notification)
          Handles the property changed event.
 boolean isSnapBackNeeded()
          Method isSnapBackNeeded.
 void refresh()
          Invoke the editpart's refresh mechanism.
 void refreshBounds()
          Updates the locator based on the changes to the offset.
protected  void refreshVisuals()
          Refresh the editpart's figure visual properties.
static void registerSnapBackPosition(java.lang.String propertyName, Point offset)
          Registers the default snap back position for this label that is retrievable from the editpolicy that creates the command to move the label back to it's original position.
protected  void removeNotationalListeners()
          This method removes all listeners to the notational world (views, figures, editpart...etc) Override this method to remove notational listeners down the hierarchy
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.editparts.TopGraphicEditPart
getResizableCompartments, getResizableNotationViews, performDirectEditRequest, understandsRequest
 
Methods inherited from class org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart
activate, addChild, addListenerFilter, addListenerFilter, addSemanticListeners, basicGetModel, createConnection, createEditPolicies, deactivate, disableEditMode, enableEditMode, eraseSourceFeedback, eraseTargetFeedback, executeCommand, findEditPart, getChildBySemanticHint, getChildBySemanticHintOnPrimaryView, getChildViewBySemanticHint, getCommand, getContentPaneFor, getDiagramEditDomain, getDiagramPreferencesHint, getDiagramView, getEditDomain, getEditingDomain, getMapMode, getModel, getModelChildren, getNotationView, getPreferredValue, getPrimaryChildEditPart, getPrimaryView, getResourceManager, getRoot, getStructuralFeatureValue, getTopGraphicEditPart, handleMajorSemanticChange, hasNotationView, isCanonical, isEditModeEnabled, isSelectable, notifyChanged, performRequest, reactivateSemanticModel, refreshBackgroundColor, refreshChild, refreshFont, refreshFontColor, refreshForegroundColor, refreshSourceConnection, refreshTargetConnection, refreshVisibility, registerModel, removeListenerFilter, removeNotify, removeSemanticListeners, resolveSemanticElement, setBackgroundColor, setFont, setFontColor, setForegroundColor, setModel, setStructuralFeatureValue, setVisibility, showSourceFeedback, showTargetFeedback, transactionAboutToCommit, unregisterModel
 
Methods inherited from class org.eclipse.gef.editparts.AbstractGraphicalEditPart
addChildVisual, addNodeListener, addNotify, addSourceConnection, addTargetConnection, createOrFindConnection, fireRemovingSourceConnection, fireRemovingTargetConnection, fireSourceConnectionAdded, fireTargetConnectionAdded, getContentPane, getFigure, getLayer, getModelSourceConnections, getModelTargetConnections, getSourceConnections, getTargetConnections, primAddSourceConnection, primAddTargetConnection, primRemoveSourceConnection, primRemoveTargetConnection, refreshSourceConnections, refreshTargetConnections, registerVisuals, removeChildVisual, removeNodeListener, removeSourceConnection, removeTargetConnection, reorderChild, reorderSourceConnection, reorderTargetConnection, setFigure, setLayoutConstraint, unregisterVisuals
 
Methods inherited from class org.eclipse.gef.editparts.AbstractEditPart
activateEditPolicies, addEditPartListener, createChild, deactivateEditPolicies, debug, debugFeedback, fireActivated, fireChildAdded, fireDeactivated, fireRemovingChild, fireSelectionChanged, getChildren, getEditPolicy, getEditPolicyIterator, getEventListeners, getFlag, getParent, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, refreshChildren, register, registerAccessibility, removeChild, removeEditPartListener, removeEditPolicy, setFlag, setFocus, setParent, setSelected, toString, unregister, unregisterAccessibility
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.gef.GraphicalEditPart
addNodeListener, getContentPane, getFigure, getSourceConnections, getTargetConnections, removeNodeListener, setLayoutConstraint
 
Methods inherited from interface org.eclipse.gef.EditPart
addEditPartListener, addNotify, getChildren, getEditPolicy, getParent, getSelected, getTargetEditPart, getViewer, hasFocus, installEditPolicy, isActive, removeEditPartListener, removeEditPolicy, setFocus, setParent, setSelected
 

Constructor Detail

LabelEditPart

public LabelEditPart(View view)
constructor

Parameters:
view - this edit part's view
Method Detail

registerSnapBackPosition

public static void registerSnapBackPosition(java.lang.String propertyName,
                                            Point offset)
Registers the default snap back position for this label that is retrievable from the editpolicy that creates the command to move the label back to it's original position. Subclasses of LabelEditPart should call this to register their labels default position.

Parameters:
propertyName - String that is usually the property identifier for the label or it can be any unique identifier the label subclass desires.
offset - Point that is the offset Point position from the keypoint.

getSnapBackPosition

public static Point getSnapBackPosition(java.lang.String propertyName)
Retrieves the default snap back position for this label that was registered using using the LabelEditPart.registerSnapBackPosition(String, Point) method.

Parameters:
propertyName - String that is usually the property identifier for the label or it can be any unique identifier the label subclass desires.
Returns:
offset Point that is the offset Point position from the keypoint.

createFigure

protected IFigure createFigure()
Overrides:
createFigure in class GraphicalEditPart

getSemanticType

protected java.lang.String getSemanticType()
Returns the model's semantic hint. This is used to calculate the reference point for the label's figure.

Returns:
the semantic type

refresh

public void refresh()
Description copied from class: GraphicalEditPart
Invoke the editpart's refresh mechanism.

Specified by:
refresh in interface EditPart
Overrides:
refresh in class GraphicalEditPart

refreshBounds

public void refreshBounds()
Updates the locator based on the changes to the offset.


createDefaultEditPolicies

protected void createDefaultEditPolicies()
Description copied from class: GraphicalEditPart
Should be overridden to install editpolicies programmatically.

Overrides:
createDefaultEditPolicies in class TopGraphicEditPart
See Also:
GraphicalEditPart.createDefaultEditPolicies()

getDragTracker

public DragTracker getDragTracker(Request request)
Return a DragTracker instance.

Specified by:
getDragTracker in interface EditPart
Overrides:
getDragTracker in class GraphicalEditPart
See Also:
EditPart.getDragTracker(org.eclipse.gef.Request)

isSnapBackNeeded

public boolean isSnapBackNeeded()
Method isSnapBackNeeded.

Returns:
boolean returns false only if the current location of the figure is not default one

refreshVisuals

protected void refreshVisuals()
Description copied from class: GraphicalEditPart
Refresh the editpart's figure visual properties.

Overrides:
refreshVisuals in class GraphicalEditPart
See Also:
AbstractEditPart.refreshVisuals()

handleNotificationEvent

protected void handleNotificationEvent(Notification notification)
Description copied from class: GraphicalEditPart
Handles the property changed event. Clients should override to respond to the specific notification events they are interested. Note: This method may get called on a non-UI thread. Clients should either ensure that their code is thread safe and/or doesn't make unsupported calls (i.e. Display.getCurrent() ) assuming they are on the main thread. Alternatively if this is not possible, then the client can wrap their handler within the Display.synchExec runnable to ensure synchronization and subsequent execution on the main thread.

Overrides:
handleNotificationEvent in class GraphicalEditPart
Parameters:
notification - the Notification object that is the property changed event
See Also:
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#handlePropertyChangeEvent(java.beans.PropertyChangeEvent)

addNotationalListeners

protected void addNotationalListeners()
Description copied from class: GraphicalEditPart
This method adds all listeners to the notational world (views, figures, editpart...etc) Override this method to add more notational listeners down the hierarchy

Overrides:
addNotationalListeners in class GraphicalEditPart

removeNotationalListeners

protected void removeNotationalListeners()
Description copied from class: GraphicalEditPart
This method removes all listeners to the notational world (views, figures, editpart...etc) Override this method to remove notational listeners down the hierarchy

Overrides:
removeNotationalListeners in class GraphicalEditPart

getAccessibleEditPart

protected AccessibleEditPart getAccessibleEditPart()
Overrides:
getAccessibleEditPart in class GraphicalEditPart
See Also:
AbstractEditPart.getAccessibleEditPart()

getAccessibleText

protected java.lang.String getAccessibleText()
Concatenates the text of all the text compartment children of this editpart to be used as the accessible text.

Returns:
String the string to be used as the accessible text

getAdapter

public java.lang.Object getAdapter(java.lang.Class key)
Returns an object which is an instance of the given class associated with this object. If there are specific class types that should be delegated to the connection editpart they must be explicitely handled here (e.g. IPropertySource is delegated to the connection editpart so that the property pages reflect the connection when the label is selected). Otherwise, the adapter from this editpart is first retrieved; if this is null, then the adapter from the connection editpart is returned. This means if a client asks for IView the label view will be returned, but if a client asks for IPrimaryView the owner view will be returned.

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class GraphicalEditPart
See Also:
IAdaptable.getAdapter(java.lang.Class)

getKeyPoint

public int getKeyPoint()
Returns a ConnectionLocator.MIDDLE as the key point.

Returns:
the key point

getReferencePoint

public Point getReferencePoint()
Returns a Point located on the parent which is used by the LabelEditPart to orient itself.

Returns:
the anchorPoint

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.