[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Fri Oct 28 07:58:08 UTC 2005


senger
Fri Oct 28 03:58:08 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv12421/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractModel.java CommonBoard.java CommonTree.java 
	Dashboard.java DashboardPanel.java DashboardProperties.java 
	DataTypesBoard.java DataTypesTree.java NOTES 
	RegistryModel.java 
Added Files:
	GraphColours.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard GraphColours.java,NONE,1.1 AbstractModel.java,1.2,1.3 CommonBoard.java,1.2,1.3 CommonTree.java,1.7,1.8 Dashboard.java,1.8,1.9 DashboardPanel.java,1.5,1.6 DashboardProperties.java,1.7,1.8 DataTypesBoard.java,1.3,1.4 DataTypesTree.java,1.4,1.5 NOTES,1.11,1.12 RegistryModel.java,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractModel.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/AbstractModel.java	2005/10/27 08:55:48	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractModel.java	2005/10/28 07:58:08	1.3
@@ -8,36 +8,12 @@
 
 package org.biomoby.service.dashboard;
 
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeSupport;
-
 /**
  * A common super-class for all Dashboard models. A model is a worker
  * for a panel: a panel displays what its model provides. <p>
  *
  * This abstract parent helps to deal with listening and fireing
- * property changes. Here is how it works generally: <p>
- *
- * <ul>
- *
- * <li> Each model gets (from its panel) an instance of a
- * <tt>PropertyChangeSupport</tt> class which gives it a list of
- * registered listeners, so a model can fire messages to them. For
- * example, a RegistryPanel may fire a message that a new list of data
- * types is available. Or typically a model will send a hear-beat
- * messages if it is working on a long-run job (this messages will be
- * intercept by a StatusBar, for example). <p>
- *
- * Note, however, that this shared <tt>PropertyChangeSupport</tt>
- * object knows only about a panel (it was created for a panel, not
- * for a model) so a model cannot use it to add its own listeners
- * (they would become listeners of a panel, not a model). In the
- * practise, this should not be a problem I guess. <p>
- *
- * <li> Each model is also a listener of property changes. <p>
- *
- * </ul> <p>
+ * property changes via a property channel. <p>
  *
  * @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
  * @version $Id$

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonBoard.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/CommonBoard.java	2005/10/27 08:55:48	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonBoard.java	2005/10/28 07:58:08	1.3
@@ -42,6 +42,9 @@
     extends JPanel
     implements NotificationListener {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
+
     protected RegistryModel model;
     protected PropertyChannel channel;
 
@@ -69,7 +72,7 @@
      * Update the underlying tree.
      ********************************************************************/
     public void updateTree (int howSorted) {
-	tree.update (howSorted);
+	tree.update (howSorted, null);
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/26 08:05:18	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/28 07:58:08	1.8
@@ -166,7 +166,7 @@
      * Get data from a registry model and update the tree. Will be
      * overwritten by subclass.
      ********************************************************************/
-    public void update (int howSorted) {
+    public void update (int howSorted, Object data) {
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java	2005/10/27 08:55:48	1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java	2005/10/28 07:58:08	1.9
@@ -26,6 +26,7 @@
 
 import java.awt.GridBagLayout;
 import java.awt.Font;
+import java.awt.Color;
 import java.awt.Dimension;
 
 import java.beans.PropertyChangeListener;
@@ -50,10 +51,14 @@
 public class Dashboard
     implements DashboardPanel, ChangeListener {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
+
     private JComponent dashboard;
     private DashboardHeader header;
     public static boolean useLoadMonitor = true;
     protected JTabbedPane tabbedPane;
+    protected Color bgcolor;
     protected DashboardPanel[] panels;
     protected PropertyChannel propertyChannel;
     protected static Properties dashboardProperties;
@@ -75,8 +80,8 @@
 		dashboardProperties.load (resourceURL.openStream());
 	    }
 	} catch (Exception e) {
-	    System.err.println ("WARNING: Cannot find/open/read dasboard property file " +
-				DASHBOARD_PROPERTIES_FILE + ": " + e.toString());
+	    log.warn ("Cannot find/open/read dasboard property file " +
+		      DASHBOARD_PROPERTIES_FILE + ": " + e.toString());
 	}
     }
 
@@ -181,8 +186,12 @@
 	    ProgressView.monitor.show ("Welcome to Biomoby Dashboard");
 	}
 
+	
 	// create itself
 	JPanel p = new JPanel (new GridBagLayout(), true);
+	bgcolor = GraphColours.getColour ((String)dashboardProperties.get (DP_BGCOLOR),
+					  p.getBackground());
+	p.setBackground (bgcolor);
 
         header = getHeader();
 	tabbedPane = new JTabbedPane();
@@ -222,6 +231,7 @@
     class DashboardHeader extends JPanel {
 	public DashboardHeader (Properties props) {
 	    super (new GridBagLayout());
+	    setBackground (bgcolor);
 	    JLabel mainTitle = getTitle();
 	    JLabel mainIcon =
 		new JLabel ("",

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardPanel.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardPanel.java	2005/10/27 08:55:48	1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardPanel.java	2005/10/28 07:58:08	1.6
@@ -12,18 +12,11 @@
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.Icon;
 import javax.swing.JComponent;
-import java.beans.PropertyChangeListener;
 
 /**
  * An interface that must be implemented by each panel that wants to
  * sit on a dashboard. <p>
  *
- * WORK IN PROGRESS <p>
- *
- * All classes that implements this interface (i.e. all dashboard
- * panels) are also PropertyChangeListener. It allows them to listen
- * to changes happening in other panels. <p>
- *
  * @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
  * @version $Id$
  */
@@ -70,20 +63,4 @@
      **************************************************************************/
     Icon getIcon();
 
-//     /**************************************************************************
-//      * Add a PropertyChangeListener to the listener list of a
-//      * panel. All listeners will be notified if this panel changes
-//      * some property. <p>
-//      *
-//      * The panel should document what properties can fire - but at the
-//      * moment it is not part of its interface. <p>
-//      *
-//      **************************************************************************/
-//     void addPropertyChangeListener (PropertyChangeListener listener);
-
-//     /**************************************************************************
-//      * Remove a PropertyChangeListener.
-//      **************************************************************************/
-//     void removePropertyChangeListener(PropertyChangeListener listener);
-
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java	2005/10/26 08:05:18	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java	2005/10/28 07:58:08	1.8
@@ -13,9 +13,6 @@
 import javax.swing.Icon;
 import javax.swing.JComponent;
 
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-
 /**
  * A list of names of most/all recognized properties that can be fired
  * by dashboard panels, and a list of names of Java properties that
@@ -71,6 +68,13 @@
      * recommended) or a relative path whose beginning can be found
      * somewhere on the CLASSPATH.
      */
+
     static final String DP_ICON = "dashboard.icon";
+    /** A property name. Its value contains a color name used to paint
+     * main dashboard background. The name can be a color name, or a
+     * number in various format (see <tt>GraphColours</tt> for
+     * details).
+     */
+    static final String DP_BGCOLOR = "dashboard.bgcolor";
 
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.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/DataTypesBoard.java	2005/10/27 08:55:48	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.java	2005/10/28 07:58:08	1.4
@@ -8,6 +8,7 @@
 
 package org.biomoby.service.dashboard;
 
+import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.event.NotificationEvent;
 import org.biomoby.shared.event.Notifier;
 import org.tulsoft.shared.UUtils;
@@ -27,6 +28,9 @@
 public class DataTypesBoard
     extends CommonBoard {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
+
     /*********************************************************************
      * Constructor. <p>
      *
@@ -64,13 +68,15 @@
      *
      ********************************************************************/
     public void notified (NotificationEvent event) {
+	Object initiator;
 	switch (event.getType()) {
 	case Notifier.DATA_TYPES_START:
 	    createProgressBar (Notifier.SIGNAL_CANCEL_DATA_TYPES);
 	    insertProgressBar();
 	    break;
 	case Notifier.DATA_TYPES_COUNT:
-	    calibrateProgressBar (UUtils.toInt (event.getMessage()));
+	    if (event.getMessage() instanceof Integer)
+		calibrateProgressBar ( ((Integer)event.getMessage()).intValue() );
 	    break;
  	case Notifier.DATA_TYPE_LOADING:
 	    channel.fire (DashboardProperties.DP_STATUS_MSG, event.getMessage());
@@ -81,9 +87,21 @@
  	case Notifier.DATA_TYPES_END:
  	case Notifier.DATA_TYPES_CANCELLED:
  	case Notifier.DATA_TYPES_RESET:
-	    channel.fire (DashboardProperties.DP_STATUS_MSG, "Done");
+	    initiator = event.getSource();
+	    if (tree == initiator)
+		channel.fire (DashboardProperties.DP_STATUS_MSG, "Done");
 	    removeProgressBar();
 	    break;
+ 	case Notifier.DATA_TYPES_UPDATED:
+	    initiator = event.getSource();
+	    if (tree != initiator) {
+		// someone else (ot this instance) initiated request
+		// for updating data types - so we need to update our
+		// own tree - using for that data types included in
+		// this event
+		tree.update (-1, (MobyDataType[])event.getDetails());
+	    }
+	    break;
 	}
 
     }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.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/DataTypesTree.java	2005/10/25 09:02:07	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/10/28 07:58:08	1.5
@@ -42,6 +42,9 @@
 public class DataTypesTree
     extends CommonTree {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
+
     // action commands for popup menu items
     protected final static String AC_NSORT = "ac-nsort";
     protected final static String AC_ASORT = "ac-asort";
@@ -87,14 +90,14 @@
 	popup.add
 	    (createMenuItem (new AbstractAction ("Sort by names") {
 		    public void actionPerformed (ActionEvent e) {
-			update (lastSorted = SORTED_BY_NAME);
+			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);
+			update (lastSorted = SORTED_BY_AUTHORITY, null);
 			deprecatedBox.setEnabled (false);
 		    }
 		}, AC_ASORT));
@@ -105,7 +108,7 @@
 	showBox.addItemListener (new ItemListener() {
 		public void itemStateChanged  (ItemEvent e) {
 		    showMembers = (e.getStateChange() == ItemEvent.SELECTED);
-		    update (lastSorted);
+		    update (lastSorted, null);
 		}
 	    });
 	popup.add (showBox);
@@ -116,7 +119,7 @@
 		public void itemStateChanged  (ItemEvent e) {
 		    showBadGuys = (e.getStateChange() == ItemEvent.SELECTED);
 		    if (showBadGuys)
-			update (lastSorted);
+			update (lastSorted, null);
 		    else
 			removeBadGuys();
 		}
@@ -125,20 +128,35 @@
     }
 
     /*********************************************************************
-     * Get data from a registry model and update the tree.
+     * Get data (usually from a registry model, but if not null, take
+     * them from 'newData') and update the tree.
      ********************************************************************/
-    public void update (int howSorted) {
-	setEnabledPopup (false);
+    public void update (int howSorted, Object newData) {
+	if (howSorted < 0) howSorted = lastSorted;
 
+	setEnabledPopup (false);
 	updateException = null;
+	final Object source = this;
 	final int sorted = howSorted;
+	final MobyDataType[] newDataTypes =
+	    (newData == null ? null : (MobyDataType[])newData);
+
 	final SwingWorker worker = new SwingWorker() {
 		public Object construct() {
 		    try {
+			// get data types (unless you already have them)
+			if (newDataTypes == null)
+			    dataTypes = registryModel.getDataTypes (source);
+			else
+			    dataTypes = newDataTypes;
+
+			// ...and sort them accordingly
 			if (sorted == SORTED_BY_AUTHORITY)
-			    dataTypes = registryModel.getDataTypesByAuthority();
+			    java.util.Arrays.sort
+				(dataTypes, MobyDataType.getAuthorityComparator());
 			else
-			    dataTypes = registryModel.getDataTypesByNames();
+			    java.util.Arrays.sort (dataTypes);
+
 		    } catch (MobyException e) {
 			updateException = e;
 		    }
@@ -277,7 +295,7 @@
      * updating) cache.
      ********************************************************************/
     protected void reload() {
-	update (lastSorted);
+	update (lastSorted, null);
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,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/NOTES	2005/10/26 08:05:18	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/10/28 07:58:08	1.12
@@ -1,40 +1,14 @@
-? logging (LogPanel and/or usual logging to a file?)
-* communication with StatusBar (incl. progress bar, cancel button)
-* disabling things during a long-time operation
-* general Console panel (save button; various renderes?)
-* graphics to trees
-
---- 
-To put this somewhere (a small "Memory panel" that can be add
-anywhere in time of debugging...):
-
-The heap is the area in memory in which objects are created.
-
-    // Get current size of heap in bytes
-    long heapSize = Runtime.getRuntime().totalMemory();
-    
-    // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
-    // Any attempt will result in an OutOfMemoryException.
-    long heapMaxSize = Runtime.getRuntime().maxMemory();
-    
-    // Get amount of free memory within the heap in bytes. This size will increase
-    // after garbage collection and decrease as new objects are created.
-    long heapFreeSize = Runtime.getRuntime().freeMemory();
-
----
-
 TODO generally:
 ---------------
 
+? some of the notification stuff can inherir from propertychange stuff
+
 * notice that the dasboard is used the first time and offer to create
 a list of wanted panels (some of them are suggested as default)
 
 * notice that user does not use cache (and that he did not select "do
 not check it at startup") and tell him "do you want a cache?"
 
-* BUG: not sure why so many (repeated) changes from the actionlistener
-in JFieldTextWithHistory
-
 ? select a part of an error message and highlight it in red?
 
 ? HELP (in a Dashboard Menu)
@@ -43,27 +17,13 @@
     - credits
     - add dynamically a URL from dashboard.properties...
 
-TODO with views:
-----------------
 * change onMethods() to be protected or even private...
 
-* add a progress bar to the status bar (on the right)
-  - add also a cancel buton there
-  - do not allow more than one progressbar-aware action in the same time
-    file:///c/Development/java-tutorial/uiswing/components/progress.html
-
-? small icons to buttons
-? use FileSystemView in file choosers
-? alltools2:
-  - combo box history is not updated if exit happened while focus is still in the text field
-
-? configure dashboard from menu:
-  * configure dashbard (add/remove dynamically panels)
-  * configure user preferences
+? improve API javadoc of all these Central*Impl
+? start to work on/think of the RDF-based cache 
 
 TODO for cache:
 ---------------
-* emit log events; use them also in cmdline clients
 * poor-man update: keep what's there but add what is not there
   (and perhaps delete what should not be there) - but do not
   check any age of existing
@@ -73,15 +33,13 @@
 * remove memory-caching from CentralImpl
 * graphics by default: yes for datatyeps and no for services
 
-? improve API javadoc of all these Central*Impl
-? start to work on/think of the RDF-based cache 
-
 General options (available from the menu)
 ---------------
 * export/import user preferences
 * set-up what panels are wanted
 * language ( => use proper ResourceBundler...)
 
+
 Registry panel
 --------------
 
@@ -114,10 +72,22 @@
 - verify registry
 - browsing in graphs
 - RDF resources
-- Log panel
-- Configure a new Dashboard
-
 - Debugging panel (with a Memory Panel embedded; replacing current two pannels)
+  To put this somewhere (a small "Memory panel" that can be add
+  anywhere in time of debugging...):
+
+  The heap is the area in memory in which objects are created.
+
+    // Get current size of heap in bytes
+    long heapSize = Runtime.getRuntime().totalMemory();
+    
+    // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
+    // Any attempt will result in an OutOfMemoryException.
+    long heapMaxSize = Runtime.getRuntime().maxMemory();
+    
+    // Get amount of free memory within the heap in bytes. This size will increase
+    // after garbage collection and decrease as new objects are created.
+    long heapFreeSize = Runtime.getRuntime().freeMemory();
 
 UNSOLVED (mysteries and not-yet-dones)
 ========
@@ -130,12 +100,6 @@
   - the BuildDataTypeTree is sometimes damaged (after adding a member
 node); not sure how to reproduce it
 
-  ! loading... does not sync correctly with the browser panel
-
-  ! more generally: simplify (or at least document) what kind of notifications
-    are used (now, it seems to be confusin what has PropertyChannel and what
-    is registered by 'support')
-
   ! finish all the caching stuff (separate scrap of paper)
 
 * After registration, update cache, update list
@@ -144,6 +108,14 @@
 
 * Icons:
   - better icon for AddHAS (with a small star)
+  ? small icons to buttons
+  ? graphics to trees
+  - small icon to the status bar
 
 * alltools2:
   - JTextFieldWithHistory should remember also an empty value ("")
+  - combo box history is not updated if exit happened while focus is still in the text field
+  ? use FileSystemView in file choosers
+  * BUG: not sure why so many (repeated) changes from the actionlistener
+    in JFieldTextWithHistory
+

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/10/27 08:55:48	1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/10/28 07:58:08	1.9
@@ -19,13 +19,8 @@
 import org.biomoby.shared.event.NotificationEvent;
 import org.biomoby.shared.event.NotificationListener;
 
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeSupport;
-
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Comparator;
 import java.util.regex.Pattern;
 
 /**
@@ -41,6 +36,9 @@
     extends AbstractModel
     implements Notifier {
 
+    private static org.apache.commons.logging.Log log =
+       org.apache.commons.logging.LogFactory.getLog (RegistryModel.class);
+
     CentralAll worker;
     boolean useCache = true;
     Hashtable dataTypesTable;
@@ -102,35 +100,18 @@
     }
 
     /*********************************************************************
-     *
+     * Fetch data types (from a cache or from a registry). When done,
+     * signal that data type are updated. If an initiator is known
+     * (not null), signal, who asked for data, as well.
      ********************************************************************/
-    public MobyDataType[] getDataTypesByNames()
+    public synchronized MobyDataType[] getDataTypes (Object initiator)
 	throws MobyException {
 	initWorker();
-	fireEvent (DATA_TYPES_RESET, "", null);
+	if (initiator != null)
+	    fireEvent (initiator, DATA_TYPES_RESET, "", null);
 	MobyDataType[] dataTypes = worker.getDataTypes();
- 	java.util.Arrays.sort (dataTypes);
-	return dataTypes;
-    }
-
-    /*********************************************************************
-     *
-     ********************************************************************/
-    public MobyDataType[] getDataTypesByAuthority()
-	throws MobyException {
-	initWorker();
-	fireEvent (DATA_TYPES_RESET, "", null);
-	MobyDataType[] dataTypes = worker.getDataTypes();
-	java.util.Arrays.sort
-	    (dataTypes,
-	     new Comparator() {
-		 public int compare (Object o1, Object o2) {
-		     String a1 = ((MobyDataType)o1).getAuthority();
-		     String a2 = ((MobyDataType)o2).getAuthority();
-		     return (a1).compareToIgnoreCase ((String)a2);
-		 }
-	     });
-
+ 	if (initiator != null)
+ 	    fireEvent (initiator, DATA_TYPES_UPDATED, "", dataTypes);
 	return dataTypes;
     }
 
@@ -142,7 +123,7 @@
 	if (dataTypeName == null)
 	    return null;
 
-	MobyDataType[] dataTypes = getDataTypesByNames();
+	MobyDataType[] dataTypes = getDataTypes (null);
 
 	if (dataTypesTable == null) {
 	    dataTypesTable = new Hashtable();
@@ -161,7 +142,7 @@
     public HashSet find (String searchText)
 	throws MobyException {
 	HashSet found = new HashSet();
-	MobyDataType[] dataTypes = getDataTypesByNames();
+	MobyDataType[] dataTypes = getDataTypes (null);
 	if (! searchText.startsWith ("(?i)"))
 	    searchText = "(?i)" + searchText;
 	Pattern pattern = Pattern.compile (searchText);
@@ -233,8 +214,7 @@
 	    initWorker();
 	    ((Notifier)worker).addNotificationListener (l);
 	} catch (MobyException e) {
-	    // TBD with proper logging
-	    System.err.println ("ERROR: " + e);
+	    log.error (e.getMessage());
 	}
     }
 
@@ -246,8 +226,7 @@
 	    initWorker();
 	    ((Notifier)worker).addNotificationListeners (l);
 	} catch (MobyException e) {
-	    // TBD with proper logging
-	    System.err.println ("ERROR: " + e);
+	    log.error (e.getMessage());
 	}
     }
 
@@ -259,8 +238,7 @@
 	    initWorker();
 	    ((Notifier)worker).removeNotificationListener (l);
 	} catch (MobyException e) {
-	    // TBD with proper logging
-	    System.err.println ("ERROR: " + e);
+	    log.error (e.getMessage());
 	}
     }
 
@@ -272,8 +250,7 @@
 	    initWorker();
 	    ((Notifier)worker).removeNotificationListeners (l);
 	} catch (MobyException e) {
-	    // TBD with proper logging
-	    System.err.println ("ERROR: " + e);
+	    log.error (e.getMessage());
 	}
     }
 
@@ -285,8 +262,7 @@
 	    initWorker();
 	    return ((Notifier)worker).getNotificationListeners();
 	} catch (MobyException e) {
-	    // TBD with proper logging
-	    System.err.println ("ERROR: " + e);
+	    log.error (e.getMessage());
 	    return new NotificationListener[] {};
 	}
     }
@@ -307,4 +283,26 @@
 	    ((Notifier)worker).fireEvent (type, message, details);
     }
 
+    /*********************************************************************
+     *
+     ********************************************************************/
+    public void fireEvent (NotificationEvent event) {
+	if (worker != null)
+	    ((Notifier)worker).fireEvent (event);
+    }
+
+
+    /*********************************************************************
+     *
+     ********************************************************************/
+    protected void fireEvent (Object source,
+			      int type, Object message, Object details) {
+	NotificationEvent event = null;
+	if (details == null)
+	    event = new NotificationEvent (source, type, message);
+	else
+	    event = new NotificationEvent (source, type, message, details);
+	fireEvent (event);
+    }
+
 }




More information about the MOBY-guts mailing list