Class AbstractUiPlugIn

All Implemented Interfaces:
EnableChecked, Iconified, PlugIn, Recordable, ShortcutEnabled, ActionListener, EventListener
Direct Known Subclasses:
AbstractThreadedUiPlugIn, AddImageLayerPlugIn, AutoAssignAttributePlugIn, CreateGridPlugIn, FileDragDropPlugin, GenerateRandomNumberPlugIn, GenerateRandomStringPlugIn, GenerateUniqueRandomIdPlugIn, MosaicInternalFramesPlugIn, OpenRecentPlugIn, SynchronizationPlugIn

public abstract class AbstractUiPlugIn extends AbstractPlugIn implements ActionListener
Default implementation of PlugIn, with useful functions for auto-generating a name, converting a PlugIn into an ActionListener (for use with JButtons, for example), and supporting undo.
  • Field Details

    • workbenchContext

      protected WorkbenchContext workbenchContext
      The workbench context.
    • enableCheck

      protected EnableCheck enableCheck
  • Constructor Details

    • AbstractUiPlugIn

      public AbstractUiPlugIn()
    • AbstractUiPlugIn

      public AbstractUiPlugIn(String name)
    • AbstractUiPlugIn

      public AbstractUiPlugIn(Icon icon)
    • AbstractUiPlugIn

      public AbstractUiPlugIn(String name, String toolTip)
    • AbstractUiPlugIn

      public AbstractUiPlugIn(String name, Icon icon)
    • AbstractUiPlugIn

      public AbstractUiPlugIn(String name, Icon icon, String toolTip)
  • Method Details

    • initialize

      public void initialize(PlugInContext context) throws Exception
      Method to be overridden by implementations to initialize the plug-in. Plug-ins must invoke super.initialize().
      Specified by:
      initialize in interface PlugIn
      Overrides:
      initialize in class AbstractPlugIn
      Parameters:
      context - The plug-in context.
      Throws:
      Exception - if an exception occur during initialization
    • execute

      public boolean execute(PlugInContext context) throws Exception
      Method to be overridden by implementations to execute the plug-in.
      Specified by:
      execute in interface PlugIn
      Overrides:
      execute in class AbstractPlugIn
      Parameters:
      context - The plug-in context.
      Returns:
      true if the PlugIn has been executed
      Throws:
      Exception - if an Exception occurs during execution
      See Also:
    • reportNothingToUndoYet

      protected void reportNothingToUndoYet(PlugInContext context)
      Indicates that this plug-in either (1) is undoable but hasn't modified the system yet or (2) does not modify the system. In either case, the undo history will be preserved. If this method is not called, then this plug-in will be assumed to be non-undoable, and the undo history will be truncated.
      Overrides:
      reportNothingToUndoYet in class AbstractPlugIn
      Parameters:
      context - plugin context
    • isRollingBackInvalidEdits

      protected boolean isRollingBackInvalidEdits(PlugInContext context)
      Overrides:
      isRollingBackInvalidEdits in class AbstractPlugIn
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Wrap the plug-in as an ActionListener.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      e - The action event.
    • getEnableCheck

      public EnableCheck getEnableCheck()
      Description copied from class: AbstractPlugIn
      Use reflection to find an EnableCheck object defined by old method createEnableCheck in this plugin.
      Specified by:
      getEnableCheck in interface EnableChecked
      Overrides:
      getEnableCheck in class AbstractPlugIn
      Returns:
      the EnableCheck defined the old way
    • getIcon

      public Icon getIcon()
      Get the icon for the plug-in.
      Specified by:
      getIcon in interface Iconified
      Overrides:
      getIcon in class AbstractPlugIn
      Returns:
      The icon.
    • getName

      public String getName()
      Get the name of the plug-in. If a name was not specified ask super class.
      Specified by:
      getName in interface PlugIn
      Overrides:
      getName in class AbstractPlugIn
      Returns:
      The plug-in name.
    • getToolTip

      public String getToolTip()
      Get the tool-tip for the plug-in.
      Returns:
      The tool-tip.
    • setWorkbenchContext

      protected void setWorkbenchContext(WorkbenchContext workbenchContext)
      Parameters:
      workbenchContext - the workbenchContext to set