[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Wed Nov 2 06:39:06 UTC 2005


senger
Wed Nov  2 01:39:06 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv12193/src/main/org/biomoby/service/dashboard

Modified Files:
	CommonTree.java DataTypesTree.java NamespacesTree.java 
	RegistryModel.java RegistryPanel.java ServiceTypesTree.java 
Added Files:
	ServicesBoard.java ServicesTree.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard ServicesBoard.java,NONE,1.1 ServicesTree.java,NONE,1.1 CommonTree.java,1.9,1.10 DataTypesTree.java,1.6,1.7 NamespacesTree.java,1.1,1.2 RegistryModel.java,1.11,1.12 RegistryPanel.java,1.15,1.16 ServiceTypesTree.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/28 11:30:37	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/11/02 06:39:06	1.10
@@ -55,14 +55,23 @@
     protected final static String AC_EXPAND   = "ac-expand";
     protected final static String AC_COLLAPSE = "ac-collapse";
     protected final static String AC_RELOAD   = "ac-reload";
+    protected final static String AC_NSORT    = "ac-nsort";
+    protected final static String AC_ASORT    = "ac-asort";
 
     // some shared constants
-    final static protected int SORTED_BY_NAME      = 0;
-    final static protected int SORTED_BY_AUTHORITY = 1;
+    final static protected int SORTED_BY_NAME         = 0;
+    final static protected int SORTED_BY_AUTHORITY    = 1;
+    final static protected int SORTED_UNUSUAL         = 9;
+    // all higher numbers indicates an unusual sorting order that we
+    // will not keep in case of reloading
+    final static protected int SORTED_BY_SERVICE_TYPE = 11;
+    final static protected int SORTED_BY_INPUT_DATA   = 12;
+    final static protected int SORTED_BY_OUTPUT_DATA  = 13;
 
     // tree components
     protected JPopupMenu popup;
     protected String lastSearchText = "";
+    protected int lastSorted = SORTED_BY_NAME;
 
     // shared icons
     static protected Icon searchIcon;
@@ -70,6 +79,11 @@
     static protected Icon menuExpandIcon, menuExpandIconDis;
     static protected Icon menuCollapseIcon, menuCollapseIconDis;
     static protected Icon menuReloadIcon, menuReloadIconDis;
+    static protected Icon smallNIcon, smallNIconDis;
+    static protected Icon smallAIcon, smallAIconDis;
+    static protected Icon smallTIcon, smallTIconDis;
+    static protected Icon smallIIcon, smallIIconDis;
+    static protected Icon smallOIcon, smallOIconDis;
 
     protected String rootNode;
 
@@ -212,6 +226,22 @@
 	if (menuReloadIconDis == null)
 	    menuReloadIconDis = 
 		SwingUtils.createIcon ("images/smallReload_dis.gif", Dashboard.class);
+
+	if (smallNIcon    == null) smallNIcon    = loadIcon ("images/smallN.gif");
+	if (smallNIconDis == null) smallNIconDis = loadIcon ("images/smallN_dis.gif");
+	if (smallAIcon    == null) smallAIcon    = loadIcon ("images/smallA.gif");
+	if (smallAIconDis == null) smallAIconDis = loadIcon ("images/smallA_dis.gif");
+	if (smallTIcon    == null) smallTIcon    = loadIcon ("images/smallT.gif");
+	if (smallTIconDis == null) smallTIconDis = loadIcon ("images/smallT_dis.gif");
+	if (smallIIcon    == null) smallIIcon    = loadIcon ("images/smallI.gif");
+	if (smallIIconDis == null) smallIIconDis = loadIcon ("images/smallI_dis.gif");
+	if (smallOIcon    == null) smallOIcon    = loadIcon ("images/smallO.gif");
+	if (smallOIconDis == null) smallOIconDis = loadIcon ("images/smallO_dis.gif");
+    }
+
+    //
+    private Icon loadIcon (String path) {
+	return SwingUtils.createIcon (path, Dashboard.class);
     }
 
     /*********************************************************************
@@ -312,6 +342,25 @@
     }
 
     /*********************************************************************
+     * Adding sorting items to the popup menu.
+     ********************************************************************/
+    protected void addSortingItems() {
+	popup.addSeparator();
+	popup.add
+	    (createMenuItem (new AbstractAction ("Sort by names") {
+		    public void actionPerformed (ActionEvent e) {
+			update (lastSorted = SORTED_BY_NAME, null);
+		    }
+		}, AC_NSORT, smallNIcon, smallNIconDis));
+	popup.add
+	    (createMenuItem (new AbstractAction ("Sort by authorities") {
+		    public void actionPerformed (ActionEvent e) {
+			update (lastSorted = SORTED_BY_AUTHORITY, null);
+		    }
+		}, AC_ASORT, smallAIcon, smallAIconDis));
+    }
+
+    /*********************************************************************
      * Collapse all nodes, starting from the root. <p>
      ********************************************************************/
     protected void collapse() {
@@ -389,7 +438,8 @@
 	Enumeration en = root.depthFirstEnumeration();
 	while (en.hasMoreElements()) {
 	    DefaultMutableTreeNode node = (DefaultMutableTreeNode)en.nextElement();
-	    if (toBeHighlighted.contains (node.getUserObject().toString())) {
+// 	    if (toBeHighlighted.contains (node.getUserObject().toString())) {
+	    if (toBeHighlighted.contains ( ((CommonNode)node.getUserObject()).getValue())) {
 		makeVisible (new TreePath (tModel.getPathToRoot (node)));
 	    }
 	}

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/10/28 11:30:37	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/11/02 06:39:06	1.7
@@ -46,8 +46,6 @@
        org.apache.commons.logging.LogFactory.getLog (DataTypesTree.class);
 
     // 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";
 
@@ -56,7 +54,6 @@
     CommonConsole console;
 
     MobyDataType[] dataTypes = null;
-    int lastSorted = SORTED_BY_NAME;
     boolean showBadGuys = false;
     boolean showMembers = false;
     JCheckBoxMenuItem deprecatedBox;
@@ -83,21 +80,7 @@
      ********************************************************************/
     protected void createPopups (String title) {
 	super.createPopups (title);
-	popup.addSeparator();
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by names") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_NAME, null);
-			deprecatedBox.setEnabled (true);
-		    }
-		}, AC_NSORT));
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by authorities") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_AUTHORITY, null);
-			deprecatedBox.setEnabled (false);
-		    }
-		}, AC_ASORT));
+	addSortingItems();
 	popup.addSeparator();
 
 	JCheckBoxMenuItem showBox = new JCheckBoxMenuItem ("Show HAS/HASA members");

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.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/NamespacesTree.java	2005/10/28 13:39:09	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.java	2005/11/02 06:39:06	1.2
@@ -45,16 +45,11 @@
     private static org.apache.commons.logging.Log log =
        org.apache.commons.logging.LogFactory.getLog (NamespacesTree.class);
 
-    // action commands for popup menu items
-    protected final static String AC_NSORT = "ac-nsort";
-    protected final static String AC_ASORT = "ac-asort";
-
     // remembered from constructor
     RegistryModel registryModel;
     CommonConsole console;
 
     MobyNamespace[] namespaces = null;
-    int lastSorted = SORTED_BY_NAME;
     MobyException updateException = null;
 
     final static String NAMESPACES_ACCESS_ERROR =
@@ -73,24 +68,11 @@
     }
 
     /*********************************************************************
-     * Adding data types tree specific menu items to a
-     * right-click-popup.
+     *
      ********************************************************************/
     protected void createPopups (String title) {
 	super.createPopups (title);
-	popup.addSeparator();
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by names") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_NAME, null);
-		    }
-		}, AC_NSORT));
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by authorities") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_AUTHORITY, null);
-		    }
-		}, AC_ASORT));
+	addSortingItems();
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/10/28 13:39:09	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/11/02 06:39:06	1.12
@@ -13,6 +13,7 @@
 import org.biomoby.shared.NoSuccessException;
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.MobyServiceType;
+import org.biomoby.shared.MobyService;
 import org.biomoby.shared.MobyNamespace;
 import org.biomoby.shared.CentralAll;
 import org.biomoby.client.CentralDigestCachedImpl;
@@ -46,6 +47,7 @@
     Hashtable dataTypesTable = new Hashtable();
     Hashtable serviceTypesTable = new Hashtable();
     Hashtable namespacesTable = new Hashtable();
+    Hashtable servicesTable = new Hashtable();
 
     private static final String MSG_REG_PENDING_CURATION =
     "Registration reports 'Pending curation'...\n" +
@@ -183,13 +185,13 @@
     public void registerServiceType (MobyServiceType serviceType)
 	throws MobyException {
 	initWorker();
- 	try {
-	    worker.registerServiceType (serviceType);
-	} catch (PendingCurationException e) {
-	    throw new MobyException (MSG_REG_PENDING_CURATION);
-	} catch (NoSuccessException e) {
-	    throw new MobyException (MSG_REG_NO_SUCCESS + e.getMessage());
-	}
+//  	try {
+// 	    worker.registerServiceType (serviceType);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_REG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_REG_NO_SUCCESS + e.getMessage());
+// 	}
     }
 
     /*********************************************************************
@@ -198,13 +200,13 @@
     public void unRegisterServiceType (MobyServiceType serviceType)
 	throws MobyException {
 	initWorker();
- 	try {
-	    worker.unregisterServiceType (serviceType);
-	} catch (PendingCurationException e) {
-	    throw new MobyException (MSG_UNREG_PENDING_CURATION);
-	} catch (NoSuccessException e) {
-	    throw new MobyException (MSG_UNREG_NO_SUCCESS + e.getMessage());
-	}
+//  	try {
+// 	    worker.unregisterServiceType (serviceType);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_UNREG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_UNREG_NO_SUCCESS + e.getMessage());
+// 	}
     }
 
     /*********************************************************************
@@ -269,13 +271,13 @@
     public void registerNamespace (MobyNamespace namespace)
 	throws MobyException {
 	initWorker();
- 	try {
-	    worker.registerNamespace (namespace);
-	} catch (PendingCurationException e) {
-	    throw new MobyException (MSG_REG_PENDING_CURATION);
-	} catch (NoSuccessException e) {
-	    throw new MobyException (MSG_REG_NO_SUCCESS + e.getMessage());
-	}
+//  	try {
+// 	    worker.registerNamespace (namespace);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_REG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_REG_NO_SUCCESS + e.getMessage());
+// 	}
     }
 
     /*********************************************************************
@@ -284,13 +286,13 @@
     public void unRegisterNamespace (MobyNamespace namespace)
 	throws MobyException {
 	initWorker();
- 	try {
-	    worker.unregisterNamespace (namespace);
-	} catch (PendingCurationException e) {
-	    throw new MobyException (MSG_UNREG_PENDING_CURATION);
-	} catch (NoSuccessException e) {
-	    throw new MobyException (MSG_UNREG_NO_SUCCESS + e.getMessage());
-	}
+//  	try {
+// 	    worker.unregisterNamespace (namespace);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_UNREG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_UNREG_NO_SUCCESS + e.getMessage());
+// 	}
     }
 
     /*********************************************************************
@@ -345,6 +347,94 @@
 
     /*********************************************************************
      *
+     * Dealing with Moby Services.
+     *
+     ********************************************************************/
+
+
+    /*********************************************************************
+     *
+     ********************************************************************/
+    public void registerService (MobyService service)
+	throws MobyException {
+	initWorker();
+//  	try {
+// 	    worker.registerService (service);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_REG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_REG_NO_SUCCESS + e.getMessage());
+// 	}
+    }
+
+    /*********************************************************************
+     *
+     ********************************************************************/
+    public void unRegisterService (MobyService service)
+	throws MobyException {
+	initWorker();
+//  	try {
+// 	    worker.unregisterService (service);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException (MSG_UNREG_PENDING_CURATION);
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException (MSG_UNREG_NO_SUCCESS + e.getMessage());
+// 	}
+    }
+
+    /*********************************************************************
+     * Fetch services (from a cache or from a registry). When done,
+     * signal that services are updated. If an initiator is known (not
+     * null), signal, who asked for it, as well.
+     ********************************************************************/
+    public synchronized MobyService[] getServices (Object initiator)
+	throws MobyException {
+	initWorker();
+	if (initiator != null)
+	    fireEvent (initiator, AUTHORITIES_RESET, "", null);
+	MobyService[] services = worker.getServices();
+	servicesTable = new Hashtable();
+	for (int i = 0; i < services.length; i++)
+	    servicesTable.put (services[i].getUniqueName(),
+			       services[i]);
+ 	if (initiator != null)
+ 	    fireEvent (initiator, AUTHORITIES_UPDATED, "", services);
+	return services;
+    }
+
+    /*********************************************************************
+     *
+     ********************************************************************/
+    public MobyService getService (String combinedServiceName)
+	throws MobyException {
+	if (combinedServiceName == null)
+	    return null;
+	MobyService[] services = getServices (null);
+	return (MobyService)servicesTable.get (combinedServiceName);
+    }
+
+    /*********************************************************************
+     * Return a HashSet filled with names of services that have
+     * somewhere given 'searchText'. Add case-insensitivity to the
+     * regular expression in 'searchText'.
+     ********************************************************************/
+    public HashSet findInServices (String searchText)
+	throws MobyException {
+	HashSet found = new HashSet();
+	MobyService[] services = getServices (null);
+	if (! searchText.startsWith ("(?i)"))
+	    searchText = "(?i)" + searchText;
+	Pattern pattern = Pattern.compile (searchText);
+	for (int i = 0; i < services.length; i++) {
+	    if (pattern.matcher (services[i].toString()).find())
+		found.add (services[i].getUniqueName());
+	}
+	return found;
+    }
+
+
+    /*********************************************************************
+     *
      * The rest...
      *
      ********************************************************************/

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/10/28 13:39:09	1.15
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/11/02 06:39:06	1.16
@@ -119,7 +119,6 @@
 	console.setAppendMode (false);
 
 	// ontology trees
-	ServicesTree servicesTree = new ServicesTree();
 	DataTypesBoard dataTypesBoard =
 	    new DataTypesBoard (registryModel,
 				console,
@@ -135,9 +134,15 @@
 				 console,
 				 propertyChannel);
 	namespacesBoard.updateTree (CommonTree.SORTED_BY_NAME);
+	ServicesBoard servicesBoard =
+	    new ServicesBoard (registryModel,
+			       console,
+			       propertyChannel);
+	servicesBoard.updateTree (CommonTree.SORTED_BY_NAME);
 
+	// split it into moving panels
 	JSplitPane split1 = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT,
-					    servicesTree.scrollable(),
+					    servicesBoard,
 					    dataTypesBoard);
 	split1.setResizeWeight (0.5);
 	split1.setContinuousLayout (true);
@@ -318,35 +323,6 @@
     /**************************************************************************
      *
      **************************************************************************/
-    class ServicesTree extends CommonTree {
-	public ServicesTree() {
-	    super ("Services");
-	}
-    }
-
-
-    /**************************************************************************
-     *
-     **************************************************************************/
-    class ServiceTypesTree extends CommonTree {
-	public ServiceTypesTree() {
-	    super ("Service Types");
-	}
-    }
-
-
-    /**************************************************************************
-     *
-     **************************************************************************/
-    class NamespacesTree extends CommonTree {
-	public NamespacesTree() {
-	    super ("Namespaces");
-	}
-    }
-
-    /**************************************************************************
-     *
-     **************************************************************************/
     public String getName() {
 	return "Registry Browser";
     }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.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/ServiceTypesTree.java	2005/10/28 13:39:09	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.java	2005/11/02 06:39:06	1.3
@@ -46,16 +46,11 @@
     private static org.apache.commons.logging.Log log =
        org.apache.commons.logging.LogFactory.getLog (ServiceTypesTree.class);
 
-    // action commands for popup menu items
-    protected final static String AC_NSORT = "ac-nsort";
-    protected final static String AC_ASORT = "ac-asort";
-
     // remembered from constructor
     RegistryModel registryModel;
     CommonConsole console;
 
     MobyServiceType[] serviceTypes = null;
-    int lastSorted = SORTED_BY_NAME;
     MobyException updateException = null;
 
     final static String SERVICE_TYPES_ACCESS_ERROR =
@@ -74,24 +69,11 @@
     }
 
     /*********************************************************************
-     * Adding data types tree specific menu items to a
-     * right-click-popup.
+     *
      ********************************************************************/
     protected void createPopups (String title) {
 	super.createPopups (title);
-	popup.addSeparator();
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by names") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_NAME, null);
-		    }
-		}, AC_NSORT));
-	popup.add
-	    (createMenuItem (new AbstractAction ("Sort by authorities") {
-		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_AUTHORITY, null);
-		    }
-		}, AC_ASORT));
+	addSortingItems();
     }
 
     /*********************************************************************




More information about the MOBY-guts mailing list