org.fife.rtext
Class RTextMenuBar

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JMenuBar
                  extended byorg.fife.ui.app.MenuBar
                      extended byorg.fife.rtext.RTextMenuBar
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.MenuElement, javax.swing.event.PopupMenuListener, java.beans.PropertyChangeListener, java.io.Serializable

public class RTextMenuBar
extends MenuBar
implements java.beans.PropertyChangeListener, javax.swing.event.PopupMenuListener

The menu bar used by rtext. The menu bar includes a "file history" feature, where it can remember any number of recent files and display them as options in the File menu.

Version:
0.8
Author:
Robert Futrell
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JMenuBar
javax.swing.JMenuBar.AccessibleJMenuBar
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String MENU_DOCKED_WINDOWS
          A key to get the "Docked Windows" menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_EDIT
          A key to get the Edit menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_FILE
          A key to get the File menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_HELP
          A key to get the Help menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_MACROS
          A key to get the Macros menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_SEARCH
          A key to get the Search menu via MenuBar.getMenuByName(String).
static java.lang.String MENU_VIEW
          A key to get the View menu via MenuBar.getMenuByName(String).
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
RTextMenuBar(RText rtext, java.lang.String lnfName, RTextPreferences properties)
          Creates an instance of the menu bar.
 
Method Summary
 java.lang.String getFileHistoryString()
          Returns a string representing all files in the file history separated by '<' characters.
 int getMaximumFileHistorySize()
          Returns the maximum number of files the file history in the File menu will remember.
protected  void menuItemAcceleratorWorkaround()
          Thanks to Java Bug ID 5026829, JMenuItems (among other Swing components) don't update their accelerators, etc. when the properties on which they were created update them.
 void popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
           
 void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
           
 void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e)
          Called when one of the popup menus is about to become visible.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Called whenever a property changes on a component we're listening to.
 void setSearchToolbarMenuItemSelected(boolean selected)
          Sets whether the "QuickSearch toolbar" menu item is selected.
 void setWindowMenuVisible(boolean visible)
          Sets whether or not the "Window" menu is visible.
 void updateUI()
          Overridden to make sure that the "Window" menu gets its look-and-feel updated too, even if it currently isn't visible.
 
Methods inherited from class org.fife.ui.app.MenuBar
addExtraMenu, createMenu, createMenu, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createMenuItem, createRadioButtonMenuItem, getExtraMenuInsertionIndex, getMenuByName, registerMenuByName
 
Methods inherited from class javax.swing.JMenuBar
add, addNotify, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getHelpMenu, getMargin, getMenu, getMenuCount, getSelectionModel, getSubElements, getUI, getUIClassID, isBorderPainted, isSelected, menuSelectionChanged, paintBorder, paramString, processKeyBinding, processKeyEvent, processMouseEvent, removeNotify, setBorderPainted, setHelpMenu, setMargin, setSelected, setSelectionModel, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MENU_FILE

public static final java.lang.String MENU_FILE
A key to get the File menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_EDIT

public static final java.lang.String MENU_EDIT
A key to get the Edit menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_SEARCH

public static final java.lang.String MENU_SEARCH
A key to get the Search menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_VIEW

public static final java.lang.String MENU_VIEW
A key to get the View menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_DOCKED_WINDOWS

public static final java.lang.String MENU_DOCKED_WINDOWS
A key to get the "Docked Windows" menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_MACROS

public static final java.lang.String MENU_MACROS
A key to get the Macros menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values

MENU_HELP

public static final java.lang.String MENU_HELP
A key to get the Help menu via MenuBar.getMenuByName(String).

See Also:
Constant Field Values
Constructor Detail

RTextMenuBar

public RTextMenuBar(RText rtext,
                    java.lang.String lnfName,
                    RTextPreferences properties)
Creates an instance of the menu bar.

Parameters:
rtext - The instance of the RText editor that this menu bar belongs to.
lnfName - The name for a look and feel; should be obtained from UIManager.getLookAndFeel().getName().
properties - The properties we'll be using to initialize the menu bar.
Method Detail

getFileHistoryString

public java.lang.String getFileHistoryString()
Returns a string representing all files in the file history separated by '<' characters. This character was chosen as the separator because it is a character that cannot be used in filenames in both Windows and UNIX/Linux.

Returns:
A String representing all files in the file history, separated by '<' characters. If no files are in the file history, then null is returned.

getMaximumFileHistorySize

public int getMaximumFileHistorySize()
Returns the maximum number of files the file history in the File menu will remember.

Returns:
The maximum size of the file history.

menuItemAcceleratorWorkaround

protected void menuItemAcceleratorWorkaround()
Thanks to Java Bug ID 5026829, JMenuItems (among other Swing components) don't update their accelerators, etc. when the properties on which they were created update them. Thus, we have to do this manually. This is still broken as of 1.5.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Called whenever a property changes on a component we're listening to.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

popupMenuCanceled

public void popupMenuCanceled(javax.swing.event.PopupMenuEvent e)
Specified by:
popupMenuCanceled in interface javax.swing.event.PopupMenuListener

popupMenuWillBecomeInvisible

public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent e)
Specified by:
popupMenuWillBecomeInvisible in interface javax.swing.event.PopupMenuListener

popupMenuWillBecomeVisible

public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent e)
Called when one of the popup menus is about to become visible.

Specified by:
popupMenuWillBecomeVisible in interface javax.swing.event.PopupMenuListener
Parameters:
e - The popup menu event.

setSearchToolbarMenuItemSelected

public void setSearchToolbarMenuItemSelected(boolean selected)
Sets whether the "QuickSearch toolbar" menu item is selected.

Parameters:
selected - Whether the QuickSearch toolbar menu item is selected.

setWindowMenuVisible

public void setWindowMenuVisible(boolean visible)
Sets whether or not the "Window" menu is visible. This menu should only be visible on the MDI view.

Parameters:
visible - Whether or not the menu should be visible.

updateUI

public void updateUI()
Overridden to make sure that the "Window" menu gets its look-and-feel updated too, even if it currently isn't visible.