Class DialogTool

java.lang.Object
mgui.interfaces.tools.dialogs.DialogTool
All Implemented Interfaces:
java.lang.Cloneable, PopupMenuObject, Tool, ToolInputListener, IconObject
Direct Known Subclasses:
ToolCreateMeshFromPolylines, ToolCutMeshWithPlane, ToolGetConvexHull2D, ToolGetMeshIntersectionPolylines

public abstract class DialogTool
extends java.lang.Object
implements Tool
Abstract class to be inherited by all tools which operate using a modal dialog box.
Since:
1.0
Version:
1.0
Author:
Andrew Reid
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected javax.swing.Icon icon  
    protected java.util.ArrayList<ToolListener> listeners  
    protected java.lang.String message  
    boolean show_progress  
  • Constructor Summary

    Constructors
    Constructor Description
    DialogTool()  
  • Method Summary

    Modifier and Type Method Description
    void activate()
    Should be called once a tool is activated within a particular InterfaceDisplayPanel.
    void activate​(boolean report_success)
    Activate the tool by showing its dialog box.
    void addListener​(ToolListener tl)  
    abstract java.lang.Object clone()  
    void deactivate()
    Should be called once a tool is deactivated; instances of Tool should perform clean-up activities here.
    protected boolean doTask​(InterfaceOptions options)
    Call this to run the task as a worker task.
    protected abstract boolean doTaskBlocking​(InterfaceOptions options, InterfaceProgressBar progress_bar)
    Runs this tool's task and blocks until it is complete.
    protected abstract DialogToolDialogBox getDialogBox()  
    java.lang.String getName()  
    javax.swing.Icon getObjectIcon()
    Returns the Icon associated with this object.
    InterfacePopupMenu getPopupMenu()
    Produces and returns a popup menu for this object.
    InterfacePopupMenu getPopupMenu​(java.util.List<java.lang.Object> selected)
    Produces and returns a popup menu for this object.
    Tool getPreviousTool()
    Returns the tool that was set previous to this one, if one exists
    protected abstract java.lang.String getToolTitle()  
    void handlePopupEvent​(java.awt.event.ActionEvent e)
    Handles an event on this object's popup menu.
    void handleToolEvent​(ToolInputEvent e)
    Handle this tool event
    protected void init()  
    boolean isExclusive()
    Specifies whether this tool requires exclusively; otherwise it will run in parallel with the default tool, if one exists.
    boolean isImmediate()
    Specifies whether this tool is immediate; this indicates that it should be run immediately upon calling and stop, rather than wait for AWT events.
    void removeListener​(ToolListener tl)  
    protected void reportSuccess​(boolean success)  
    protected void setIcon()  
    void setTargetPanel​(InterfacePanel panel)  
    void showPopupMenu​(java.awt.event.MouseEvent e)
    Shows a popup menu at the point of the given MouseEvent.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • listeners

      protected java.util.ArrayList<ToolListener> listeners
    • icon

      protected javax.swing.Icon icon
    • message

      protected java.lang.String message
    • show_progress

      public boolean show_progress
  • Constructor Details

    • DialogTool

      public DialogTool()
  • Method Details

    • init

      protected void init()
    • getPreviousTool

      public Tool getPreviousTool()
      Description copied from interface: Tool
      Returns the tool that was set previous to this one, if one exists
      Specified by:
      getPreviousTool in interface Tool
      Returns:
    • setIcon

      protected void setIcon()
    • activate

      public void activate()
      Description copied from interface: Tool
      Should be called once a tool is activated within a particular InterfaceDisplayPanel.
      Specified by:
      activate in interface Tool
    • deactivate

      public void deactivate()
      Description copied from interface: Tool
      Should be called once a tool is deactivated; instances of Tool should perform clean-up activities here.
      Specified by:
      deactivate in interface Tool
    • setTargetPanel

      public void setTargetPanel​(InterfacePanel panel)
      Specified by:
      setTargetPanel in interface Tool
    • isExclusive

      public boolean isExclusive()
      Description copied from interface: Tool
      Specifies whether this tool requires exclusively; otherwise it will run in parallel with the default tool, if one exists.
      Specified by:
      isExclusive in interface Tool
      Returns:
    • reportSuccess

      protected void reportSuccess​(boolean success)
    • activate

      public void activate​(boolean report_success)
      Activate the tool by showing its dialog box.
      Parameters:
      report_success -
    • doTask

      protected boolean doTask​(InterfaceOptions options)
      Call this to run the task as a worker task.
      Parameters:
      options -
      Returns:
    • getToolTitle

      protected abstract java.lang.String getToolTitle()
    • getDialogBox

      protected abstract DialogToolDialogBox getDialogBox()
    • doTaskBlocking

      protected abstract boolean doTaskBlocking​(InterfaceOptions options, InterfaceProgressBar progress_bar)
      Runs this tool's task and blocks until it is complete. To avoid GUI freezing, call doTask(mgui.interfaces.InterfaceOptions) instead.
      Parameters:
      options -
      progress_bar -
      Returns:
    • addListener

      public void addListener​(ToolListener tl)
      Specified by:
      addListener in interface Tool
    • removeListener

      public void removeListener​(ToolListener tl)
      Specified by:
      removeListener in interface Tool
    • getName

      public java.lang.String getName()
      Specified by:
      getName in interface Tool
    • isImmediate

      public boolean isImmediate()
      Description copied from interface: Tool
      Specifies whether this tool is immediate; this indicates that it should be run immediately upon calling and stop, rather than wait for AWT events.
      Specified by:
      isImmediate in interface Tool
      Returns:
    • handleToolEvent

      public void handleToolEvent​(ToolInputEvent e)
      Description copied from interface: ToolInputListener
      Handle this tool event
      Specified by:
      handleToolEvent in interface ToolInputListener
    • getObjectIcon

      public javax.swing.Icon getObjectIcon()
      Description copied from interface: IconObject
      Returns the Icon associated with this object.
      Specified by:
      getObjectIcon in interface IconObject
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu()
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • getPopupMenu

      public InterfacePopupMenu getPopupMenu​(java.util.List<java.lang.Object> selected)
      Description copied from interface: PopupMenuObject
      Produces and returns a popup menu for this object. Allows an associated list of objects to be passed as an argument.
      Specified by:
      getPopupMenu in interface PopupMenuObject
      Returns:
    • handlePopupEvent

      public void handlePopupEvent​(java.awt.event.ActionEvent e)
      Description copied from interface: PopupMenuObject
      Handles an event on this object's popup menu.
      Specified by:
      handlePopupEvent in interface PopupMenuObject
    • showPopupMenu

      public void showPopupMenu​(java.awt.event.MouseEvent e)
      Description copied from interface: PopupMenuObject
      Shows a popup menu at the point of the given MouseEvent.
      Specified by:
      showPopupMenu in interface PopupMenuObject
    • clone

      public abstract java.lang.Object clone() throws java.lang.CloneNotSupportedException
      Specified by:
      clone in interface Tool
      Overrides:
      clone in class java.lang.Object
      Throws:
      java.lang.CloneNotSupportedException