Class XtextDirectEditManager

java.lang.Object
org.eclipse.gef.tools.DirectEditManager
org.yakindu.base.xtext.utils.gmf.directedit.DirectEditManagerEx
org.yakindu.base.xtext.utils.gmf.directedit.XtextDirectEditManager

public class XtextDirectEditManager extends DirectEditManagerEx
Full copy of the TextDirectEditManager for a StyledText
  • Constructor Details

    • XtextDirectEditManager

      public XtextDirectEditManager(IXtextAwareEditPart source, com.google.inject.Injector injector, int style)
      constructor
      Parameters:
      source - GraphicalEditPart to support direct edit of. The figure of the source edit part must be of type WrapLabel.
    • XtextDirectEditManager

      public XtextDirectEditManager(IXtextAwareEditPart source, com.google.inject.Injector injector, int style, IXtextFakeContextResourcesProvider provider)
    • XtextDirectEditManager

      public XtextDirectEditManager(org.eclipse.gef.GraphicalEditPart source, Class<?> editorType, org.eclipse.gef.tools.CellEditorLocator locator, com.google.inject.Injector injector, int style)
      Parameters:
      source -
      editorType -
      locator -
  • Method Details

    • getTextCellEditorLocator

      public static org.eclipse.gef.tools.CellEditorLocator getTextCellEditorLocator(IXtextAwareEditPart source)
      Parameters:
      source - the ITextAwareEditPart to determine the cell editor for
      Returns:
      the CellEditorLocator that is appropriate for the source EditPart
    • createCellEditorOn

      protected CellEditor createCellEditorOn(Composite composite)
      This method is overridden so that the editor class can have a style as the style needs to be passed into the editor class when it is created. It will default to the super behavior if an editorType was passed into the constructor.
      Overrides:
      createCellEditorOn in class DirectEditManagerEx
      Parameters:
      composite - the composite to create the cell editor on
      Returns:
      the newly created cell editor
      Since:
      2.1
    • getScaledFont

      protected Font getScaledFont(org.eclipse.draw2d.IFigure label)
      Given a label figure object, this will calculate the correct Font needed to display into screen coordinates, taking into account the current mapmode. This will typically be used by direct edit cell editors that need to display independent of the zoom or any coordinate mapping that is taking place on the drawing surface.
      Parameters:
      label - the label to use for the font calculation
      Returns:
      the Font that is scaled to the screen coordinates. Note: the returned Font should not be disposed since it is cached by a common resource manager.
    • initCellEditor

      protected void initCellEditor()
      Description copied from class: DirectEditManagerEx
      Initializes the cell editor. Subclasses should implement this to set the initial text and add things such as VerifyListeners, if needed.
      Specified by:
      initCellEditor in class DirectEditManagerEx
    • commit

      protected void commit()
      Description copied from class: DirectEditManagerEx
      Commits the current value of the cell editor by getting a Command from the source edit part and executing it via the CommandStack. Finally, DirectEditManagerEx.bringDown() is called to perform and necessary cleanup.
      Overrides:
      commit in class DirectEditManagerEx
      See Also:
      • DirectEditManager.commit()
    • bringDown

      protected void bringDown()
      Description copied from class: DirectEditManagerEx
      Cleanup is done here. Any feedback is erased and listeners unhooked. If the cell editor is not null, it will be deativated, disposed, and set to null.
      Overrides:
      bringDown in class DirectEditManagerEx
      See Also:
      • DirectEditManager.bringDown()
    • setEditText

      public void setEditText(String toEdit)
      This method is used to set the cell editors text
      Parameters:
      toEdit - String to be set in the cell editor
    • show

      public void show(char initialChar)
      Performs show and sets the edit string to be the initial character or string
      Parameters:
      initialChar -
    • show

      public void show()
      Description copied from class: DirectEditManagerEx
      Shows the cell editor when direct edit is started. Calls DirectEditManagerEx.initCellEditor(), CellEditor.activate(), and DirectEditManagerEx.showFeedback().
      Overrides:
      show in class DirectEditManagerEx
    • show

      public void show(Point location)
      Performs show and sends an extra mouse click to the point location so that cursor appears at the mouse click point The Text control does not allow for the cursor to appear at point location but at a character location
      Parameters:
      location -
    • hookListeners

      protected void hookListeners()
      Overrides:
      hookListeners in class DirectEditManagerEx
    • unhookListeners

      protected void unhookListeners()
      Description copied from class: DirectEditManagerEx
      Unhooks listeners. Called from DirectEditManagerEx.bringDown().
      Overrides:
      unhookListeners in class DirectEditManagerEx
    • setCellEditor

      protected void setCellEditor(CellEditor editor)
      Description copied from class: DirectEditManagerEx
      Sets the cell editor to the given editor.
      Overrides:
      setCellEditor in class DirectEditManagerEx
      Parameters:
      editor - the cell editor
    • showFeedback

      public void showFeedback()
      Description copied from class: DirectEditManagerEx
      Asks the source edit part to show source feedback.
      Overrides:
      showFeedback in class DirectEditManagerEx
    • getCellEditorFrame

      protected org.eclipse.draw2d.IFigure getCellEditorFrame()
      Overridden to enlarge the cell editor frame for a control decorator
      Overrides:
      getCellEditorFrame in class DirectEditManagerEx
    • getEditPart

      protected IXtextAwareEditPart getEditPart()
      Description copied from class: DirectEditManagerEx
      Returns the source edit part.
      Overrides:
      getEditPart in class DirectEditManagerEx
      Returns:
      the source edit part
    • getResourceManager

      protected ResourceManager getResourceManager()
      Gets the resource manager to remember the resources allocated for this graphical viewer. All resources will be disposed when the graphical viewer is closed if they have not already been disposed.
      Returns: