nl.lxtreme.ols.tool.base
Class BaseToolDialog<RESULT_TYPE>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by nl.lxtreme.ols.tool.base.BaseToolDialog<RESULT_TYPE>
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, nl.lxtreme.ols.api.Configurable, nl.lxtreme.ols.api.task.TaskStatusListener, ToolDialog, nl.lxtreme.ols.util.swing.StandardActionFactory.CloseAction.Closeable

public abstract class BaseToolDialog<RESULT_TYPE>
extends JDialog
implements ToolDialog, nl.lxtreme.ols.api.task.TaskStatusListener, nl.lxtreme.ols.api.Configurable, nl.lxtreme.ols.util.swing.StandardActionFactory.CloseAction.Closeable

Provides a base tool dialog.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected static Insets COMP_INSETS
          Provides insets (padding) that can be used for components.
protected static Insets LABEL_INSETS
          Provides insets (padding) that can be used for labels.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected BaseToolDialog(Window aOwner, Dialog.ModalityType aModalityType, nl.lxtreme.ols.api.tools.ToolContext aContext, org.osgi.framework.BundleContext aBundleContext, nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> aTool)
          Creates a new BaseToolDialog instance that is document modal.
protected BaseToolDialog(Window aOwner, nl.lxtreme.ols.api.tools.ToolContext aContext, org.osgi.framework.BundleContext aBundleContext, nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> aTool)
          Creates a new BaseToolDialog instance that is document modal.
 
Method Summary
 void cancelTool()
          Called to cancel the tool (if it is running).
 void close()
          
protected  org.osgi.framework.BundleContext getBundleContext()
          Returns the current value of bundleContext.
 nl.lxtreme.ols.api.tools.ToolContext getContext()
           
protected  nl.lxtreme.ols.api.acquisition.AcquisitionResult getData()
          Returns the acquisition result data.
 RESULT_TYPE getLastResult()
          Returns the current value of lastResult.
 nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> getTool()
          Returns the current value of tool.
 boolean invokeTool()
          Called to invoke the actual tool.
protected  void onBeforeCloseDialog()
          Called right before this dialog is made invisible.
protected  void onBeforeShowDialog()
          Called right before this dialog is made visible.
protected abstract  void onToolEnded(RESULT_TYPE aResult)
          Called when the tool finished its job.
protected  void onToolFailed(Exception aException)
          Called when the tool is failed.
protected abstract  void onToolStarted()
          Called when the tool is just started to do its task.
protected  void prepareToolTask(nl.lxtreme.ols.api.tools.ToolTask<RESULT_TYPE> aToolTask)
          Allows additional preparations to be performed on the given ToolTask instance, such as setting parameters and such.
protected  void setComboBoxIndex(JComboBox aComboBox, nl.lxtreme.ols.api.UserSettings aSettings, String aSettingName)
          Convenience method to set the combobox index to a "safe" value, based on the given user settings.
protected  void setControlsEnabled(boolean aEnabled)
          set the controls of the dialog enabled/disabled
 void showDialog()
          Shows the dialog with the given capture results.
<RT> void
taskEnded(nl.lxtreme.ols.api.task.Task<RT> aTask, RT aResult)
          
<RT> void
taskFailed(nl.lxtreme.ols.api.task.Task<RT> aTask, Exception aException)
          
<RT> void
taskStarted(nl.lxtreme.ols.api.task.Task<RT> aTask)
          
protected  boolean validateToolSettings()
          Called right before the tool is invoked to allow additional validation on the tool settings.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface nl.lxtreme.ols.tool.base.ToolDialog
reset
 
Methods inherited from interface nl.lxtreme.ols.api.Configurable
readPreferences, writePreferences
 

Field Detail

LABEL_INSETS

protected static final Insets LABEL_INSETS
Provides insets (padding) that can be used for labels.


COMP_INSETS

protected static final Insets COMP_INSETS
Provides insets (padding) that can be used for components.

Constructor Detail

BaseToolDialog

protected BaseToolDialog(Window aOwner,
                         Dialog.ModalityType aModalityType,
                         nl.lxtreme.ols.api.tools.ToolContext aContext,
                         org.osgi.framework.BundleContext aBundleContext,
                         nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> aTool)
Creates a new BaseToolDialog instance that is document modal.

Parameters:
aOwner - the owning window of this dialog;
aTitle - the title of this dialog;
aModalityType - the modality type;
aContext - the tool context to use in this dialog.

BaseToolDialog

protected BaseToolDialog(Window aOwner,
                         nl.lxtreme.ols.api.tools.ToolContext aContext,
                         org.osgi.framework.BundleContext aBundleContext,
                         nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> aTool)
Creates a new BaseToolDialog instance that is document modal.

Parameters:
aOwner - the owning window of this dialog;
aTitle - the title of this dialog;
aContext - the tool context to use in this dialog.
Method Detail

cancelTool

public final void cancelTool()
                      throws IllegalStateException
Called to cancel the tool (if it is running).

Specified by:
cancelTool in interface ToolDialog
Throws:
IllegalStateException - in case the tool isn't running.

close

public final void close()

Specified by:
close in interface nl.lxtreme.ols.util.swing.StandardActionFactory.CloseAction.Closeable

getContext

public final nl.lxtreme.ols.api.tools.ToolContext getContext()
Returns:

getLastResult

public final RESULT_TYPE getLastResult()
Returns the current value of lastResult.

Returns:
the lastResult

getTool

public final nl.lxtreme.ols.api.tools.Tool<RESULT_TYPE> getTool()
Returns the current value of tool.

Returns:
the tool

invokeTool

public final boolean invokeTool()
                         throws IllegalStateException
Called to invoke the actual tool.

Specified by:
invokeTool in interface ToolDialog
Returns:
TODO
Throws:
IllegalStateException - in case the tool is already running.

showDialog

public final void showDialog()
Shows the dialog with the given capture results.

Specified by:
showDialog in interface ToolDialog

taskEnded

public final <RT> void taskEnded(nl.lxtreme.ols.api.task.Task<RT> aTask,
                                 RT aResult)

Specified by:
taskEnded in interface nl.lxtreme.ols.api.task.TaskStatusListener

taskFailed

public final <RT> void taskFailed(nl.lxtreme.ols.api.task.Task<RT> aTask,
                                  Exception aException)

Specified by:
taskFailed in interface nl.lxtreme.ols.api.task.TaskStatusListener

taskStarted

public final <RT> void taskStarted(nl.lxtreme.ols.api.task.Task<RT> aTask)

Specified by:
taskStarted in interface nl.lxtreme.ols.api.task.TaskStatusListener

getBundleContext

protected final org.osgi.framework.BundleContext getBundleContext()
Returns the current value of bundleContext.

Returns:
the bundleContext

getData

protected final nl.lxtreme.ols.api.acquisition.AcquisitionResult getData()
Returns the acquisition result data.

Returns:
the acquisition data, never null.

onBeforeCloseDialog

protected void onBeforeCloseDialog()
Called right before this dialog is made invisible.


onBeforeShowDialog

protected void onBeforeShowDialog()
Called right before this dialog is made visible.


onToolEnded

protected abstract void onToolEnded(RESULT_TYPE aResult)
Called when the tool finished its job.

THIS METHOD WILL BE INVOKED ON THE EVENT-DISPATCH THREAD (EDT)!

Parameters:
aResult - the result of the tool, can be null.

onToolFailed

protected void onToolFailed(Exception aException)
Called when the tool is failed.

By default, shows a error dialog with the details of the failure.

THIS METHOD WILL BE INVOKED ON THE EVENT-DISPATCH THREAD (EDT)!

Parameters:
aException - the exception with the failure, can be null.

onToolStarted

protected abstract void onToolStarted()
Called when the tool is just started to do its task.

THIS METHOD WILL BE INVOKED ON THE EVENT-DISPATCH THREAD (EDT)!


prepareToolTask

protected void prepareToolTask(nl.lxtreme.ols.api.tools.ToolTask<RESULT_TYPE> aToolTask)
Allows additional preparations to be performed on the given ToolTask instance, such as setting parameters and such.

This method will be called right before the tool task is to be executed.

Parameters:
aToolTask - the tool task to prepare, cannot be null.

setComboBoxIndex

protected final void setComboBoxIndex(JComboBox aComboBox,
                                      nl.lxtreme.ols.api.UserSettings aSettings,
                                      String aSettingName)
Convenience method to set the combobox index to a "safe" value, based on the given user settings.

Parameters:
aComboBox - the combobox to set the selected index for;
aSettings - the user settings to take the selected index from;
aSettingName - the name of the user setting to use.

setControlsEnabled

protected void setControlsEnabled(boolean aEnabled)
set the controls of the dialog enabled/disabled

Parameters:
aEnabled - status of the controls

validateToolSettings

protected boolean validateToolSettings()
Called right before the tool is invoked to allow additional validation on the tool settings.

Returns:
true if the tool settings are correct and the task can be started, false if the settings are incorrect and the task should not be started.


Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.