"+text+"";
+ }
+
+ StringBuffer result = new StringBuffer("");
+ int lineCharCount = 0;
+ String[] tokens = text.split("[ \t\n]");
+ for(String word: tokens){
+ while(word.length()+1 > maxLineLength){ //single word is bigger than preset width, hyphenate
+ int cutPoint = maxLineLength - lineCharCount - 1;
+ result.append(word.substring(0, cutPoint)+"-
");
+ lineCharCount = 0;
+ word = word.substring(cutPoint);
+ }
+ if(lineCharCount != 0 && lineCharCount + word.length() > maxLineLength){
+ result.append("
" + word + " ");
+ lineCharCount = word.length()+1;
+ continue;
+ }
+ result.append(word+" ");
+ lineCharCount += word.length()+1;
+ }
+ result.append("");
+
+ return result.toString();
+ }
+
+ /**
+ * Given an HTML fragment (e.g. cut'n'pasted from a browser), see if we unescape the
+ * HTML we get a MOBY XML block (e.g. from the biomoby.org web site examples).
+ */
+ public static MobyContentInstance checkForMobyXML(String text){
+ if(//(text.indexOf("moby:") != -1 || text.indexOf("articleName=\"") != -1) &&
+ text.indexOf("namespace=\"") == -1 ||
+ text.indexOf("id=\"") == -1){
+ return null;
+ }
+
+ MobyContentInstance content = null;
+ String xmltext = text;
+ // See if the xml needs unescaping (e.g. if preformatted HTML dropped from Firefox or Thunderbird)
+ int preStart = xmltext.indexOf("")+1);
+ xmltext = xmltext.replaceAll(">", ">");
+ xmltext = xmltext.replaceAll("<", "<");
+ xmltext = xmltext.replaceAll("&", "&");
+ }
+ xmltext = xmltext.trim(); // remove leading and trailing spaces
+ try{
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware (true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ if(xmltext.indexOf("xmlns:moby") == -1){
+ // Ensure that the moby: prefix is declared in the first tag
+ xmltext = xmltext.replaceFirst("<([A-Za-z0-9_][^> \t\n]*)", "<$1 xmlns:moby=\""+
+ MobyPrefixResolver.MOBY_XML_NAMESPACE+"\"");
+ }
+ if(xmltext.indexOf("\n" + xmltext;
+ }
+
+ org.w3c.dom.Element data = db.parse(new ByteArrayInputStream(xmltext.getBytes())).getDocumentElement();
+ if(data.getLocalName().equals(MobyTags.MOBY)){
+ content = MobyDataUtils.fromXMLDocument(data);
+ }
+ else if(data.getLocalName().equals(MobyTags.MOBYCONTENT)){
+ content = new MobyContentInstance(data);
+ }
+ else if(data.getLocalName().equals(MobyTags.MOBYDATA)){
+ content = new MobyContentInstance();
+ content.parseDataGroup(data);
+ }
+ else{
+ // Any other data can be processed by the base object class
+ content = new MobyContentInstance(MobyDataObject.createInstanceFromDOM(data), "Drag 'n' Drop data");
+ }
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ return content;
+ }
}
From gordonp at dev.open-bio.org Thu Apr 26 11:19:58 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:19:58 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261519.l3QFJwIh000668@dev.open-bio.org>
gordonp
Thu Apr 26 11:19:58 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv637/src/main/ca/ucalgary/seahawk/gui
Added Files:
MobyDataObjectWidget.java MobyObjectReceiver.java
MobyObjectTransferHandler.java
Log Message:
GUI components added in support of direct manipulation of multiple parameters for Moby service input
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyDataObjectWidget.java,NONE,1.1 MobyObjectReceiver.java,NONE,1.1 MobyObjectTransferHandler.java,NONE,1.1
From gordonp at dev.open-bio.org Thu Apr 26 11:22:27 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:22:27 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261522.l3QFMRB1000753@dev.open-bio.org>
gordonp
Thu Apr 26 11:22:27 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services
In directory dev.open-bio.org:/tmp/cvs-serv718/src/main/ca/ucalgary/seahawk/services
Modified Files:
MobyClient.java
Log Message:
Small method sig and doc updates
moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.11,1.12
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/18 16:01:00 1.11
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2007/04/26 15:22:27 1.12
@@ -740,11 +740,11 @@
return new MobyDataObject[0];
}
- // Vector of moby objects we construct based on the xpath mappings found
+ // Vector of moby objects we construct based on the regex mappings found
Vector objectVector = new Vector();
Iterator regex_keys = regexMap.keySet().iterator();
- while(regex_keys.hasNext()){ //map still has untraversed xpath entry to test
+ while(regex_keys.hasNext()){ //map still has untraversed regex entry to test
Pattern pattern = (Pattern) regex_keys.next();
Matcher matcher = pattern.matcher(textData);
@@ -771,29 +771,44 @@
* Using the URL regular expression mappings that have been set up,
* maps a string to moby objects. URL regexs are special because they are
* flexible in the order in which query parameters are given. They
- * may also have requirements based on the hypertext linked.
+ * may also have requirements based on the hypertext linked. This method
+ * does not look at the contents of the URL, but rather the URL itself.
*/
public MobyDataObject[] getMobyObjects(URL url){
- return getMobyObjects(url, null);
+ return getMobyObjects(url, null, null);
}
public MobyDataObject[] getMobyObjects(URL url, String linkText){
+ return getMobyObjects(url, linkText, null);
+ }
+
+ public MobyDataObject[] getMobyObjects(URL url, MobyDataType targetDataType){
+ return getMobyObjects(url, null, targetDataType);
+ }
+
+ public MobyDataObject[] getMobyObjects(URL url, String linkText, MobyDataType targetDataType){
if(urlRegexMap.isEmpty()){
System.out.println("The MOBY Client has not been provided any url regex->moby data mappings!");
return new MobyDataObject[0];
}
- // Vector of moby objects we construct based on the xpath mappings found
+ // Vector of moby objects we construct based on the regex mappings found
Vector objectVector = new Vector();
String urlString = url.toString();
Iterator url_regex_keys = urlRegexMap.keySet().iterator();
- while(url_regex_keys.hasNext()){ // map still has untraversed xpath entry to test
+ while(url_regex_keys.hasNext()){ // map still has untraversed regex entry to test
Pattern pattern = (Pattern) url_regex_keys.next();
+ MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern);
+
+ // If we asked for a particular data type, make sure the rule can produce it before we
+ // start to go matching it.
+ if(targetDataType != null && !rule.getDataType().inheritsFrom(targetDataType)){
+ continue;
+ }
Matcher matcher = pattern.matcher(urlString);
while(matcher.find()){
- MobyComplexBuilder rule = (MobyComplexBuilder) urlRegexMap.get(pattern);
try{
MobyDataObject mobyObj = rule.apply(matcher);
From gordonp at dev.open-bio.org Thu Apr 26 11:23:59 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:23:59 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261523.l3QFNx94000819@dev.open-bio.org>
gordonp
Thu Apr 26 11:23:59 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv784/src/main/ca/ucalgary/seahawk/gui
Modified Files:
MobyContentGUI.java
Log Message:
Minor fix to allow tab close when 2 tabs and no clipboard showing
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/18 15:57:00 1.7
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2007/04/26 15:23:59 1.8
@@ -846,7 +846,8 @@
}
if(tabbedPane.getComponentAt(index) == clipboard && tabbedPane.getTabCount() > 1 ||
- tabbedPane.getTabCount() > 2){
+ tabbedPane.getTabCount() > 2 ||
+ tabbedPane.indexOfComponent(clipboard) == -1 && tabbedPane.getTabCount() >= 2){
item = new JMenuItem(MobyContentGUI.CLOSE_OTHERS_OPTION);
item.setActionCommand(MobyContentGUI.CLOSE_OTHERS_OPTION);
item.addActionListener(gui);
From gordonp at dev.open-bio.org Thu Apr 26 11:25:13 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:25:13 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261525.l3QFPDvh000883@dev.open-bio.org>
gordonp
Thu Apr 26 11:25:13 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv848/src/main/ca/ucalgary/seahawk/gui
Modified Files:
MobySecondaryInputGUI.java
Log Message:
Added proper multi-primary parameter support, and tooltip formatting for secondary parameters
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySecondaryInputGUI.java,1.5,1.6
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/12 01:03:14 1.5
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySecondaryInputGUI.java 2007/04/26 15:25:13 1.6
@@ -1,21 +1,22 @@
package ca.ucalgary.seahawk.gui;
-import org.biomoby.shared.data.MobyDataSecondaryInstance;
-import org.biomoby.shared.MobySecondaryData;
+import ca.ucalgary.seahawk.services.MobyClient;
+import ca.ucalgary.seahawk.util.HTMLUtils;
+import org.biomoby.shared.data.*;
+import org.biomoby.shared.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.text.JTextComponent;
import java.awt.event.*;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.*;
/**
* A class that generates a GUI to fill in (instantiate or change) the values of Secondary Input to MOBY services.
*/
public class MobySecondaryInputGUI extends JDialog implements ActionListener, Runnable {
+ public final static int MAX_TOOLTIP_WIDTH = 40;
public final static int INT_CHOICE_MAX = 100;
public final static int DEFAULT_TEXT_SIZE = 12;
public final static String UNBOUNDED_INT_RANGE_DESC = "[integer]";
@@ -23,6 +24,7 @@
public final static String TITLE = "Secondary Inputs for MOBY Service";
public final static String OK_BUTTON_NAME = "MSIGexecuteButton";
+ private MobyPrimaryData[] inputsPrimary = null;
private MobyDataSecondaryInstance[] inputs = null;
private JButton cancelButton;
private String cancelMessage = "Cancel";
@@ -34,35 +36,38 @@
private ActionListener listener;
private int handlerCode = 0; // callback event ID provided by caller to c-tor
private boolean showingNew = false;
+ private MobyClient mobyClient;
private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobySecondaryInputGUI.class);
- public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal){
- this(al, owner, modal, 0);
+ public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, MobyClient client){
+ this(al, owner, modal, 0, client);
}
/**
* @param al the object to receive the "all done" callback
* @param actionCommandID the id to give back as the event ID during callback
*/
- public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID){
+ public MobySecondaryInputGUI(ActionListener al, Frame owner, boolean modal, int actionCommandID, MobyClient client){
super(owner, modal);
setup();
listener = al;
handlerCode = actionCommandID;
+ mobyClient = client;
setVisible(false);
showingNew = false;
setName(TITLE);
}
- public MobySecondaryInputGUI(ActionListener al){
- this(al, 0);
+ public MobySecondaryInputGUI(ActionListener al, MobyClient client){
+ this(al, 0, client);
}
- public MobySecondaryInputGUI(ActionListener al, int actionCommandID){
+ public MobySecondaryInputGUI(ActionListener al, int actionCommandID, MobyClient client){
super();
setup();
listener = al;
+ mobyClient = client;
handlerCode = actionCommandID;
setVisible(false);
}
@@ -121,19 +126,24 @@
}
public void fillIn(MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){
- if(secondaryInputs == null){
+ fillIn(null, secondaryInputs, showGUI);
+ }
+
+ public void fillIn(MobyPrimaryData[] primaryInputs, MobyDataSecondaryInstance[] secondaryInputs, boolean showGUI){
+ // If more than 1 primary input parameter, need to disable
+ // submission until these fields are filled in too.
+ if(!setupPrimaryInput(primaryInputs) && secondaryInputs == null){
run();
//should do callback
return;
}
inputs = secondaryInputs;
- java.util.Arrays.sort(inputs);
// Create a thread here to prevent possible AWT-EventQueue deadlock
// when widgets are added and the thread of caller of the method was
// the AWT-EventQueue.
- WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI);
+ WidgetCreatorThread widgetMaker = new WidgetCreatorThread(showGUI, true);
if(!showGUI){
// Call synchronous to ensure data is present before returning
widgetMaker.run();
@@ -145,11 +155,31 @@
}
+ /**
+ * Is there more than one primary parameter? Do we need to populate it?
+ * @return true if we can submit the job as is, otherwise false (data still needs to be filled in)
+ */
+ protected boolean setupPrimaryInput(MobyPrimaryData[] primaryInputs){
+ confirmButton.setEnabled(true); //unless otherwise noted, we can submit
+ if(primaryInputs != null){
+ inputsPrimary = primaryInputs;
+ for(MobyPrimaryData primary: inputsPrimary){
+ if(!(primary instanceof MobyDataInstance)){
+ // a primary parameter has not yet been instantiated
+ confirmButton.setEnabled(false);
+ }
+ }
+ }
+ return confirmButton.isEnabled();
+ }
+
class WidgetCreatorThread extends Thread{
private boolean showGUI;
+ private boolean showSinglePrimaryInput;
- public WidgetCreatorThread(boolean b){
- showGUI = b;
+ public WidgetCreatorThread(boolean gui, boolean single){
+ showGUI = gui;
+ showSinglePrimaryInput = single;
}
public void run(){
@@ -159,10 +189,24 @@
setVisible(true);
}
- // Add a widget for each input value
- for(int i = 0; i < inputs.length; i++){
- optionsPanel.add(makeWidget(inputs[i]));
+ if(!confirmButton.isEnabled() || showSinglePrimaryInput){
+ //java.util.Arrays.sort(inputsPrimary);
+ for(MobyPrimaryData input: inputsPrimary){
+ optionsPanel.add(makeWidget(input));
+ }
+
+ // Visually separate the primary and secondary inputs
+ optionsPanel.add(new JSeparator());
+ }
+
+ // Sort the parameters alphabetically
+ Arrays.sort(inputs); // MobyDataSecondaryInstance implements Comparable
+
+ // Add a widget for each secondary param
+ for(MobyDataSecondaryInstance input: inputs){
+ optionsPanel.add(makeWidget(input));
}
+
// Make the window the preferred size of its widget contents
if(showGUI){
pack();
@@ -182,6 +226,22 @@
return ret;
}
+ public Component makeWidget(MobyPrimaryData data){
+ boolean DATA_EDITABLE = true;
+ MobyDataObjectWidget primaryDataWidget = null;
+ // Choose c-tor based on if param is instantiated or not
+ if(data instanceof MobyDataInstance){
+ primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, (MobyDataInstance) data, DATA_EDITABLE);
+ }
+ else{
+ primaryDataWidget = new MobyDataObjectWidget(data.getName(), mobyClient, data);
+ }
+ // We want to get informed of updates to the data, as this
+ // may change whether the dialog should be submittable or not
+ primaryDataWidget.addActionListener(this);
+ return primaryDataWidget;
+ }
+
public Component makeWidget(MobyDataSecondaryInstance msdi){
String dataType = msdi.getDataType();
@@ -410,7 +470,7 @@
if(desc == null || desc.length() == 0){
desc = "Sorry, no description of this input is available from the service provider";
}
- label.setToolTipText(desc);
+ label.setToolTipText(HTMLUtils.htmlifyToolTipText(desc, MAX_TOOLTIP_WIDTH));
return label;
}
@@ -441,6 +501,25 @@
else if(source == cancelButton){
dispose();
}
+ // Primary input data update
+ else if(source instanceof MobyDataObjectWidget){
+ MobyPrimaryData newData = ((MobyDataObjectWidget) source).getData();
+ String newDataName = ((MobyDataObjectWidget) source).getName();
+ boolean enableSubmit = true;
+
+ // Copy the new data value to the original array
+ for(int i = 0; i < inputsPrimary.length; i++){
+ if(inputsPrimary[i].getName().equals(newDataName)){
+ newData.setName(newDataName);
+ inputsPrimary[i] = newData;
+ }
+ // Is there still some uninstantiated data?
+ if(enableSubmit && !(inputsPrimary[i] instanceof MobyDataInstance)){
+ enableSubmit = false;
+ }
+ }
+ confirmButton.setEnabled(enableSubmit);
+ }
else{
logger.warn("Unrecognized event source (" + source + ") in " + getClass());
}
From gordonp at dev.open-bio.org Thu Apr 26 11:26:25 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:26:25 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261526.l3QFQPXh000947@dev.open-bio.org>
gordonp
Thu Apr 26 11:26:24 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui
In directory dev.open-bio.org:/tmp/cvs-serv912/src/main/ca/ucalgary/seahawk/gui
Modified Files:
MobyServicesGUI.java
Log Message:
Added support for multiple primary input parameters to a service, and fixed up tooltip formatting
moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyServicesGUI.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/18 16:08:15 1.9
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyServicesGUI.java 2007/04/26 15:26:24 1.10
@@ -1,6 +1,7 @@
package ca.ucalgary.seahawk.gui;
import ca.ucalgary.seahawk.services.MobyClient;
+import ca.ucalgary.seahawk.util.HTMLUtils;
import javax.swing.*;
import org.w3c.dom.*;
import org.biomoby.shared.*;
@@ -13,6 +14,7 @@
import java.awt.*;
import java.io.*;
import java.text.Collator;
+import java.net.URL;
import java.util.*;
import javax.swing.event.PopupMenuListener;
import javax.swing.event.PopupMenuEvent;
@@ -47,6 +49,7 @@
MobyDataServiceAssocInstance[] ms;
MobyDataSecondaryInstance[] secondaryInputInstances = null;
+ MobyPrimaryData[] primaryInput = null;
int maxDataDesc = 22;
private HashMap service2submenu; //tracks nested submenus to root submenus of choices popup
private HashMap submenu2msIndex;
@@ -174,23 +177,50 @@
}
public void setupServiceSecondaryData(MobyRequestEventHandler handler){
+ MobyDataInstance[] castInputs = new MobyDataInstance[primaryInput.length];
+ System.err.println("Submitting job with " + primaryInput.length + " parameters");
+ for(int i = 0; i < primaryInput.length; i++){
+ if(!(primaryInput[i] instanceof MobyDataInstance)){
+ logger.warn("Warning: setupServiceSecondaryData was called before the primary input" +
+ " for the service was instantiated, ignoring the call. Object found was" +
+ " of class "+primaryInput[i].getClass().getName());
+ return;
+ }
+ castInputs[i] = (MobyDataInstance) primaryInput[i];
+ }
+
+ try{
+ mobyRequest.setInput(castInputs);
+ } catch(MobyException me){
+ me.printStackTrace();
+ logger.warn("Error while trying to set service input: " + me);
+ }
mobyRequest.setSecondaryInput(secondaryInputInstances);
executeService(handler);
}
protected void setupService(MobyService mobyService, MobyDataInstance mdi, int handlerHashCode, boolean useDefaultSecondaries){
- mobyRequest.setDebugMode(System.getProperty("moby.debug") != null);
- mobyRequest.setService(mobyService);
- // We only implement simple input for now (i.e. only one input argument)
- try{
- mobyRequest.setInput(mdi, "");
- }
- catch(MobyException me){
- logger.error("Failure in MOBY input, was not acceptable:" + me);
+ if(!(mdi instanceof MobyPrimaryData)){
+ logger.error("Failure in MOBY input, was not primary data as expected, but rather "+mdi.getClass().getName());
return;
}
+
+ mobyRequest.setDebugMode(System.getProperty("moby.debug") != null);
+ mobyRequest.setService(mobyService);
+ MobyPrimaryData[] primaryInputTemplate = mobyService.getPrimaryInputs();
+ primaryInput = new MobyPrimaryData[primaryInputTemplate.length];
+ System.arraycopy(primaryInputTemplate, 0, primaryInput, 0, primaryInput.length);
if(!hasSecondaryInput(mobyService)){
+ try{
+ // Implement simple input (i.e. only one input argument)
+ mobyRequest.setInput(mdi, "");
+ }
+ catch(MobyException me){
+ logger.error("Failure in MOBY input, was not acceptable:" + me);
+ return;
+ }
+
// No need for further info, just launch the request
removePopupOptions();
executeService(getHandlerByHashCode(handlerHashCode));
@@ -198,14 +228,55 @@
else{
// We need more info from the user to launch this service
//logger.warn("Need to get secondary parameters: " + secondaryInputTemplate.getClass());
- MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs();
- getSecondaryInput((MobySecondaryData[]) secondaryInputTemplate, handlerHashCode, useDefaultSecondaries);
+ MobyService metaDataMobyService = MobyService.getService(mobyService.getName(), mobyService.getAuthority());
+
+ // We need to figure out where the provided data instance goes into the parameter list for the service
+ Vector paramMatch = new Vector();
+ int paramMatchDefault = 0;
+ MobyDataType providedDataType = ((MobyPrimaryData) mdi).getDataType();
+ for(MobyPrimaryData input: primaryInput){
+ if(providedDataType.inheritsFrom(input.getDataType())){
+ paramMatch.add(input.getName());
+ }
+ }
+ if(paramMatch.size() == 0){
+ logger.error("Failure in MOBY input, could not match the input (" +providedDataType.getName() +
+ ") to any service param for service "+mobyService.getName());
+ return;
+ }
+
+ String targetParamName = paramMatch.elementAt(0);
+ // Need to choose among multiple parameters
+ if(paramMatch.size() > 1){
+ targetParamName = (String) JOptionPane.showInputDialog(null,
+ "Choose the service parameter the chosen " +
+ "object represents",
+ "Service Parameter Choice",
+ JOptionPane.QUESTION_MESSAGE,
+ null,
+ paramMatch.toArray(),
+ paramMatch.elementAt(paramMatchDefault));
+ }
+ // Finds the matching param and set it
+ for(int i = 0; i < primaryInput.length; i++){
+ if(targetParamName.equals(primaryInput[i].getName())){
+ mdi.setName(targetParamName);
+ primaryInput[i] = (MobyPrimaryData) mdi;
+ }
+ }
+
+ // We need to create the secondary parameters too, and launch the dialog to fill in the
+ // uninstantiated data.
+ getSecondaryInput(metaDataMobyService, handlerHashCode, useDefaultSecondaries);
}
}
+ // True if there are secondaries, or more than one primary input
+ // (which also needs the dialog for user data instantiation)
private boolean hasSecondaryInput(MobyService mobyService){
MobyData[] secondaryInputTemplate = mobyService.getSecondaryInputs();
- return secondaryInputTemplate != null && secondaryInputTemplate.length != 0;
+ return secondaryInputTemplate != null && secondaryInputTemplate.length != 0 ||
+ mobyService.getPrimaryInputs().length > 1;
}
/**
@@ -233,11 +304,14 @@
* Launches a dialog that the user can configure secondary parameters in,
* or tries to fill in and use all defaults if valid and useDefaults is specified.
*/
- protected void getSecondaryInput(MobySecondaryData[] secondaryInputTemplate, int handlerHashCode, boolean useDefaults){
+ protected void getSecondaryInput(MobyService mobyService, int handlerHashCode, boolean useDefaults){
+ MobySecondaryData[] secondaryInputTemplate = mobyService.getSecondaryInputs();
if(secondaryGUI == null){
- secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode);
+ secondaryGUI = new MobySecondaryInputGUI(this, handlerHashCode, mobyClient);
}
+ // Create the param array that will be modified in the secondary dialog and used
+ // after the callback to run the service.
secondaryInputInstances =
new MobyDataSecondaryInstance[secondaryInputTemplate.length];
for(int i = 0; i < secondaryInputInstances.length; i++){
@@ -249,7 +323,8 @@
return;
}
// The GUI will perform a callback when the user is done the input
- secondaryGUI.fillIn(secondaryInputInstances);
+ boolean SHOW_DIALOG = true;
+ secondaryGUI.fillIn(primaryInput, secondaryInputInstances, SHOW_DIALOG);
}
/**
@@ -943,19 +1018,12 @@
String serviceDesc = service.getDescription();
String serviceAuthority = service.getAuthority();
if(serviceDesc != null && serviceDesc.length() > 0){
- if(serviceDesc.length() > MAX_SERVICE_DESC_LEN){
- serviceDesc = htmlifyToolTipText(serviceDesc);
+ if(serviceAuthority != null && serviceAuthority.length() > 0){
+ serviceDesc += " [" + serviceAuthority + "]";
}
+ serviceDesc = HTMLUtils.htmlifyToolTipText(serviceDesc, MAX_SERVICE_DESC_LEN);
sdesc = serviceDesc;
}
- if(serviceAuthority != null && serviceAuthority.length() > 0){
- if(sdesc == null){
- sdesc = serviceAuthority;
- }
- else{
- sdesc += " [" + serviceAuthority + "]";
- }
- }
if(sdesc != null){
mobyItem.setToolTipText(sdesc);
}
@@ -987,10 +1055,7 @@
}
String menuToolTip = commonAncestorDesc + type.getDescription();
- if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){
- // Cut down really long ancestry descs to the last part (most precise)
- menuToolTip = htmlifyToolTipText(menuToolTip);
- }
+ menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN);
menu.setToolTipText(menuToolTip);
parentMenu.add(menu);
@@ -1017,46 +1082,6 @@
}
}
- /**
- * By turning the tool tip text into HTML, we can make it multiline
- */
- protected String htmlifyToolTipText(String text){
- int maxLine = MAX_SERVICE_DESC_LEN;
- StringBuffer result = null;
-
- while(true){
- result = new StringBuffer("");
- StringTokenizer st = new StringTokenizer(text, " \t\n");
- int lineCharCount = 0;
-
- if(st.hasMoreTokens()){
- result.append(st.nextToken());
- lineCharCount = result.length()-6;
- }
- while(st.hasMoreTokens()){
- String word = st.nextToken();
- if(lineCharCount != 0 && lineCharCount + word.length() >= maxLine){
- result.append("
" + word);
- lineCharCount = word.length();
- continue;
- }
- result.append(" " + word);
- lineCharCount += word.length()+1;
-
- if(lineCharCount > maxLine){ //single word is bigger than preset width, redo layout
- maxLine = lineCharCount;
- break;
- }
- }
- result.append("");
- if(!st.hasMoreTokens()){ //used up all the text, didn't break previous loop abnormally
- break;
- }
- } //end layout block
-
- return result.toString();
- }
-
public JMenu addNameDivSubMenu(JMenu parentMenu, MobyService[] services){
if(services == null || services.length == 0){
return null;
@@ -1097,10 +1122,7 @@
desc = type.getComment();
}
String menuToolTip = commonAncestorDesc + desc;
- if(menuToolTip.length() > MAX_SERVICE_DESC_LEN){
- // Cut down really long ancestry descs to the last part (most precise)
- menuToolTip = htmlifyToolTipText(menuToolTip);
- }
+ menuToolTip = HTMLUtils.htmlifyToolTipText(menuToolTip, MAX_SERVICE_DESC_LEN);
menu.setToolTipText(menuToolTip);
parentMenu.add(menu);
@@ -1230,9 +1252,7 @@
assignMenuDataIndex(submenu);
}
desc = "Input data: " + desc;
- if(desc.length() > MAX_SERVICE_DESC_LEN){
- desc = htmlifyToolTipText(desc);
- }
+ desc = HTMLUtils.htmlifyToolTipText(desc, MAX_SERVICE_DESC_LEN);
submenu.setToolTipText(desc);
submenu.setName(SERVICE_SUBMENU_NAME);
return submenu;
From gordonp at dev.open-bio.org Thu Apr 26 11:30:01 2007
From: gordonp at dev.open-bio.org (Paul Gordon)
Date: Thu, 26 Apr 2007 11:30:01 -0400
Subject: [MOBY-guts] biomoby commit
Message-ID: <200704261530.l3QFU1sE001011@dev.open-bio.org>
gordonp
Thu Apr 26 11:30:01 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources
In directory dev.open-bio.org:/tmp/cvs-serv976/src/main/ca/ucalgary/seahawk/resources
Modified Files:
mobyBuilderRules.xml
Log Message:
Added binary object rules for images and ABI trace files, plus DNASequence
moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/03 02:37:43 1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2007/04/26 15:30:01 1.4
@@ -4,6 +4,77 @@
http://www.bioxml.info/dtd/tigrxml.dtd
http://www.bioxml.info/dtd/Bioseq.dtd
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+