[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Thu Nov 3 15:21:57 UTC 2005


senger
Thu Nov  3 10:21:57 EST 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard
In directory pub.open-bio.org:/tmp/cvs-serv20017/src/main/org/biomoby/service/dashboard

Modified Files:
	AbstractPanel.java DashboardProperties.java NOTES 
	RegistrationPanel.java 
Log Message:


moby-live/Java/src/main/org/biomoby/service/dashboard AbstractPanel.java,1.12,1.13 DashboardProperties.java,1.9,1.10 NOTES,1.15,1.16 RegistrationPanel.java,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/03 08:38:39	1.12
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/AbstractPanel.java	2005/11/03 15:21:57	1.13
@@ -94,6 +94,8 @@
 
     // re-use "style" components
     protected static final Insets BREATH_TOP = new Insets (10,0,0,0);
+    protected static final Insets BREATH_TOP_LEFT = new Insets (10,10,0,0);
+    protected static final Insets BREATH_LEFT = new Insets (0,10,0,0);
     protected static final Font MSG_AREA_FONT = new Font ("Courier", Font.PLAIN, 10);
     protected static final Font TITLE_FONT = new Font ("Serif", Font.BOLD, 20);
     protected static final Color TITLE_FGCOLOR = new Color (12, 55, 241);
@@ -213,7 +215,8 @@
 	JCheckBox box = new JCheckBox (label, isSelected);
 	if (mnemonic > 0)
 	    box.setMnemonic (mnemonic);
-	box.addItemListener (listener);
+	if (listener != null)
+	    box.addItemListener (listener);
         box.setFocusPainted (false);
 	return box;
     }

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.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/DashboardProperties.java	2005/11/03 08:38:39	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/DashboardProperties.java	2005/11/03 15:21:57	1.10
@@ -58,6 +58,16 @@
     static final String DP_REG_ST_ISA = "dp-reg-st-isa";
     static final String DP_REG_ST_COPY_BY_SELECT = "dp-reg-st-cbs";  // type: Boolean
 
+    static final String DP_REG_S_NAME = "dp-reg-s-name";
+    static final String DP_REG_S_AUTH = "dp-reg-s-auth";
+    static final String DP_REG_S_EMAIL = "dp-reg-s-email";
+    static final String DP_REG_S_DESC = "dp-reg-s-desc";
+    static final String DP_REG_S_URL = "dp-reg-s-url";
+    static final String DP_REG_S_RDF_URL = "dp-reg-s-rdf-url";
+    static final String DP_REG_S_RDF_PATH = "dp-reg-s-rdf-path";
+    static final String DP_USE_SIGNATURE = "dp-use-signature";  // type: Boolean
+    static final String DP_USE_AUTHORITATIVE = "dp-use-auth";  // type: Boolean
+
     /** A filename containing Java properties that configure the
 	dashboard. */
     static final String DASHBOARD_PROPERTIES_FILE = "dashboard.properties";

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/11/03 08:38:39	1.15
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/NOTES	2005/11/03 15:21:57	1.16
@@ -1,3 +1,8 @@
+* show/store XML sent to register this service
+  (a place for using it other time?)
+
+* how to squeeze too long combo boxes into smaller place ?
+
 * registration: selecting an authority is really propagated to the
 text fields? (Do for data type registration the same as was done for
 Namespace registration.)

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.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/RegistrationPanel.java	2005/11/03 08:38:39	1.6
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/dashboard/RegistrationPanel.java	2005/11/03 15:21:57	1.7
@@ -13,6 +13,7 @@
 import org.biomoby.shared.MobyDataType;
 import org.biomoby.shared.MobyNamespace;
 import org.biomoby.shared.MobyServiceType;
+import org.biomoby.shared.MobyService;
 import org.biomoby.shared.MobyRelationship;
 import org.biomoby.shared.parser.MobyTags;
 import org.biomoby.service.generator.DataTypesGenerator;
@@ -73,7 +74,8 @@
     static final String COPY_BY_SELECT_NS = "ns-copy-by-select";
     static final String COPY_BY_SELECT_ST = "st-copy-by-select";
     static final String COPY_BY_SELECT_DT = "dt-copy-by-select";
-    static final String COPY_BY_SELECT_S  = "s-copy-by-select";
+    static final String USE_SIGNATURE = "use-signature";
+    static final String USE_AUTHORITATIVE = "use-authoritative";
 
     // associated model working behind the scenes
     RegistryModel registryModel;
@@ -86,14 +88,18 @@
     JButton sRegisterButton;
     CommonConsole console;
 
-    JTextFieldWithHistory dtName, nsName, stName;
-    JTextFieldWithHistory dtAuth, nsAuth, stAuth;
-    JTextFieldWithHistory dtEmail, nsEmail, stEmail;
-    JTextArea dtDescArea, nsDescArea, stDescArea;
+    JTextFieldWithHistory dtName, nsName, stName, sName;
+    JTextFieldWithHistory dtAuth, nsAuth, stAuth, sAuth;
+    JTextFieldWithHistory dtEmail, nsEmail, stEmail, sEmail;
+    JTextArea dtDescArea, nsDescArea, stDescArea, sDescArea;
     JLabel stISA;
+    JLabel sType, labelSigURL, labelRDFPath;
+    JTextFieldWithHistory sURL, sSigURL;
+    JFileChooserWithHistory localRDFFile;
+    JCheckBox useAuth;
 
-    MobyException dtException, nsException, stException;
-    MobyException dtUnregException, nsUnregException, stUnregException;
+    MobyException dtException, nsException, stException, sException;
+    MobyException dtUnregException, nsUnregException, stUnregException, sUnregException;
 
     // shared icons
     protected static Icon menuAddISAIcon, menuAddISAIconDis;
@@ -126,6 +132,12 @@
     final static String SERVICE_TYPE_UNREG_PROLOGUE =
     "An error occured when trying to unregister a service type.\n\n";
 
+    final static String SERVICE_PROLOGUE =
+    "An error occured when trying to register a new service.\n\n";
+
+    final static String SERVICE_UNREG_PROLOGUE =
+    "An error occured when trying to unregister a service.\n\n";
+
     /*********************************************************************
      * Default constructor.
      ********************************************************************/
@@ -306,11 +318,173 @@
     protected JPanel getServiceRegistration() {
 
 	JPanel p = new JPanel (new GridBagLayout());
- 	SwingUtils.addComponent (p, new JLabel ("Not Yet Implemented"), 0, 0, 1, 1, BOTH, NWEST, 1.0, 1.0);
+
+	// text fields to define new service
+   	JLabel labelSName = new JLabel ("Service name");
+	sName = createText (null, "serviceName", DP_REG_S_NAME);
+   	JLabel labelSAuth = new JLabel ("Authority");
+	sAuth = createText (null, "serviceAuth", DP_REG_S_AUTH);
+   	JLabel labelSEmail = new JLabel ("Contact email");
+	sEmail = createText (null, "serviceEmail", DP_REG_S_EMAIL);
+   	JLabel labelSURL = new JLabel ("Service endpoint - URL");
+	sURL = createText (null, "serviceURL", DP_REG_S_URL);
+	boolean usingAuth = getPrefValue (USE_AUTHORITATIVE, true);
+	useAuth =
+	    createCheckBox ("authoritative", usingAuth, KeyEvent.VK_A,
+			    new ItemListener() {
+				public void itemStateChanged (ItemEvent e) {
+				    onAuth (e.getStateChange() == ItemEvent.SELECTED);
+				}
+			    });
+	onAuth (usingAuth);
+
+	// group of fields for RDF signature
+   	labelSigURL = new JLabel ("RDF endpoint - signature URL");
+	sSigURL = createText (null, "signatureURL", DP_REG_S_RDF_URL);
+   	labelRDFPath = new JLabel ("Where to store RDF document");
+	String defValue =
+	    System.getProperty ("java.io.tmpdir") +
+	    System.getProperty ("file.separator") +
+	    "service.rdf";
+	localRDFFile = createFileSelector ("File name for RDF service signature",
+					   "Select",
+					   defValue,
+					   "localRDFFile",
+					   DP_REG_S_RDF_PATH);
+	boolean usingSignature = getPrefValue (USE_SIGNATURE, false);
+	JCheckBox useSignature =
+	    createCheckBox ("Use RDF signature", usingSignature, KeyEvent.VK_R,
+			    new ItemListener() {
+				public void itemStateChanged (ItemEvent e) {
+				    onUseRDFSignature (e.getStateChange() == ItemEvent.SELECTED);
+				}
+			    });
+	onUseRDFSignature (usingSignature);
+
+	JPanel pRDF = createTitledPanel ("Service RDF Signature");
+ 	SwingUtils.addComponent (pRDF, useSignature, 0, 0, 1, 1, NONE, NWEST, 0.0, 0.0);
+  	SwingUtils.addComponent (pRDF, labelSigURL,  0, 1, 1, 1, NONE, NWEST, 0.0, 0.0, BREATH_TOP);
+	SwingUtils.addComponent (pRDF, sSigURL,      0, 2, 1, 1, HORI, NWEST, 1.0, 0.0);
+ 	SwingUtils.addComponent (pRDF, labelRDFPath, 0, 3, 1, 1, NONE, NWEST, 0.0, 0.0);
+	SwingUtils.addComponent (pRDF, localRDFFile, 0, 4, 1, 1, HORI, NWEST, 1.0, 0.0);
+
+	// service type
+	JPanel serviceType = new JPanel (new GridBagLayout());
+   	JLabel labelST = new JLabel ("Service type: ");
+	sType = new JLabel ("");
+ 	SwingUtils.addComponent (serviceType, labelST, 0, 0, 1, 1, NONE, NWEST,  0.0, 0.0);
+ 	SwingUtils.addComponent (serviceType, sType,   1, 0, 1, 1, NONE, NWEST,  0.0, 0.0);
+
+	// put together service fields
+	JPanel defs = new JPanel (new GridBagLayout());
+ 	SwingUtils.addComponent (defs, labelSName,       0, 0, 1, 1, NONE, NWEST,  0.0, 0.0);
+ 	SwingUtils.addComponent (defs, sName,            0, 1, 1, 1, HORI, NWEST,  1.0, 0.0);
+ 	SwingUtils.addComponent (defs, useAuth,          1, 1, 1, 1, NONE, NWEST,  0.0, 0.0, BREATH_LEFT);
+ 	SwingUtils.addComponent (defs, labelSAuth,       0, 2, 2, 1, NONE, NWEST,  0.0, 0.0);
+ 	SwingUtils.addComponent (defs, sAuth,            0, 3, 2, 1, HORI, NWEST,  1.0, 0.0);
+ 	SwingUtils.addComponent (defs, labelSEmail,      0, 4, 2, 1, NONE, NWEST,  0.0, 0.0);
+ 	SwingUtils.addComponent (defs, sEmail,           0, 5, 2, 1, HORI, NWEST,  1.0, 0.0);
+ 	SwingUtils.addComponent (defs, labelSURL,        0, 6, 2, 1, NONE, NWEST,  0.0, 0.0);
+ 	SwingUtils.addComponent (defs, sURL,             0, 7, 2, 1, HORI, NWEST,  1.0, 0.0);
+ 	SwingUtils.addComponent (defs, pRDF,             0, 8, 2, 1, HORI, NWEST,  1.0, 0.0, BREATH_TOP);
+ 	SwingUtils.addComponent (defs, serviceType,      0, 9, 2, 1, NONE, NWEST,  0.0, 0.0, BREATH_TOP);
+
+	// description
+	sDescArea = new JTextArea();
+	JPanel sDesc = createCustomTextArea ("Description", null, "serviceDesc", DP_REG_S_DESC,
+					     sDescArea);
+
+	// a tree with all service types
+	ServiceTypesBoard stBoard =
+	    new ServiceTypesBoard (registryModel,
+				   console,
+				   propertyChannel,
+				   new CustomServiceTypesTree2 (registryModel, console));
+	stBoard.updateTree (CommonTree.SORTED_BY_NAME);
+
+	JPanel main = createTitledPanel ("New Service");
+ 	SwingUtils.addComponent (main, defs,             0, 0, 2, 1, HORI, NWEST,  1.0, 0.0);
+ 	SwingUtils.addComponent (main, sDesc,            0, 1, 1, 1, BOTH, NWEST,  1.0, 1.0, BREATH_TOP);
+ 	SwingUtils.addComponent (main, stBoard,          1, 1, 1, 1, BOTH, NWEST,  1.0, 1.0, BREATH_TOP_LEFT);
+
+	// sub-panels for input/output data
+	JTabbedPane dataPane = new JTabbedPane();
+	dataPane.addTab ("Primary Inputs", getPrimaryInputs());
+	dataPane.addTab ("Secondary Inputs", getSecondaryInputs());
+	dataPane.addTab ("Outputs", getOutputs());
+
+	// split data defs and service fields 
+	JSplitPane split = new JSplitPane (JSplitPane.HORIZONTAL_SPLIT,
+					   main,
+					   dataPane);
+	split.setResizeWeight (0.3);
+	split.setContinuousLayout (true);
+	split.setOneTouchExpandable (true);
+
+	// registration button
+	sRegisterButton =
+	    createButton (" Register Service ",
+			  "Register a new service in a Biomoby registry",
+			  KeyEvent.VK_S,
+			  new ActionListener() {
+			      public void actionPerformed (ActionEvent e) {
+				  onRegisterService();
+			      }
+			  });
+	sRegisterButton.setIcon (registerIcon);
+	sRegisterButton.setDisabledIcon (registerIconDis);
+
+	// put it together
+ 	SwingUtils.addComponent (p, split,           0, 0, 1, 1, BOTH, NWEST,  1.0, 1.0);
+ 	SwingUtils.addComponent (p, sRegisterButton, 0, 1, 1, 1, NONE, CENTER, 0.0, 0.0);
 	return p;
     }
 
     /**************************************************************************
+     *
+     **************************************************************************/
+    protected void onUseRDFSignature (boolean enabled) {
+	sSigURL.setEnabled (enabled);
+	labelSigURL.setEnabled (enabled);
+	localRDFFile.setEnabled (enabled);
+	labelRDFPath.setEnabled (enabled);
+	setPrefValue (USE_SIGNATURE, enabled);
+	propertyChannel.put (DP_USE_SIGNATURE, new Boolean (enabled).toString());
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    protected void onAuth (boolean enabled) {
+	setPrefValue (USE_AUTHORITATIVE, enabled);
+	propertyChannel.put (DP_USE_AUTHORITATIVE, new Boolean (enabled).toString());
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    protected JPanel getPrimaryInputs() {
+	JPanel p = new JPanel (new GridBagLayout());
+	return p;
+    }	
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    protected JPanel getSecondaryInputs() {
+	JPanel p = new JPanel (new GridBagLayout());
+	return p;
+    }	
+
+    /**************************************************************************
+     *
+     **************************************************************************/
+    protected JPanel getOutputs() {
+	JPanel p = new JPanel (new GridBagLayout());
+	return p;
+    }	
+
+    /**************************************************************************
      * Panel to register a namespace and a service type.
      **************************************************************************/
     protected JPanel getOtherRegistration() {
@@ -728,6 +902,75 @@
     /**************************************************************************
      *
      **************************************************************************/
+    public void onRegisterService() {
+	sRegisterButton.setEnabled (false);
+	sException = null;
+	final SwingWorker worker = new SwingWorker() {
+		public Object construct() {
+		    try {
+			String value = sName.getText();
+			if (UUtils.isEmpty (value)) {
+			    sException = new MobyException ("Service name is still missing. Please fill it first.");
+			    return null;
+			}
+			MobyService service = new MobyService (value);
+
+			value = sAuth.getText();
+			if (UUtils.isEmpty (value)) {
+			    sException = new MobyException ("Every service must have an authority.\n" +
+							    "Please fill it.");
+			    return null;
+			}
+			service.setAuthority (value);
+
+			value = sEmail.getText();
+			if (UUtils.isEmpty (value)) {
+			    sException = new MobyException ("Every service must have a contact person.\n" +
+							    "Please fill in an email address.");
+			    return null;
+			}
+			service.setEmailContact (value);
+
+			value = sDescArea.getText();
+			if (UUtils.isEmpty (value)) {
+			    sException = new MobyException ("Every service must have a description.\n" +
+							    "Please fill in the most detailed one.");
+			    return null;
+			}
+			service.setDescription (value);
+
+			value = sType.getText();
+			if (UUtils.isEmpty (value)) {
+			    sException = new MobyException ("Every service must belong to an existing service type.\n" +
+							    "Please select a type from available service types.");
+			    return null;
+			}
+			service.setType (value);
+
+			console.setText ("Service to be registered:\n" +
+					 "-------------------------\n" + service.toString());
+			registryModel.registerService (service);
+			console.setText ("\nRegistration successful!\n\n");
+
+		    } catch (MobyException e) {
+			sException = e;
+		    }
+		    return null;  // not used here
+		}
+
+		// runs on the event-dispatching thread.
+		public void finished() {
+		    if (sException != null)
+			error (SERVICE_PROLOGUE, sException);
+		    sRegisterButton.setEnabled (true);
+		}
+	    };
+	worker.start(); 
+    }
+
+    /**************************************************************************
+     *
+     **************************************************************************/
     public String getName() {
 	return "Biomoby Registration";
     }
@@ -1235,4 +1478,48 @@
     }
 
 
+
+    /**************************************************************************
+     *
+     * Customized tree of service types - use for service registration
+     *
+     **************************************************************************/
+    protected class CustomServiceTypesTree2
+	extends ServiceTypesTree {
+
+	/*********************************************************************
+	 * Construtor
+	 ********************************************************************/
+	public CustomServiceTypesTree2 (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 service type to the service fields.
+	 ********************************************************************/
+	protected void selected (DefaultMutableTreeNode node) {
+	    if (node == null) return;
+	    CommonNode nodeObject = (CommonNode)node.getUserObject();
+	    if (nodeObject.getType() == CommonNode.NODE_SERVICE_TYPE)
+		sType.setText (nodeObject.getValue());
+	}
+    }
 }




More information about the MOBY-guts mailing list