[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Wed Oct 26 08:05:19 UTC 2005


senger
Wed Oct 26 04:05:18 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv30201/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractPanel.java BuildDataTypeTree.java CommonConsole.java 
	CommonTree.java DashboardProperties.java NOTES 
	RegistrationPanel.java RegistryModel.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard AbstractPanel.java,1.9,1.10 BuildDataTypeTree.java,1.3,1.4 CommonConsole.java,1.2,1.3 CommonTree.java,1.6,1.7 DashboardProperties.java,1.6,1.7 NOTES,1.10,1.11 RegistrationPanel.java,1.3,1.4 RegistryModel.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.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/AbstractPanel.java	2005/10/25 09:02:07	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/10/26 08:05:18	1.10
@@ -90,6 +90,8 @@
     // something need to be done only once - keep it here
     protected Icon panelIcon;
     protected JComponent pComponent;
+
+    // shared icons
     protected static Icon confirmIcon;
     protected static Icon warningIcon;
     protected static Icon clearIcon;
@@ -108,6 +110,7 @@
      ********************************************************************/
     protected AbstractPanel() {
 	support = new PropertyChangeSupport (this);
+	loadIcons();
     }
 
     /**************************************************************************
@@ -178,6 +181,22 @@
     abstract public String getName();
 
     //
+    // Few other methods
+    //
+
+    /*********************************************************************
+     * Load all menu icons.
+     ********************************************************************/
+    protected void loadIcons() {
+	if (clearIcon == null)
+	    clearIcon = SwingUtils.createIcon ("images/smallClear.gif", this);
+	if (warningIcon == null)
+	    warningIcon = SwingUtils.createIcon ("images/warningButton.gif", this);
+	if (confirmIcon == null)
+	    confirmIcon = SwingUtils.createIcon ("images/confirmButton.gif", this);
+    }
+
+    //
     // Methods to be used by sub-classes
     //
 
@@ -375,8 +394,6 @@
 	}
 
 	// reset/clear button
-	if (clearIcon == null)
-	    clearIcon = SwingUtils.createIcon ("images/smallClear.gif", this);
 	JButton clearButton = new JButton (clearIcon);
         clearButton.setFocusPainted (false);
         clearButton.setMargin (new Insets (0,0,0,0));
@@ -401,7 +418,7 @@
     protected String getPrefValue (String key,
 				   String defaultValue) {
 	Preferences node = PrefsUtils.getNode (this.getClass());
-	return node.get (key, defaultValue);
+ 	return showNewlines (node.get (key, defaultValue));
     }
 
     protected boolean getPrefValue (String key,
@@ -416,7 +433,7 @@
     protected void setPrefValue (String key,
 				 String value) {
 	Preferences node = PrefsUtils.getNode (this.getClass());
-	node.put (key, value);
+	node.put (key, hideNewlines (value));
     }
 
     protected void setPrefValue (String key,
@@ -426,12 +443,26 @@
     }
 
     /*********************************************************************
+     * Sorry for this hack, but I do not know better...
+     *
+     * Problem is that attribute values (preferences) ignore
+     * newlines. I wanted to replace them with something like '
'
+     * but this did not work because the ampersand was escape (as it
+     * should) to '&'. So I have to "invent" my own escaping by
+     * introducing MRVAJS.
+     ********************************************************************/
+    static final private String MRVAJS = "#MRVAJS#";
+    private static String hideNewlines (String value) {
+	return value.replaceAll ("\n", MRVAJS);
+    }
+    private static String showNewlines (String value) {
+	return value.replaceAll (MRVAJS, "\n");
+    }
+
+    /*********************************************************************
      * Return true if confirmation dialog passed.
      ********************************************************************/
     public static boolean confirm (Object msg) {
-	if (confirmIcon == null)
-	    confirmIcon =
-		SwingUtils.createIcon ("images/confirmButton.gif", Dashboard.class);
         return SwingUtils.confirm (null, msg, confirmIcon);
     }
 
@@ -439,9 +470,6 @@
      * Display an error message.
      ********************************************************************/
     public static void error (Object msg) {
-	if (warningIcon == null)
-	    warningIcon = SwingUtils.createIcon ("images/warningButton.gif",
-						 Dashboard.class);
 	JOptionPane.showMessageDialog (null, msg, "Error message",
 				       JOptionPane.PLAIN_MESSAGE, warningIcon);
     }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/BuildDataTypeTree.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/BuildDataTypeTree.java	2005/10/25 09:02:07	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/BuildDataTypeTree.java	2005/10/26 08:05:18	1.4
@@ -117,25 +117,6 @@
 	getSelectionModel().setSelectionMode
 	    (TreeSelectionModel.SINGLE_TREE_SELECTION);
 
-
-
-//  	setEditable (true);
-// 	DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree
-// 	    .getCellRenderer();
-// 	TreeCellEditor editor = new LeafCellEditor(tree, renderer);
-// 	tree.setCellEditor(editor);
-
-
-// 	// listen for when the selection changes
-// 	addTreeSelectionListener ( new TreeSelectionListener() {
-// 		public void valueChanged (TreeSelectionEvent e) {
-// 		    DefaultMutableTreeNode node =
-// 			(DefaultMutableTreeNode)getLastSelectedPathComponent();
-// 		    if (node == null) return;
-// 		    selected (node);
-// 		}
-// 	    });
-
 	// enable tool tips
 	ToolTipManager.sharedInstance().registerComponent (this);
 

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonConsole.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/CommonConsole.java	2005/10/22 14:35:46	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonConsole.java	2005/10/26 08:05:18	1.3
@@ -40,14 +40,18 @@
     // components
     JTextArea textArea;
     JCheckBox appendModeBox;
+    JButton cleanButton;
     boolean appendMode = true;
-    static Icon clearIcon;
+
+    // shared icons
+    static Icon clearIcon, clearIconDis;
 
     /*********************************************************************
      * Constructor.
      ********************************************************************/
     public CommonConsole() {
 	super();
+	loadIcons();
 	setLayout (new GridBagLayout());
 
         textArea = new JTextArea();
@@ -55,20 +59,22 @@
 	textArea.setEditable (false);
 	JScrollPane scroller = new JScrollPane (textArea);
 
-	JButton cleanButton = AbstractPanel.createButton
+	cleanButton = AbstractPanel.createButton
 	    (" Clean ",
 	     "Remove all messages from the console area",
 	     KeyEvent.VK_C,
 	     new ActionListener() {
 		 public void actionPerformed (ActionEvent e) {
-		     if (! "".equals (textArea.getText()) && AbstractPanel.confirm ("Remove all messages?"))
+		     if (! "".equals (textArea.getText()) && AbstractPanel.confirm ("Remove all messages?")) {
 			 textArea.setText ("");
+			 cleanButton.setEnabled (false);
+		     }
 		 }
 	     });
 
-	if (clearIcon == null)
-	    clearIcon = SwingUtils.createIcon ("images/smallClear.gif", this);
 	cleanButton.setIcon (clearIcon);
+	cleanButton.setDisabledIcon (clearIconDis);
+	cleanButton.setEnabled (false);
 
 	appendModeBox = AbstractPanel.createCheckBox
 	    ("append mode", appendMode, KeyEvent.VK_A,
@@ -99,6 +105,7 @@
 	    textArea.append (value);
 	else
 	    textArea.setText (value);
+	cleanButton.setEnabled (true);
     }
 
     /*********************************************************************
@@ -116,4 +123,14 @@
 	return appendMode;
     }
 
+    /*********************************************************************
+     * Load all menu icons.
+     ********************************************************************/
+    protected void loadIcons() {
+	if (clearIcon == null)
+	    clearIcon = SwingUtils.createIcon ("images/smallClear.gif", this);
+	if (clearIconDis == null)
+	    clearIconDis = SwingUtils.createIcon ("images/smallClear_dis.gif", this);
+    }
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.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/CommonTree.java	2005/10/25 09:02:07	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/10/26 08:05:18	1.7
@@ -28,6 +28,7 @@
 import javax.swing.tree.TreePath;
 import javax.swing.event.TreeSelectionListener;
 import javax.swing.event.TreeSelectionEvent;
+import javax.swing.SwingUtilities;
 
 import java.awt.Component;
 import java.awt.Font;
@@ -39,11 +40,6 @@
 import java.util.HashSet;
 import java.util.Enumeration;
 
-// import java.beans.PropertyChangeListener;
-// import java.beans.PropertyChangeEvent;
-// import java.beans.PropertyChangeSupport;
-
-
 /**
  * A common JTree re-used (and always slightly modified) by all
  * Biomoby registry trees. <p>
@@ -75,9 +71,6 @@
     static protected Icon menuCollapseIcon, menuCollapseIconDis;
     static protected Icon menuReloadIcon, menuReloadIconDis;
 
-//     protected PropertyChangeSupport support;
-//     protected boolean expanded = true;   // the status of the application list
-
     protected String rootNode;
 
     /*********************************************************************
@@ -89,20 +82,11 @@
 
 	// create an almost empty tree, only with a root node that
 	// contains just a String holding the name of the root node;
-//         setFont (new Font ("Dialog",  Font.PLAIN, 10));
         putClientProperty ("JTree.lineStyle", "Angled");
 	setCellRenderer (new CommonTreeCellRenderer());
 	getSelectionModel().setSelectionMode
 	    (TreeSelectionModel.SINGLE_TREE_SELECTION);
 
-//   	addMouseListener (new MouseAdapter() {
-// 		public void mouseClicked (MouseEvent e) {
-// 		    TreePath selPath = getPathForLocation (e.getX(), e.getY());
-// 		    if (e.getClickCount() == 1)
-// 			onSelected (selPath);
-// 		}
-// 	    });
-
 	// listen for when the selection changes
 	addTreeSelectionListener ( new TreeSelectionListener() {
 		public void valueChanged (TreeSelectionEvent e) {
@@ -178,7 +162,6 @@
  	return new JScrollPane (this);
     }
 
-
     /*********************************************************************
      * Get data from a registry model and update the tree. Will be
      * overwritten by subclass.
@@ -333,9 +316,6 @@
      * Expand all nodes, starting from the root. <p>
      ********************************************************************/
     protected void expand() {
-//  	SwingUtils.expandTree (this, (DefaultMutableTreeNode)getModel().getRoot());
-
-
 	final SwingWorker worker = new SwingWorker() {
 		public Object construct() {
 		    SwingUtils.expandTree (CommonTree.this, (DefaultMutableTreeNode)getModel().getRoot());
@@ -347,7 +327,6 @@
 		}
 	    };
 	worker.start(); 
-
     }
 
     /*********************************************************************
@@ -355,7 +334,6 @@
      * concrete tree.
      ********************************************************************/
     protected void reload() {
-	System.out.println ("Invoking a reload.");
     }
 
     /*********************************************************************
@@ -364,7 +342,6 @@
      * be overwritten by a concrete tree.
      ********************************************************************/
     protected void search (String searchText) {
-	System.out.println ("Search text: " + searchText);
     }
 
     /*********************************************************************
@@ -393,6 +370,9 @@
 	return result;
     }
     
+    /*********************************************************************
+     *
+     ********************************************************************/
     protected void highlightAndJumpTo (HashSet toBeHighlighted) {
 
 	CommonTreeCellRenderer r = (CommonTreeCellRenderer)getCellRenderer();
@@ -455,40 +435,16 @@
      * popup menu.
      ********************************************************************/
     protected void setEnabledPopupItem (String actionCommand, boolean enabled) {
- 	synchronized (popup) {
-	    Component[] components = popup.getComponents();
-	    for (int i = 0; i < components.length; i++) {
-		if ( components[i] instanceof JMenuItem &&
-		     actionCommand.equals (((JMenuItem)components[i]).getActionCommand()) ) {
-		    ((JMenuItem)components[i]).setEnabled (enabled);
-		    return;
-		}
-	    }
- 	}
-
-// 	final String ac = actionCommand;
-// 	final boolean fEnabled = enabled;
-// 	final SwingWorker worker = new SwingWorker() {
-// 		public Object construct() {
-// 		    synchronized (popup) {
-// 			Component[] components = popup.getComponents();
-// 			for (int i = 0; i < components.length; i++) {
-// 			    if ( components[i] instanceof JMenuItem &&
-// 				 ac.equals (((JMenuItem)components[i]).getActionCommand()) ) {
-// 				((JMenuItem)components[i]).setEnabled (fEnabled);
-// 				break;
-// 			    }
-// 			}
-// 		    }
-// 		    return null;  // not used here
-// 		}
-// 		// runs on the event-dispatching thread.
-// 		public void finished() {
-// 		    repaint();
-// 		}
-// 	    };
-// 	worker.start(); 
 
+	Component[] components = popup.getComponents();
+	for (int i = 0; i < components.length; i++) {
+	    if ( components[i] instanceof JMenuItem &&
+		 actionCommand.equals (((JMenuItem)components[i]).getActionCommand()) ) {
+		((JMenuItem)components[i]).setEnabled (enabled);
+		return;
+	    }
+	}
     }
 
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.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/DashboardProperties.java	2005/10/25 09:02:07	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java	2005/10/26 08:05:18	1.7
@@ -39,7 +39,7 @@
     static final String DP_REGISTRY_ENDPOINT = "dp-registry-endpoint";
     static final String DP_REGISTRY_NAMESPACE = "dp-registry-namespace";
     static final String DP_CACHE_DIR = "dp-cache-dir";
-    static final String DP_USE_CACHE = "dp-use-cache";
+    static final String DP_USE_CACHE = "dp-use-cache";  // type: Boolean
 
     static final String DP_REG_DT_NAME = "dp-reg-dt-name";
     static final String DP_REG_DT_AUTH = "dp-reg-dt-auth";

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/10/25 09:02:07	1.10
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/10/26 08:05:18	1.11
@@ -1,109 +1,3 @@
-Setting colors:
-
-articleName.setForeground (new Color (0xffffdd));
-
------
-
-invokeLater()
--------------
-/**
- * Create the GUI and show it.  For thread safety,
- * this method should be invoked from the
- * event-dispatching thread.
- */
-private static void createAndShowGUI() {
-    //Make sure we have nice window decorations.
-    JFrame.setDefaultLookAndFeelDecorated(true);
-
-    //Create and set up the window.
-    frame = new JFrame("FocusConceptsDemo");
-    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
-    //Create and set up the content pane.
-    JComponent newContentPane = new FocusConceptsDemo();
-    newContentPane.setOpaque(true); //content panes must be opaque
-    frame.setContentPane(newContentPane);
-
-    //Display the window.
-    frame.pack();
-    frame.setVisible(true);
-}
-public static void main(String[] args) {
-    //Schedule a job for the event-dispatching thread:
-    //creating and showing this application's GUI.
-    javax.swing.SwingUtilities.invokeLater(new Runnable() {
-        public void run() {
-            createAndShowGUI();
-        }
-    });
-
-invokeAndWait():
-----------------
-void printTextField() throws Exception {
-    final String[] myStrings = new String[2];
-
-    Runnable getTextFieldText = new Runnable() {
-        public void run() {
-            myStrings[0] = textField0.getText();
-            myStrings[1] = textField1.getText();
-        }
-    };
-    SwingUtilities.invokeAndWait(getTextFieldText);
-
-    System.out.println(myStrings[0] + " " + myStrings[1]);
-}
-
-SwingWorker:
-------------
-
-//BETTER CODE:
-public void actionPerformed(ActionEvent e) {
-    ...
-    final SwingWorker worker = new SwingWorker() {
-        public Object construct() {
-            //...code that might take a while to execute is here...
-            return someValue;
-        }
-    };
-    worker.start();  //required for SwingWorker 3
-    ...
-}
-
-using finished:
-
-public void actionPerformed(ActionEvent e) {
-    ...
-    if (icon == null) {     //haven't viewed this photo before
-        loadImage(imagedir + pic.filename, current);
-    } else {
-        updatePhotograph(current, pic);
-    }
-}
-...
-//Load an image in a separate thread.
-private void loadImage(final String imagePath, final int index) {
-    final SwingWorker worker = new SwingWorker() {
-        ImageIcon icon = null;
-
-        public Object construct() {
-            icon = new ImageIcon(getURL(imagePath));
-            return icon; //return value not used by this program
-        }
-
-        //Runs on the event-dispatching thread.
-        public void finished() {
-            Photo pic = (Photo)pictures.elementAt(index);
-            pic.setIcon(icon);
-            if (index == current)
-                updatePhotograph(index, pic);
-        }
-    };
-    worker.start(); 
-}
-
-
-----
-
 ? logging (LogPanel and/or usual logging to a file?)
 * communication with StatusBar (incl. progress bar, cancel button)
 * disabling things during a long-time operation
@@ -191,8 +85,7 @@
 Registry panel
 --------------
 
-* model (worker: org.biomoby.shared.CentralAll,
-CentralDigestCachedImpl.java )
+* finish all buttons
 
 
 Registration panel
@@ -225,3 +118,32 @@
 - Configure a new Dashboard
 
 - Debugging panel (with a Memory Panel embedded; replacing current two pannels)
+
+UNSOLVED (mysteries and not-yet-dones)
+========
+
+* RegistrationPanel -> Data type registration
+
+  - at the beginning, the 'add...' menu item in the popup menu are not
+  disabled - but should be (I do not know why they are not)
+
+  - 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
+* The same, after de-registration
+* Then make the reg/unreg real...
+
+* Icons:
+  - better icon for AddHAS (with a small star)
+
+* 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/10/25 09:02:07	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/10/26 08:05:18	1.4
@@ -12,6 +12,7 @@
 import org.biomoby.shared.Central;
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.MobyRelationship;
+import org.biomoby.shared.parser.MobyTags;
 import org.biomoby.service.generator.DataTypesGenerator;
 
 import org.tulsoft.shared.UUtils;
@@ -77,14 +78,25 @@
     CommonConsole console;
 
     MobyException dtException;
-
-    final static String DATA_TYPE_PROLOGUE =
-    "An error occured when trying to register a new data type.\n\n";
+    MobyException dtUnregException;
 
     // shared icons
     protected static Icon menuAddISAIcon, menuAddISAIconDis;
     protected static Icon menuAddHASAIcon, menuAddHASAIconDis;
     protected static Icon menuAddHASIcon, menuAddHASIconDis;
+    protected static Icon menuUnregisterIcon, menuUnregisterIconDis;
+
+    // some texts
+    final static String DATA_TYPE_PROLOGUE =
+    "An error occured when trying to register a new data type.\n\n";
+
+    final static String DATA_TYPE_UNREG_PROLOGUE =
+    "An error occured when trying to unregister a data type.\n\n";
+
+    final static String DATA_TYPE_INTRO =
+    "Create new data type by filling the form in the middle and adding"
+    + " parent and children types from the tree on the right. Adding is done"
+    + " by selecting first a data type, then right-click gives you menu.";
 
     /*********************************************************************
      * propertyChange()
@@ -117,6 +129,10 @@
 	if (pComponent != null)
 	    return pComponent;
 
+	// console panel
+	console = new CommonConsole();
+	console.setAppendMode (true);
+
 	pComponent = new JPanel (new GridBagLayout(), true);
 
 	// sub-panels for registering various entities
@@ -126,10 +142,6 @@
 	tabbedPane.addTab ("Service Type", getServiceTypeRegistration());
 	tabbedPane.addTab ("Service", getServiceRegistration());
 
-	// console panel
-	console = new CommonConsole();
-	console.setAppendMode (true);
-
 	// split the screen
 	JSplitPane split = new JSplitPane (JSplitPane.VERTICAL_SPLIT,
 					   tabbedPane,
@@ -340,6 +352,7 @@
 	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";
+	protected final static String AC_UNREG  = "ac-unreg";
 
 	/*********************************************************************
 	 * Construtor
@@ -374,6 +387,13 @@
 	    if (menuAddHASIconDis == null)
 		menuAddHASIconDis = 
 		    SwingUtils.createIcon ("images/smallAddHAS_dis.gif", Dashboard.class);
+
+	    if (menuUnregisterIcon == null)
+		menuUnregisterIcon = 
+		    SwingUtils.createIcon ("images/smallUnregister.gif", Dashboard.class);
+	    if (menuUnregisterIconDis == null)
+		menuUnregisterIconDis = 
+		    SwingUtils.createIcon ("images/smallUnregister_dis.gif", Dashboard.class);
 	}
 
 	/*********************************************************************
@@ -387,36 +407,49 @@
  	    removeSeparatorAfter (AC_COLLAPSE);
 
  	    popup.add
- 		(createMenuItem (new AbstractAction ("<html>Add selected as a parent type - <font color='blue'>ISA</font>") {
+ 		(createMenuItem (new AbstractAction ("Add selected as a parent type - ISA") {
  			public void actionPerformed (ActionEvent e) {
 			    onParentSelected();
  			}
  		    }, AC_PARENT, menuAddISAIcon, menuAddISAIconDis));
 
  	    popup.add
- 		(createMenuItem (new AbstractAction ("<html>Add selected as a member - <font color='blue'>HASA</font>") {
+ 		(createMenuItem (new AbstractAction ("Add selected as a member - HASA") {
  			public void actionPerformed (ActionEvent e) {
 			    onMemberSelected (Central.iHASA);
  			}
  		    }, AC_MHASA, menuAddHASAIcon, menuAddHASAIconDis));
 
  	    popup.add
- 		(createMenuItem (new AbstractAction ("<html>Add selected as a list of members - <font color='blue'>HAS</font>") {
+ 		(createMenuItem (new AbstractAction ("Add selected as a list of members - HAS") {
  			public void actionPerformed (ActionEvent e) {
 			    onMemberSelected (Central.iHAS);
  			}
  		    }, AC_MHAS, menuAddHASIcon, menuAddHASIconDis));
 
-	    selected (null);
+	    popup.addSeparator();
+
+ 	    popup.add
+ 		(createMenuItem (new AbstractAction ("Unregister") {
+ 			public void actionPerformed (ActionEvent e) {
+			    onUnregisterDataType();
+ 			}
+ 		    }, AC_UNREG, menuUnregisterIcon, menuUnregisterIconDis));
+
+	    selected (null);   // TBD: this has no effect; why?
 	}
 
 	/*********************************************************************
 	 * Called when a tree node is selected, or deselected (in
-	 * which case 'node' is null). If anything is selected, enable
-	 * few popup menu items, otherwise disable them.
+	 * which case 'node' is null). If a data type name is
+	 * selected, enable few popup menu items, otherwise disable them.
 	 ********************************************************************/
 	protected void selected (DefaultMutableTreeNode node) {
-	    boolean enabled = (node != null);
+	    boolean enabled = true;
+	    if ( node == null ||
+		 node.isRoot() ||
+		 (lastSorted == SORTED_BY_AUTHORITY && ! node.isLeaf()) )
+		enabled = false;
 	    setEnabledPopupItem (AC_PARENT, enabled);
 	    setEnabledPopupItem (AC_MHASA,  enabled);
 	    setEnabledPopupItem (AC_MHAS,   enabled);
@@ -430,7 +463,9 @@
 		(DefaultMutableTreeNode)getLastSelectedPathComponent();
 	    if (node != null) {  // i.e. something is really selected
 		CommonNode nodeObject = (CommonNode)node.getUserObject();
-		buildTree.setParent (nodeObject.getValue());
+		String value = nodeObject.getValue();
+		if (! DataTypesGenerator.isPrimitiveType (value))
+		    buildTree.setParent (value);
 	    }
 	}
 
@@ -446,6 +481,50 @@
 	    }
 	}
 
-    }
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void onUnregisterDataType() {
+	    DefaultMutableTreeNode node =
+		(DefaultMutableTreeNode)getLastSelectedPathComponent();
+	    if (node == null) return;   // nothing selected
+	    CommonNode nodeObject = (CommonNode)node.getUserObject();
+	    final String dataTypeName = nodeObject.getValue();
+
+	    if (DataTypesGenerator.isPrimitiveType (dataTypeName) ||
+		dataTypeName.equals (MobyTags.MOBYOBJECT)) {
+		AbstractPanel.error ("Sorry, but the top-level object and\n" +
+				     "the objects representing primitive types\n" +
+				     "cannot unregister. At least not so easily.");
+		return;
+	    }
+
+	    if (! confirm ("Are you sure you wish to unregister\n" +
+			   "data type: " + dataTypeName + " ?"))
+		return;
+
+	    dtUnregException = null;
+	    final SwingWorker worker = new SwingWorker() {
+		    public Object construct() {
+			try {
+			    MobyDataType dataType = new MobyDataType (dataTypeName);
+			    console.setText ("Data type to be unregistered: " + dataTypeName + "\n");
+			    registryModel.unRegisterDataType (dataType);
+			    console.setText ("\nUnregistration successful!\n\n");
 
+			} catch (MobyException e) {
+			    dtUnregException = e;
+			}
+			return null;  // not used here
+		    }
+
+		    // runs on the event-dispatching thread.
+		    public void finished() {
+			if (dtUnregException != null)
+			    error (DATA_TYPE_UNREG_PROLOGUE, dtUnregException);
+		    }
+		};
+	    worker.start(); 
+	}
+    }
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.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/RegistryModel.java	2005/10/25 09:02:07	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryModel.java	2005/10/26 08:05:18	1.7
@@ -95,6 +95,23 @@
     /*********************************************************************
      *
      ********************************************************************/
+    public void unRegisterDataType (MobyDataType dataType)
+	throws MobyException {
+	initWorker();
+//  	try {
+// 	    worker.unregisterDataType (dataType);
+// 	} catch (PendingCurationException e) {
+// 	    throw new MobyException ("Unregistration reports 'Pending curation'...\n" +
+// 				     "Well, nobody knows what it means. Call Mark!");
+// 	} catch (NoSuccessException e) {
+// 	    throw new MobyException ("Unregistration reports 'No Success'...\n" +
+// 				     e.getMessage());
+// 	}
+    }
+
+    /*********************************************************************
+     *
+     ********************************************************************/
     public MobyDataType[] getDataTypesByNames()
 	throws MobyException {
 	initWorker();




More information about the MOBY-guts mailing list