Class KlighdTextSelection

java.lang.Object
de.cau.cs.kieler.klighd.ui.KlighdTextSelection
All Implemented Interfaces:
IKlighdSelection, Iterable, org.eclipse.jface.text.ITextSelection, org.eclipse.jface.viewers.ISelection, org.eclipse.jface.viewers.IStructuredSelection

public class KlighdTextSelection extends Object implements IKlighdSelection, org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.jface.text.ITextSelection
KLighD-specific implementation of ITextSelection.
Its aim is to broadcast the selection of cursor selectable label's text to platform's ISelectionService.
In order to let the Properties View also react on this type of selection this class also implements IStructuredSelection by providing itself as the only element.
Be aware of the risk of recursion!
Author:
chsch
  • Constructor Details

    • KlighdTextSelection

      public KlighdTextSelection(String theText, int theOffset, boolean isCompleteLine, boolean isCompleteLabel, KlighdNode.KlighdFigureNode<KText> figureNode, IViewer theViewer)
      Standard Constructor.
      Parameters:
      theText - the text selection
      theOffset - see ITextSelection.getOffset()
      isCompleteLine - true if whole line is selected
      isCompleteLabel - true if whole label is selected
      figureNode - the underlying KGraphElement containing the selected text
      theViewer -
  • Method Details

    • isCompleteLine

      public boolean isCompleteLine()
      Deprecated.
      this method may still return wrong values
      Returns:
      the completeLine
    • isCompleteLabel

      public boolean isCompleteLabel()
      Returns:
      the completeLabel
    • getViewer

      public IViewer getViewer()
      Specified by:
      getViewer in interface IKlighdSelection
      Returns:
      the viewer
    • getViewContext

      public ViewContext getViewContext()
      Specified by:
      getViewContext in interface IKlighdSelection
      Returns:
      the ViewContext
    • getViewElement

      public KText getViewElement()
      Returns:
      the corresponding KText instance.
    • getKGraphElement

      public KGraphElement getKGraphElement()
      Returns:
      the corresponding KGraphElement instance.
    • getKLabel

      public KLabel getKLabel()
      Returns:
      the corresponding KLabel instance, may be null.
    • getKNode

      public KNode getKNode()
      Returns:
      the parent KNode of getKGraphElement()
    • diagramElementsIterator

      public Iterator<org.eclipse.emf.ecore.EObject> diagramElementsIterator()
      Specified by:
      diagramElementsIterator in interface IKlighdSelection
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getText

      public String getText()
      Specified by:
      getText in interface org.eclipse.jface.text.ITextSelection
      Returns:
      the text
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface org.eclipse.jface.viewers.ISelection
    • getOffset

      public int getOffset()
      Specified by:
      getOffset in interface org.eclipse.jface.text.ITextSelection
    • getLength

      public int getLength()
      Specified by:
      getLength in interface org.eclipse.jface.text.ITextSelection
    • getStartLine

      public int getStartLine()
      Deprecated.
      this method still simply returns zero
      Specified by:
      getStartLine in interface org.eclipse.jface.text.ITextSelection
    • getEndLine

      public int getEndLine()
      Deprecated.
      this method still simply returns zero
      Specified by:
      getEndLine in interface org.eclipse.jface.text.ITextSelection
    • getFirstElement

      public Object getFirstElement()
      Specified by:
      getFirstElement in interface org.eclipse.jface.viewers.IStructuredSelection
    • iterator

      public Iterator<KlighdTextSelection> iterator()
      Specified by:
      iterator in interface org.eclipse.jface.viewers.IStructuredSelection
      Specified by:
      iterator in interface Iterable
    • size

      public int size()
      Specified by:
      size in interface org.eclipse.jface.viewers.IStructuredSelection
    • toArray

      public KlighdTextSelection[] toArray()
      Specified by:
      toArray in interface org.eclipse.jface.viewers.IStructuredSelection
    • toList

      public List<KlighdTextSelection> toList()
      Specified by:
      toList in interface org.eclipse.jface.viewers.IStructuredSelection