[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sun Sep 18 08:46:26 UTC 2005


senger
Sun Sep 18 04:46:26 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv23355/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractPanel.java ConsolePanel.java Dashboard.java 
	DashboardPanel.java DashboardProperties.java 
	EventGeneratorPanel.java NOTES RegistryPanel.java 
Added Files:
	CommonTree.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard CommonTree.java,NONE,1.1 AbstractPanel.java,1.3,1.4 ConsolePanel.java,1.1,1.2 Dashboard.java,1.1,1.2 DashboardPanel.java,1.2,1.3 DashboardProperties.java,1.1,1.2 EventGeneratorPanel.java,1.1,1.2 NOTES,1.1,1.2 RegistryPanel.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/09/13 06:53:28	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/09/18 08:46:26	1.4
@@ -8,21 +8,48 @@
 
 package org.biomoby.service.dashboard;
 
+import org.tulsoft.shared.UUtils;
+import org.tulsoft.shared.PrefsUtils;
 import org.tulsoft.tools.gui.SwingUtils;
+import org.tulsoft.tools.gui.JTextFieldWithHistory;
+import org.tulsoft.tools.gui.JFileChooserWithHistory;
 
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.Icon;
-import javax.swing.JComponent;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JTextField;
+import javax.swing.JFileChooser;
 import javax.swing.AbstractButton;
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import javax.swing.border.Border;
+import javax.swing.border.TitledBorder;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.filechooser.FileFilter;
 import javax.swing.text.html.HTMLDocument;
 
+import java.awt.GridBagLayout;
 import java.awt.GridBagConstraints;
 import java.awt.Insets;
+import java.awt.Font;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemListener;
+
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeSupport;
 
+import java.io.File;
+import java.util.prefs.Preferences;
+
 /**
  * WORK IN PROGRESS. <p>
  *
@@ -34,31 +61,29 @@
     extends JPanel
     implements DashboardPanel {
 
-
     // copy here some often used constants
     protected static final int RELATIVE = GridBagConstraints.RELATIVE;
     protected static final int REMAINDER = GridBagConstraints.REMAINDER;
     protected static final int NONE = GridBagConstraints.NONE;
     protected static final int BOTH = GridBagConstraints.BOTH;
-    protected static final int HORIZONTAL = GridBagConstraints.HORIZONTAL;
-    protected static final int VERTICAL = GridBagConstraints.VERTICAL;
+    protected static final int HORI = GridBagConstraints.HORIZONTAL;
+    protected static final int VERT = GridBagConstraints.VERTICAL;
     protected static final int CENTER = GridBagConstraints.CENTER;
     protected static final int NORTH = GridBagConstraints.NORTH;
-    protected static final int NORTHEAST = GridBagConstraints.NORTHEAST;
+    protected static final int NEAST = GridBagConstraints.NORTHEAST;
     protected static final int EAST = GridBagConstraints.EAST;
-    protected static final int SOUTHEAST = GridBagConstraints.SOUTHEAST;
+    protected static final int SEAST = GridBagConstraints.SOUTHEAST;
     protected static final int SOUTH = GridBagConstraints.SOUTH;
-    protected static final int SOUTHWEST = GridBagConstraints.SOUTHWEST;
+    protected static final int SWEST = GridBagConstraints.SOUTHWEST;
     protected static final int WEST = GridBagConstraints.WEST;
-    protected static final int NORTHWEST = GridBagConstraints.NORTHWEST;
-    protected static final int PAGE_START = GridBagConstraints.PAGE_START;
-    protected static final int PAGE_END = GridBagConstraints.PAGE_END;
-    protected static final int LINE_START = GridBagConstraints.LINE_START;
-    protected static final int LINE_END = GridBagConstraints.LINE_END;
-    protected static final int FIRST_LINE_START = GridBagConstraints.FIRST_LINE_START;
-    protected static final int FIRST_LINE_END = GridBagConstraints.FIRST_LINE_END;
-    protected static final int LAST_LINE_START = GridBagConstraints.LAST_LINE_START;
-    protected static final int LAST_LINE_END = GridBagConstraints.LAST_LINE_END;
+    protected static final int NWEST = GridBagConstraints.NORTHWEST;
+
+    // something need to be done only once - keep it here
+    protected Icon panelIcon;
+    protected JComponent pComponent;
+
+    // re-use "style" components
+    protected static final Insets BREATH_TOP = new Insets (10,0,0,0);
 
 
     /*********************************************************************
@@ -82,6 +107,16 @@
 	return null;
     }
 
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public JLabel getTitle() {
+	JLabel title = new JLabel (getName(), getIcon(), JLabel.CENTER);
+	title.setFont (new Font ("Serif", Font.BOLD, 20));
+	title.setForeground (new Color (12, 55, 241));
+	return title;
+    }
+
     /*********************************************************************
      * Property change stuff
      ********************************************************************/
@@ -117,11 +152,6 @@
      **************************************************************************/
     abstract public String getName();
 
-    /**************************************************************************
-     *
-     **************************************************************************/
-    abstract public JLabel getTitle();
-
     //
     // Methods to be used by sub-classes
     //
@@ -137,6 +167,112 @@
     }
 
     /*********************************************************************
+     * Create a button (with a unified style).
+     ********************************************************************/
+    protected static JButton createButton (String name,
+					   String toolTipText,
+					   int mnemonic,
+					   ActionListener listener) {
+	JButton button = new JButton (name);
+ 	commonButtonLookAndFeel (button);
+        button.setToolTipText (toolTipText);
+	if (mnemonic > 0)
+	    button.setMnemonic (mnemonic);
+        button.addActionListener (listener);
+	return button;
+    }
+
+    /*********************************************************************
+     * Create a check-box (with a unified style).
+     ********************************************************************/
+    protected static JCheckBox createCheckBox (String label,
+					       boolean isSelected,
+					       int mnemonic,
+					       ItemListener listener) {
+	JCheckBox box = new JCheckBox (label, isSelected);
+	if (mnemonic > 0)
+	    box.setMnemonic (mnemonic);
+	box.addItemListener (listener);
+        box.setFocusPainted (false);
+	return box;
+    }
+
+    /*********************************************************************
+     * Create a horizontal panel with given buttons.
+     ********************************************************************/
+    protected static JPanel createButtonPanel (JButton[] buttons) {
+
+	JPanel buttonPanel = new JPanel();
+	buttonPanel.setLayout (new BoxLayout (buttonPanel, BoxLayout.LINE_AXIS));
+	buttonPanel.setBorder (BorderFactory.createEmptyBorder (10, 0, 0, 10));
+	buttonPanel.add (Box.createHorizontalGlue());
+	for (int i = 0; i < buttons.length; i++)
+	    buttonPanel.add (buttons[i]);
+	return buttonPanel;
+    }
+
+    /*********************************************************************
+     * Create a titled panel using the given title and GridBagLayout.
+     ********************************************************************/
+    protected static JPanel createTitledPanel (String title) {
+	JPanel titledPanel = new JPanel (new GridBagLayout());
+	Border blackline = BorderFactory.createLineBorder (Color.black);
+	CompoundBorder compoundBorder =
+	    BorderFactory.createCompoundBorder (BorderFactory.createTitledBorder (blackline, title),
+						BorderFactory.createEmptyBorder (5, 5, 5, 5));
+	titledPanel.setBorder (compoundBorder);
+	return titledPanel;
+    }
+
+    /*********************************************************************
+     * Create a panel with given text field and with a directory/file
+     * browser button attached.
+     *
+     * @param chooserMode should be one of
+     * JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_ONLY, and
+     * JFileChooser.FILES_AND_DIRECTORIES (but it is not tested)
+     ********************************************************************/
+    protected JFileChooserWithHistory createFileSelector (String chooserTitle,
+							  String approveButtonText,
+							  int chooserMode,
+							  String defaultValue,
+							  FileFilter filter) {
+	JFileChooserWithHistory chooser =
+	    new JFileChooserWithHistory (null, this, "cacheDirectory");
+
+	JFileChooser ch = chooser.getFileChooser();
+	ch.setFileSelectionMode (chooserMode);
+	if (filter != null)
+	    ch.setFileFilter (filter);
+	ch.setApproveButtonText (approveButtonText);
+	ch.setDialogTitle (chooserTitle);
+
+ 	if (UUtils.notEmpty (defaultValue) &&
+ 	    chooser.getSelectedFile() == null)
+ 	    chooser.setSelectedFile (new File (defaultValue));
+
+	return chooser;
+    }
+
+    /*********************************************************************
+     * 
+     ********************************************************************/
+    protected boolean getPrefValue (String key,
+				    boolean defaultValue) {
+	Preferences node = PrefsUtils.getNode (this.getClass());
+	return node.getBoolean (key, defaultValue);
+    }
+
+    /*********************************************************************
+     * 
+     ********************************************************************/
+    protected void setPrefValue (String key,
+				 boolean value) {
+	Preferences node = PrefsUtils.getNode (this.getClass());
+	node.putBoolean (key, value);
+    }
+
+    /*********************************************************************
      * Return true if confirmation dialog passed.
      ********************************************************************/
     public boolean confirm (Object msg) {

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ConsolePanel.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/ConsolePanel.java	2005/09/13 06:54:36	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/ConsolePanel.java	2005/09/18 08:46:26	1.2
@@ -22,6 +22,7 @@
 
 import java.awt.Font;
 import java.awt.GridBagLayout;
+import java.awt.event.KeyEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeListener;
@@ -85,19 +86,20 @@
 	textArea.setEditable (false);
 	JScrollPane scroller = new JScrollPane (textArea);
 
-	JButton cleanButton = new JButton (" Clean ");
- 	commonButtonLookAndFeel (cleanButton);
-        cleanButton.setToolTipText ("Remove all messages from the console area");
-        cleanButton.addActionListener (new ActionListener() {
-		public void actionPerformed (ActionEvent e) {
-		    if (! "".equals (textArea.getText()) && confirm ("Remove all messages?"))
-			textArea.setText ("");
-		}
-	    });
+	JButton cleanButton =
+	    createButton (" Clean ",
+			  "Remove all messages from the console area",
+			  KeyEvent.VK_C,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  if (! "".equals (textArea.getText()) && confirm ("Remove all messages?"))
+				      textArea.setText ("");
+			      }
+			  });
 
 	// put it together
- 	SwingUtils.addComponent (p, scroller,    0, 0, 1, 1, BOTH, FIRST_LINE_START, 1.0, 1.0);
- 	SwingUtils.addComponent (p, cleanButton, 0, 1, 1, 1, NONE, FIRST_LINE_START, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, scroller,    0, 0, 1, 1, BOTH, NWEST, 1.0, 1.0);
+ 	SwingUtils.addComponent (p, cleanButton, 0, 1, 1, 1, NONE, NWEST, 0.0, 0.0);
 
 	return p;
     }
@@ -109,11 +111,4 @@
 	return "Debugging Console";
     }
 
-    /**************************************************************************
-     *
-     **************************************************************************/
-    public JLabel getTitle() {
-	return new JLabel (getName());
-    }
-
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.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/Dashboard.java	2005/09/13 06:54:36	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/Dashboard.java	2005/09/18 08:46:26	1.2
@@ -20,7 +20,11 @@
 import javax.swing.JLabel;
 import javax.swing.Icon;
 import javax.swing.text.html.HTMLDocument;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.ChangeEvent;
+
 import java.awt.GridBagLayout;
+import java.awt.Font;
 
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeEvent;
@@ -29,7 +33,9 @@
 import java.util.Vector;
 import java.util.Enumeration;
 import java.util.Properties;
+import java.util.Date;
 import java.net.URL;
+import java.text.DateFormat;
 
 /**
  * WORK IN PROGRESS. <p>
@@ -39,13 +45,16 @@
  */
 
 public class Dashboard
-    implements DashboardPanel {
+    implements DashboardPanel, ChangeListener {
 
+    private JComponent dashboard;
+    private StatusBar statusBar;
+    private DashboardHeader header;
+    protected JTabbedPane tabbedPane;
     protected DashboardPanel[] panels;
     protected static Properties dashboardProperties;
 
     static {
-	final String DASHBOARD_PROPERTIES_FILE = "dashboard.properties";
 	try {
 	    // get the classloader for this class
 	    ClassLoader loader = Dashboard.class.getClassLoader();
@@ -53,11 +62,8 @@
 		loader = Thread.currentThread().getContextClassLoader();
 	    }
 
-// 	    unknownProcessorIcon =
-// 		new ImageIcon(loader.getResource("org/embl/ebi/escience/scuflui/icons/explorer/unknownprocessor.png"));
-
-	    // load values from any dashboard.properties file located
-	    // by the class resource loader
+	    // load dashboard properties from a file located by the
+	    // class resource loader
 	    Enumeration en = loader.getResources (DASHBOARD_PROPERTIES_FILE);
 	    dashboardProperties = new Properties();
 	    while (en.hasMoreElements()) {
@@ -71,6 +77,16 @@
     }
 
     /**************************************************************************
+     * Default constructor. It loads all panels, connect them and
+     * creates the GUI - but does not show it yet.
+     **************************************************************************/
+    public Dashboard() {
+	loadPanels();
+	dashboard = getComponent();
+	connectPanels();
+    }
+
+    /**************************************************************************
      * Load all available Dashboard panels...
      **************************************************************************/
     public void loadPanels() {
@@ -84,31 +100,26 @@
     }
 
     /**************************************************************************
-     * Connect all available Dashboard panels...
+     * Connect all available Dashboard panels: a) together, and b)
+     * with the status bar.
      **************************************************************************/
     public void connectPanels() {
 	for (int i = 0; i < panels.length; i++) {
 	    for (int j = 0; j < i; j++)
-		connect (panels[i], panels[j]);
+		panels[i].addPropertyChangeListener (panels[j]);
 	    for (int j = i+1; j < panels.length; j++)
-		connect (panels[i], panels[j]);
+		panels[i].addPropertyChangeListener (panels[j]);
+	    if (statusBar != null)
+		panels[i].addPropertyChangeListener (statusBar);
 	}
     }
 
-    //
-    void connect (DashboardPanel one, DashboardPanel two) {
-	one.addPropertyChangeListener (two);
-    }
-
     /**************************************************************************
      * Show the main frame.
      **************************************************************************/
     public void show() {
-	JComponent dashboard = getComponent();
-
-  	JFrame frame = SwingUtils.createMainFrame (dashboard, getName());
+  	JFrame frame = SwingUtils.createMainFrame (getComponent(), getName());
   	SwingUtils.showMainFrame (frame, dashboard.getPreferredSize());
-//   	SwingUtils.showMainFrame (frame, dashboard.getPreferredFrameSize());
     }
 
     /**************************************************************************
@@ -125,20 +136,6 @@
 	return new String (buf);
     }
 
-    /**************************************************************************
-     *
-     **************************************************************************/
-    public static void main (String[] args) {
-	SwingUtils.checkJavaVersion();
-
-	Dashboard dashboard = new Dashboard();
-	dashboard.loadPanels();
-	dashboard.connectPanels();
-// 	System.out.println ("DASHBOARD:\n" + dashboard.toString());
-	dashboard.show();
-
-    }
-
     //
     // Implement DashboardPanel interface
     //
@@ -154,7 +151,15 @@
      *
      **************************************************************************/
     public JLabel getTitle() {
-	return new JLabel (getName());
+	Icon titleIcon =
+	    SwingUtils.createIcon (dashboardProperties.getProperty (DP_TITLE_ICON),
+				   this);
+	String titleStr = dashboardProperties.getProperty (DP_TITLE);
+	if (titleStr == null && titleIcon == null)
+	    titleStr = getName();
+	JLabel title = new JLabel (titleStr, titleIcon, JLabel.CENTER);
+	title.setFont (new Font ("Serif", Font.BOLD, 30));
+	return title;
     }
 
     /**************************************************************************
@@ -168,7 +173,8 @@
      *
      **************************************************************************/
     public Icon getIcon() {
-	return null;
+	return SwingUtils.createIcon (dashboardProperties.getProperty (DP_TITLE_ICON),
+				      this);
     }
 
     /**************************************************************************
@@ -176,24 +182,93 @@
      **************************************************************************/
     public JComponent getComponent() {
 
+	if (dashboard != null)
+	    return dashboard;
+
+	// create itself
 	JPanel p = new JPanel (new GridBagLayout(), true);
 
-        JComponent header = createHeader();
-	JTabbedPane tabbedPane = new JTabbedPane();
+        header = getHeader();
+	tabbedPane = new JTabbedPane();
+	tabbedPane.addChangeListener (this);
 	for (int i = 0; i < panels.length; i++) {
 	    tabbedPane.addTab (panels[i].getName(), panels[i].getIcon(), panels[i].getComponent());
 	}
+        statusBar = getStatusBar();
 
 	// put it all together
-	SwingUtils.addComponent (p, header,     0, 0, 1, 1, AbstractPanel.HORIZONTAL, AbstractPanel.FIRST_LINE_START, 1.0, 0.0);
-	SwingUtils.addComponent (p, tabbedPane, 0, 1, 1, 1, AbstractPanel.BOTH,       AbstractPanel.FIRST_LINE_START, 1.0, 1.0);
+	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);
 
 	return p;
     }
 
-    //
-    JComponent createHeader() {
-	return getTitle();
+    /**************************************************************************
+     *
+     **************************************************************************/
+    DashboardHeader getHeader() {
+	DashboardHeader h = new DashboardHeader (dashboardProperties);
+	if (panels.length > 0)
+	    h.setPanelTitle (panels[0].getTitle());
+	return h;
+    }
+
+    class DashboardHeader extends JPanel {
+	public DashboardHeader (Properties props) {
+	    super (new GridBagLayout());
+	    JLabel mainTitle = getTitle();
+	    JLabel mainIcon =
+		new JLabel ("",
+			    SwingUtils.createIcon (props.getProperty (DP_ICON), this),
+			    JLabel.CENTER);	  
+	    JLabel panelTitle = new JLabel();
+
+	    // put it all together (keep 'panelTitle' always as the 3rd component)
+	    SwingUtils.addComponent (this, mainIcon,   0, 0, 1, 2, AbstractPanel.NONE, AbstractPanel.NWEST, 0.0, 0.0);
+	    SwingUtils.addComponent (this, mainTitle,  1, 0, 1, 1, AbstractPanel.NONE, AbstractPanel.NORTH, 1.0, 0.0);
+	    SwingUtils.addComponent (this, panelTitle, 1, 1, 1, 1, AbstractPanel.NONE, AbstractPanel.SOUTH, 0.0, 0.0);
+	}
+	public void setPanelTitle (JLabel newTitle) {
+	    remove (2);
+	    SwingUtils.addComponent (this, newTitle,   1, 1, 1, 1, AbstractPanel.NONE, AbstractPanel.SOUTH, 0.0, 0.0);
+	    AwtUtils.redisplay (this);
+	}
+    }  
+
+    /**************************************************************************
+     * Return a component representing status bar (usually placed at
+     * the bottom of a dashboard).
+     **************************************************************************/
+    StatusBar getStatusBar() {
+	return new StatusBar ("Status: Work in progress");
+    }
+
+    class StatusBar extends JLabel implements PropertyChangeListener {
+	DateFormat df = DateFormat.getTimeInstance();
+	public StatusBar (String text) {
+	    super (text);
+	}
+	public void propertyChange (PropertyChangeEvent e) {
+	    String prop = e.getPropertyName();
+	    if (prop == null) return;     // no interest in non-specific changes
+	    Object value = e.getNewValue();
+	    if (value == null) return;   // no interest in non-defined  new values
+	    if (prop.equalsIgnoreCase (DP_STATUS_MSG))
+		setText ("[" + df.format (new Date()) + "] " + value.toString());
+	}
+    }
+
+    /**************************************************************************
+     * Dashboard is listening to the changes of panels in order to
+     * repaint the header with a label of a currently selected panel.
+     **************************************************************************/
+    public void stateChanged (ChangeEvent e) {
+	int panelIndex = tabbedPane.getSelectedIndex();
+	if (panelIndex < 0 || panelIndex >= panels.length)
+	    header.setPanelTitle (null);
+	else
+	    header.setPanelTitle (panels[panelIndex].getTitle());
     }
 
     /**************************************************************************
@@ -214,9 +289,13 @@
     public void propertyChange (PropertyChangeEvent event) {
     }
 
-//     Preferences prefs = Preferences.userNodeForPackage (DataThingViewer.class);
-//     String curDir = prefs.get ("currentDir", System.getProperty("user.home"));
-//     ...
-//     prefs.put ("currentDir", fc.getCurrentDirectory().toString());
+    /**************************************************************************
+     *
+     * An entry point...
+     *
+     **************************************************************************/
+    public static void main (String[] args) {
+	new Dashboard().show();
+    }
 
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardPanel.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/DashboardPanel.java	2005/09/13 06:53:28	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardPanel.java	2005/09/18 08:46:26	1.3
@@ -16,7 +16,7 @@
 
 /**
  * An interface that must be implemented by each panel that wants to
- * sit on the dashboard. <p>
+ * sit on a dashboard. <p>
  *
  * WORK IN PROGRESS <p>
  *
@@ -32,6 +32,11 @@
     extends PropertyChangeListener, DashboardProperties {
 
     /**************************************************************************
+     * Return a graphical representation of this panel.
+     **************************************************************************/
+    JComponent getComponent();
+
+    /**************************************************************************
      * A name identifies a panel in the dashboard's tabs. It should be
      * relatively short, without newlines, or any other special
      * characters. <p>
@@ -63,11 +68,6 @@
     Icon getIcon();
 
     /**************************************************************************
-     * The main contents. Here is everything...
-     **************************************************************************/
-    JComponent getComponent();
-
-    /**************************************************************************
      * Add a PropertyChangeListener to the listener list of a
      * panel. All listeners will be notified if this panel changes
      * some property. <p>

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.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/DashboardProperties.java	2005/09/13 06:54:36	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java	2005/09/18 08:46:26	1.2
@@ -18,7 +18,8 @@
 
 /**
  * A list of names of most/all recognized properties that can be fired
- * by dashboard panels. <p>
+ * by dashboard panels, and a list of names of Java properties that
+ * can be used to configure the dashboard. <p>
  *
  * @author <A HREF="mailto:martin.senger at gmail.com">Martin Senger</A>
  * @version $Id$
@@ -27,7 +28,34 @@
 public interface DashboardProperties {
 
     static final String DP_LOG_MSG = "log-msg";
+    static final String DP_STATUS_MSG = "status-msg";
     static final String DP_SERVICE_NAME = "dp-service-name";
     static final String DP_DATATYPE_NAME = "dp-datatype-name";
 
+    /** A filename containing Java properties that configure the
+	dashboard. */
+    static final String DASHBOARD_PROPERTIES_FILE = "dashboard.properties";
+
+    /** A property name. Its value contains a title that will appear
+     * in big fonts on top of the dashboard.  It may be empty if
+     * property {@link #DP_TITLE_ICON} is defined; otherwise a default
+     * value will be used.
+     */
+    static final String DP_TITLE = "dashboard.title";
+
+    /** A property name. Its value contains a filename with an icon
+     * accompanying a dashboard title (defined by property {@link
+     * #DP_TITLE}. No default value used. Specify here either an
+     * absolute path (not recommended) or a relative path whose
+     * beginning can be found somewhere on the CLASSPATH.
+     */
+    static final String DP_TITLE_ICON = "dashboard.title.icon";
+
+    /** A property name. Its value contains a filename with the main
+     * dashboard icon. Specify here either an absolute path (not
+     * recommended) or a relative path whose beginning can be found
+     * somewhere on the CLASSPATH.
+     */
+    static final String DP_ICON = "dashboard.icon";
+
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/EventGeneratorPanel.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/EventGeneratorPanel.java	2005/09/13 06:54:36	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/EventGeneratorPanel.java	2005/09/18 08:46:26	1.2
@@ -48,13 +48,14 @@
 			"Some buttons may use a text put in the adjacent form field.<br>" +
 			"For some events, the form field accepts a comma-separated list.</html>");
 
-  	SwingUtils.addComponent (p, desc, 0, 0, REMAINDER, 1, HORIZONTAL, FIRST_LINE_START, 0.0, 0.0);
+  	SwingUtils.addComponent (p, desc, 0, 0, REMAINDER, 1, HORI, NWEST, 0.0, 0.0);
 
 	addStringEvent (p, "Service name", DP_SERVICE_NAME);
 	addStringEvent (p, "Data type name", DP_DATATYPE_NAME);
+	addStringEvent (p, "Status bar message", DP_STATUS_MSG);
 
 	JLabel empty = new JLabel();
-  	SwingUtils.addComponent (p, empty, 0, RELATIVE, 2, 1, HORIZONTAL, FIRST_LINE_START, 0.0, 0.1);
+  	SwingUtils.addComponent (p, empty, 0, RELATIVE, 2, 1, HORI, NWEST, 0.0, 0.1);
 
 	return p;
     }
@@ -74,8 +75,8 @@
 	    });
 
 	// add it to the common panel
- 	SwingUtils.addComponent (p, button, 0, RELATIVE, 1, 1, HORIZONTAL, FIRST_LINE_START, 0.0, 0.0);
- 	SwingUtils.addComponent (p, text,   1, RELATIVE, 1, 1, HORIZONTAL, LINE_START,       1.0, 0.0);
+ 	SwingUtils.addComponent (p, button, 0, RELATIVE, 1, 1, HORI, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (p, text,   1, RELATIVE, 1, 1, HORI, WEST,  1.0, 0.0);
     }
 
     //
@@ -90,11 +91,5 @@
 	return "Debugging Event Generator";
     }
 
-    /**************************************************************************
-     *
-     **************************************************************************/
-    public JLabel getTitle() {
-	return new JLabel (getName());
-    }
 
 }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,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/NOTES	2005/09/13 06:53:28	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/09/18 08:46:26	1.2
@@ -1,18 +1,17 @@
+TODO with views:
+----------------
+? small icons to buttons
+? use FileSystemView in file choosers
+* alltools2: - PrefsUtils may become just a common parent for both *WithHistory classes
+             - combo box history is not updated if exit happened while focus is till in the text field
+
+? configure dashboard from menu:
+  * configure dashbard (add/remove dynamically panels)
+  * configure user preferences
 
-src/main/org/biomoby/service/dashboard/Dashboard.java
-
-Dashboard configuration - by getResource()
------------------------
-
-* SPI for panel interfaces (Apache - commons - Discovery)
-
-* persistence of the last used properties (at least those easily
-serializable)
-
-* own properties, such as:
-  - title, icon, sub-title (will be replaced by a panel title)
+* Registry panel:
+  - trees should be in panned blocks (user-resizable)
 
-* java.beans (property chnages)
 
 Registry panel
 --------------
@@ -42,3 +41,10 @@
 
 * model (worker: antWorker)
 
+Other (future, possible) panels:
+--------------------------------
+- verify registry
+- browsing in graphs
+- RDF resources
+- Log panel
+- Configure a new Dashboard

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.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/RegistryPanel.java	2005/09/13 06:53:28	1.3
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistryPanel.java	2005/09/18 08:46:26	1.4
@@ -9,14 +9,25 @@
 package org.biomoby.service.dashboard;
 
 import org.tulsoft.tools.gui.SwingUtils;
+import org.tulsoft.tools.gui.JTextFieldWithHistory;
+import org.tulsoft.tools.gui.JFileChooserWithHistory;
 
+import javax.swing.JPanel;
 import javax.swing.JLabel;
 import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFileChooser;
 import javax.swing.JComponent;
 import javax.swing.text.html.HTMLDocument;
 
+import java.awt.GridBagLayout;
+
+import java.awt.event.KeyEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeEvent;
 
@@ -34,6 +45,13 @@
 public class RegistryPanel
     extends AbstractPanel {
 
+    // names of user preferences keys
+    static final String USE_CACHE = "use-cache";
+
+    // components that are used from more methods
+    JFileChooserWithHistory cacheDir;
+    JLabel labelCacheDir;
+
     /*********************************************************************
      * propertyChange()
      ********************************************************************/
@@ -52,21 +70,210 @@
      *
      **************************************************************************/
     public JComponent getComponent() {
-	return null;
+	if (pComponent != null)
+	    return pComponent;
+
+	pComponent = new JPanel (new GridBagLayout(), true);
+
+	// ontology trees
+	ServicesTree servicesTree = new ServicesTree();
+	DataTypesTree dataTypesTree = new DataTypesTree();
+	NamespacesTree namespacesTree = new NamespacesTree();
+
+	// registry and cache locations
+	JPanel regLocation = getRegistryLocation();
+	JPanel cacheLocation = getCacheLocation();
+
+	// put all together
+ 	SwingUtils.addComponent (pComponent, servicesTree.scrollable(),   0, 0, 1, 2, BOTH, NWEST, 0.25, 0.66);
+ 	SwingUtils.addComponent (pComponent, dataTypesTree.scrollable(),  1, 0, 1, 2, BOTH, NWEST, 0.25, 0.66);
+ 	SwingUtils.addComponent (pComponent, namespacesTree.scrollable(), 2, 0, 1, 2, BOTH, NWEST, 0.25, 0.66);
+ 	SwingUtils.addComponent (pComponent, regLocation,                 3, 0, 1, 1, HORI, NWEST, 0.1, 0.0);
+ 	SwingUtils.addComponent (pComponent, cacheLocation,               3, 1, 1, 1, HORI, NWEST, 0.1, 0.0);
+
+	return pComponent;
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onReloadAll() {
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onDefaults() {
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onCacheInfo() {
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onCacheErase() {
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onCacheUpdate() {
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    public void onUseCache (boolean enabled) {
+	cacheDir.setEnabled (enabled);
+	labelCacheDir.setEnabled (enabled);
+	setPrefValue (USE_CACHE, enabled);
+    }
+
+    /**************************************************************************
+     * Panel for registry.
+     **************************************************************************/
+    protected JPanel getRegistryLocation() {
+   	JLabel labelRegistryURL = new JLabel("Endpoint");
+	JTextFieldWithHistory registryURL =
+	    new JTextFieldWithHistory ("", this, "registryEndpoint");
+   	JLabel labelRegistryNS = new JLabel("Namespace (URI)");
+	JTextFieldWithHistory registryNS =
+	    new JTextFieldWithHistory ("", this, "registryNamespace");
+	JButton reloadAllButton =
+	    createButton (" Reload all ",
+			  "Reload all ontology trees from the Biomoby registry",
+			  KeyEvent.VK_R,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onReloadAll();
+			      }
+			  });
+	JButton defaultsButton =
+	    createButton (" Restore defaults ",
+			  "Fill the text fields above with the default values",
+			  KeyEvent.VK_D,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onDefaults();
+			      }
+			  });
+	JPanel buttonPanel = createButtonPanel (new JButton[] { reloadAllButton,
+								defaultsButton });
+	JPanel rLocation = createTitledPanel ("Biomoby registry location");
+ 	SwingUtils.addComponent (rLocation, labelRegistryURL, 0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
+ 	SwingUtils.addComponent (rLocation, registryURL,      0, 1, 1, 1, HORI, NWEST, 1.0, 0.0);
+ 	SwingUtils.addComponent (rLocation, labelRegistryNS,  0, 2, 1, 1, NONE, NWEST, 0.0, 0.0, BREATH_TOP);
+ 	SwingUtils.addComponent (rLocation, registryNS,       0, 3, 1, 1, HORI, NWEST, 1.0, 0.0);
+ 	SwingUtils.addComponent (rLocation, buttonPanel,      0, 4, 1, 1, NONE, SWEST, 0.0, 0.0);
+
+	return rLocation;
+    }
+
+    /**************************************************************************
+     * Panel for local cache.
+     **************************************************************************/
+    protected JPanel getCacheLocation() {
+	boolean usingCache = getPrefValue (USE_CACHE, true);
+	JCheckBox useCache =
+	    createCheckBox ("Use local cache", usingCache, KeyEvent.VK_C,
+			    new ItemListener() {
+				public void itemStateChanged (ItemEvent e) {
+				    onUseCache (e.getStateChange() == ItemEvent.SELECTED);
+				}
+			    });
+   	labelCacheDir = new JLabel("Cache directory");
+	cacheDir = createFileSelector ("Select directory for/with local cache",
+				       "Select",
+				       JFileChooser.DIRECTORIES_ONLY,
+				       System.getProperty ("java.io.tmpdir"),
+				       null);
+	onUseCache (usingCache);
+	JButton infoButton =
+	    createButton (" Info ",
+			  "Show current information about the local cache",
+			  KeyEvent.VK_I,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onCacheInfo();
+			      }
+			  });
+	JButton updateButton =
+	    createButton (" Update ",
+			  "Update local cache from Biomoby registry",
+			  KeyEvent.VK_U,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onCacheUpdate();
+			      }
+			  });
+	JButton eraseButton =
+	    createButton (" Erase ",
+			  "Remove everything from the local cache",
+			  KeyEvent.VK_E,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onCacheErase();
+			      }
+			  });
+	JPanel buttonPanel = createButtonPanel (new JButton[] { infoButton,
+								updateButton,
+								eraseButton });
+
+	JPanel cLocation = createTitledPanel ("Local cache");
+ 	SwingUtils.addComponent (cLocation, useCache,      0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
+  	SwingUtils.addComponent (cLocation, labelCacheDir, 0, 1, 1, 1, NONE, NWEST, 0.0, 0.0, BREATH_TOP);
+	SwingUtils.addComponent (cLocation, cacheDir,      0, 2, 1, 1, HORI, NWEST, 1.0, 0.0);
+ 	SwingUtils.addComponent (cLocation, buttonPanel,   0, 3, 1, 1, NONE, SWEST, 0.0, 0.0);
+
+	return cLocation;
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class ServicesTree extends CommonTree {
+	public ServicesTree() {
+	    super ("Services");
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class DataTypesTree extends CommonTree {
+	public DataTypesTree() {
+	    super ("DataTypes");
+	}
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    class NamespacesTree extends CommonTree {
+	public NamespacesTree() {
+	    super ("Namespaces");
+	}
     }
 
     /**************************************************************************
      *
      **************************************************************************/
     public String getName() {
-	return "Biomoby Registry";
+	return "Registry Browser";
     }
 
     /**************************************************************************
      *
      **************************************************************************/
-    public JLabel getTitle() {
-	return new JLabel (getName());
+    public Icon getIcon() {
+	if (panelIcon == null)
+	    panelIcon = SwingUtils.createIcon ("images/registry.gif", this);
+	return panelIcon;
     }
 
+
 }




More information about the MOBY-guts mailing list