Class AbstractSelection

java.lang.Object
com.bc.ceres.core.ExtensibleObject
com.bc.ceres.swing.selection.AbstractSelection
All Implemented Interfaces:
Extensible, Selection, ClipboardOwner, Cloneable
Direct Known Subclasses:
DefaultSelection

public abstract class AbstractSelection extends ExtensibleObject implements Selection
A handy base class for implementations of the Selection interface.

Clients only need to implement Selection.getSelectedValue() for single selection modes. For multiple selections, getSelectedValues() will need to be overridden.

Since:
Ceres 0.10
  • Constructor Details

    • AbstractSelection

      protected AbstractSelection()
  • Method Details

    • getSelectedValues

      public Object[] getSelectedValues()
      Description copied from interface: Selection
      Gets the selected values of a multiple selection. The method returns an empty array if this selection is empty.
      Specified by:
      getSelectedValues in interface Selection
      Returns:
      The array of selected values.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Selection
      Returns:
      true if this selection is empty.
    • getPresentationName

      public String getPresentationName()
      The default implementation returns an empty string.
      Specified by:
      getPresentationName in interface Selection
      Returns:
      An empty string.
    • createTransferable

      public Transferable createTransferable(boolean snapshot)
      The default implementation returns null.
      Specified by:
      createTransferable in interface Selection
      Parameters:
      snapshot - If true, the returned Transferable should hold a copy-of rather than a reference-to the selection.
      Returns:
      null by default.
    • lostOwnership

      public void lostOwnership(Clipboard clipboard, Transferable contents)
      Notifies this object that it is no longer the clipboard owner. This method will be called when another application or another object within this application asserts ownership of the clipboard.

      The default implementation does nothing.

      Specified by:
      lostOwnership in interface ClipboardOwner
      Parameters:
      clipboard - the clipboard that is no longer owned
      contents - the contents which this owner had placed on the clipboard
    • clone

      public AbstractSelection clone()
      Description copied from interface: Selection
      Creates and returns a copy of this selection.
      Specified by:
      clone in interface Selection
      Overrides:
      clone in class Object
      Returns:
      A clone of this selection instance.