edu.rice.cs.drjava.ui
Class DetachedFrame

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 edu.rice.cs.util.swing.SwingFrame
                          extended by edu.rice.cs.drjava.ui.DetachedFrame
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class DetachedFrame
extends SwingFrame

See Also:
Serialized Form

Nested Class Summary
static class DetachedFrame.FrameState
          Class to save the frame state, i.e.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
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
(package private)  Runnable1<DetachedFrame> _detach
          Lambda to execute when component is being detached.
private  OptionListener<Vector<KeyStroke>> _keyBindingOptionListener
          OptionListener responding to changes for the undo/redo key bindings.
private  DetachedFrame.FrameState _lastState
          Last frame state.
private  HashMap<PropertyChangeListener,JMenuItem> _listenersToRemoveWhenDisposed
          Listeners that need to be removed when this frame is disposed.
private  MainFrame _mainFrame
          Main frame.
private  InputMap _oldInputMap
          Old InputMap without accelerators added.
(package private)  Runnable1<DetachedFrame> _reattach
          Lambda to execute when component is being re-attached.
private  WindowAdapter _wa
          Window adapter to re-attach the tabbed pane when the window is closed.
 
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
DetachedFrame(String name, MainFrame mf, Runnable1<DetachedFrame> detach, Runnable1<DetachedFrame> reattach)
          Create a tabbed pane frame.
 
Method Summary
protected  void copyAccelerators(JMenuBar source, JMenuBar dest)
          Recursively copy the first menu bar's accelerators into the second menu bar.
protected  void copyAccelerators(MenuElement source, MenuElement dest)
          Recursively copy the first menu's accelerators into the second menu.
 void dispose()
           
 DetachedFrame.FrameState getFrameState()
          Returns the last state of the frame, i.e.
protected static void processMenuElement(MenuElement elt, InputMap im, ActionMap am)
          Recursively process the MenuElement and add entries to the InputMap and ActionMap so that the menu element's accelerator will invoke the menu element's action even if the MenuElement is not present in another frame.
 void setDisplayInFrame(boolean b)
          Set whether the the tabbed pane is displayed in this frame.
 void setFrameState(DetachedFrame.FrameState ds)
          Sets state of the frame, i.e.
 void setFrameState(String s)
          Sets state of the frame, i.e.
 void setUpMenuBar()
           
 void setVisible(boolean vis)
          Toggle visibility of this frame.
 void updateKeyBindings()
          Update the key bindings from the MainFrame menu bar.
 
Methods inherited from class edu.rice.cs.util.swing.SwingFrame
duringInit, initDone
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, 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, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, 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, 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, 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 java.awt.MenuContainer
getFont, postEvent
 

Field Detail

_detach

Runnable1<DetachedFrame> _detach
Lambda to execute when component is being detached. The parameter is the instance of DetachedFrame that may contain the component.


_reattach

Runnable1<DetachedFrame> _reattach
Lambda to execute when component is being re-attached. The parameter is the instance of DetachedFrame that may contain the component.


_lastState

private DetachedFrame.FrameState _lastState
Last frame state. It can be stored and restored.


_mainFrame

private MainFrame _mainFrame
Main frame.


_wa

private WindowAdapter _wa
Window adapter to re-attach the tabbed pane when the window is closed.


_oldInputMap

private final InputMap _oldInputMap
Old InputMap without accelerators added.


_listenersToRemoveWhenDisposed

private final HashMap<PropertyChangeListener,JMenuItem> _listenersToRemoveWhenDisposed
Listeners that need to be removed when this frame is disposed. Key=Listener, Value=JMenuItem listened to.


_keyBindingOptionListener

private final OptionListener<Vector<KeyStroke>> _keyBindingOptionListener
OptionListener responding to changes for the undo/redo key bindings.

Constructor Detail

DetachedFrame

public DetachedFrame(String name,
                     MainFrame mf,
                     Runnable1<DetachedFrame> detach,
                     Runnable1<DetachedFrame> reattach)
Create a tabbed pane frame. Initially, the tabbed pane is displayed in the split pane

Parameters:
name - frame name
mf - the MainFrame
detach - command to detach the component. The parameter is the instance of DetachedFrame that may contain the component.
reattach - command to re-attach the component. The parameter is the instance of DetachedFrame that may contain the component.
Method Detail

getFrameState

public DetachedFrame.FrameState getFrameState()
Returns the last state of the frame, i.e. the location and dimension.

Returns:
frame state

setFrameState

public void setFrameState(DetachedFrame.FrameState ds)
Sets state of the frame, i.e. the location and dimension of the frame for the next use.

Parameters:
ds - State to update to, or null to reset

setFrameState

public void setFrameState(String s)
Sets state of the frame, i.e. the location and dimension of the frame for the next use.

Parameters:
s - State to update to, or null to reset

processMenuElement

protected static void processMenuElement(MenuElement elt,
                                         InputMap im,
                                         ActionMap am)
Recursively process the MenuElement and add entries to the InputMap and ActionMap so that the menu element's accelerator will invoke the menu element's action even if the MenuElement is not present in another frame. Note that this will only use the first key stroke configured for an action, because a menu item can only have one accelerator key stroke.


copyAccelerators

protected void copyAccelerators(JMenuBar source,
                                JMenuBar dest)
Recursively copy the first menu bar's accelerators into the second menu bar. Installs listeners to keep the accelerators updated.


copyAccelerators

protected void copyAccelerators(MenuElement source,
                                MenuElement dest)
Recursively copy the first menu's accelerators into the second menu. Installs listeners to keep the accelerators updated.


updateKeyBindings

public void updateKeyBindings()
Update the key bindings from the MainFrame menu bar.


dispose

public void dispose()
Overrides:
dispose in class Window

setUpMenuBar

public void setUpMenuBar()

setVisible

public void setVisible(boolean vis)
Toggle visibility of this frame. Warning, it behaves like a modal dialog.

Overrides:
setVisible in class Window

setDisplayInFrame

public void setDisplayInFrame(boolean b)
Set whether the the tabbed pane is displayed in this frame.

Parameters:
b - true to display the tabbed pane in this window, false to display it in the MainFrame split pane