[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Wed Nov 9 16:23:32 UTC 2005


senger
Wed Nov  9 11:23:32 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv32177/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractPanel.java NOTES RegistrationPanel.java 
	RegistrationServiceTypeSubPanel.java RegistryModel.java 
	RegistryPanel.java ServiceTypesBoard.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard AbstractPanel.java,1.18,1.19 NOTES,1.20,1.21 RegistrationPanel.java,1.14,1.15 RegistrationServiceTypeSubPanel.java,1.4,1.5 RegistryModel.java,1.16,1.17 RegistryPanel.java,1.20,1.21 ServiceTypesBoard.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/09 05:29:38	1.18
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/09 16:23:32	1.19
@@ -404,7 +404,7 @@
         clearButton.setFocusPainted (false);
         clearButton.setMargin (new Insets (0,0,0,0));
         clearButton.setContentAreaFilled (false);
-        clearButton.setToolTipText ("Clear text area");
+        clearButton.setToolTipText ("Clear " + title.toLowerCase() + " text area");
 	clearButton.addActionListener (new ActionListener() {
 		public void actionPerformed (ActionEvent e) {
 		    area.requestFocusInWindow();

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/11/07 17:14:46	1.20
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/11/09 16:23:32	1.21
@@ -1,15 +1,14 @@
+* after unregistration, fill the form with just unregistered entity -
+  so it is easier to update it and register again
 
 * better initial dimension of the whole dashboard
 * too much empty space in the dashboard title...
   (perhaps to move the icon somewhere else - like a "splash panel")
 
 ---
-* show/store XML sent to register this service
-  (a place for using it other time?)
-
 * how to squeeze too long combo boxes into smaller place ?
 
-*introduce perhaps preferred/minimal/maximal sizes into text fields?
+* introduce perhaps preferred/minimal/maximal sizes into text fields?
 
 * registration: selecting an authority is really propagated to the
 text fields? (Do for data type registration the same as was done for
@@ -130,6 +129,8 @@
 * The same, after de-registration
 * Then make the reg/unreg real...
 
+* log4j.configuration property - works only from Ant... add it to the
+  cmd-line clients, as well
 
 * alltools2:
   - JTextFieldWithHistory should remember also an empty value ("")

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/11/09 05:29:38	1.14
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/11/09 16:23:32	1.15
@@ -284,7 +284,7 @@
 			error ("An error occured when trying to register a new entity.\n\n",
 			       exception);
 		    registerButton.setEnabled (true);
-		    showXMLButton.setEnabled (true);
+		    fromXMLButton.setEnabled (true);
 		    maybeDisableVerbose (bag);
 		    console.setAppendMode (oldAppendMode);
 		}
@@ -299,6 +299,13 @@
 	throws MobyException {
     }
 
+    /**************************************************************************
+     * Should be overwritten by sub-panels.
+     **************************************************************************/
+    protected void updateCache()
+	throws MobyException {
+    }
+
     /*********************************************************************
      *
      ********************************************************************/
@@ -321,6 +328,8 @@
 			console.setText (registryModel.callRegistry (myMethodName,
 								     xmlFile));
 			console.setText ("\n");
+			updateCache();
+
 		    } catch (MobyException e) {
 			exception = e;
 		    }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationServiceTypeSubPanel.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/RegistrationServiceTypeSubPanel.java	2005/11/09 05:29:38	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationServiceTypeSubPanel.java	2005/11/09 16:23:32	1.5
@@ -200,6 +200,7 @@
 			     serviceType.toString() + "\n");
 	    registryModel.registerServiceType (serviceType);
 	    console.setText ("\nRegistration successful!\n\n");
+	    updateCache();
 	} else {
 	    String xml = registryModel.getRegisterServiceTypeXML (serviceType);
 	    console.setText ("\n" + xml + "\n");
@@ -208,6 +209,16 @@
     }
 
     /**************************************************************************
+     * This is separated here because the registration from XML is
+     * done in the super-class (RegistrationPanel), but the update
+     * must be done here, in sub-class.
+     **************************************************************************/
+    protected void updateCache()
+	throws MobyException {
+	registryModel.updateServiceTypesCache();
+    }
+
+    /**************************************************************************
      *
      * Customized tree of service types - has different popup menus etc...
      *
@@ -352,6 +363,7 @@
 			    console.setText ("Service type to be unregistered: " + name + "\n");
 			    registryModel.unRegisterServiceType (serviceType);
 			    console.setText ("\nUnregistration successful!\n\n");
+			    updateCache();
 
 			} catch (MobyException e) {
 			    exception = e;

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/11/09 05:29:38	1.16
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/11/09 16:23:32	1.17
@@ -48,6 +48,8 @@
        org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
 
     CentralAll worker;
+    CentralDigestCachedImpl castWorker;
+
     boolean useCache = true;
     Hashtable dataTypesTable = new Hashtable();
     Hashtable serviceTypesTable = new Hashtable();
@@ -262,6 +264,27 @@
     }
 
     /*********************************************************************
+     *
+     ********************************************************************/
+    public void updateServiceTypesCache()
+	throws MobyException {
+	initWorker();
+	castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+	fireEvent (Notifier.SERVICE_TYPES_UPDATED, "", null);
+    }
+
+    /*********************************************************************
+     *
+     ********************************************************************/
+    public void reloadServiceTypesCache()
+	throws MobyException {
+	initWorker();
+	castWorker.removeFromCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+	castWorker.updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES);
+	fireEvent (Notifier.SERVICE_TYPES_UPDATED, "", null);
+    }
+
+    /*********************************************************************
      * Fetch service types (from a cache or from a registry). When done,
      * signal that service types are updated. If an initiator is known
      * (not null), signal, who asked for it, as well.
@@ -505,7 +528,7 @@
 
     /*********************************************************************
      *
-     * The rest...
+     * Dealing with local cache.
      *
      ********************************************************************/
 
@@ -521,6 +544,12 @@
 
     /*********************************************************************
      *
+     * The rest...
+     *
+     ********************************************************************/
+
+    /*********************************************************************
+     *
      ********************************************************************/
     protected void initWorker()
 	throws MobyException {
@@ -554,6 +583,7 @@
 						  maybeNewCacheDir);
 	    ((Notifier)worker).addNotificationListeners (nls);
 	}
+	castWorker = (CentralDigestCachedImpl)worker;
     }
 
     /*************************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/11/07 07:03:49	1.20
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/11/09 16:23:32	1.21
@@ -12,11 +12,16 @@
 import org.tulsoft.tools.gui.JTextFieldWithHistory;
 import org.tulsoft.tools.gui.JFileChooserWithHistory;
 
+import org.biomoby.shared.MobyException;
+import org.biomoby.shared.event.Notifier;
+import org.biomoby.client.CentralDigestCachedImpl;
+
 import javax.swing.JPanel;
 import javax.swing.JLabel;
 import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
+import javax.swing.JOptionPane;
 import javax.swing.JFileChooser;
 import javax.swing.JSplitPane;
 import javax.swing.JComponent;
@@ -40,10 +45,13 @@
 public class RegistryPanel
     extends AbstractPanel {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryPanel.class);
+
     // names of user preferences keys
     static final String USE_CACHE = "use-cache";
 
-    // associated model working behind the scenes
+    // associated model working behind the scene
     RegistryModel registryModel;
 
     // components that are used from more methods
@@ -53,6 +61,8 @@
     JLabel labelCacheDir;
     CommonConsole console;
 
+    JCheckBox bServices, bDataTypes, bNamespaces, bServiceTypes, bAll;
+
     // shared icons
     protected static Icon defaultsIcon;
     protected static Icon reloadIcon;
@@ -142,6 +152,37 @@
     /**************************************************************************
      *
      **************************************************************************/
+    private JPanel createCacheDialog (String introText) {
+	JPanel p = new JPanel (new GridBagLayout());
+	JLabel start = new JLabel (introText);
+
+	bServices = createCheckBox ("Services", false, KeyEvent.VK_S, null);
+	bDataTypes = createCheckBox ("Data types", false, KeyEvent.VK_D, null);
+	bNamespaces = createCheckBox ("Namespaces", false, KeyEvent.VK_N, null);
+	bServiceTypes = createCheckBox ("Service types", false, KeyEvent.VK_T, null);
+	bAll = createCheckBox ("All", false, KeyEvent.VK_A,
+			       new ItemListener() {
+				   public void itemStateChanged (ItemEvent e) {
+				       boolean enabled = (e.getStateChange() != ItemEvent.SELECTED);
+				       bServices.setEnabled (enabled);
+				       bDataTypes.setEnabled (enabled);
+				       bNamespaces.setEnabled (enabled);
+				       bServiceTypes.setEnabled (enabled);
+				   }
+			       });
+	// put it together
+ 	SwingUtils.addComponent (p, start,         0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, bServices,     0, 1, 1, 1, NONE, NWEST, 0.0, 0.0, BREATH_TOP);
+ 	SwingUtils.addComponent (p, bDataTypes,    0, 2, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, bNamespaces,   0, 3, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, bServiceTypes, 0, 4, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, bAll,          0, 5, 1, 1, NONE, NWEST, 0.0, 0.0, BREATH_TOP);
+	return p;
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
     public void onDefaults() {
 	registryURL.setText (registryModel.getDefaultRegistryEndpoint());
 	registryNS.setText (registryModel.getDefaultRegistryNamespace());
@@ -159,10 +200,84 @@
     public void onCacheErase() {
     }
 
+    final static String UPDATE_LABEL =
+    "<html>Update or reload your local cache<br>" +
+    "for the entities selected below.<p><p>" +
+
+    "<font color='red'>Update</font> is faster than reload but<br>" +
+    "it may not reflect changes in the<br>" +
+    "contents of the entities.<p><p>" +
+
+    "<font color='red'>Reload</font> is slower than update but it<br>" +
+    "guarantees that the full contents<br>" +
+    "of all cached entities is up to date.<p>";
+
     /**************************************************************************
      *
      **************************************************************************/
     public void onCacheUpdate() {
+	JPanel p = createCacheDialog (UPDATE_LABEL);
+	String[] buttons = new String[] { "Update", "Reload", "Cancel"};
+	int selected =
+	    JOptionPane.showOptionDialog (null, p,
+					  "Update/Reload local cache",
+					  JOptionPane.YES_NO_OPTION,
+					  JOptionPane.QUESTION_MESSAGE,
+					  confirmIcon,
+					  buttons,
+					  null);
+	boolean toReload;
+	if (selected == 0)
+	    toReload = false; // 'update' selected
+	else if (selected == 1)
+	    toReload = true;  // 'reload' selected
+	else
+	    return;           // cancelled
+
+	boolean all = bAll.isSelected();
+	if (all || bServices.isSelected())
+	    updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICES, toReload);
+	if (all || bDataTypes.isSelected())
+	    updateCache (CentralDigestCachedImpl.CACHE_PART_DATATYPES, toReload);
+	if (all || bNamespaces.isSelected())
+	    updateCache (CentralDigestCachedImpl.CACHE_PART_NAMESPACES, toReload);
+	if (all || bServiceTypes.isSelected())
+	    updateCache (CentralDigestCachedImpl.CACHE_PART_SERVICETYPES, toReload);
+    }
+	    
+    /**************************************************************************
+     *
+     **************************************************************************/
+    private void updateCache (String cachePart, boolean reload) {
+	final String myCachePart = cachePart;
+	final boolean myReload = reload;
+	final SwingWorker worker = new SwingWorker() {
+		MobyException exception = null;
+		public Object construct() {
+		    try {
+			if (myReload) {
+			    registryModel.reloadServiceTypesCache();
+			} else {
+			    registryModel.updateServiceTypesCache();
+			}
+		    } catch (MobyException e) {
+			exception = e;
+		    }
+		    return null;  // not used here
+		}
+
+		// runs on the event-dispatching thread.
+		public void finished() {
+		    if (log.isDebugEnabled())
+			log.debug (myReload ? "Reload of " : "Update of " + myCachePart + " finished");
+		    if (exception != null)
+			error ("An error occured when filling/updating the cache.\n\n",
+			       exception);
+		}
+
+	    };
+	worker.start(); 
+
     }
 
     /**************************************************************************
@@ -184,8 +299,8 @@
    	JLabel labelRegistryNS = new JLabel("Namespace (URI)");
 	registryNS = createText (null, "registryNamespace", DP_REGISTRY_NAMESPACE);
 	JButton reloadAllButton =
-	    createButton (" Reload all ",
-			  "Reload all ontology trees from the Biomoby registry",
+	    createButton (" Reload ",
+			  "Reload fully some or all ontology trees from the Biomoby registry",
 			  KeyEvent.VK_R,
 			  new ActionListener() {
 			      public void actionPerformed (ActionEvent e) {

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesBoard.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesBoard.java	2005/11/07 17:14:46	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesBoard.java	2005/11/09 16:23:32	1.4
@@ -88,12 +88,14 @@
  	case Notifier.SERVICE_TYPES_CANCELLED:
  	case Notifier.SERVICE_TYPES_RESET:
 	    initiator = event.getSource();
+// 	    log.info ("RESET initiator: " + initiator + ", this tree: " + tree);
 	    if (tree == initiator)
 		channel.fire (DashboardProperties.DP_STATUS_MSG, "Done");
 	    removeProgressBar();
 	    break;
  	case Notifier.SERVICE_TYPES_UPDATED:
 	    initiator = event.getSource();
+// 	    log.info ("UPDATED initiator: " + initiator + ", this tree: " + tree);
 	    if (tree != initiator) {
 		// someone else (of this instance) initiated request
 		// for updating service types - so we need to update our




More information about the MOBY-guts mailing list