[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sat Nov 5 17:51:04 UTC 2005


senger
Sat Nov  5 12:51:04 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv1394/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractPanel.java CommonTree.java Dashboard.java 
	DataTypesTree.java NOTES NamespacesTree.java 
	RegistrationPanel.java RegistryPanel.java 
	ServiceTypesTree.java ServicesTree.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard AbstractPanel.java,1.13,1.14 CommonTree.java,1.11,1.12 Dashboard.java,1.10,1.11 DataTypesTree.java,1.8,1.9 NOTES,1.16,1.17 NamespacesTree.java,1.3,1.4 RegistrationPanel.java,1.7,1.8 RegistryPanel.java,1.16,1.17 ServiceTypesTree.java,1.4,1.5 ServicesTree.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/03 15:21:57	1.13
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/05 17:51:04	1.14
@@ -17,6 +17,7 @@
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
 import javax.swing.Icon;
 import javax.swing.JButton;
 import javax.swing.JCheckBox;
@@ -406,6 +407,32 @@
     }
 
     /*********************************************************************
+     * Split two components horizontaly with given weight. Add some
+     * common style.
+     ********************************************************************/
+    protected JSplitPane hSplit (Component a, Component b, double weight) {
+	JSplitPane split = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT,
+					   a, b);
+	split.setResizeWeight (0.5);
+	split.setContinuousLayout (true);
+	split.setOneTouchExpandable (true);
+	return split;
+    }
+
+    /*********************************************************************
+     * Split two components vertically with given weight. Add some
+     * common style.
+     ********************************************************************/
+    protected JSplitPane vSplit (Component a, Component b, double weight) {
+	JSplitPane split = new JSplitPane (JSplitPane.VERTICAL_SPLIT,
+					   a, b);
+	split.setResizeWeight (0.5);
+	split.setContinuousLayout (true);
+	split.setOneTouchExpandable (true);
+	return split;
+    }
+
+    /*********************************************************************
      * 
      ********************************************************************/
     protected String getPrefValue (String key,

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.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/CommonTree.java	2005/11/03 08:38:39	1.11
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java	2005/11/05 17:51:04	1.12
@@ -84,6 +84,7 @@
     static protected Icon smallTIcon, smallTIconDis;
     static protected Icon smallIIcon, smallIIconDis;
     static protected Icon smallOIcon, smallOIconDis;
+    static protected Icon sLeafIcon, stLeafIcon, dtLeafIcon, nsLeafIcon;
 
     protected String rootNode;
 
@@ -123,11 +124,18 @@
 	loadIcons();
     }
 
-    //
+    /*********************************************************************
+     *
+     ********************************************************************/
     class CommonTreeCellRenderer
 	extends DefaultTreeCellRenderer {
 
 	HashSet toBeHighlighted;
+	Icon leafImage;
+
+	public void setLeafIcon (Icon icon) {
+	    leafImage = icon;
+	}
 
 	public void setToBeHighlighted (HashSet toBeHighlighted) {
 	    this.toBeHighlighted = toBeHighlighted;
@@ -160,9 +168,9 @@
 		setText (rootNode);
 	    }
 
-	    // TBD: whale icon?
-// 	    if (leaf)
-// 		((JLabel)c).setIcon (icons [COMPUTER]);
+	    // some icons
+ 	    if (leaf)
+ 		((JLabel)c).setIcon (leafImage);
 
 
 	    // do highlight
@@ -176,6 +184,14 @@
     }
 
     /*********************************************************************
+     *
+     ********************************************************************/
+    public void setLeafIcon (Icon icon) {
+	CommonTreeCellRenderer r = (CommonTreeCellRenderer)getCellRenderer();
+	r.setLeafIcon (icon);
+    }
+
+    /*********************************************************************
      * Put this tree in a scrollable pane.
      ********************************************************************/
     public JScrollPane scrollable() {
@@ -237,6 +253,11 @@
 	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");
+
+	if (nsLeafIcon == null) nsLeafIcon = loadIcon ("images/small_yellow.gif");
+	if (stLeafIcon == null) stLeafIcon = loadIcon ("images/magentaDiamond.gif");
+	if (sLeafIcon  == null) sLeafIcon  = loadIcon ("images/console.gif");
+	if (dtLeafIcon == null) dtLeafIcon = loadIcon ("images/smallPage.gif");
     }
 
     //

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java,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/Dashboard.java	2005/10/28 11:30:37	1.10
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java	2005/11/05 17:51:04	1.11
@@ -23,10 +23,12 @@
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.event.ChangeListener;
 import javax.swing.event.ChangeEvent;
+import javax.swing.SwingUtilities;
 
 import java.awt.GridBagLayout;
 import java.awt.Font;
 import java.awt.Color;
+import java.awt.Insets;
 import java.awt.Dimension;
 
 import java.beans.PropertyChangeListener;
@@ -115,7 +117,15 @@
   	JFrame frame = SwingUtils.createMainFrame (getComponent (propertyChannel),
 						   getName());
 	addMenuBar (frame);
-   	SwingUtils.showMainFrame (frame, dashboard.getPreferredSize());
+//    	SwingUtils.showMainFrame (frame, dashboard.getPreferredSize());
+   	SwingUtils.showMainFrame (frame, new Dimension (1000, 800));
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public Dimension getPreferredSize() {
+	return new Dimension (800, 640);
     }
 
     /**************************************************************************
@@ -211,9 +221,10 @@
 	    ProgressView.monitor.destroy();
 
 	// put it all together
+	Insets BREATH = new Insets (5,5,5,5);
 	SwingUtils.addComponent (p, header,     0, 0, 1, 1, AbstractPanel.HORI, AbstractPanel.NWEST, 1.0, 0.0);
 	SwingUtils.addComponent (p, tabbedPane, 0, 1, 1, 1, AbstractPanel.BOTH, AbstractPanel.NWEST, 1.0, 1.0);
-	SwingUtils.addComponent (p, statusBar,  0, 2, 1, 1, AbstractPanel.HORI, AbstractPanel.WEST,  1.0, 0.0);
+	SwingUtils.addComponent (p, statusBar,  0, 2, 1, 1, AbstractPanel.HORI, AbstractPanel.WEST,  1.0, 0.0, BREATH);
 
 	return p;
     }
@@ -261,6 +272,7 @@
 
     class StatusBar extends JLabel implements PropertyChangeListener {
 	DateFormat df = DateFormat.getTimeInstance();
+	Icon myIcon;
 	public StatusBar (String text) {
 	    super (text);
 	}
@@ -272,6 +284,11 @@
 	    if (prop.equalsIgnoreCase (DP_STATUS_MSG))
 		setText ("[" + df.format (new Date()) + "] " + value.toString());
 	}
+	public Icon getIcon() {
+	    if (myIcon == null)
+		myIcon = SwingUtils.createIcon ("images/smallDone.gif", Dashboard.class);
+	    return myIcon;
+	}
     }
 
     /**************************************************************************
@@ -302,7 +319,13 @@
     public static void main (String[] args) {
 	if (args.length > 0 && args[0].equals ("-nop"))
 	    Dashboard.useLoadMonitor = false;
-	new Dashboard().show();
+
+        // schedule a job for the event-dispatching thread
+        SwingUtilities.invokeLater (new Runnable() {
+		public void run() {
+		    new Dashboard().show();
+		}
+	    });
     }
 
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.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/DataTypesTree.java	2005/11/03 08:38:39	1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java	2005/11/05 17:51:04	1.9
@@ -72,6 +72,7 @@
 	this.registryModel = registryModel;
 	this.console = console;
 	createPopups ("Data Types Menu");
+	setLeafIcon (dtLeafIcon);
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,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/NOTES	2005/11/03 15:21:57	1.16
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/11/05 17:51:04	1.17
@@ -1,3 +1,8 @@
+* 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?)
 
@@ -125,8 +130,6 @@
 * 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 ("")
@@ -134,4 +137,4 @@
   ? use FileSystemView in file choosers
   * BUG: not sure why so many (repeated) changes from the actionlistener
     in JFieldTextWithHistory
-
+  * SwingUtils can be simplified (closeOnExit etc.)

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.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/NamespacesTree.java	2005/11/03 08:38:39	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.java	2005/11/05 17:51:04	1.4
@@ -65,6 +65,7 @@
 	this.registryModel = registryModel;
 	this.console = console;
 	createPopups ("Namespaces Menu");
+	setLeafIcon (nsLeafIcon);
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.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/RegistrationPanel.java	2005/11/03 15:21:57	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/11/05 17:51:04	1.8
@@ -17,6 +17,10 @@
 import org.biomoby.shared.MobyRelationship;
 import org.biomoby.shared.parser.MobyTags;
 import org.biomoby.service.generator.DataTypesGenerator;
+import org.biomoby.shared.MobyData;
+import org.biomoby.shared.MobyPrimaryDataSimple;
+import org.biomoby.shared.MobyPrimaryDataSet;
+import org.biomoby.shared.MobySecondaryData;
 
 import org.tulsoft.shared.UUtils;
 import org.tulsoft.tools.gui.SwingUtils;
@@ -33,17 +37,32 @@
 import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.JTabbedPane;
+import javax.swing.JTable;
+import javax.swing.JComboBox;
 import javax.swing.JPopupMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.AbstractAction;
 import javax.swing.JComponent;
+import javax.swing.DefaultListModel;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultCellEditor;
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableColumn;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.border.Border;
 
 import java.awt.GridBagLayout;
 import java.awt.Font;
+import java.awt.Component;
 import java.awt.event.KeyEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -98,6 +117,9 @@
     JFileChooserWithHistory localRDFFile;
     JCheckBox useAuth;
 
+    JTable table;
+    PrimaryDataTableModel tableModel;
+
     MobyException dtException, nsException, stException, sException;
     MobyException dtUnregException, nsUnregException, stUnregException, sUnregException;
 
@@ -107,6 +129,9 @@
     protected static Icon menuAddHASIcon, menuAddHASIconDis;
     protected static Icon menuUnregisterIcon, menuUnregisterIconDis;
     protected static Icon registerIcon, registerIconDis;
+    protected static Icon addDataIcon, addDataIconDis;
+    protected static Icon editDataIcon, editDataIconDis;
+    protected static Icon deleteDataIcon, trashIcon;
 
     // some texts
     final static String DATA_TYPE_PROLOGUE =
@@ -174,6 +199,20 @@
 	    registerIcon = loadIcon ("images/smallRegister.gif");
 	if (registerIconDis == null)
 	    registerIconDis = loadIcon ("images/smallRegister_dis.gif");
+
+	if (addDataIcon == null)
+	    addDataIcon = loadIcon ("images/smallAddData.gif");
+	if (addDataIconDis == null)
+	    addDataIconDis = loadIcon ("images/smallAddData_dis.gif");
+
+	if (editDataIcon == null)
+	    editDataIcon = loadIcon ("images/smallEdit.gif");
+	if (editDataIconDis == null)
+	    editDataIconDis = loadIcon ("images/smallEdit_dis.gif");
+
+	if (deleteDataIcon == null) deleteDataIcon = loadIcon ("images/smallRemove.gif");
+	if (trashIcon == null) trashIcon = loadIcon ("images/smallTrash.gif");
+
     }
 
     /**************************************************************************
@@ -464,10 +503,351 @@
      *
      **************************************************************************/
     protected JPanel getPrimaryInputs() {
-	JPanel p = new JPanel (new GridBagLayout());
+
+	JPanel p = createTitledPanel ("");
+
+	tableModel = new PrimaryDataTableModel();
+	table = new JTable (tableModel);
+
+	// set renderers for buttons column
+	TableColumn buttonColumn =
+	    table.getColumnModel().getColumn (PrimaryDataTableModel.COL_BUTTON);
+	if (trashIcon != null)
+	    buttonColumn.setMaxWidth (trashIcon.getIconWidth() + 15);
+	buttonColumn.setCellRenderer (new ButtonRenderer());
+	buttonColumn.setCellEditor (new ButtonEditor());
+ 	buttonColumn.setHeaderRenderer (new TableCellRenderer() {
+		public Component getTableCellRendererComponent
+		(JTable table, Object value, boolean isSelected,
+		 boolean hasFocus, int row, int column) {
+		    return (JComponent)value;
+		}
+	    });
+	JButton headerButton = new JButton ("", trashIcon);
+        headerButton.setToolTipText ("Click in this column to remove data from this service");
+	buttonColumn.setHeaderValue (headerButton);
+
+	// set renderers for namespaces column
+	TableColumn nsColumn =
+	    table.getColumnModel().getColumn (PrimaryDataTableModel.COL_NAMESPACE);
+	nsColumn.setCellRenderer (new NamespaceRenderer());
+ 	nsColumn.setCellEditor (new NamespaceEditor());
+
+	JScrollPane tablePane = new JScrollPane (table);
+
+	// an add button
+	JButton addButton =
+	    createButton (" Add new data ",
+			  "Add new data to the service definition",
+			  KeyEvent.VK_A,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onAddData();
+			      }
+			  });
+	addButton.setIcon (addDataIcon);
+	addButton.setDisabledIcon (addDataIconDis);
+
+	// a tree with all already existing data types
+	DataTypesBoard dataTypesBoard =
+	    new DataTypesBoard (registryModel,
+				console,
+				propertyChannel,
+				new CustomDataTypesSimplestTree (registryModel, console));
+	dataTypesBoard.updateTree (CommonTree.SORTED_BY_NAME);
+
+	// a tree with all already existing namespaces
+	NamespacesBoard namespacesBoard =
+	    new NamespacesBoard (registryModel,
+				 console,
+				 propertyChannel,
+				 new CustomNamespacesSimplestTree (registryModel, console));
+	namespacesBoard.updateTree (CommonTree.SORTED_BY_NAME);
+
+	// split the trees
+	JSplitPane split = hSplit (dataTypesBoard, namespacesBoard, 0.5);
+
+	// put it together
+ 	SwingUtils.addComponent (p, addButton, 0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, tablePane, 0, 1, 1, 1, BOTH, NWEST, 1.0, 0.3, BREATH_TOP);
+ 	SwingUtils.addComponent (p, split,     0, 2, 1, 1, BOTH, NWEST, 1.0, 1.0, BREATH_TOP);
 	return p;
     }	
 
+
+    private Vector data = new Vector();
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    protected void onAddData() {
+	data.addElement (new MobyPrimaryDataSimple (""));
+
+	int rowCount = tableModel.getRowCount();
+	tableModel.fireTableRowsInserted (rowCount-1, rowCount-1);
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class DeleteRowButton extends JButton {
+	int rowToDelete = -1;
+	public DeleteRowButton() {
+	    super();
+	    setText ("");
+	    setIcon (deleteDataIcon);
+	    setToolTipText ("Remove this data from this service");
+ 	    setFocusPainted (false);
+	    addActionListener (new ActionListener() {
+		    public void actionPerformed (ActionEvent e) {
+			if (rowToDelete >= 0) {
+ 			    tableModel.removeRow (rowToDelete);
+			}
+		    }
+		});
+	}
+	public void setRowToDelete (int row) {
+	    rowToDelete = row;
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class ButtonRenderer extends DeleteRowButton
+	implements TableCellRenderer {
+	public ButtonRenderer() {
+	    setOpaque (true);
+	}	
+	public Component getTableCellRendererComponent (JTable table,
+							Object value,
+							boolean isSelected,
+							boolean hasFocus,
+							int row, int column) {
+	    return this;
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class ButtonEditor extends AbstractCellEditor
+	implements TableCellEditor {
+	public Object getCellEditorValue() {
+	    return null;
+	}
+	public Component getTableCellEditorComponent (JTable table,
+						      Object value,
+						      boolean isSelected,
+						      int row, int column) {
+	    DeleteRowButton button = new DeleteRowButton();
+	    button.setRowToDelete (row);
+	    return button;
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class NamespaceRenderer extends DefaultTableCellRenderer {
+
+	public NamespaceRenderer() {
+	    setOpaque (true);
+	}	
+	protected void setValue (Object value) {
+	    if (value == null) {
+		setText ("");
+		return;
+	    }
+	    MobyPrimaryDataSimple simple = null;
+	    if (value instanceof MobyPrimaryDataSimple) {
+		simple = (MobyPrimaryDataSimple)value;
+	    } else if (value instanceof MobyPrimaryDataSet) {
+		MobyPrimaryDataSimple[] simples = ((MobyPrimaryDataSet)value).getElements();
+		if (simples.length > 0)
+		    simple = simples[0];
+	    }
+	    if (simple != null) {
+		MobyNamespace[] nss = simple.getNamespaces();
+		if (nss.length == 0)
+		    setText ("");
+		else if (nss.length == 1)
+		    setText (nss[0].getName());
+		else
+		    setText (nss.length + " chosen");
+	    }
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class NamespaceEditor extends AbstractCellEditor
+	implements TableCellEditor {
+	DefaultComboBoxModel comboModel = new DefaultComboBoxModel();
+
+	public Object getCellEditorValue() {
+	    return null;
+	}
+
+	public Component getTableCellEditorComponent (JTable table,
+						      Object value,
+						      boolean isSelected,
+						      int row, int column) {
+
+	    JComboBox comboBox = new JComboBox (comboModel);
+	    comboBox.setOpaque (true);
+
+	    MobyPrimaryDataSimple simple = null;
+	    if (value instanceof MobyPrimaryDataSimple) {
+		simple = (MobyPrimaryDataSimple)value;
+	    } else if (value instanceof MobyPrimaryDataSet) {
+		MobyPrimaryDataSimple[] simples = ((MobyPrimaryDataSet)value).getElements();
+		if (simples.length > 0)
+		    simple = simples[0];
+	    }
+	    if (simple != null) {
+		MobyNamespace[] nss = simple.getNamespaces();
+		comboModel.removeAllElements();
+		for (int i = 0; i < nss.length; i++) {
+		    comboModel.addElement (nss[i].getName());
+		}
+	    }
+	    return comboBox;
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class PrimaryDataTableModel extends AbstractTableModel {
+	public final static int COL_BUTTON    = 0;
+	public final static int COL_ARTICLE   = 1;
+	public final static int COL_DATATYPE  = 2;
+	public final static int COL_IN_SET    = 3;
+	public final static int COL_NAMESPACE = 4;
+
+	private String[] columnNames = new String[] {
+	    "Remove",
+	    "Article name",
+	    "Data Type",
+	    "In Set",
+	    "Namespaces" };
+
+	private Class[] columnClasses = new Class[] {
+	    Integer.class,
+	    String.class,
+	    String.class,
+	    Boolean.class,
+	    MobyData.class };
+
+	public int getColumnCount() {
+	    return columnNames.length;
+	}
+
+	public int getRowCount() {
+	    return data.size();
+	}
+
+	public String getColumnName (int col) {
+	    return columnNames [col];
+	}
+
+	public Class getColumnClass (int col) {
+	    return columnClasses [col];
+	}
+
+	private String getDataTypeName (MobyData data) {
+	    if (data == null) return "";
+	    MobyDataType dataType = null;
+	    if (data instanceof MobyPrimaryDataSimple)
+		dataType = ((MobyPrimaryDataSimple)data).getDataType();
+	    else if (data instanceof MobyPrimaryDataSet)
+		dataType = ((MobyPrimaryDataSet)data).getDataType();
+	    if (dataType == null) return "";
+	    String name = dataType.getName();
+	    return (name == null ? "" : name);
+	}
+
+	private void setDataTypeName (MobyData data, String name) {
+	    if (data == null) return;
+	    MobyDataType dataType = new MobyDataType (name);
+	    if (data instanceof MobyPrimaryDataSimple)
+		((MobyPrimaryDataSimple)data).setDataType (dataType);
+	    else if (data instanceof MobyPrimaryDataSet)
+		((MobyPrimaryDataSet)data).setDataType (dataType);
+	}
+
+	public Object getValueAt (int row, int col) {
+	    try {
+		MobyData d = (MobyData)data.elementAt (row);
+		switch (col) {
+		case COL_BUTTON:    return new Integer (row);
+		case COL_ARTICLE:   return d.getName();
+		case COL_DATATYPE:  return getDataTypeName (d);
+		case COL_IN_SET:    return new Boolean (d instanceof MobyPrimaryDataSet);
+		case COL_NAMESPACE: return d;
+		}
+	    } catch (Exception e) { }
+	    return "";
+	}
+
+	public void setValueAt (Object value, int row, int col) {
+	    // TBD: I do not know why this method is called after a
+	    // last row has been deleted - so the 'row' is actually
+	    // out of bounds; but if other than last row is deleted
+	    // things work fine... (that's why i put here try{} but I
+	    // am not happy about it
+	    try {
+		MobyData d = (MobyData)data.elementAt (row);
+		switch (col) {
+		case COL_ARTICLE:
+		    d.setName (value.toString());
+		    break;
+		case COL_DATATYPE:
+		    setDataTypeName (d, value.toString());
+		    break;
+		case COL_IN_SET:
+		    if ( ((Boolean)value).booleanValue() ) {
+			// change data to a collection (if necessary)
+			if (d instanceof MobyPrimaryDataSimple) {
+			    MobyPrimaryDataSet set = new MobyPrimaryDataSet (d.getName());
+			    set.addElement ((MobyPrimaryDataSimple)d);
+			    synchronized (data) {
+				data.removeElementAt (row);
+				data.insertElementAt (set, row);
+			    }
+			}
+		    } else {
+			// change data to a simple (if necessary)
+			if (d instanceof MobyPrimaryDataSet) {
+			    MobyPrimaryDataSimple[] simples =
+				((MobyPrimaryDataSet)d).getElements();
+			    if (simples.length > 0) {
+				simples[0].setName (d.getName());
+				synchronized (data) {
+				    data.removeElementAt (row);
+				    data.insertElementAt (simples[0], row);
+				}
+			    }
+			}
+		    }
+		    break;
+		}
+		fireTableCellUpdated (row, col);
+	    } catch (Exception e) { }
+	}
+
+	public void removeRow (int row) {
+ 	    data.removeElementAt (row);
+ 	    fireTableRowsDeleted (row, row);
+	}
+
+	public boolean isCellEditable (int row, int col) {
+	    return (col != COL_DATATYPE);
+	}
+    }
+
     /**************************************************************************
      *
      **************************************************************************/
@@ -1522,4 +1902,123 @@
 		sType.setText (nodeObject.getValue());
 	}
     }
+
+
+    /**************************************************************************
+     *
+     * Customized tree of data types - use for service registration
+     *
+     **************************************************************************/
+    protected class CustomDataTypesSimplestTree
+	extends DataTypesTree {
+
+	/*********************************************************************
+	 * Construtor
+	 ********************************************************************/
+	public CustomDataTypesSimplestTree (RegistryModel model,
+					    CommonConsole console) {
+	    super (model, console);
+	}
+
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void createPopups (String title) {
+ 	    super.createPopups (title);
+ 	    removeFromPopups (AC_RELOAD);
+ 	    removeFromPopups (AC_HASA);
+ 	    removeFromPopups (AC_DEPR);
+ 	    removeSeparatorAfter (AC_ASORT);
+ 	    removeSeparatorAfter (AC_COLLAPSE);
+	}
+
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void setEnabledPopup (boolean enabled) {
+	    super.setEnabledPopup (enabled);
+	    selected (null);
+	}
+
+	/*********************************************************************
+	 * Copy selected data type to the data table.
+	 ********************************************************************/
+	protected void selected (DefaultMutableTreeNode node) {
+	    if (node == null) return;
+	    CommonNode nodeObject = (CommonNode)node.getUserObject();
+	    if (nodeObject.getType() == CommonNode.NODE_DATA_TYPE) {
+		int[] rows = table.getSelectedRows();
+		for (int i = 0; i < rows.length; i++) {
+		    String value = nodeObject.getValue();
+		    table.setValueAt (value, rows[i], PrimaryDataTableModel.COL_DATATYPE);
+		    Object article = table.getValueAt (rows[i],PrimaryDataTableModel.COL_ARTICLE);
+		    if (article == null || UUtils.isEmpty (article.toString()))
+			table.setValueAt (value, rows[i], PrimaryDataTableModel.COL_ARTICLE);
+		}
+	    }
+	}
+    }
+
+    /**************************************************************************
+     *
+     * Customized tree of namespaces - use for service registration
+     *
+     **************************************************************************/
+    protected class CustomNamespacesSimplestTree
+	extends NamespacesTree {
+
+	/*********************************************************************
+	 * Construtor
+	 ********************************************************************/
+	public CustomNamespacesSimplestTree (RegistryModel model,
+					     CommonConsole console) {
+	    super (model, console);
+	}
+
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void createPopups (String title) {
+ 	    super.createPopups (title);
+ 	    removeFromPopups (AC_RELOAD);
+ 	    removeSeparatorAfter (AC_COLLAPSE);
+	}
+
+	/*********************************************************************
+	 *
+	 ********************************************************************/
+	protected void setEnabledPopup (boolean enabled) {
+	    super.setEnabledPopup (enabled);
+	    selected (null);
+	}
+
+	/*********************************************************************
+	 * Copy selected namespace to the data table.
+	 ********************************************************************/
+	protected void selected (DefaultMutableTreeNode node) {
+	    if (node == null) return;
+	    CommonNode nodeObject = (CommonNode)node.getUserObject();
+	    if (nodeObject.getType() == CommonNode.NODE_NAMESPACE) {
+		int[] rows = table.getSelectedRows();
+		for (int i = 0; i < rows.length; i++) {
+		    String value = nodeObject.getValue();
+// 		    table.setValueAt (value, rows[i], PrimaryDataTableModel.COL_DATATYPE);
+		    Object data = table.getValueAt (rows[i],PrimaryDataTableModel.COL_NAMESPACE);
+		    MobyPrimaryDataSimple simple = null;
+		    if (data instanceof MobyPrimaryDataSimple) {
+			simple = (MobyPrimaryDataSimple)data;
+		    } else if (data instanceof MobyPrimaryDataSet) {
+			MobyPrimaryDataSimple[] simples = ((MobyPrimaryDataSet)data).getElements();
+			if (simples.length > 0)
+			    simple = simples[0];
+		    }
+		    if (simple != null) {
+			simple.addNamespace (new MobyNamespace (value));
+			tableModel.fireTableCellUpdated (rows[i], PrimaryDataTableModel.COL_NAMESPACE);
+		    }
+		}
+	    }
+	}
+    }
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.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/RegistryPanel.java	2005/11/02 06:39:06	1.16
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/11/05 17:51:04	1.17
@@ -81,6 +81,9 @@
     JLabel labelCacheDir;
     CommonConsole console;
 
+    // shared icons
+    protected static Icon infoIcon, infoIconDis;
+
     /*********************************************************************
      * Default constructor.
      ********************************************************************/
@@ -88,6 +91,14 @@
 	super();
     }
 
+    /*********************************************************************
+     * Load shared icons.
+     ********************************************************************/
+    protected void loadIcons() {
+	super.loadIcons();
+	if (infoIcon    == null) infoIcon = loadIcon ("images/smallInfo.gif");
+    }
+	
     /**************************************************************************
      *
      **************************************************************************/
@@ -289,6 +300,8 @@
 				  onCacheInfo();
 			      }
 			  });
+// 	infoButton.setIcon (infoIcon);
+
 	JButton updateButton =
 	    createButton (" Update ",
 			  "Update local cache from Biomoby registry",

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.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/ServiceTypesTree.java	2005/11/03 08:38:39	1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.java	2005/11/05 17:51:04	1.5
@@ -66,6 +66,7 @@
 	this.registryModel = registryModel;
 	this.console = console;
 	createPopups ("Service Types Menu");
+	setLeafIcon (stLeafIcon);
     }
 
     /*********************************************************************

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesTree.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/ServicesTree.java	2005/11/02 06:39:06	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesTree.java	2005/11/05 17:51:04	1.2
@@ -75,6 +75,7 @@
 	this.registryModel = registryModel;
 	this.console = console;
 	createPopups ("Services Menu");
+	setLeafIcon (sLeafIcon);
     }
 
     /*********************************************************************




More information about the MOBY-guts mailing list