org.knime.core.node.interrupt
Class InterruptibleNodeView

java.lang.Object
  extended by org.knime.core.node.AbstractNodeView<T>
      extended by org.knime.core.node.NodeView
          extended by org.knime.core.node.interrupt.InterruptibleNodeView
All Implemented Interfaces:
ActionListener, EventListener, NodeModelWarningListener

public abstract class InterruptibleNodeView
extends NodeView
implements ActionListener

This class provides a generic view for the InterruptibleNodeModel and all deriving classes, which basically consists in a control panel, with some control elements such as a "Run"-, a "Break"- and a "Finish"-Button and a slider to adjust the delay. Additionally, all the listener stuff is done here, that is the status of he InterruptibleNodeModel is set from here to paused or not or finished.

Author:
Fabian Dill, University of Konstanz

Field Summary
 
Fields inherited from class org.knime.core.node.NodeView
COLOR_BACKGROUND, PROP_CHANGE_CLOSE
 
Constructor Summary
InterruptibleNodeView(InterruptibleNodeModel model)
          Constructs an instance of the InterruptibleNodeView with the underlying InterruptibleNodeModel and a title.
InterruptibleNodeView(InterruptibleNodeModel model, JPanel innerView)
          Creates an instance of the interruptible node view with the control elements and a specific additional panel.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Here the control of the InterruptibleNodeModel is done.
 InterruptControlPanel getControlPanel()
          This method returns the control panel, which provides control elements over the underlying model.
abstract  void modelChanged()
          Implement here all the view updating methods.
 void onClose()
          Forces the model to pause and then to finish.
protected  void onOpen()
          Invoked when the window has been opened.
 void refreshInterruptMenu()
          Refreshes the enabled status of the control elements depending on the status of the underlying model.
 void setEmbeddedComponent(Component toBeSet)
          Guarantees that the control panel is always added at the very top of the view.
 void updateModel(Object model)
          The updateModel(Object model) method is invoked whenever the NodeModel.notifyViews(Object) method was called and the NodeView.modelChanged() method is only called when execution is finished but is the default method to implement the visualization of the NodeModel.
 
Methods inherited from class org.knime.core.node.NodeView
callCloseView, closeView, createFrame, getComponent, getJMenuBar, getViewTitle, isOpen, openViewComponent, setComponent, setShowNODATALabel, setViewTitleSuffix, warningChanged
 
Methods inherited from class org.knime.core.node.AbstractNodeView
getLogger, getNodeModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterruptibleNodeView

public InterruptibleNodeView(InterruptibleNodeModel model)
Constructs an instance of the InterruptibleNodeView with the underlying InterruptibleNodeModel and a title.

Parameters:
model - - the underlying InterruptibleNodeModel.

InterruptibleNodeView

public InterruptibleNodeView(InterruptibleNodeModel model,
                             JPanel innerView)
Creates an instance of the interruptible node view with the control elements and a specific additional panel.

Parameters:
model - - the underlying interruptible model.
innerView - - an additional view of the model.
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Here the control of the InterruptibleNodeModel is done. Either from the menu or the buttons coming events to control the InterruptibleNodeModel are processed here. Basically these events are "run", "break" and "finish".

Specified by:
actionPerformed in interface ActionListener

getControlPanel

public InterruptControlPanel getControlPanel()
This method returns the control panel, which provides control elements over the underlying model. It also realizes a lazy initialization of the control panel.

Returns:
- the controlPanel which itself provides getters to its components.

refreshInterruptMenu

public void refreshInterruptMenu()
Refreshes the enabled status of the control elements depending on the status of the underlying model. It makes no sense to have an enabled "Break"-Button, when the status is paused, and so on. Call it whenever the status of the underlying method changes without the influence of the control elements in order to set their right status again.


onClose

public void onClose()
Forces the model to pause and then to finish. Since it makes no sense to let the model run without watching at it. Invoked when the window is about to be closed. Unregister HiLiteListeners. Dispose internal members.
This method is the first to be called on a close request (right after the view is unregistered from the NodeModel

Specified by:
onClose in class NodeView

onOpen

protected void onOpen()
Invoked when the window has been opened. Register property listeners.
This method is called last on view construction - right before the components are made visible. It is not called on re-opening.

Specified by:
onOpen in class NodeView

setEmbeddedComponent

public void setEmbeddedComponent(Component toBeSet)
Guarantees that the control panel is always added at the very top of the view. The passed component will be set below the control panel.

Parameters:
toBeSet - the panel to be set below the control panel, mind that all view components necessary for the underlying model have to be packed in one component

updateModel

public void updateModel(Object model)
The updateModel(Object model) method is invoked whenever the NodeModel.notifyViews(Object) method was called and the NodeView.modelChanged() method is only called when execution is finished but is the default method to implement the visualization of the NodeModel. Therefore this method simply invokes the NodeView.modelChanged() method. This method can be overridden by views that want to receive events from their assigned models via the NodeModel.notifyViews(Object) method. Can be used to iteratively update the view during execute.

Overrides:
updateModel in class AbstractNodeView
Parameters:
model - The argument that is provided in the notifyViews method.

modelChanged

public abstract void modelChanged()
Implement here all the view updating methods. This method is called whenever the underlying model triggers a refresh (that is every delay-th iteration). Method is invoked when the underlying NodeModel has changed. Also the HiLightHandler have changed. Note, the NodeModel content may be not available. Be sure to modify GUI components in the EventDispatchThread only.

Specified by:
modelChanged in class AbstractNodeView


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.