[gui][PATCH] fixed formatting style for MenuSelectionManager

Olga Rodimina rodimina@redhat.com
Mon Jun 14 16:42:00 GMT 2004


Hi,

I've just committed a patch to java-gui-branch to fix formatting 
style for MenuSelectionManager.java


Olga.
-------------- next part --------------
? .snprj
? libjava.proj
? patch
? popup_Patch
? resources
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2660.2.179
diff -c -p -u -r1.2660.2.179 ChangeLog
--- ChangeLog	14 Jun 2004 14:16:38 -0000	1.2660.2.179
+++ ChangeLog	14 Jun 2004 14:20:53 -0000
@@ -1,4 +1,9 @@
 2004-06-14  Olga Rodimina  <rodimina@redhat.com>
+
+	* javax/swing/MenuSelectionManager.java: 
+	Ran through jalopy to fix formatting style.
+
+2004-06-14  Olga Rodimina  <rodimina@redhat.com>
 	
 	* javax/swing/JLayeredPane.java: 
 	(remove): Revalidate and repaint layered pane after
Index: javax/swing/MenuSelectionManager.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/MenuSelectionManager.java,v
retrieving revision 1.2.18.3
diff -c -p -u -r1.2.18.3 MenuSelectionManager.java
--- javax/swing/MenuSelectionManager.java	14 Jun 2004 14:16:58 -0000	1.2.18.3
+++ javax/swing/MenuSelectionManager.java	14 Jun 2004 14:20:53 -0000
@@ -51,267 +51,266 @@ import javax.swing.event.EventListenerLi
 
 
 /**
- * This class manages current menu selectection. It provides 
- * methods to clear and set current selected menu path. 
+ * This class manages current menu selectection. It provides
+ * methods to clear and set current selected menu path.
  * It also fires StateChange event to its registered
  * listeners whenever selected path of the current menu hierarchy
  * changes.
  *
  */
 public class MenuSelectionManager
+{
+  /** ChangeEvent fired when selected path changes*/
+  protected ChangeEvent changeEvent = new ChangeEvent(this);
+
+  /** List of listeners for this MenuSelectionManager */
+  protected EventListenerList listenerList = new EventListenerList();
+
+  /** Default manager for the current menu hierarchy*/
+  private static final MenuSelectionManager manager = new MenuSelectionManager();
+
+  /** Path to the currently selected menu */
+  private Vector selectedPath = new Vector();
+
+  /**
+   * Fires StateChange event to registered listeners
+   */
+  protected void fireStateChanged()
   {
-  
-    /** ChangeEvent fired when selected path changes*/
-    protected ChangeEvent changeEvent = new ChangeEvent(this);
-    
-    /** List of listeners for this MenuSelectionManager */
-    protected EventListenerList listenerList = new EventListenerList();
-    
-    /** Default manager for the current menu hierarchy*/
-    private static final MenuSelectionManager manager = new MenuSelectionManager();
-    
-    /** Path to the currently selected menu */
-    private Vector selectedPath = new Vector();
-
-    /**
-     * Fires StateChange event to registered listeners
-     */
-    protected void fireStateChanged ()
-      {
-	ChangeListener[] listeners = getChangeListeners ();
+    ChangeListener[] listeners = getChangeListeners();
 
-	for (int i = 0; i < listeners.length; i++)
-	  listeners[i].stateChanged (changeEvent);
-      }
+    for (int i = 0; i < listeners.length; i++)
+      listeners[i].stateChanged(changeEvent);
+  }
 
-    /**
-     * Adds ChangeListener to this MenuSelectionManager
-     *
-     * @param listener ChangeListener to add
-     */
-    public void addChangeListener (ChangeListener listener)
-      {
-	listenerList.add (ChangeListener.class, listener);
-      }
+  /**
+   * Adds ChangeListener to this MenuSelectionManager
+   *
+   * @param listener ChangeListener to add
+   */
+  public void addChangeListener(ChangeListener listener)
+  {
+    listenerList.add(ChangeListener.class, listener);
+  }
 
-    /**
-     * Removes ChangeListener from the list of registered listeners
-     * for this MenuSelectionManager.
-     *
-     * @param listener ChangeListner to remove
-     */
-    public void removeChangeListener (ChangeListener listener)
-      {
-	listenerList.remove (ChangeListener.class, listener);
-      }
+  /**
+   * Removes ChangeListener from the list of registered listeners
+   * for this MenuSelectionManager.
+   *
+   * @param listener ChangeListner to remove
+   */
+  public void removeChangeListener(ChangeListener listener)
+  {
+    listenerList.remove(ChangeListener.class, listener);
+  }
 
-    /**
-     * Returns list of registered listeners with MenuSelectionManager
-     *
-     * @since 1.4 
-     */    
-    public ChangeListener[] getChangeListeners ()
-      {
-	return (ChangeListener[]) listenerList.getListeners (ChangeListener.class);
-      }
+  /**
+   * Returns list of registered listeners with MenuSelectionManager
+   *
+   * @since 1.4
+   */
+  public ChangeListener[] getChangeListeners()
+  {
+    return (ChangeListener[]) listenerList.getListeners(ChangeListener.class);
+  }
 
-    /**
-     * Unselects all the menu elements on the selection path
-     */
-    public void clearSelectedPath ()
-      {
-	// Send events from the bottom most item in the menu - hierarchy to the
-	// top most
-	for (int i = selectedPath.size () - 1; i >= 0; i--)
-	  ((MenuElement) selectedPath.get (i)).menuSelectionChanged (false);
+  /**
+   * Unselects all the menu elements on the selection path
+   */
+  public void clearSelectedPath()
+  {
+    // Send events from the bottom most item in the menu - hierarchy to the
+    // top most
+    for (int i = selectedPath.size() - 1; i >= 0; i--)
+      ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false);
 
-	// notify all listeners that the selected path was changed    
-	fireStateChanged ();
+    // notify all listeners that the selected path was changed    
+    fireStateChanged();
 
-	// clear selected path
-	selectedPath.clear ();
-      }
+    // clear selected path
+    selectedPath.clear();
+  }
 
-    /**
-     * DOCUMENT ME!
-     *
-     * @param source DOCUMENT ME!
-     * @param sourcePoint DOCUMENT ME!
-     *
-     * @return DOCUMENT ME!
-     */
-    public Component componentForPoint (Component source, Point sourcePoint)
-      {
-	throw new UnsupportedOperationException("not implemented");
-      }
+  /**
+   * DOCUMENT ME!
+   *
+   * @param source DOCUMENT ME!
+   * @param sourcePoint DOCUMENT ME!
+   *
+   * @return DOCUMENT ME!
+   */
+  public Component componentForPoint(Component source, Point sourcePoint)
+  {
+    throw new UnsupportedOperationException("not implemented");
+  }
 
-    /**
-     * Returns shared instance of MenuSelection Manager
-     *
-     * @return default Manager
-     */
-    public static MenuSelectionManager defaultManager ()
-      {
-	return manager;
-      }
+  /**
+   * Returns shared instance of MenuSelection Manager
+   *
+   * @return default Manager
+   */
+  public static MenuSelectionManager defaultManager()
+  {
+    return manager;
+  }
 
-    /**
-     * Returns path representing current menu selection
-     *
-     * @return Current selection path
-     */
-    public MenuElement[] getSelectedPath ()
-      {
-	MenuElement[] path = new MenuElement[selectedPath.size ()];
+  /**
+   * Returns path representing current menu selection
+   *
+   * @return Current selection path
+   */
+  public MenuElement[] getSelectedPath()
+  {
+    MenuElement[] path = new MenuElement[selectedPath.size()];
 
-	for (int i = 0; i < path.length; i++)
-	  path[i] = (MenuElement) selectedPath.get (i);
+    for (int i = 0; i < path.length; i++)
+      path[i] = (MenuElement) selectedPath.get(i);
 
-	return path;
-      }
+    return path;
+  }
 
-    /**
-     * Returns true if specified component is part of current menu
-     * heirarchy and false otherwise
-     *
-     * @param c Component for which to check
-     * @return True if specified component is part of current menu
-     */
-    boolean isComponentPartOfCurrentMenu (Component c)
+  /**
+   * Returns true if specified component is part of current menu
+   * heirarchy and false otherwise
+   *
+   * @param c Component for which to check
+   * @return True if specified component is part of current menu
+   */
+  boolean isComponentPartOfCurrentMenu(Component c)
+  {
+    MenuElement[] subElements;
+    for (int i = 0; i < selectedPath.size(); i++)
       {
-	MenuElement[] subElements;
-	for (int i = 0; i < selectedPath.size (); i++)
+	subElements = ((MenuElement) selectedPath.get(i)).getSubElements();
+	for (int j = 0; j < subElements.length; j++)
 	  {
-	    subElements = ((MenuElement) selectedPath.get (i)).getSubElements ();
-	    for (int j = 0; j < subElements.length; j++)
-	      {
-		if ((subElements[j].getComponent ()).equals (c))
-		  return true;
-	      }
+	    if ((subElements[j].getComponent()).equals(c))
+	      return true;
 	  }
-
-	return false;
       }
 
-    /**
-     * DOCUMENT ME!
-     *
-     * @param e DOCUMENT ME!
-     */
-    public void processKeyEvent (KeyEvent e)
-      {
-	throw new UnsupportedOperationException("not implemented");
-      }
+    return false;
+  }
 
-    /**
-     * Forwards given mouse event to all of the source subcomponents.
-     *
-     * @param event Mouse event
-     */
-    public void processMouseEvent (MouseEvent event)
-      {
-	JComponent c = ((JComponent) event.getSource ());
+  /**
+   * DOCUMENT ME!
+   *
+   * @param e DOCUMENT ME!
+   */
+  public void processKeyEvent(KeyEvent e)
+  {
+    throw new UnsupportedOperationException("not implemented");
+  }
 
-	MenuElement[] path = getPath (c);
-	((MenuElement) c).processMouseEvent (event, path, manager);
+  /**
+   * Forwards given mouse event to all of the source subcomponents.
+   *
+   * @param event Mouse event
+   */
+  public void processMouseEvent(MouseEvent event)
+  {
+    JComponent c = ((JComponent) event.getSource());
 
-	// forward events to subcomponents 
-	MenuElement[] subComponents = ((MenuElement) c).getSubElements ();
+    MenuElement[] path = getPath(c);
+    ((MenuElement) c).processMouseEvent(event, path, manager);
 
-	for (int i = 0; i < subComponents.length; i++)
-	  {
-	    if (subComponents[i] instanceof JMenuItem)
-	      subComponents[i].processMouseEvent (event, path, manager);
-	  }
+    // forward events to subcomponents 
+    MenuElement[] subComponents = ((MenuElement) c).getSubElements();
+
+    for (int i = 0; i < subComponents.length; i++)
+      {
+	if (subComponents[i] instanceof JMenuItem)
+	  subComponents[i].processMouseEvent(event, path, manager);
       }
+  }
 
-    /**
-     * Sets menu selection to the specified path
-     *
-     * @param path new selection path
-     */
-    public void setSelectedPath (MenuElement[] path)
+  /**
+   * Sets menu selection to the specified path
+   *
+   * @param path new selection path
+   */
+  public void setSelectedPath(MenuElement[] path)
+  {
+    if (path == null)
       {
-	if (path == null)
-	  {
-	    clearSelectedPath ();
-	    return;
-	  }
+	clearSelectedPath();
+	return;
+      }
 
-	fireStateChanged ();
+    fireStateChanged();
 
-	int i;
-	int minSize = path.length; // size of the smaller path. 
+    int i;
+    int minSize = path.length; // size of the smaller path. 
 
-	if (path.length > selectedPath.size ())
+    if (path.length > selectedPath.size())
+      {
+	// if new selected path contains more elements then current
+	// selection then first add all elements at 
+	// the indexes > selectedPath.size 
+	for (i = selectedPath.size(); i < path.length; i++)
 	  {
-	    // if new selected path contains more elements then current
-	    // selection then first add all elements at 
-	    // the indexes > selectedPath.size 
-	    for (i = selectedPath.size (); i < path.length; i++)
-	      {
-		selectedPath.add (path[i]);
-		path[i].menuSelectionChanged (true);
-	      }
-
-	    minSize = selectedPath.size ();
+	    selectedPath.add(path[i]);
+	    path[i].menuSelectionChanged(true);
 	  }
 
-	else if (path.length < selectedPath.size ())
-	  {
-	    // if new selected path contains less elements then current 
-	    // selection then first remove all elements from the selection
-	    // at the indexes > path.length
-	    for (i = selectedPath.size () - 1; i >= path.length; i--)
-	      {
-		((MenuElement) selectedPath.get (i)).menuSelectionChanged (false);
-		selectedPath.remove (i);
-	      }
+	minSize = selectedPath.size();
+      }
 
-	    minSize = path.length;
+    else if (path.length < selectedPath.size())
+      {
+	// if new selected path contains less elements then current 
+	// selection then first remove all elements from the selection
+	// at the indexes > path.length
+	for (i = selectedPath.size() - 1; i >= path.length; i--)
+	  {
+	    ((MenuElement) selectedPath.get(i)).menuSelectionChanged(false);
+	    selectedPath.remove(i);
 	  }
 
-	// Now compare elements in new and current selection path at the 
-	// same location and adjust selection until 
-	// same menu elements will be encountered at the
-	// same index in both current and new selection path.
-	MenuElement oldSelectedPath;
+	minSize = path.length;
+      }
+
+    // Now compare elements in new and current selection path at the 
+    // same location and adjust selection until 
+    // same menu elements will be encountered at the
+    // same index in both current and new selection path.
+    MenuElement oldSelectedPath;
 
-	for (i = minSize - 1; i >= 0; i--)
-	  {
-	    oldSelectedPath = (MenuElement) selectedPath.get (i);
+    for (i = minSize - 1; i >= 0; i--)
+      {
+	oldSelectedPath = (MenuElement) selectedPath.get(i);
 
-	    if (path[i].equals (oldSelectedPath))
-	      break;
+	if (path[i].equals(oldSelectedPath))
+	  break;
 
-	    oldSelectedPath.menuSelectionChanged (false);
-	    path[i].menuSelectionChanged (true);
-	    selectedPath.setElementAt (path[i], i);
-	  }
+	oldSelectedPath.menuSelectionChanged(false);
+	path[i].menuSelectionChanged(true);
+	selectedPath.setElementAt(path[i], i);
       }
+  }
 
-    /**
-     * Returns path to the specified component
-     *
-     * @param c component for which to find path for
-     *
-     * @return path to the specified component
-     */
-    private MenuElement[] getPath (Component c)
+  /**
+   * Returns path to the specified component
+   *
+   * @param c component for which to find path for
+   *
+   * @return path to the specified component
+   */
+  private MenuElement[] getPath(Component c)
+  {
+    ArrayList path = new ArrayList();
+    while (c instanceof MenuElement)
       {
-	ArrayList path = new ArrayList();
-	while (c instanceof MenuElement)
-	  {
-	    path.add (0, (MenuElement) c);
-
-	    if (c instanceof JPopupMenu)
-	      c = ((JPopupMenu) c).getInvoker ();
-	    else
-	      c = c.getParent ();
-	  }
+	path.add(0, (MenuElement) c);
 
-	MenuElement[] pathArray = new MenuElement[path.size ()];
-	path.toArray (pathArray);
-	return pathArray;
+	if (c instanceof JPopupMenu)
+	  c = ((JPopupMenu) c).getInvoker();
+	else
+	  c = c.getParent();
       }
+
+    MenuElement[] pathArray = new MenuElement[path.size()];
+    path.toArray(pathArray);
+    return pathArray;
   }
+}


More information about the Java-patches mailing list