fr.esrf.tangoatk.widget.util.interlock
Class NetEditorFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by fr.esrf.tangoatk.widget.util.interlock.NetEditorFrame
All Implemented Interfaces:
NetEditorListener, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class NetEditorFrame
extends javax.swing.JFrame
implements NetEditorListener, java.awt.event.ActionListener

A Frame for the NetEditor. This class is a good base class to create specific network editor. By default, It constructs all menus needed by the NetEditor and its toolbar.

All actions are handled by this frame. So you can override actionPerformed() to get the control on a menu item or a button. Ex: overriding the 'load' menu item action

 public void actionPerformed(ActionEvent evt) {

   if( evt.getSource() == getFileMenuItem(NetEditorFrame.FILE_LOAD) ) {
     ...
   } else {
     super.actionPerformed(evt);
   }

 }
 

You can also add or remove menu items or toolbar buttons. Here is an example of code that customize the option menu :

  traceMode = NetUtils.createMenuItem("Trace mode",0,0,this);
  editMode = NetUtils.createMenuItem("Edit mode",0,0,this);
  getOptionMenu().add(traceMode,0);
  getOptionMenu().add(editMode,1);
  getOptionMenu().add(new JSeparator(),2);

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int EDIT_COPY
           
static int EDIT_CUT
           
static int EDIT_DELETE
           
static int EDIT_PASTE
           
static int EDIT_REDO
           
static int EDIT_SELECT_ALL
           
static int EDIT_SELECT_NONE
           
static int EDIT_UNDO
           
static int FILE_EXIT
           
static int FILE_LOAD
           
static int FILE_NEW
           
static int FILE_SAVE
           
static int FILE_SAVEAS
           
static int OPTION_FIT
           
static int OPTION_PREF
           
static int TOOL_BUBBLE
           
static int TOOL_LABEL
           
static int TOOL_LINK
           
static int TOOL_REDO
           
static int TOOL_UNDO
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
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, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
NetEditorFrame()
          Construct a frame for the NetEditor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 void cancelCreate(NetEditor src)
          Clear the help label when the creation mode is aborted
 javax.swing.JButton createIconButton(java.lang.String resPath, java.lang.String preffix, java.lang.String toolTip, java.awt.event.ActionListener l)
          Create an icon button.
 void exitApp()
          Ask to save if the current scheme has unsaved modification before exiting.
 javax.swing.JMenu getEditMenu()
          Returns the edit menu.
 javax.swing.JMenuItem getEditMenuItem(int which)
          Returns a reference to the specified menu item of the edit menu.
 javax.swing.JMenu getFileMenu()
          Returns the file menu.
 javax.swing.JMenuItem getFileMenuItem(int which)
          Returns a reference to the specified menu item of the file menu.
 javax.swing.JLabel getHelpLabel()
          Returns a reference to the help label
 javax.swing.JMenu getOptionMenu()
          Returns the option menu.
 javax.swing.JMenuItem getOptionMenuItem(int which)
          Returns a reference to the specified menu item of the option menu.
 javax.swing.JScrollPane getScrollPane()
          Return the JScrollPane that contains the NetEditor object
 javax.swing.JButton getToobarButton(int which)
          Returns a reference to the specified button of the toolbar.
 javax.swing.JToolBar getToolbar()
          Returns the default toolbar
 void linkClicked(NetEditor src, NetObject obj, int childIdx, java.awt.event.MouseEvent e)
          Trigerred when the user click on a link if the editor is not editable.
static void main(java.lang.String[] args)
          Main function which launch the default NerEditor .
 void objectClicked(NetEditor src, NetObject obj, java.awt.event.MouseEvent e)
          Trigerred when the user click on an object only if the editor is not editable.
 void setAppTitle(java.lang.String appName)
          Sets the app name used to build the frame title.
 void setEditor(NetEditor editor)
          Sets the NetEditor.
 void sizeChanged(NetEditor src, java.awt.Dimension d)
          Revalidate the inner ScrollPane
 void valueChanged(NetEditor src)
          Update the title bar with the filename and the apptitle when the scheme change .
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, 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, paint, 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, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, 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, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

FILE_NEW

public static final int FILE_NEW
See Also:
Constant Field Values

FILE_LOAD

public static final int FILE_LOAD
See Also:
Constant Field Values

FILE_SAVE

public static final int FILE_SAVE
See Also:
Constant Field Values

FILE_SAVEAS

public static final int FILE_SAVEAS
See Also:
Constant Field Values

FILE_EXIT

public static final int FILE_EXIT
See Also:
Constant Field Values

EDIT_UNDO

public static final int EDIT_UNDO
See Also:
Constant Field Values

EDIT_REDO

public static final int EDIT_REDO
See Also:
Constant Field Values

EDIT_CUT

public static final int EDIT_CUT
See Also:
Constant Field Values

EDIT_COPY

public static final int EDIT_COPY
See Also:
Constant Field Values

EDIT_PASTE

public static final int EDIT_PASTE
See Also:
Constant Field Values

EDIT_DELETE

public static final int EDIT_DELETE
See Also:
Constant Field Values

EDIT_SELECT_ALL

public static final int EDIT_SELECT_ALL
See Also:
Constant Field Values

EDIT_SELECT_NONE

public static final int EDIT_SELECT_NONE
See Also:
Constant Field Values

OPTION_FIT

public static final int OPTION_FIT
See Also:
Constant Field Values

OPTION_PREF

public static final int OPTION_PREF
See Also:
Constant Field Values

TOOL_BUBBLE

public static final int TOOL_BUBBLE
See Also:
Constant Field Values

TOOL_LABEL

public static final int TOOL_LABEL
See Also:
Constant Field Values

TOOL_LINK

public static final int TOOL_LINK
See Also:
Constant Field Values

TOOL_UNDO

public static final int TOOL_UNDO
See Also:
Constant Field Values

TOOL_REDO

public static final int TOOL_REDO
See Also:
Constant Field Values
Constructor Detail

NetEditorFrame

public NetEditorFrame()
Construct a frame for the NetEditor.

See Also:
setEditor(fr.esrf.tangoatk.widget.util.interlock.NetEditor)
Method Detail

setEditor

public void setEditor(NetEditor editor)
Sets the NetEditor.

Parameters:
editor - NetEditor object

setAppTitle

public void setAppTitle(java.lang.String appName)
Sets the app name used to build the frame title.

Parameters:
appName - application name
See Also:
valueChanged(fr.esrf.tangoatk.widget.util.interlock.NetEditor)

getFileMenu

public javax.swing.JMenu getFileMenu()
Returns the file menu.


getFileMenuItem

public javax.swing.JMenuItem getFileMenuItem(int which)
Returns a reference to the specified menu item of the file menu.

Parameters:
which - Menu identifier
See Also:
FILE_NEW, FILE_LOAD, FILE_SAVE, FILE_SAVEAS, FILE_EXIT

getEditMenu

public javax.swing.JMenu getEditMenu()
Returns the edit menu.


getEditMenuItem

public javax.swing.JMenuItem getEditMenuItem(int which)
Returns a reference to the specified menu item of the edit menu.

Parameters:
which - Menu identifier
See Also:
EDIT_UNDO, EDIT_REDO, EDIT_CUT, EDIT_COPY, EDIT_PASTE, EDIT_DELETE, EDIT_SELECT_ALL, EDIT_SELECT_NONE

getOptionMenu

public javax.swing.JMenu getOptionMenu()
Returns the option menu.


getOptionMenuItem

public javax.swing.JMenuItem getOptionMenuItem(int which)
Returns a reference to the specified menu item of the option menu.

Parameters:
which - Menu identifier
See Also:
OPTION_FIT, OPTION_PREF

getToolbar

public javax.swing.JToolBar getToolbar()
Returns the default toolbar


getToobarButton

public javax.swing.JButton getToobarButton(int which)
Returns a reference to the specified button of the toolbar.

Parameters:
which - Button identifier
See Also:
TOOL_BUBBLE, TOOL_LABEL, TOOL_LINK, TOOL_UNDO, TOOL_REDO

getHelpLabel

public javax.swing.JLabel getHelpLabel()
Returns a reference to the help label


getScrollPane

public javax.swing.JScrollPane getScrollPane()
Return the JScrollPane that contains the NetEditor object


exitApp

public void exitApp()
Ask to save if the current scheme has unsaved modification before exiting.


createIconButton

public javax.swing.JButton createIconButton(java.lang.String resPath,
                                            java.lang.String preffix,
                                            java.lang.String toolTip,
                                            java.awt.event.ActionListener l)
Create an icon button. The function laods 3 gif files from the resource. They must be named "preffix_btn_up.gif" , "preffix_btn_down.gif" and "preffix_btn_dis.gif".

Parameters:
resPath - Resource path (ended with a '/')
preffix - Preffix of gif files
toolTip - Tooltip text
l - ActionListener
Returns:
an icon JButton

valueChanged

public void valueChanged(NetEditor src)
Update the title bar with the filename and the apptitle when the scheme change . Update also the state of menu and icon according to the editor (clipboard,selection,...)

Specified by:
valueChanged in interface NetEditorListener
Parameters:
src - NetEditor
See Also:
setAppTitle(java.lang.String)

objectClicked

public void objectClicked(NetEditor src,
                          NetObject obj,
                          java.awt.event.MouseEvent e)
Description copied from interface: NetEditorListener
Trigerred when the user click on an object only if the editor is not editable.

Specified by:
objectClicked in interface NetEditorListener
Parameters:
src - NetEditor that has trigerred the event.
obj - Clicked object.
e - Original MouseEvent
See Also:
NetEditor.setEditable(boolean)

linkClicked

public void linkClicked(NetEditor src,
                        NetObject obj,
                        int childIdx,
                        java.awt.event.MouseEvent e)
Description copied from interface: NetEditorListener
Trigerred when the user click on a link if the editor is not editable.

Specified by:
linkClicked in interface NetEditorListener
Parameters:
src - NetEditor that has trigerred the event.
obj - Clicked object.
childIdx - Child index.
e - Original MouseEvent
See Also:
NetEditor.setEditable(boolean)

sizeChanged

public void sizeChanged(NetEditor src,
                        java.awt.Dimension d)
Revalidate the inner ScrollPane

Specified by:
sizeChanged in interface NetEditorListener
Parameters:
src - NetEditor that has trigerred the event.
d - New dimension (in pixel coordinates)
See Also:
NetEditor.computePreferredSize(), NetEditor.loadFile(java.lang.String)

cancelCreate

public void cancelCreate(NetEditor src)
Clear the help label when the creation mode is aborted

Specified by:
cancelCreate in interface NetEditorListener
Parameters:
src - NetEditor that has trigerred the event.
See Also:
NetEditor.setEditable(boolean)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

main

public static void main(java.lang.String[] args)
Main function which launch the default NerEditor .