Class LinkData

java.lang.Object
com.iizigo.link.LinkData

public class LinkData extends Object
Data for the link operation, i.e. the target and the sources of the operation.
Author:
Christopher Mindus
  • Constructor Details

    • LinkData

      public LinkData(IAdaptable target, GProp<?>[] props)
      Creates the link data information.
      Parameters:
      target - The target adaptable.
      props - The properties.
    • LinkData

      public LinkData(IAdaptable target, IStructuredSelection selection)
      Creates the link data information.
      Parameters:
      target - The target adaptable.
      selection - The structured selection.
    • LinkData

      public LinkData(IAdaptable target, List<IAdaptable> sources)
      Creates the link data information.
      Parameters:
      target - The target adaptable.
      sources - The unmodifiable list of adaptable sources.
  • Method Details

    • getTarget

      public IAdaptable getTarget()
      Gets the target adaptable.
      Returns:
      The target, never null.
    • getTargetProperty

      public GProp<?> getTargetProperty()
      Gets the target property.
      Returns:
      A cached target property, may be null.
    • getSources

      public List<IAdaptable> getSources()
      Returns the source.
      Returns:
      The unmodifiable list of the properties. The list may be empty.
    • adapt

      public <T> T adapt(IAdaptable adaptable, Class<T> adaptToClass)
      Adapts an object if possible to the class.
      Parameters:
      adaptable - The object.
      adaptToClass - The class to adapt to.
      Returns:
      The adapted instance, or null if it couldn't be adapted.
    • getSources

      public <T> ArrayList<T> getSources(Class<T> adaptedClass)
      Returns the source adapted to the requested class.
      Parameters:
      adaptedClass - The class to adapt to.
      Returns:
      A NEW list (that may be empty).
    • getSourceProperties

      public List<GProp<?>> getSourceProperties()
      Returns the source properties.
      Returns:
      The unmodifiable list of the properties. The list may be empty.
    • getLinkSources

      public List<ILinkCapable> getLinkSources()
      Returns the list of possible ILinkCapable sources.
      Returns:
      A cached unmodifiable list of the possible link capable sources.
    • assignProcessed

      public void assignProcessed(ILinkCapable linkCapable, IAdaptable source)
      Assigns the set of sources that are processed by the link-capable processor. This makes it possible to verify that all sources are used once and not more, and that none are left out.

      This method can be called several times for the same link-capable processor, the list of sources will be increased.

      Parameters:
      linkCapable - The link-capable instance.
      source - The source processed.
    • assignProcessed

      public void assignProcessed(ILinkCapable linkCapable, IAdaptable... sources)
      Assigns the set of sources that are processed by the link-capable processor. This makes it possible to verify that all sources are used once and not more, and that none are left out.

      This method can be called several times for the same link-capable processor, the list of sources will be increased.

      Parameters:
      linkCapable - The link-capable instance.
      sources - The sources processed.
    • assignProcessed

      public void assignProcessed(ILinkCapable linkCapable, Collection<IAdaptable> sources)
      Assigns the set of sources that are processed by the link-capable processor. This makes it possible to verify that all sources are used once and not more, and that none are left out.

      This method can be called several times for the same link-capable processor, the list of sources will be increased.

      Parameters:
      linkCapable - The link-capable instance.
      sources - The sources processed.
    • canLink

      public IStatus canLink()
      Checks if the operation could link.
      Returns:
      A status.
    • doLink

      public PasteFeedback doLink(boolean doPerform, Shell shell, boolean doDisplayDialog)
      Attempt to perform the link.
      Parameters:
      doPerform - The perform operation flag.
      shell - The shell is only needed when performing the operation.
      doDisplayDialog - Flag to always display dialog.
      Returns:
      The feedback.
    • adaptLinkCapable

      public static ILinkCapable adaptLinkCapable(Object o)
      Gets or creates an adapter for an object. Object types supported are: ILinkCapable, GProp, DesignerProp, IResource, IMethod, IAdaptable (IType).
      Parameters:
      o - The object.
      Returns:
      The link capable, or null if not link capable.
    • isLinkCapableAdaptable

      public static boolean isLinkCapableAdaptable(Object o)
      Gets or creates an adapter for an object. Object types supported are: ILinkCapable, GProp, DesignerProp, IResource, IMethod, IAdaptable (IType).
      Parameters:
      o - The object.
      Returns:
      true if it could potentially become an ILinkCapable object if adapted.
    • isLinkable

      public static boolean isLinkable(ISelection sel)
      Checks if a selection is linkable.
    • getLinkTargets

      public static List<UIComp> getLinkTargets(UIPanelBase panel, List<ILinkCapable> linkCapableList)
      Finds the list of UI components that this link capable component can be linked to in a panel.
      Parameters:
      panel - The target panel.