net.aerith.misao.gui
Class ControlPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--net.aerith.misao.gui.ControlPanel
Direct Known Subclasses:
AdditionalIdentificationControlPanel, BatchExaminationControlPanel, HtmlImageGalleryControlPanel, ImageConversionControlPanel, NewStarSearchControlPanel, PhotometryCalibrationControlPanel, RawDatabaseConstructionControlPanel, RecordSearchControlPanel, ReportBatchControlPanel

public class ControlPanel
extends javax.swing.JPanel
implements OperationObserver

The ControlPanel represents a control panel with four buttons: one is to set parameters, one is to start the operation, one is to stop the operation and one is to reset.

See Also:
Serialized Form

Inner Class Summary
protected  class ControlPanel.OperationProceedingThread
          The OperationProceedingThread is a thread to wait until the current operation ends and start the new operation.
protected  class ControlPanel.ResetListener
          The ResetListener is a listener class of menu selection to reset.
protected  class ControlPanel.SetListener
          The SetListener is a listener class of menu selection to set parameters.
protected  class ControlPanel.StartListener
          The StartListener is a listener class of menu selection to start the operation.
protected  class ControlPanel.StopListener
          The StopListener is a listener class of menu selection to stop the operation.
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardBinding, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
protected  javax.swing.JButton button_reset
           
protected  javax.swing.JButton button_set
           
protected  javax.swing.JButton button_start
           
protected  javax.swing.JButton button_stop
           
protected  boolean failed_message_flag
          True when to show the failed message.
protected  boolean interrupted_message_flag
          True when to show the interrupted message.
protected  ControlPanel.ResetListener listener_reset
          The listener to reset.
protected  ControlPanel.SetListener listener_set
          The listener to set parameters.
protected  ControlPanel.StartListener listener_start
          The listener to start the operation.
protected  ControlPanel.StopListener listener_stop
          The listener to stop parameters.
protected  javax.swing.JMenuItem[] menu_items
           
protected  int mode
          The mode.
static int MODE_OPERATING
          The mode number which indicates in operating phase.
static int MODE_SETTING
          The mode number which indicates in setting phase.
static int MODE_STOPPED
          The mode number which indicates in stopped phase.
protected  Operation operation
           
protected  java.awt.Container pane
          The content pane of this panel.
protected  boolean succeeded_message_flag
          True when to show the succeeded message.
protected  java.lang.Thread thread
           
 
Fields inherited from class javax.swing.JPanel
defaultLayout, uiClassID
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, alignmentX, alignmentY, ANCESTOR_USING_BUFFER, ancestorNotifier, autoscroller, border, changeSupport, clientProperties, flags, HAS_FOCUS, IS_DOUBLE_BUFFERED, IS_OPAQUE, IS_PAINTING_TILE, KEYBOARD_BINDINGS_KEY, listenerList, maximumSize, minimumSize, NEXT_FOCUS, paintImmediatelyClip, paintingChild, preferredSize, readObjectCallbacks, REQUEST_FOCUS_DISABLED, tmpRect, TOOL_TIP_TEXT_KEY, ui, uiClassID, UNDEFINED_CONDITION, vetoableChangeSupport, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Constructor Summary
ControlPanel()
          Constructs an ControlPanel.
ControlPanel(Operation operation)
          Constructs a ControlPanel.
 
Method Summary
 void actionPerformedReset(java.awt.event.ActionEvent e)
          Invoked when the reset button is pushed.
 void actionPerformedSet(java.awt.event.ActionEvent e)
          Invoked when the set button is pushed.
 void actionPerformedStart(java.awt.event.ActionEvent e)
          Invoked when the start button is pushed.
 void actionPerformedStop(java.awt.event.ActionEvent e)
          Invoked when the stop button is pushed.
 int getCurrentMode()
           
 javax.swing.JMenuItem[] getMenuItems()
           
 java.lang.String getResetButtonTitle()
          Gets the button title to reset.
 java.awt.event.ActionListener getResetListener()
          Gets the listener to reset.
 java.lang.String getSetButtonTitle()
          Gets the button title to set parameters.
 java.awt.event.ActionListener getSetListener()
          Gets the listener to set parameters.
 java.lang.String getStartButtonTitle()
          Gets the button title to start the operation.
 java.awt.event.ActionListener getStartListener()
          Gets the listener to start the operation.
 java.lang.String getStopButtonTitle()
          Gets the button title to stop the operation.
 java.awt.event.ActionListener getStopListener()
          Gets the listener to stop the operation.
 void notifyEnd(java.lang.Exception exception)
          Invoked when the operation ends.
 void notifyFailed(java.lang.Object arg)
          Invoked when a task is failed.
 void notifyStart()
          Invoked when the operation starts.
 void notifySucceeded(java.lang.Object arg)
          Invoked when a task is succeeded.
 void notifyWarned(java.lang.Object arg)
          Invoked when a task is warned.
 void proceedOperation()
          Starts the operation.
 void proceedOperation(Operation new_operation)
          Starts the specified operation.
 void setFailedMessageEnabled(boolean flag)
          Enables/disables to show the failed message.
 void setInterruptedMessageEnabled(boolean flag)
          Enables/disables to show the interrupted message.
 void setOperation(Operation operation)
          Sets the operation.
 void setSucceededMessageEnabled(boolean flag)
          Enables/disables to show the succeeded message.
 boolean start()
          Starts the operation.
private  void updateButtons()
          Updates the enable/disable status of buttons based on the current mode.
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, bindingForKeyStroke, checkIfChildObscuredBySibling, computeVisibleRect, computeVisibleRect, contains, createToolTip, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperties, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getFlag, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, keyboardBindings, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintWithBuffer, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFlag, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setCursor, setFocusOwner, setLayout, transferFocus, updateCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

thread

protected java.lang.Thread thread

operation

protected Operation operation

mode

protected int mode
The mode.

MODE_SETTING

public static final int MODE_SETTING
The mode number which indicates in setting phase.

MODE_OPERATING

public static final int MODE_OPERATING
The mode number which indicates in operating phase.

MODE_STOPPED

public static final int MODE_STOPPED
The mode number which indicates in stopped phase.

pane

protected java.awt.Container pane
The content pane of this panel.

button_set

protected javax.swing.JButton button_set

button_start

protected javax.swing.JButton button_start

button_stop

protected javax.swing.JButton button_stop

button_reset

protected javax.swing.JButton button_reset

menu_items

protected javax.swing.JMenuItem[] menu_items

listener_set

protected ControlPanel.SetListener listener_set
The listener to set parameters.

listener_start

protected ControlPanel.StartListener listener_start
The listener to start the operation.

listener_stop

protected ControlPanel.StopListener listener_stop
The listener to stop parameters.

listener_reset

protected ControlPanel.ResetListener listener_reset
The listener to reset.

succeeded_message_flag

protected boolean succeeded_message_flag
True when to show the succeeded message.

interrupted_message_flag

protected boolean interrupted_message_flag
True when to show the interrupted message.

failed_message_flag

protected boolean failed_message_flag
True when to show the failed message.
Constructor Detail

ControlPanel

public ControlPanel()
Constructs an ControlPanel.

ControlPanel

public ControlPanel(Operation operation)
Constructs a ControlPanel.
Parameters:
operation - the operation.
Method Detail

setOperation

public void setOperation(Operation operation)
Sets the operation.
Parameters:
operation - the operation.

start

public boolean start()
Starts the operation.
Returns:
truen when the operation is successfully started.

proceedOperation

public void proceedOperation()
Starts the operation. When the current operation is still running, here waits until it ends.

proceedOperation

public void proceedOperation(Operation new_operation)
Starts the specified operation. When the current operation is still running, here waits until it ends.
Parameters:
new_operation - the new operation to start.

notifyStart

public void notifyStart()
Invoked when the operation starts.
Specified by:
notifyStart in interface OperationObserver

notifyEnd

public void notifyEnd(java.lang.Exception exception)
Invoked when the operation ends.
Specified by:
notifyEnd in interface OperationObserver
Parameters:
exception - the exception if an error occurs, or null if succeeded.

notifySucceeded

public void notifySucceeded(java.lang.Object arg)
Invoked when a task is succeeded.
Specified by:
notifySucceeded in interface OperationObserver
Parameters:
arg - the argument.

notifyFailed

public void notifyFailed(java.lang.Object arg)
Invoked when a task is failed.
Specified by:
notifyFailed in interface OperationObserver
Parameters:
arg - the argument.

notifyWarned

public void notifyWarned(java.lang.Object arg)
Invoked when a task is warned.
Specified by:
notifyWarned in interface OperationObserver
Parameters:
arg - the argument.

setSucceededMessageEnabled

public void setSucceededMessageEnabled(boolean flag)
Enables/disables to show the succeeded message.
Parameters:
flag - true when to show the message.

setInterruptedMessageEnabled

public void setInterruptedMessageEnabled(boolean flag)
Enables/disables to show the interrupted message.
Parameters:
flag - true when to show the message.

setFailedMessageEnabled

public void setFailedMessageEnabled(boolean flag)
Enables/disables to show the failed message.
Parameters:
flag - true when to show the message.

updateButtons

private void updateButtons()
Updates the enable/disable status of buttons based on the current mode.

getCurrentMode

public int getCurrentMode()

getMenuItems

public javax.swing.JMenuItem[] getMenuItems()

getSetButtonTitle

public java.lang.String getSetButtonTitle()
Gets the button title to set parameters. This must be overrided in the subclasses.
Returns:
the button title to set parameters.

getStartButtonTitle

public java.lang.String getStartButtonTitle()
Gets the button title to start the operation. This must be overrided in the subclasses.
Returns:
the button title to start the operation.

getStopButtonTitle

public java.lang.String getStopButtonTitle()
Gets the button title to stop the operation. This must be overrided in the subclasses.
Returns:
the button title to stop the operation.

getResetButtonTitle

public java.lang.String getResetButtonTitle()
Gets the button title to reset. This must be overrided in the subclasses.
Returns:
the button title to reset.

getSetListener

public java.awt.event.ActionListener getSetListener()
Gets the listener to set parameters.
Returns:
the listener to set parameters.

getStartListener

public java.awt.event.ActionListener getStartListener()
Gets the listener to start the operation.
Returns:
the listener to start the operation.

getStopListener

public java.awt.event.ActionListener getStopListener()
Gets the listener to stop the operation.
Returns:
the listener to stop the operation.

getResetListener

public java.awt.event.ActionListener getResetListener()
Gets the listener to reset.
Returns:
the listener to reset.

actionPerformedSet

public void actionPerformedSet(java.awt.event.ActionEvent e)
Invoked when the set button is pushed. This must be overrided in the subclasses.
Parameters:
e - contains the selected menu item.

actionPerformedStart

public void actionPerformedStart(java.awt.event.ActionEvent e)
Invoked when the start button is pushed. This must be overrided in the subclasses.
Parameters:
e - contains the selected menu item.

actionPerformedStop

public void actionPerformedStop(java.awt.event.ActionEvent e)
Invoked when the stop button is pushed. This must be overrided in the subclasses.
Parameters:
e - contains the selected menu item.

actionPerformedReset

public void actionPerformedReset(java.awt.event.ActionEvent e)
Invoked when the reset button is pushed. This must be overrided in the subclasses.
Parameters:
e - contains the selected menu item.