[MOBY-guts] biomoby commit
Martin Senger
senger at pub.open-bio.org
Sun Nov 20 12:30:52 UTC 2005
senger
Sun Nov 20 07:30:51 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv4966/src/main/org/biomoby/service/dashboard
Modified Files:
CommonBoard.java CommonDataTable.java CommonTree.java
Dashboard.java DataTypesBoard.java DataTypesTree.java
DebuggingPanel.java GeneratorPanel.java NamespacesBoard.java
NamespacesTree.java PrimaryDataTable.java PropertyChannel.java
RegistryPanel.java ServiceTypesBoard.java
ServiceTypesTree.java ServicesBoard.java ServicesTree.java
Log Message:
moby-live/Java/src/main/org/biomoby/service/dashboard CommonBoard.java,1.6,1.7 CommonDataTable.java,1.4,1.5 CommonTree.java,1.18,1.19 Dashboard.java,1.17,1.18 DataTypesBoard.java,1.10,1.11 DataTypesTree.java,1.12,1.13 DebuggingPanel.java,1.3,1.4 GeneratorPanel.java,1.4,1.5 NamespacesBoard.java,1.5,1.6 NamespacesTree.java,1.7,1.8 PrimaryDataTable.java,1.4,1.5 PropertyChannel.java,1.8,1.9 RegistryPanel.java,1.24,1.25 ServiceTypesBoard.java,1.6,1.7 ServiceTypesTree.java,1.9,1.10 ServicesBoard.java,1.6,1.7 ServicesTree.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonBoard.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/CommonBoard.java 2005/11/07 17:14:46 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonBoard.java 2005/11/20 12:30:51 1.7
@@ -42,8 +42,8 @@
extends JPanel
implements NotificationListener {
- private static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog (CommonBoard.class);
+// private static org.apache.commons.logging.Log log =
+// org.apache.commons.logging.LogFactory.getLog (CommonBoard.class);
protected RegistryModel model;
protected PropertyChannel channel;
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonDataTable.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/CommonDataTable.java 2005/11/10 14:32:42 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonDataTable.java 2005/11/20 12:30:51 1.5
@@ -227,7 +227,6 @@
public void setData (MobyData[] newData) {
synchronized (this) {
int rowCount = getRowCount();
- int colCount = getColumnCount();
for (int i = 0; i < rowCount; i++)
removeRow (i);
for (int i = 0; i < newData.length; i++)
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.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/CommonTree.java 2005/11/19 18:33:01 1.18
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/CommonTree.java 2005/11/20 12:30:51 1.19
@@ -156,17 +156,17 @@
public Component getTreeCellRendererComponent (JTree tree,
java.lang.Object value,
- boolean selected,
+ boolean isSelected,
boolean expanded,
boolean leaf,
int row,
- boolean hasFocus) {
+ boolean hasAFocus) {
//
// I will reuse the default rendering done by my parent,
// except the change of an icon (for naming contexts)
//
- Component c = super.getTreeCellRendererComponent (tree, value, selected,
- expanded, leaf, row, hasFocus);
+ Component c = super.getTreeCellRendererComponent (tree, value, isSelected,
+ expanded, leaf, row, hasAFocus);
// add a tool-tip for the root node
if (row == 0) {
setToolTipText ("Right-click will show other options");
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java 2005/11/19 18:33:01 1.17
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java 2005/11/20 12:30:51 1.18
@@ -143,6 +143,7 @@
* creates the GUI - but does not show it yet.
**************************************************************************/
public Dashboard() {
+ log.debug ("----------------------- new dashboard start ------------------------");
loadIcons();
loadPanels();
propertyChannel = new PropertyChannel();
@@ -251,13 +252,10 @@
getName());
addMenuBar (frame);
- Dimension screenSize = frame.getToolkit().getScreenSize();
- double myWidth = Math.min (screenSize.getWidth(), 1100);
- double myHeight = Math.min (screenSize.getHeight() - 25, 900);
- Dimension mySize = new Dimension();
- mySize.setSize (myWidth, myHeight);
-
- SwingUtils.showMainFrame (frame, mySize);
+ Dimension screenSize = frame.getToolkit().getScreenSize();
+ int width = screenSize.width * 4 / 5;
+ int height = screenSize.height * 5 / 6;
+ SwingUtils.showMainFrame (frame, width, height);
}
/**************************************************************************
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.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/DataTypesBoard.java 2005/11/12 16:43:47 1.10
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesBoard.java 2005/11/20 12:30:51 1.11
@@ -72,10 +72,14 @@
Object initiator;
switch (event.getType()) {
case Notifier.DATA_TYPES_START:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
createProgressBar (Notifier.SIGNAL_CANCEL_DATA_TYPES);
insertProgressBar();
break;
case Notifier.DATA_TYPES_COUNT:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
if (event.getMessage() instanceof Integer)
calibrateProgressBar ( ((Integer)event.getMessage()).intValue() );
break;
@@ -88,12 +92,16 @@
case Notifier.DATA_TYPES_END:
case Notifier.DATA_TYPES_CANCELLED:
case Notifier.DATA_TYPES_RESET:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree == initiator)
channel.fire (this, DashboardProperties.DP_STATUS_MSG, "Done");
removeProgressBar();
break;
case Notifier.DATA_TYPES_UPDATED:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree != initiator) {
// some other instance of this class initiated request
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java 2005/11/12 16:43:47 1.12
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DataTypesTree.java 2005/11/20 12:30:51 1.13
@@ -49,11 +49,9 @@
RegistryModel registryModel;
CommonConsole console;
- MobyDataType[] dataTypes = null;
boolean showBadGuys = false;
boolean showMembers = false;
JCheckBoxMenuItem deprecatedBox;
- MobyException updateException = null;
final static String DATA_TYPES_ACCESS_ERROR =
"An error happened when accessing a list of available data types.\n\n"
@@ -110,33 +108,28 @@
********************************************************************/
public void update (int howSorted, Object newData) {
if (howSorted < 0) howSorted = lastSorted;
-
+ lastSorted = howSorted;
+
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() {
+ MobyException updateException = null;
+ MobyDataType[] dataTypes = null;
public Object construct() {
try {
- log.debug ("Tree updating started");
+ if (log.isDebugEnabled())
+ log.debug ("Tree update request. Sorted: " + sorted + ", Data: " + newDataTypes);
// get data types (unless you already have them)
if (newDataTypes == null) {
- log.debug ("Asking registry model to update");
dataTypes = registryModel.getDataTypes (source);
} else {
dataTypes = newDataTypes;
}
- // ...and sort them accordingly
- if (sorted == SORTED_BY_AUTHORITY)
- java.util.Arrays.sort
- (dataTypes, MobyDataType.getAuthorityComparator());
- else
- java.util.Arrays.sort (dataTypes);
-
} catch (MobyException e) {
updateException = e;
}
@@ -165,7 +158,10 @@
worker.start();
}
- void onUpdateDataTree (MobyDataType[] dataTypes) {
+ void onUpdateDataTree (MobyDataType[] theDataTypes) {
+ MobyDataType[] dataTypes = copy (theDataTypes);
+ java.util.Arrays.sort (dataTypes);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -199,8 +195,11 @@
}
- void onUpdateDataTreeByAuth (MobyDataType[] dataTypes) {
- DefaultTreeModel tModel = (DefaultTreeModel)getModel();
+ void onUpdateDataTreeByAuth (MobyDataType[] theDataTypes) {
+ MobyDataType[] dataTypes = copy (theDataTypes);
+ java.util.Arrays.sort (dataTypes, MobyDataType.getAuthorityComparator());
+
+ DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
HashMap nodes = new HashMap (dataTypes.length);
@@ -268,6 +267,17 @@
}
/*********************************************************************
+ * Make a private copy (of pointers) that will be used for sorting...
+ ********************************************************************/
+ private MobyDataType[] copy (MobyDataType[] s) {
+ synchronized (s) {
+ MobyDataType[] result = new MobyDataType [s.length];
+ System.arraycopy (s, 0, result, 0, s.length);
+ return result;
+ }
+ }
+
+ /*********************************************************************
* Reload the tree from the Biomoby registry, ignoring (and
* updating) cache.
********************************************************************/
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DebuggingPanel.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/DebuggingPanel.java 2005/11/19 18:33:01 1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DebuggingPanel.java 2005/11/20 12:30:51 1.4
@@ -14,7 +14,6 @@
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JTextField;
-import javax.swing.Icon;
import javax.swing.JComponent;
import java.awt.GridBagLayout;
@@ -42,8 +41,8 @@
/**************************************************************************
*
**************************************************************************/
- public JComponent getComponent (PropertyChannel propertyChannel) {
- setPropertyChannel (propertyChannel);
+ public JComponent getComponent (PropertyChannel newPropertyChannel) {
+ setPropertyChannel (newPropertyChannel);
JPanel p = new JPanel (new GridBagLayout(), true);
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/GeneratorPanel.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/GeneratorPanel.java 2005/11/19 18:33:01 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/GeneratorPanel.java 2005/11/20 12:30:51 1.5
@@ -9,11 +9,9 @@
package org.biomoby.service.dashboard;
import org.tulsoft.tools.gui.SwingUtils;
-import org.tulsoft.tools.gui.JTextFieldWithHistory;
import org.tulsoft.tools.gui.JFileChooserWithHistory;
import org.biomoby.shared.MobyException;
-import org.biomoby.shared.event.Notifier;
import javax.swing.JPanel;
import javax.swing.JLabel;
@@ -23,7 +21,6 @@
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;
-import javax.swing.JOptionPane;
import javax.swing.JFileChooser;
import javax.swing.JSplitPane;
import javax.swing.JComponent;
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesBoard.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/NamespacesBoard.java 2005/11/12 16:43:47 1.5
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesBoard.java 2005/11/20 12:30:51 1.6
@@ -72,10 +72,14 @@
Object initiator;
switch (event.getType()) {
case Notifier.NAMESPACES_START:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
createProgressBar (Notifier.SIGNAL_CANCEL_NAMESPACES);
insertProgressBar();
break;
case Notifier.NAMESPACES_COUNT:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
if (event.getMessage() instanceof Integer)
calibrateProgressBar ( ((Integer)event.getMessage()).intValue() );
break;
@@ -88,12 +92,16 @@
case Notifier.NAMESPACES_END:
case Notifier.NAMESPACES_CANCELLED:
case Notifier.NAMESPACES_RESET:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree == initiator)
channel.fire (this, DashboardProperties.DP_STATUS_MSG, "Done");
removeProgressBar();
break;
case Notifier.NAMESPACES_UPDATED:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree != initiator) {
// someone else (of this instance) initiated request
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.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/NamespacesTree.java 2005/11/12 16:43:47 1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NamespacesTree.java 2005/11/20 12:30:51 1.8
@@ -36,9 +36,6 @@
RegistryModel registryModel;
CommonConsole console;
- MobyNamespace[] namespaces = null;
- MobyException updateException = null;
-
final static String NAMESPACES_ACCESS_ERROR =
"An error happened when accessing a list of available namespaces.\n\n"
+ ACCESS_ERROR_INTRO;
@@ -69,33 +66,28 @@
********************************************************************/
public void update (int howSorted, Object newData) {
if (howSorted < 0) howSorted = lastSorted;
-
+ lastSorted = howSorted;
+
setEnabledPopup (false);
- updateException = null;
final Object source = this;
final int sorted = howSorted;
final MobyNamespace[] newNamespaces =
(newData == null ? null : (MobyNamespace[])newData);
final SwingWorker worker = new SwingWorker() {
+ MobyException updateException = null;
+ MobyNamespace[] namespaces = null;
public Object construct() {
try {
- log.debug ("Tree updating started");
+ if (log.isDebugEnabled())
+ log.debug ("Tree update request. Sorted: " + sorted + ", Data: " + newNamespaces);
// get namespaces (unless you already have them)
if (newNamespaces == null) {
- log.debug ("Asking registry model to update");
namespaces = registryModel.getNamespaces (source);
} else {
namespaces = newNamespaces;
}
- // ...and sort them accordingly
- if (sorted == SORTED_BY_AUTHORITY)
- java.util.Arrays.sort
- (namespaces, MobyNamespace.getAuthorityComparator());
- else
- java.util.Arrays.sort (namespaces);
-
} catch (MobyException e) {
updateException = e;
}
@@ -119,7 +111,10 @@
worker.start();
}
- void onUpdateNamespacesTree (MobyNamespace[] namespaces) {
+ void onUpdateNamespacesTree (MobyNamespace[] theNamespaces) {
+ MobyNamespace[] namespaces = copy (theNamespaces);
+ java.util.Arrays.sort (namespaces);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -131,7 +126,10 @@
}
- void onUpdateNamespacesTreeByAuth (MobyNamespace[] namespaces) {
+ void onUpdateNamespacesTreeByAuth (MobyNamespace[] theNamespaces) {
+ MobyNamespace[] namespaces = copy (theNamespaces);
+ java.util.Arrays.sort (namespaces, MobyNamespace.getAuthorityComparator());
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -158,6 +156,17 @@
}
/*********************************************************************
+ * Make a private copy (of pointers) that will be used for sorting...
+ ********************************************************************/
+ private MobyNamespace[] copy (MobyNamespace[] s) {
+ synchronized (s) {
+ MobyNamespace[] result = new MobyNamespace [s.length];
+ System.arraycopy (s, 0, result, 0, s.length);
+ return result;
+ }
+ }
+
+ /*********************************************************************
* Reload the tree from the Biomoby registry, ignoring (and
* updating) cache.
********************************************************************/
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PrimaryDataTable.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/PrimaryDataTable.java 2005/11/11 08:34:39 1.4
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PrimaryDataTable.java 2005/11/20 12:30:51 1.5
@@ -165,15 +165,15 @@
return null;
}
- public Component getTableCellEditorComponent (JTable table,
+ public Component getTableCellEditorComponent (JTable aTable,
Object value,
boolean isSelected,
- int row, int col) {
+ int aRow, int aCol) {
// remember (used when a namespace is being deleted)
- this.table = table;
- this.row = row;
- this.col = col;
+ this.table = aTable;
+ this.row = aRow;
+ this.col = aCol;
// fill combo box with the current namespaces
if (value == null) {
@@ -288,9 +288,9 @@
return "";
}
- private String getDataTypeName (MobyPrimaryData data) {
- if (data == null) return "";
- MobyDataType dataType = data.getDataType();
+ private String getDataTypeName (MobyPrimaryData theData) {
+ if (theData == null) return "";
+ MobyDataType dataType = theData.getDataType();
if (dataType == null) return "";
String name = dataType.getName();
return (name == null ? "" : name);
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PropertyChannel.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/PropertyChannel.java 2005/11/16 08:39:48 1.8
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/PropertyChannel.java 2005/11/20 12:30:51 1.9
@@ -185,6 +185,8 @@
********************************************************************/
protected void logDebug (Object source, String key, Object value) {
+ if (DashboardProperties.DP_STATUS_MSG.equals (key))
+ return;
StringBuffer buf = new StringBuffer (100);
if (source != null) {
buf.append ("[");
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java 2005/11/19 18:33:01 1.24
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java 2005/11/20 12:30:51 1.25
@@ -13,7 +13,6 @@
import org.tulsoft.tools.gui.JFileChooserWithHistory;
import org.biomoby.shared.MobyException;
-import org.biomoby.shared.event.Notifier;
import javax.swing.JPanel;
import javax.swing.JLabel;
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesBoard.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/ServiceTypesBoard.java 2005/11/12 16:43:47 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesBoard.java 2005/11/20 12:30:51 1.7
@@ -72,10 +72,14 @@
Object initiator;
switch (event.getType()) {
case Notifier.SERVICE_TYPES_START:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
createProgressBar (Notifier.SIGNAL_CANCEL_SERVICE_TYPES);
insertProgressBar();
break;
case Notifier.SERVICE_TYPES_COUNT:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
if (event.getMessage() instanceof Integer)
calibrateProgressBar ( ((Integer)event.getMessage()).intValue() );
break;
@@ -88,12 +92,16 @@
case Notifier.SERVICE_TYPES_END:
case Notifier.SERVICE_TYPES_CANCELLED:
case Notifier.SERVICE_TYPES_RESET:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree == initiator)
channel.fire (this, DashboardProperties.DP_STATUS_MSG, "Done");
removeProgressBar();
break;
case Notifier.SERVICE_TYPES_UPDATED:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree != initiator) {
// someone else (of this instance) initiated request
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.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/ServiceTypesTree.java 2005/11/12 16:43:47 1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServiceTypesTree.java 2005/11/20 12:30:51 1.10
@@ -36,9 +36,6 @@
RegistryModel registryModel;
CommonConsole console;
- MobyServiceType[] serviceTypes = null;
- MobyException updateException = null;
-
final static String SERVICE_TYPES_ACCESS_ERROR =
"An error happened when accessing a list of available service types.\n\n"
+ ACCESS_ERROR_INTRO;
@@ -69,33 +66,28 @@
********************************************************************/
public void update (int howSorted, Object newData) {
if (howSorted < 0) howSorted = lastSorted;
-
+ lastSorted = howSorted;
+
setEnabledPopup (false);
- updateException = null;
final Object source = this;
final int sorted = howSorted;
final MobyServiceType[] newServiceTypes =
(newData == null ? null : (MobyServiceType[])newData);
final SwingWorker worker = new SwingWorker() {
+ MobyException updateException = null;
+ MobyServiceType[] serviceTypes = null;
public Object construct() {
try {
- log.debug ("Tree updating started");
+ if (log.isDebugEnabled())
+ log.debug ("Tree update request. Sorted: " + sorted + ", Data: " + newServiceTypes);
// get service types (unless you already have them)
if (newServiceTypes == null) {
- log.debug ("Asking registry model to update");
serviceTypes = registryModel.getServiceTypes (source);
} else {
serviceTypes = newServiceTypes;
}
- // ...and sort them accordingly
- if (sorted == SORTED_BY_AUTHORITY)
- java.util.Arrays.sort
- (serviceTypes, MobyServiceType.getAuthorityComparator());
- else
- java.util.Arrays.sort (serviceTypes);
-
} catch (MobyException e) {
updateException = e;
}
@@ -119,7 +111,10 @@
worker.start();
}
- void onUpdateServiceTypesTree (MobyServiceType[] serviceTypes) {
+ void onUpdateServiceTypesTree (MobyServiceType[] theServiceTypes) {
+ MobyServiceType[] serviceTypes = copy (theServiceTypes);
+ java.util.Arrays.sort (serviceTypes);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -148,7 +143,10 @@
}
- void onUpdateServiceTypesTreeByAuth (MobyServiceType[] serviceTypes) {
+ void onUpdateServiceTypesTreeByAuth (MobyServiceType[] theServiceTypes) {
+ MobyServiceType[] serviceTypes = copy (theServiceTypes);
+ java.util.Arrays.sort (serviceTypes, MobyServiceType.getAuthorityComparator());
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -175,6 +173,17 @@
}
/*********************************************************************
+ * Make a private copy (of pointers) that will be used for sorting...
+ ********************************************************************/
+ private MobyServiceType[] copy (MobyServiceType[] s) {
+ synchronized (s) {
+ MobyServiceType[] result = new MobyServiceType [s.length];
+ System.arraycopy (s, 0, result, 0, s.length);
+ return result;
+ }
+ }
+
+ /*********************************************************************
* Reload the tree from the Biomoby registry (or from the current
* cache). If you want to update also cache, use the cache buttons
* - they will invoke this method also after updating the cache.
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesBoard.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/ServicesBoard.java 2005/11/12 16:43:47 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesBoard.java 2005/11/20 12:30:51 1.7
@@ -72,10 +72,14 @@
Object initiator;
switch (event.getType()) {
case Notifier.AUTHORITIES_START:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
createProgressBar (Notifier.SIGNAL_CANCEL_SERVICES);
insertProgressBar();
break;
case Notifier.AUTHORITIES_COUNT:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
if (event.getMessage() instanceof Integer)
calibrateProgressBar ( ((Integer)event.getMessage()).intValue() );
break;
@@ -88,12 +92,16 @@
case Notifier.AUTHORITIES_END:
case Notifier.AUTHORITIES_CANCELLED:
case Notifier.AUTHORITIES_RESET:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree == initiator)
channel.fire (this, DashboardProperties.DP_STATUS_MSG, "Done");
removeProgressBar();
break;
case Notifier.AUTHORITIES_UPDATED:
+ if (log.isDebugEnabled())
+ log.debug (event.toString());
initiator = event.getSource();
if (tree != initiator) {
// someone else (of this instance) initiated request
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesTree.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/ServicesTree.java 2005/11/12 16:43:47 1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ServicesTree.java 2005/11/20 12:30:51 1.7
@@ -51,11 +51,6 @@
RegistryModel registryModel;
CommonConsole console;
- MobyService[] services = null;
- MobyServiceType[] serviceTypes = null;
- MobyDataType[] dataTypes = null;
- MobyException updateException = null;
-
final static String SERVICES_ACCESS_ERROR =
"An error happened when accessing a list of available services.\n\n"
+ ACCESS_ERROR_INTRO;
@@ -104,33 +99,30 @@
********************************************************************/
public void update (int howSorted, Object newData) {
if (howSorted < 0) howSorted = lastSorted;
-
+ lastSorted = howSorted;
+
setEnabledPopup (false);
- updateException = null;
final Object source = this;
final int sorted = howSorted;
final MobyService[] newServices =
(newData == null ? null : (MobyService[])newData);
final SwingWorker worker = new SwingWorker() {
+ MobyException updateException = null;
+ MobyService[] services = null;
+ MobyServiceType[] serviceTypes = null;
+ MobyDataType[] dataTypes = null;
public Object construct() {
try {
- log.debug ("Tree updating started");
+ if (log.isDebugEnabled())
+ log.debug ("Tree update request. Sorted: " + sorted + ", Data: " + newServices);
// get services (unless you already have them)
if (newServices == null) {
- log.debug ("Asking registry model to update");
services = registryModel.getServices (source);
} else {
services = newServices;
}
- // ...and sort them accordingly
- if (sorted == SORTED_BY_AUTHORITY)
- java.util.Arrays.sort
- (services, MobyService.getAuthorityComparator());
- else
- java.util.Arrays.sort (services);
-
// ...and perhaps add some other types
if (sorted == SORTED_BY_SERVICE_TYPE)
serviceTypes = registryModel.getServiceTypes (source);
@@ -169,7 +161,10 @@
worker.start();
}
- void onUpdateServicesTree (MobyService[] services) {
+ void onUpdateServicesTree (MobyService[] theServices) {
+ MobyService[] services = copy (theServices);
+ java.util.Arrays.sort (services);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -194,8 +189,11 @@
}
- void onUpdateServicesTreeByAuth (MobyService[] services) {
- DefaultTreeModel tModel = (DefaultTreeModel)getModel();
+ void onUpdateServicesTreeByAuth (MobyService[] theServices) {
+ MobyService[] services = copy (theServices);
+ java.util.Arrays.sort (services, MobyService.getAuthorityComparator());
+
+ DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
HashMap nodes = new HashMap (services.length);
@@ -220,8 +218,11 @@
tModel.reload();
}
- void onUpdateServicesTreeByType (MobyService[] services,
+ void onUpdateServicesTreeByType (MobyService[] theServices,
MobyServiceType[] serviceTypes) {
+ MobyService[] services = copy (theServices);
+ java.util.Arrays.sort (services);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -283,9 +284,12 @@
tModel.reload();
}
- void onUpdateServicesTreeByData (MobyService[] services,
+ void onUpdateServicesTreeByData (MobyService[] theServices,
MobyDataType[] dataTypes,
int whatData) {
+ MobyService[] services = copy (theServices);
+ java.util.Arrays.sort (services);
+
DefaultTreeModel tModel = (DefaultTreeModel)getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode)tModel.getRoot();
root.removeAllChildren(); // does not harm if no children exist
@@ -361,6 +365,17 @@
}
/*********************************************************************
+ * Make a private copy (of pointers) that will be used for sorting...
+ ********************************************************************/
+ private MobyService[] copy (MobyService[] s) {
+ synchronized (s) {
+ MobyService[] result = new MobyService [s.length];
+ System.arraycopy (s, 0, result, 0, s.length);
+ return result;
+ }
+ }
+
+ /*********************************************************************
* Reload the tree from the Biomoby registry, ignoring (and
* updating) cache.
********************************************************************/
More information about the MOBY-guts
mailing list