[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sun Oct 23 19:00:24 UTC 2005


senger
Sun Oct 23 15:00:24 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv20917/src/main/org/biomoby/service/dashboard

Modified Files:
	BuildDataTypeTree.java CommonTree.java DataTypesBoard.java 
	DataTypesTree.java RegistrationPanel.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard BuildDataTypeTree.java,1.1,1.2 CommonTree.java,1.4,1.5 DataTypesBoard.java,1.1,1.2 DataTypesTree.java,1.2,1.3 RegistrationPanel.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/BuildDataTypeTree.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/BuildDataTypeTree.java	2005/10/22 14:35:46	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/BuildDataTypeTree.java	2005/10/23 19:00:24	1.2
@@ -78,6 +78,8 @@
 
 	// enable tool tips
 	ToolTipManager.sharedInstance().registerComponent (this);
+
+// 	expand();
     }
 
     //
@@ -125,4 +127,20 @@
     protected void selected (DefaultMutableTreeNode node) {
     }
 
+    /*********************************************************************
+     * Expand all nodes.
+     ********************************************************************/
+    protected void expand() {
+	final SwingWorker worker = new SwingWorker() {
+		public Object construct() {
+		    SwingUtils.expandTree (BuildDataTypeTree.this, (DefaultMutableTreeNode)getModel().getRoot());
+		    return null;  // not used here
+		}
+		// runs on the event-dispatching thread.
+		public void finished() {
+		    repaint();
+		}
+	    };
+	worker.start(); 
+    }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/22 01:38:04	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/23 19:00:24	1.5
@@ -18,6 +18,7 @@
 import javax.swing.JPopupMenu;
 import javax.swing.JOptionPane;
 import javax.swing.JMenuItem;
+import javax.swing.JSeparator;
 import javax.swing.ToolTipManager;
 import javax.swing.AbstractAction;
 import javax.swing.tree.DefaultMutableTreeNode;
@@ -53,7 +54,11 @@
 public class CommonTree
     extends JTree {
 
-    final static String RELOAD = "Reload";
+    // action commands for popup menu items
+    protected final static String AC_SEARCH   = "ac-search";
+    protected final static String AC_EXPAND   = "ac-expand";
+    protected final static String AC_COLLAPSE = "ac-collapse";
+    protected final static String AC_RELOAD   = "ac-reload";
 
     // some shared constants
     final static protected int SORTED_BY_NAME      = 0;
@@ -61,9 +66,15 @@
 
     // tree components
     protected JPopupMenu popup;
-    protected Icon searchIcon;
     protected String lastSearchText = "";
 
+    // shared icons
+    static protected Icon searchIcon;
+    static protected Icon menuSearchIcon, menuSearchIconDis;
+    static protected Icon menuExpandIcon, menuExpandIconDis;
+    static protected Icon menuCollapseIcon, menuCollapseIconDis;
+    static protected Icon menuReloadIcon, menuReloadIconDis;
+
 //     protected PropertyChangeSupport support;
 //     protected boolean expanded = true;   // the status of the application list
 
@@ -104,6 +115,9 @@
 
 	// enable tool tips
 	ToolTipManager.sharedInstance().registerComponent (this);
+
+	// load menu icons
+	loadIcons();
     }
 
     //
@@ -180,6 +194,39 @@
     }
 
     /*********************************************************************
+     * Load all menu icons.
+     ********************************************************************/
+    protected void loadIcons() {
+	if (menuSearchIcon == null)
+	    menuSearchIcon = 
+		SwingUtils.createIcon ("images/smallSearch.gif", Dashboard.class);
+	if (menuSearchIconDis == null)
+	    menuSearchIconDis = 
+		SwingUtils.createIcon ("images/smallSearchDis.gif", Dashboard.class);
+
+	if (menuExpandIcon == null)
+	    menuExpandIcon = 
+		SwingUtils.createIcon ("images/smallExpand.gif", Dashboard.class);
+	if (menuExpandIconDis == null)
+	    menuExpandIconDis = 
+		SwingUtils.createIcon ("images/smallExpandDis.gif", Dashboard.class);
+
+	if (menuCollapseIcon == null)
+	    menuCollapseIcon = 
+		SwingUtils.createIcon ("images/smallCollapse.gif", Dashboard.class);
+	if (menuCollapseIconDis == null)
+	    menuCollapseIconDis = 
+		SwingUtils.createIcon ("images/smallCollapseDis.gif", Dashboard.class);
+
+	if (menuReloadIcon == null)
+	    menuReloadIcon = 
+		SwingUtils.createIcon ("images/smallReload.gif", Dashboard.class);
+	if (menuReloadIconDis == null)
+	    menuReloadIconDis = 
+		SwingUtils.createIcon ("images/smallReloadDis.gif", Dashboard.class);
+    }
+
+    /*********************************************************************
      * Create a popup object with common items. Subclasses can (and
      * usually do) add more items, or re-created the whole popup. <p>
      *
@@ -188,35 +235,35 @@
     protected void createPopups (String title) {
 	popup = new JPopupMenu (title);
 	popup.add
-	    (new JMenuItem (new AbstractAction ("Search") {
+	    (createMenuItem (new AbstractAction ("Search") {
 		    public void actionPerformed (ActionEvent e) {
 			String searchText = searchDialog();
 			if (searchText != null)
 			    search (searchText);
 		    }
-		}));
+		}, AC_SEARCH, menuSearchIcon, menuSearchIconDis));
 	popup.add
-	    (new JMenuItem (new AbstractAction ("Expand all nodes") {
+	    (createMenuItem (new AbstractAction ("Expand all nodes") {
 		    public void actionPerformed (ActionEvent e) {
 			expand();
 		    }
-		}));
+		}, AC_EXPAND, menuExpandIcon, menuExpandIconDis));
 
 	popup.add
-	    (new JMenuItem (new AbstractAction ("Collapse all nodes") {
+	    (createMenuItem (new AbstractAction ("Collapse all nodes") {
 		    public void actionPerformed (ActionEvent e) {
 			collapse();
 		    }
-		}));
+		}, AC_COLLAPSE, menuCollapseIcon, menuCollapseIconDis));
 
 	popup.addSeparator();
 
 	popup.add
-	    (new JMenuItem (new AbstractAction (RELOAD) {
+	    (createMenuItem (new AbstractAction ("Reload") {
 		    public void actionPerformed (ActionEvent e) {
 			reload();
 		    }
-		}));
+		}, AC_RELOAD, menuReloadIcon, menuReloadIconDis));
 
 	// add listener to this tree to bring up popup menus
 	MouseListener popupListener = new PopupListener();
@@ -239,6 +286,29 @@
     }
 
     /*********************************************************************
+     * Create a menu item.
+     ********************************************************************/
+    protected JMenuItem createMenuItem (AbstractAction action,
+					String actionCommand) {
+	JMenuItem mi = new JMenuItem (action);
+	mi.setActionCommand (actionCommand);
+	return mi;
+    }
+
+    /*********************************************************************
+     * Create a menu item.
+     ********************************************************************/
+    protected JMenuItem createMenuItem (AbstractAction action,
+					String actionCommand,
+					Icon icon,
+					Icon disabledIcon) {
+	JMenuItem mi = createMenuItem (action, actionCommand);
+	mi.setIcon (icon);
+	mi.setDisabledIcon (disabledIcon);
+	return mi;
+    }
+
+    /*********************************************************************
      * Enable/disable the whole popup except the 'Reload' option (that
      * one remains enabled always).
      ********************************************************************/
@@ -247,7 +317,7 @@
 	    Component[] components = popup.getComponents();
 	    for (int i = 0; i < components.length; i++) {
 		if ( components[i] instanceof JMenuItem &&
-		     ! ((JMenuItem)components[i]).getText().equals (RELOAD) )
+		     ! AC_RELOAD.equals (((JMenuItem)components[i]).getActionCommand()) )
 		    ((JMenuItem)components[i]).setEnabled (enabled);
 	    }
 	}
@@ -347,4 +417,37 @@
 	AbstractPanel.error (prologue, e);
     }
 
+    /*********************************************************************
+     * Remove a menu item (given by an action command string) from a
+     * popup menu.
+     ********************************************************************/
+    protected void removeFromPopups (String actionCommand) {
+	if (popup == null) return;
+	Component[] components = popup.getComponents();
+	for (int i = 0; i < components.length; i++) {
+	    if ( components[i] instanceof JMenuItem &&
+		 actionCommand.equals (((JMenuItem)components[i]).getActionCommand()) ) {
+		popup.remove (components[i]);
+		return;
+	    }
+	}
+    }
+
+    /*********************************************************************
+     * Remove a menu separator (that is after menu item given by an
+     * action command string) from a popup menu.
+     ********************************************************************/
+    protected void removeSeparatorAfter (String actionCommand) {
+	if (popup == null) return;
+	Component[] components = popup.getComponents();
+	boolean found = false;
+	for (int i = 0; i < components.length; i++) {
+	    if ( components[i] instanceof JSeparator && found) {
+		popup.remove (components[i]);
+		return;
+	    }
+	    found = ( components[i] instanceof JMenuItem &&
+		      actionCommand.equals (((JMenuItem)components[i]).getActionCommand()) );
+	}
+    }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.java	2005/10/22 01:38:04	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.java	2005/10/23 19:00:24	1.2
@@ -40,8 +40,16 @@
     public DataTypesBoard (RegistryModel model,
 			   CommonConsole console,
 			   PropertyChangeSupport support) {
+	this (model, console, support,
+	      new DataTypesTree (model, console));
+    }
+
+    public DataTypesBoard (RegistryModel model,
+			   CommonConsole console,
+			   PropertyChangeSupport support,
+			   CommonTree customTree) {
 	super (model, support);
-	tree = new DataTypesTree (model, console);
+	tree = customTree;
 	createItself();
     }
 

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/10/22 01:38:04	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/10/23 19:00:24	1.3
@@ -42,6 +42,12 @@
 public class DataTypesTree
     extends CommonTree {
 
+    // action commands for popup menu items
+    protected final static String AC_NSORT = "ac-nsort";
+    protected final static String AC_ASORT = "ac-asort";
+    protected final static String AC_HASA  = "ac-hasa";
+    protected final static String AC_DEPR  = "ac-depr";
+
     // remembered from constructor
     RegistryModel registryModel;
     CommonConsole console;
@@ -79,22 +85,23 @@
 	super.createPopups (title);
 	popup.addSeparator();
 	popup.add
-	    (new JMenuItem (new AbstractAction ("Sort by names") {
+	    (createMenuItem (new AbstractAction ("Sort by names") {
 		    public void actionPerformed (ActionEvent e) {
 			update (lastSorted = SORTED_BY_NAME);
 			deprecatedBox.setEnabled (true);
 		    }
-		}));
+		}, AC_NSORT));
 	popup.add
-	    (new JMenuItem (new AbstractAction ("Sort by authorities") {
+	    (createMenuItem (new AbstractAction ("Sort by authorities") {
 		    public void actionPerformed (ActionEvent e) {
 			update (lastSorted = SORTED_BY_AUTHORITY);
 			deprecatedBox.setEnabled (false);
 		    }
-		}));
+		}, AC_ASORT));
 	popup.addSeparator();
 
 	JCheckBoxMenuItem showBox = new JCheckBoxMenuItem ("Show HAS/HASA members");
+	showBox.setActionCommand (AC_HASA);
 	showBox.addItemListener (new ItemListener() {
 		public void itemStateChanged  (ItemEvent e) {
 		    showMembers = (e.getStateChange() == ItemEvent.SELECTED);
@@ -104,6 +111,7 @@
 	popup.add (showBox);
 
 	deprecatedBox = new JCheckBoxMenuItem ("Show deprecated objects");
+	deprecatedBox.setActionCommand (AC_DEPR);
 	deprecatedBox.addItemListener (new ItemListener() {
 		public void itemStateChanged  (ItemEvent e) {
 		    showBadGuys = (e.getStateChange() == ItemEvent.SELECTED);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/10/22 14:35:46	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/10/23 19:00:24	1.2
@@ -68,27 +68,16 @@
 public class RegistrationPanel
     extends AbstractPanel {
 
-    // names of user preferences keys
-//     static final String USE_CACHE = "use-cache";
-
     // associated model working behind the scenes
     RegistryModel registryModel;
 
     // components that are used from more methods
-//     JTextFieldWithHistory dtName;
-//     JTextFieldWithHistory dtAuth;
-//     JTextFieldWithHistory dtEmail;
-
     CommonConsole console;
 
     /*********************************************************************
      * propertyChange()
      ********************************************************************/
     public void propertyChange (PropertyChangeEvent e) {
-//         String prop = e.getPropertyName();
-//         String newVal = (String)e.getNewValue();
-//         if (newVal == null) return;   // no interest in non-defined  new values
-//         if (prop == null) return;     // no interest in non-specific changes
     }
 
     /*********************************************************************
@@ -169,9 +158,11 @@
  	SwingUtils.addComponent (defs, dtDesc,       0, 6, 1, 1, BOTH, NWEST, 1.0, 1.0, BREATH_TOP);
 
 	// a tree with all already existing data types
-	DataTypesBoard dataTypesBoard = new DataTypesBoard (registryModel,
-							    console,
-							    support);
+	DataTypesBoard dataTypesBoard =
+	    new DataTypesBoard (registryModel,
+				console,
+				support,
+				new CustomDataTypesTree (registryModel, console));
 	dataTypesBoard.updateTree (CommonTree.SORTED_BY_NAME);
 
 	// a tree with a new data type && registration button
@@ -261,4 +252,51 @@
 	return panelIcon;
     }
 
+    /**************************************************************************
+     * Customized tree of data types - has different popup menus...
+     **************************************************************************/
+    protected class CustomDataTypesTree
+	extends DataTypesTree {
+
+	// action commands for popup menu items
+	protected final static String AC_PARENT = "ac-parent";
+	protected final static String AC_MHASA  = "ac-m-hasa";
+	protected final static String AC_MHAS   = "ac-m-has";
+
+	public CustomDataTypesTree (RegistryModel model,
+				    CommonConsole console) {
+	    super (model, console);
+	}
+
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void createPopups (String title) {
+ 	    super.createPopups (title);
+ 	    removeFromPopups (AC_RELOAD);
+ 	    removeFromPopups (AC_HASA);
+ 	    removeFromPopups (AC_DEPR);
+ 	    removeSeparatorAfter (AC_COLLAPSE);
+
+ 	    popup.add
+ 		(createMenuItem (new AbstractAction ("<html>Add selected as a parent type (<font color='blue'>ISA</font>)") {
+ 			public void actionPerformed (ActionEvent e) {
+ 			}
+ 		    }, AC_PARENT));
+
+ 	    popup.add
+ 		(createMenuItem (new AbstractAction ("<html>Add selected as a member (<font color='blue'>HASA</font>)") {
+ 			public void actionPerformed (ActionEvent e) {
+ 			}
+ 		    }, AC_MHASA));
+
+ 	    popup.add
+ 		(createMenuItem (new AbstractAction ("<html>Add selected as a list of members (<font color='blue'>HAS</font>)") {
+ 			public void actionPerformed (ActionEvent e) {
+ 			}
+ 		    }, AC_MHAS));
+
+	}
+    }
+
 }




More information about the MOBY-guts mailing list