From drepchevski at dev.open-bio.org Wed Feb 2 08:23:41 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Wed, 2 Feb 2011 08:23:41 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102021323.p12DNfTJ016946@dev.open-bio.org> drepchevski Wed Feb 2 08:23:41 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry In directory dev.open-bio.org:/tmp/cvs-serv16893/registry Modified Files: RegisterServiceOperation.java Log Message: registerService() was broken in MobyCentral library moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry RegisterServiceOperation.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.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/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.java 2009/09/09 19:47:48 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.java 2011/02/02 13:23:41 1.2 @@ -194,27 +194,27 @@ @XmlTransient protected static class Data { - private List collection; - private List simple; + private List collections; + private List simples; @XmlElement(name = "Collection") - public List getCollection() + public List getCollections() { - if (collection == null) + if (collections == null) { - collection = new ArrayList(); + collections = new ArrayList(); } - return this.collection; + return this.collections; } @XmlElement(name = "Simple") - public List getSimple() + public List getSimples() { - if (simple == null) + if (simples == null) { - simple = new ArrayList(); + simples = new ArrayList(); } - return this.simple; + return this.simples; } } @@ -269,7 +269,7 @@ public static class Simple { private String objectType; - private List namespace; + private List namespaces; private String articleName; @XmlElement(required = true) @@ -284,14 +284,14 @@ } @XmlElement(name = "Namespace") - public List getNamespace() + public List getNamespaces() { - if (namespace == null) + if (namespaces == null) { - namespace = new ArrayList(); + namespaces = new ArrayList(); } - return this.namespace; + return namespaces; } @XmlAttribute(required = true) From drepchevski at dev.open-bio.org Wed Feb 2 08:23:41 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Wed, 2 Feb 2011 08:23:41 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102021323.p12DNfP2016928@dev.open-bio.org> drepchevski Wed Feb 2 08:23:41 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb In directory dev.open-bio.org:/tmp/cvs-serv16893 Modified Files: JAXBMobyCentralImpl.java Log Message: registerService() was broken in MobyCentral library moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb JAXBMobyCentralImpl.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.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/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.java 2009/09/09 19:47:48 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.java 2011/02/02 13:23:40 1.2 @@ -71,7 +71,168 @@ request.setAuthURI(service.getAuthURI()); request.setContactEmail(service.getContactEmail()); request.setDescription(service.getDescription()); - + + request.setURL(service.getUrl()); + request.setCategory(service.getCategory().name()); + + request.setAuthoritativeService(service.isAuthoritative() ? 1 : 0); + + ServiceType serviceType = service.getServiceType(); + request.setServiceType(serviceType == null ? "" : serviceType.getName()); + + Input input = service.getInput(); + + if (input != null) + { + RegisterServiceOperation.Input in = new RegisterServiceOperation.Input(); + + for (Simple simple : input.getSimples()) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + in.getSimples().add(sm); + } + + for (Collection collection : input.getCollections()) + { + RegisterServiceOperation.Collection cl = new RegisterServiceOperation.Collection(); + + cl.setArticleName(collection.getArticleName()); + + Simple simple = collection.getSimple(); + + if (simple != null) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + cl.setSimple(sm); + } + + in.getCollections().add(cl); + } + + request.setInput(in); + } + + Output output = service.getOutput(); + + if (output != null) + { + RegisterServiceOperation.Output out = new RegisterServiceOperation.Output(); + + for (Simple simple : output.getSimples()) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + out.getSimples().add(sm); + } + + for (Collection collection : output.getCollections()) + { + RegisterServiceOperation.Collection cl = new RegisterServiceOperation.Collection(); + + cl.setArticleName(collection.getArticleName()); + + Simple simple = collection.getSimple(); + + if (simple != null) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + cl.setSimple(sm); + } + + out.getCollections().add(cl); + } + + request.setOutput(out); + } + + List parameters = service.getSecondaryArticles(); + + if (!parameters.isEmpty()) + { + RegisterServiceOperation.SecondaryArticles sa = new RegisterServiceOperation.SecondaryArticles(); + + for (Parameter parameter :service.getSecondaryArticles()) + { + RegisterServiceOperation.Parameter p = new RegisterServiceOperation.Parameter(); + + p.setDatatype(parameter.getDatatype().name()); + p.setArticleName(parameter.getArticleName()); + p.setDefault(parameter.getDefault()); + p.setDescription(parameter.getDescription()); + p.setMin(parameter.getMin()); + p.setMax(parameter.getMax()); + + List enums = parameter.getEnum(); + + if (!enums.isEmpty()) + { + for (String _enum : enums) + { + p.getEnum().add(_enum); + } + } + + sa.getParameter().add(p); + } + + request.setSecondaryArticles(sa); + } + MobyRegistration response = endpoint.call(request); Registration registration = new Registration(); From drepchevski at dev.open-bio.org Thu Feb 3 12:34:01 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Thu, 3 Feb 2011 12:34:01 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102031734.p13HY153015378@dev.open-bio.org> drepchevski Thu Feb 3 12:34:00 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv15343 Modified Files: MobyDispatch.java Log Message: fixed argument parsing when it is specified as soap type instead of schema (string/base64Binary) moby-live/Java/src/main/org/inb/biomoby/client MobyDispatch.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client/MobyDispatch.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/inb/biomoby/client/MobyDispatch.java 2010/08/31 16:15:44 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client/MobyDispatch.java 2011/02/03 17:34:00 1.3 @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; +import javax.xml.XMLConstants; import org.inb.biomoby.MobyMessageContext; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -61,6 +62,7 @@ import org.inb.wsrf.rp2.QueryResourceProperties; import org.inb.wsrf.rp2.QueryResourcePropertiesResponse; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** @@ -287,6 +289,37 @@ Node method = body.getFirstChild(); // check mobyService.getName() + "Response"? Node argument = method.getFirstChild(); + // fixing method argument type {http://schemas.xmlsoap.org/soap/encoding/}string => {http://www.w3.org/2001/XMLSchema}string + // Actually JAXB shouldn't support soap types in a first place... + + NamedNodeMap attributes = argument.getAttributes(); + if (attributes != null) + { + Node attribute = attributes.getNamedItemNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); + + if (attribute != null) + { + String soapencPrefix = argument.lookupPrefix(SOAPConstants.URI_NS_SOAP_ENCODING); + + if (soapencPrefix != null) + { + String type = attribute.getNodeValue(); + + if (type.startsWith(soapencPrefix)) + { + String xsdPrefix = argument.lookupPrefix(XMLConstants.W3C_XML_SCHEMA_NS_URI); + + if (xsdPrefix != null) + { + type = xsdPrefix + type.substring(soapencPrefix.length()); + + attribute.setNodeValue(type); + } + } + } + } + } + Unmarshaller u = MobyMessageContext.getContext().createUnmarshaller(); JAXBElement jel = u.unmarshal(argument, byte[].class); From gordonp at dev.open-bio.org Thu Feb 3 16:38:27 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:38:27 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032138.p13LcRoM019912@dev.open-bio.org> gordonp Thu Feb 3 16:38:27 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv19880/src/main/ca/ucalgary/seahawk/gui Added Files: FontSizeChangeListener.java Log Message: Added capability to change document font size, for accessibility moby-live/Java/src/main/ca/ucalgary/seahawk/gui FontSizeChangeListener.java,NONE,1.1 From gordonp at dev.open-bio.org Thu Feb 3 16:39:18 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:39:18 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032139.p13LdIex019952@dev.open-bio.org> gordonp Thu Feb 3 16:39:18 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv19920/src/main/ca/ucalgary/seahawk/resources Added Files: SelectFilesBeanShell BinaryFileLoaderBeanShell Log Message: Taverna helper processors to facilitate use of binary input into a Moby workflow moby-live/Java/src/main/ca/ucalgary/seahawk/resources SelectFilesBeanShell,NONE,1.1 BinaryFileLoaderBeanShell,NONE,1.1 From gordonp at dev.open-bio.org Thu Feb 3 16:40:36 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:40:36 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032140.p13Leaji020018@dev.open-bio.org> gordonp Thu Feb 3 16:40:36 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv19982/src/main/ca/ucalgary/seahawk/gui Modified Files: DataImportChoiceDialog.java Log Message: Fixed javadoc and enabled multi-selection (import more than one item to the clipboard at a time) moby-live/Java/src/main/ca/ucalgary/seahawk/gui DataImportChoiceDialog.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java 2010/04/11 02:25:03 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java 2011/02/03 21:40:36 1.2 @@ -1,11 +1,8 @@ package ca.ucalgary.seahawk.gui; /** - * Generates a preview of a Taverna2 workflow and shows it in a dialog where - * metadata such as title, author, and description can be entered. - * - * Renders the workflow using a remote CGI and asks the user if they want to - * proceed with the export of the workflow. + * Generates a dialog for the user to select what Moby object(s) should be + * imported from the legacy data being pasted into Seahawk. */ import java.awt.*; @@ -42,6 +39,7 @@ // Default select items inheriting from the preferred data type, or choiceList = new JList(this.dataChoices); + choiceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); Vector initialSelectionIndices = new Vector(); if(preferredDataType != null && !preferredDataType.getName().equals(MobyTags.MOBYOBJECT)){ for(int i = 0; i < dataChoices.length; i++){ From gordonp at dev.open-bio.org Thu Feb 3 16:42:11 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:42:11 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032142.p13LgAbS020084@dev.open-bio.org> gordonp Thu Feb 3 16:42:10 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20048/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Added ability to export text selections from Seahawk to the clipboard moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.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/gui/FileAndTextTransferHandler.java 2010/05/13 16:03:59 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2011/02/03 21:42:10 1.12 @@ -246,7 +246,14 @@ protected Transferable createTransferable(JComponent c) { if(c instanceof MobyContentPane){ - return new SeahawkTransferable((MobyContentPane) c); + // Can export Moby data (via hyperlink drag) + if(((MobyContentPane) c).isDraggingHyperlink()){ + return new SeahawkTransferable((MobyContentPane) c); + } + // or text selection as string + else{ + return new StringSelection(((MobyContentPane) c).getSelectedText()); + } } else{ return null; From gordonp at dev.open-bio.org Thu Feb 3 16:45:38 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:45:38 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032145.p13LjcT4020152@dev.open-bio.org> gordonp Thu Feb 3 16:45:38 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20116/src/main/ca/ucalgary/seahawk/gui Modified Files: FilterSearchWidget.java Log Message: Several fixes including ability to not have highlight-as-you-type (can cause freezing), suspending matching when regex has trailing pipe, and search input field that responds to user preference for font size (accessibility) moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.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/FilterSearchWidget.java 2010/06/15 22:20:51 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java 2011/02/03 21:45:38 1.8 @@ -4,6 +4,8 @@ import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; +import java.awt.geom.AffineTransform; import java.awt.event.*; import java.net.URL; import java.util.concurrent.*; @@ -15,12 +17,13 @@ * Displays an editable SearchFilter within a MobyContentPane. */ -public class FilterSearchWidget extends JPanel implements ActionListener, DocumentListener{ +public class FilterSearchWidget extends JPanel implements ActionListener, DocumentListener, FontSizeChangeListener{ private FilterSearch currentFilterSearch; private JLabel closeIcon; private JToggleButton caseButton; private JButton inverseButton; // decides whether filter is "if" or "unless" + private JButton applyButton; // used when filter is in "non-interactive" mode private JTextField searchField; private JComboBox docPartOptions; private MobyContentPane contentPane; @@ -28,6 +31,7 @@ public static final String CASE_SENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_sensitive.png"; public static final String CASE_INSENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_insensitive.png"; + private static final String APPLY_TEXT = "Apply Filter"; private static final String IF_TEXT = "if"; private static final String UNLESS_TEXT = "unless"; private static final String CASE_INSENSITIVE_MSG = "The filter is case insensitive,
click to make case sensitive"; @@ -80,20 +84,41 @@ add(new JLabel("Show data ")); add(inverseButton); add(Box.createRigidArea(new Dimension(5,0))); + searchField = new JTextField(25); + setSearchFieldFontSize(SeahawkOptions.getFontSizeAsDouble()); searchField.setToolTipText("A literal string, or a regular expression"); searchField.getDocument().addDocumentListener(this); add(searchField); + add(Box.createRigidArea(new Dimension(5,0))); add(new JLabel("in")); add(Box.createRigidArea(new Dimension(5,0))); docPartOptions = new JComboBox(); docPartOptions.addActionListener(this); add(docPartOptions); + add(Box.createRigidArea(new Dimension(5,0))); + + if(!SeahawkOptions.isFilterInteractive()){ + // Normally we update any time the user types a letter. + // On some systems this freezes the system randomly, so there is the option to + // type, then press a button to apply the filter... + applyButton = new JButton(APPLY_TEXT); + applyButton.setEnabled(true); + applyButton.addActionListener(this); + add(applyButton); + } add(Box.createHorizontalGlue()); setFilter(null); } + private void setSearchFieldFontSize(double scale){ // Proportion of font compared to default + AffineTransform scaler = new AffineTransform(); + scaler.setToScale(scale, scale); + Font preferredFont = (new JTextField(1)).getFont().deriveFont(scaler); + searchField.setFont(preferredFont); + } + /** * The filter to display as editable right now. */ @@ -104,6 +129,7 @@ inverseButton.setEnabled(false); searchField.setEnabled(false); docPartOptions.setEnabled(false); + if(applyButton != null){applyButton.setEnabled(false);} return; } @@ -119,6 +145,9 @@ docPartOptions.setEnabled(true); docPartOptions.setModel(new DefaultComboBoxModel(fs.getXPathOptions())); docPartOptions.setSelectedItem(fs.getSelectedXPath()); + + if(applyButton != null){applyButton.setEnabled(true);} + currentFilterSearch = fs; // done in this order so no feedback as DocumentEvents while setting fields programmatically } @@ -153,6 +182,14 @@ contentPane.applyFilter(true); return; } + else if(e.getSource() == applyButton){ + StringBuffer sb = currentFilterSearch.getFilterRegex(); + synchronized(searchField){ + sb.replace(0, sb.length(), searchField.getText()); + } + applyFilterWhenSuitable(); + return; + } else if(currentFilterSearch == null || e.getSource() != docPartOptions){ return; } @@ -164,7 +201,7 @@ * Called when the regex has been changed by the user */ public void changedUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -175,7 +212,7 @@ } public void insertUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -186,7 +223,7 @@ } public void removeUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -196,6 +233,22 @@ applyFilterWhenSuitable(); } + // Check if the user is typing a regex and current has a | operator at the end. + // Don't update the matches at this point because of course the empty right side of the regex + // will match between every character, causing hardship for matching and highlight update + // on some machines. + private boolean danglingPipe(){ + String currentText = searchField.getText(); + // Running a regex on a regex to see if there is a trailing unescaped '|'...trippy + if(currentText.matches("(^|.*[^\\\\])(\\\\\\\\)*\\|")){ + searchField.setBackground(Color.YELLOW); + return true; + } + else{ + return false; + } + } + // Waits 600 milliseconds to see if the user is typing a phrase, rather than // filtering for each letter added, which can be slow private void applyFilterWhenSuitable(){ @@ -211,7 +264,7 @@ } catch(Exception e){ logger.log(Level.WARNING, - "Delay less than 400ms on search input due to interrupt", + "Delay less than 500ms on search input due to interrupt", e); } synchronized(sf){ @@ -245,6 +298,12 @@ // else, it's going to be updated soon anyway with the latest string buffer...just return } + public void fontSizeChanged(String size){ + // Data coming in is 110%, etc., convert to decimal scale required by + double scale = Double.parseDouble(size.substring(0, size.length()-1))/100.0; // lop off % sign, convert to ratio + setSearchFieldFontSize(scale); + } + class Closer extends MouseAdapter{ boolean active = false; private FilterSearchWidget widget; From gordonp at dev.open-bio.org Thu Feb 3 16:46:40 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:46:40 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032146.p13Lkee1020218@dev.open-bio.org> gordonp Thu Feb 3 16:46:40 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20182/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java Log Message: Make empty but well-formed clipboard file on startup to avoid exceptions in various widgets like the filter moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.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/gui/MobyContentClipboard.java 2010/04/16 20:36:17 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2011/02/03 21:46:40 1.12 @@ -92,6 +92,12 @@ return; } clipboardFile.deleteOnExit(); + try{ + writeClipboardDataToFile(); // Set up empty clipboard doc + } + catch(Exception e){ + logger.log(Level.SEVERE, "Clipboard failed to initialize, cannot write or load temp file", e); + } // The dfeault is to open a new tab when contents is transfered (dropped/pasted) onto the tab, // we want to override that behaviour to a collation for the clipboard @@ -270,7 +276,7 @@ logger.log(Level.FINE, urlContents); MobyDataType targetDataType = null; - if(collection != null){ + if(collection != null && !collection.isEmpty()){ targetDataType = collection.getDataType(); } MobyDataObject[] mobyDataFound = client.getMobyObjects(urlContents, targetDataType); @@ -341,21 +347,24 @@ } } - public void updateDisplay(){ + private void writeClipboardDataToFile() throws Exception{ // Write to temp file + FileOutputStream os = new FileOutputStream(clipboardFile); + MobyDataUtils.toXMLDocument(os, content); + os.close(); + } + + public void updateDisplay(){ try{ - FileOutputStream os = new FileOutputStream(clipboardFile); - MobyDataUtils.toXMLDocument(os, content); - os.close(); + writeClipboardDataToFile(); gotoURL(clipboardFile.toURI().toURL(), false); - } - catch(Exception e){ + tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), CLIPBOARD_TAB_NAME + + ": " + getResponseType(content)); + contentGUI.setVisible(true); + } catch(Exception e){ logger.log(Level.SEVERE, "Clipboard failed to update the display, cannot write or load temp file", e); return; } - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), CLIPBOARD_TAB_NAME + - ": " + getResponseType(content)); - contentGUI.setVisible(true); } /** From gordonp at dev.open-bio.org Thu Feb 3 16:47:57 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:47:57 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032147.p13LlvQl020284@dev.open-bio.org> gordonp Thu Feb 3 16:47:57 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20248/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Implement font resizing, and singleton application launching moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/05/13 16:13:21 1.23 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/03 21:47:57 1.24 @@ -26,6 +26,7 @@ import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; +import ca.ucalgary.util.*; import ca.ucalgary.seahawk.util.*; import ca.ucalgary.seahawk.services.MobyClient; @@ -36,7 +37,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -248,7 +249,7 @@ tabbedPane.add(clipboard); clipboard.init(); - settingsGUI = new SeahawkOptionsGUI(this); + settingsGUI = new SeahawkOptionsGUI(this, this); // params are frame owner, font change listener } public Acme.Serve.Serve getServletContainer(){ @@ -1189,15 +1190,17 @@ new Thread(){ public void run(){ for(;;) { - renderSplashFrame(g); - splash.update(); try { + renderSplashFrame(g); + splash.update(); Thread.sleep(100); } - catch(InterruptedException e) { + catch(Exception e) { } if(killSplash.tryAcquire()){ - splash.close(); + // Okay, we don't need to close the splash screen + // because it autocloses when a Java Window is shown. + //splash.close(); return; } } @@ -1277,6 +1280,24 @@ gui.loadPaneFromURL(startURL, true); } } + SingletonApplication.setArgumentListener(gui); + } + + // Called when user attempts to launch Seahawk again while its running + public void processArgument(String arg){ + try{ + loadPaneFromURL(new URL(arg), true); + } + catch(Exception e){ + System.err.println("Could not load "+arg+" as a URL, trying as a file"); + try{ + File f = new File(arg); + loadPaneFromURL(f.toURI().toURL(), true); + } catch(Exception fe){ + logger.error("Could not load "+arg+" as a URL or file: "+fe.getMessage()); + e.printStackTrace(); + } + } } protected static void cacheOntologies(){ @@ -1314,4 +1335,11 @@ public JLabel getStatusComponent() { return status; } + + public void fontSizeChanged(String fontSize) { + // Update font in all Seahawk-generated documents + for(int i = 0; i < tabbedPane.getTabCount(); i++){ + ((MobyContentPane) tabbedPane.getComponentAt(i)).setFontSize(fontSize); + } + } } From gordonp at dev.open-bio.org Thu Feb 3 16:49:01 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:49:01 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032149.p13Ln1mG020350@dev.open-bio.org> gordonp Thu Feb 3 16:49:01 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20314/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentHelpPane.java Log Message: Tiny fix so fot resizing can happen properly (requires help document URL be in history) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentHelpPane.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.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/MobyContentHelpPane.java 2010/03/29 19:55:22 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2011/02/03 21:49:01 1.6 @@ -68,7 +68,7 @@ } } - gotoURL(helpHTMLURL, false); + gotoURL(helpHTMLURL, true); editorPane.scrollToReference("start"); // use anchor at top of doc: pane scrolls to bottom normally... } From gordonp at dev.open-bio.org Thu Feb 3 16:50:51 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:50:51 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032150.p13LopH7020516@dev.open-bio.org> gordonp Thu Feb 3 16:50:50 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20460/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixes for font resizing, copying of data from Seahawk to the clipboard moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.33,1.34 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/05/13 16:12:19 1.33 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/03 21:50:50 1.34 @@ -31,9 +31,11 @@ import javax.swing.text.SimpleAttributeSet; import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; +import javax.swing.text.MutableAttributeSet; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; +import javax.swing.text.html.CSS; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLDocument; @@ -81,6 +83,7 @@ /** The name of the param in the stylesheet that will hold the Moby doc URL for XPointer usage */ public final static String XSL_DOC_SOURCE_PARAM = "sourceURL"; + public final static String XSL_DOC_FONTSIZE_PARAM = "fontSize"; private JScrollPane scrollPane; protected JTabbedPane tabbedPane; @@ -110,6 +113,7 @@ private Map jobXPtrs = null; // Map private List origStyles = null; private boolean firstDocRendering = true; + private String tempFontSize = null; // Next two items used for service wrapping private JMenuItem createServicePopupItem; @@ -485,6 +489,20 @@ } /** + * Used to temporarily change the font size of the displayed document. + * Normally the SeahawkOptions values are used. + * + * @param fontSize an absolute or relative font size as per HTML's basefont size specification. If null, document default size is used. + */ + public synchronized void setFontSize(String fontSize){ + tempFontSize = fontSize == null ? "100%" : fontSize; + gotoURL(getCurrentURL(), false); + // Also notify filter widget since the text input field will need resizing + filterSearchWidget.fontSizeChanged(tempFontSize); + tempFontSize = null; + } + + /** * This is the URLLoader callback method the MOBY data fetcher * will call when MOBY XML data is ready to be seen. */ @@ -534,7 +552,12 @@ } // Tell the stylesheet the URL of the moby data (it will create xpointers to it) - contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, url.toString()); + contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, + url.toString()); + //String fontSize = tempFontSize != null ? tempFontSize : SeahawkOptions.getFontSize(); + //System.err.println("Font size for XML doc will be "+fontSize); + //contentGUI.getTransformer().setParameter(XSL_DOC_FONTSIZE_PARAM, + // fontSize); // Do the actual transformation String htmlContents = "[Seahawk Internal Error]"; try{ @@ -542,6 +565,9 @@ contentGUI.getTransformer().transform(new StreamSource(url.openStream()), new StreamResult(stringWriter)); htmlContents = stringWriter.toString(); + if(htmlContents == null || htmlContents.length() == 0){ + htmlContents = "[Empty]"; + } // NOTE: If you switch the registry in the middle of using Seahawk, // the following might fail on documents in the history, as they were // encoded according to a different registry than the current value of @@ -549,7 +575,9 @@ // registries, there has to be a way to note the source registry for the data in the // document (preferred), or we must maintain a hash of the document:registry mappings // for the session. - htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents, SeahawkOptions.getRegistry()); + else{ + htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents, SeahawkOptions.getRegistry()); + } } catch(TransformerException te){ status.setText("Sorry! Could not transform the MOBY data into presentation form"); @@ -710,6 +738,16 @@ e.printStackTrace(); } + // Adjust font size if necessary in HTML docs + if((tempFontSize != null || !SeahawkOptions.getFontSize().equals("100%")) && + editorPane.getDocument() instanceof HTMLDocument){ + HTMLDocument doc = (HTMLDocument) editorPane.getDocument(); + MutableAttributeSet attr = new SimpleAttributeSet(); + String fontSize = tempFontSize != null ? tempFontSize : SeahawkOptions.getFontSize(); + doc.getStyleSheet().addCSSAttribute(attr, CSS.Attribute.FONT_SIZE, fontSize); + doc.setCharacterAttributes(0, editorPane.getDocument().getLength(), attr, false); + } + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if(addToHistory){ @@ -854,6 +892,7 @@ * PBE recorder. */ public void exportDone(String valuePasted, String transformRuleURI){ + System.err.println("Export done, notifying wrapping servlet (if any)"); if(cgiServlet != null && cgiServlet.getRecorder() != null && (cgiServlet.getRecorder() instanceof PBERecorder)){ ((PBERecorder) cgiServlet.getRecorder()).dataCopied(getDraggedData(), valuePasted, transformRuleURI); } @@ -1124,6 +1163,8 @@ public void hyperlinkUpdate(HyperlinkEvent he){ URL targetURL = he.getURL(); if(he.getEventType() == HyperlinkEvent.EventType.ACTIVATED){ + overHyperlink = true; + lastHyperlinkHovered = targetURL; // Internal moby pseudo-URL if(targetURL == null){ String desc = he.getDescription(); @@ -1554,6 +1595,9 @@ } FilterSearch filter = filterHistory.get(getCurrentURL()); + if(getCurrentDoc() == null){ + return; + } filterableNodes = DataUtils.findFilteredNodes(getCurrentDoc(), filter, filterableNodes, filteredData, jobXPtrs, currentSelectedData, currentSelectionXPath, apply); @@ -1660,7 +1704,7 @@ javax.swing.text.Element el = d.getElement(filterable); String fragment = d.getText(el.getStartOffset(), el.getEndOffset() - el.getStartOffset()); - Matcher matcher = p.matcher(fragment); + Matcher matcher = p.matcher(fragment.trim()); while (matcher.find()) { // Only count match if not already highlighted in a containing filterable node // todo: in future, avoid looking in text bits already checked, for efficiency @@ -1880,6 +1924,10 @@ return; } else{ // keep track of the previous selection so we can use it once it's gone + if(dragging){ //if a hyperlink is being dragged, don't highlight too + System.err.println("Ignoring highlight while dragging hyperlink"); + return; + } oldMark = mark; oldDot = dot; } @@ -1904,13 +1952,29 @@ tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + "or drag'n'drop/paste data from your desktop or Web browser."); } + // Ctrl+C copy of selection if any + if(e.getKeyCode() == KeyEvent.VK_C && e.isControlDown() && selectedTextData != null){ + getTransferHandler().exportToClipboard(this, + Toolkit.getDefaultToolkit().getSystemClipboard(), + TransferHandler.COPY); + } } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} + public boolean isDraggingHyperlink(){ + return dragging; + } + + public String getSelectedText(){ + return selectedTextData; + } + public void paste(){ - getTransferHandler().importData(this, Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this)); + if(!dragging){ //don't allow drag onto self... + getTransferHandler().importData(this, Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this)); + } } public void mouseDragged(MouseEvent e){ @@ -1919,13 +1983,14 @@ dragging = true; // so we don't export many times in a row while dragging lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - getTransferHandler().exportToClipboard(this, - Toolkit.getDefaultToolkit().getSystemClipboard(), - TransferHandler.COPY); + System.err.println("Dragging initiated via mouseDragged for "+lastHyperlinkDragged); + //getTransferHandler().exportToClipboard(this, + // Toolkit.getDefaultToolkit().getSystemClipboard(), + // TransferHandler.COPY); getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); } else if(!dragging){ - //System.err.println("Dragging with no hyperlink activated"); + System.err.println("Dragging with no hyperlink activated"); } } @@ -1935,18 +2000,24 @@ // mouse button being down here. if(overHyperlink && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK){ //System.err.println("Got wonky drag"); - lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - //System.err.println("Dragging "+lastHyperlinkDragged); - getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); + if(lastHyperlinkDragged != lastHyperlinkHovered){ + System.err.println("Dragging initiated via mouseMoved for "+lastHyperlinkDragged); + lastHyperlinkDragged = lastHyperlinkHovered; + //getTransferHandler().exportToClipboard(this, + // Toolkit.getDefaultToolkit().getSystemClipboard(), + // TransferHandler.COPY); + getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); + } } else if(dragging){ + System.err.println("Dragging stopped...no mouse down on mouseMoved"); dragging = false; } } public void lostOwnership(Clipboard clipboard, Transferable contents){ - //System.err.println("Lost clipboard ownership"); + System.err.println("Lost clipboard ownership"); } } From gordonp at dev.open-bio.org Thu Feb 3 16:52:05 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:52:05 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032152.p13Lq5W0020642@dev.open-bio.org> gordonp Thu Feb 3 16:52:05 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20606/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: Added support for disabling highlight-while-typing (may cause freezing), and font resizing moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/12/06 18:47:31 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2011/02/03 21:52:05 1.7 @@ -34,8 +34,12 @@ private JTextField converterPortTextField; private JTextField cacheExpiryTextField; private JFileChooser cacheDirFileChooser; + private JComboBox fontComboBox; + private String[] fontSizes = new String[]{"50%","75%","90%","100%","110%","125%","150%","200%"}; + private FontSizeChangeListener fontSizeChangeListener; private JCheckBox sendReferrerCheckBox; + private JCheckBox filterInteractiveCheckBox; private JButton resetButton; private JButton okButton; @@ -49,14 +53,15 @@ /** * @param owner the frame that launches this dialog */ - public SeahawkOptionsGUI(Frame owner){ + public SeahawkOptionsGUI(Frame owner, FontSizeChangeListener listener){ super(owner, DIALOG_TITLE, DIALOG_MODAL); // Custom handling of window close operation setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(this); + fontSizeChangeListener = listener; - // The dreaded GridBagLayout... + // The dreaded GridBagLayout...see http://madbean.com/anim/totallygridbag/ GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; @@ -72,6 +77,16 @@ registryNames[i] = CUSTOM_REGISTRY_SYNONYM; c.insets = new Insets(3,2,3,2); + + // Font size widget + + //........................................ + //c.gridx = 0; + //c.gridy = 4; + //c.gridwidth = 5; + //JSeparator line = new JSeparator(); + //add(line, c); + //........................................ c.gridwidth = 2; @@ -185,20 +200,50 @@ //........................................ c.gridx = 0; c.gridy = 7; - c.gridwidth = 4; + c.gridwidth = 2; c.gridheight = 1; sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); add(sendReferrerCheckBox, c); + c.gridx = 2; + c.gridwidth = 2; + c.gridheight = 1; + filterInteractiveCheckBox = new JCheckBox("Highlight filter matches while typing"); + add(filterInteractiveCheckBox, c); //........................................ + c.gridx = 0; c.gridy = 8; c.gridwidth = 5; line = new JSeparator(); add(line, c); - //........................................ + c.gridx = 0; c.gridy = 9; c.gridwidth = 2; + c.weightx = 0.0; + c.weighty = 0.0; + c.fill = GridBagConstraints.HORIZONTAL; + label = new JLabel("Document Font Size:", JLabel.RIGHT); + add(label, c); + c.gridx = 2; + c.gridwidth = 1; + + adjustFontSizesIfNecessary(); + fontComboBox = new JComboBox(fontSizes); + fontComboBox.setSelectedItem(SeahawkOptions.getFontSize()); // do this here to avoid unnecessary callback + fontComboBox.addActionListener(this); + add(fontComboBox, c); + + //........................................ + c.gridx = 0; + c.gridy = 10; + c.gridwidth = 5; + line = new JSeparator(); + add(line, c); + + c.gridy = 11; + c.gridx = 0; + c.gridwidth = 2; label = new JLabel("Cache expiry (in hours)", JLabel.RIGHT); add(label, c); @@ -232,10 +277,54 @@ pack(); } + // If the value of the user preferred font size is not one of the standard presets + // (e.g. they set it manually in the config file), + // add that custom value to the list of options. + private void adjustFontSizesIfNecessary(){ + String currentFontSize = SeahawkOptions.getFontSize(); + double currentSizeDouble = convertFontSizeToDouble(currentFontSize); + for(String presetChoice: fontSizes){ + if(convertFontSizeToDouble(presetChoice) == currentSizeDouble){ + SeahawkOptions.setFontSize(presetChoice); // avoids confusion in parts of app looking for 100%, not 100.000% etc. + return; // it's an existing choice + } + } + + // If we got here, it's a custom value + System.err.println("Inserting custom value (" + currentFontSize + ") into font size choices"); + String[] newFontSizes = new String[fontSizes.length+1]; + // Insertion of custom value into ordered presets list assumes existing font sizes and ordered small to large + boolean customValuePlaced = false; + for(int i = 0; i < fontSizes.length; i++){ + if(customValuePlaced){ + newFontSizes[i+1] = fontSizes[i]; + } + else if(currentSizeDouble < convertFontSizeToDouble(fontSizes[i])){ + newFontSizes[i] = currentFontSize; + customValuePlaced = true; + i--; + } + else{ + newFontSizes[i] = fontSizes[i]; // verbatim 'cause custom value not encountered yet + } + } + // Bigger than any preset? append to new list + if(!customValuePlaced){ + newFontSizes[fontSizes.length] = currentFontSize; + } + fontSizes = newFontSizes; + } + + // "100%" -> 100.0 + private double convertFontSizeToDouble(String fontSize){ + return Double.parseDouble(fontSize.substring(0, fontSize.length()-1)); // lop off % sign + } + public void actionPerformed(ActionEvent event){ Object source = event.getSource(); if(source == cancelButton){ setCurrentValues(); + updateDocumentFont(SeahawkOptions.getFontSize()); setVisible(false); } else if(source == okButton){ @@ -257,6 +346,9 @@ else if(source == registryComboBox){ updateRegistryFields(); } + else if(source == fontComboBox){ + updateDocumentFont(fontComboBox.getSelectedItem().toString()); + } } /** @@ -279,8 +371,9 @@ converterHostTextField.setText(""+SeahawkOptions.getDocConverterHost()); converterPortTextField.setText(""+SeahawkOptions.getDocConverterPort()); sendReferrerCheckBox.setSelected(SeahawkOptions.getSendReferrerPolicy()); + filterInteractiveCheckBox.setSelected(SeahawkOptions.isFilterInteractive()); cacheExpiryTextField.setText(""+SeahawkOptions.getCacheExpiry()); - cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); } private void saveSettings(){ @@ -350,6 +443,15 @@ SeahawkOptions.setDocConverterHost(converterHostTextField.getText().trim()); SeahawkOptions.setSendReferrerPolicy(sendReferrerCheckBox.isSelected()); SeahawkOptions.setCacheExpiry(expiry); + if(filterInteractiveCheckBox.isSelected() != SeahawkOptions.isFilterInteractive()){ + JOptionPane.showMessageDialog(null, + "Please restart Seahawk to fully apply the filter behaviour change.", + "Filter behaviour change requires restart", + JOptionPane.INFORMATION_MESSAGE); + } + SeahawkOptions.setFilterInteractive(filterInteractiveCheckBox.isSelected()); + SeahawkOptions.setFontSize(fontComboBox.getSelectedItem().toString()); + updateDocumentFont(fontComboBox.getSelectedItem().toString()); // Saves the new values to a file, so they will perpetuate themselves between sessions if(!SeahawkOptions.saveSettings()){ @@ -377,6 +479,12 @@ setVisible(false); } + private void updateDocumentFont(String fontSize){ + if(fontSizeChangeListener != null){ + fontSizeChangeListener.fontSizeChanged(fontSize); + } + } + private void updateRegistryFields(){ // Update all the registry fields if the name switches String selectedRegistryName = registryComboBox.getSelectedItem().toString(); @@ -446,7 +554,7 @@ JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - SeahawkOptionsGUI dialog = new SeahawkOptionsGUI(frame); + SeahawkOptionsGUI dialog = new SeahawkOptionsGUI(frame, null); frame.pack(); frame.setVisible(true); From gordonp at dev.open-bio.org Thu Feb 3 16:54:51 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:54:51 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032154.p13Lsp92020752@dev.open-bio.org> gordonp Thu Feb 3 16:54:51 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv20716/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: New and improved protein recognition rule moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/resources/mobyBuilderRules.xml 2010/04/11 02:20:46 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2011/02/03 21:54:51 1.12 @@ -55,8 +55,8 @@ urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareAA2AminoAcidSequence (?:^|[^A-Za-z]) # some non-alphabetical boundary - (\P*\s*(?:\P{10,}(?:\x20|\r|\t|\n){2,})+\P*) # iupac or spacing - (?![A-Za-z]) # should not be followed by letters + (\P*[^ACGTNacgtn]\s*(?:\P{10,}(?:\x20|\r|\t|\n)+)+\P*) # iupac or spacing, at least one non-DNA char + (?![A-Za-z]|\Z) # should not be followed by letters (try not to recognize free text as protein) From gordonp at dev.open-bio.org Thu Feb 3 16:57:23 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:57:23 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032157.p13LvNgT020840@dev.open-bio.org> gordonp Thu Feb 3 16:57:23 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv20804/src/main/ca/ucalgary/seahawk/util Modified Files: DataFlowRecorder.java Log Message: Numerous improvements to port labelling, input data support, removing cruft code moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/04/18 00:23:42 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2011/02/03 21:57:23 1.7 @@ -33,6 +33,8 @@ public static final String T2FLOW_XPATHFILTER_BEANSHELL = "ca/ucalgary/seahawk/resources/XPathFilterBeanShell"; public static final String T2FLOW_PASSFILTER_BEANSHELL = "ca/ucalgary/seahawk/resources/PassFilterBeanShell"; // = if condition public static final String T2FLOW_LISTFLATTEN_BEANSHELL = "ca/ucalgary/seahawk/resources/FlattenListBeanShell"; + public static final String T2FLOW_SELECTFILES_BEANSHELL = "ca/ucalgary/seahawk/resources/SelectFilesBeanShell"; + public static final String T2FLOW_READBINARYFILE_BEANSHELL = "ca/ucalgary/seahawk/resources/BinaryFileLoaderBeanShell"; private Central mobyCentral; private Map namesUsed; // keep count of workflow element name usage so as not to duplicate an ID @@ -47,6 +49,8 @@ private static String xpathFilterScript = null; private static String passFilterScript = null; private static String listFlattenScript = null; + private static String fileSelectionScript = null; + private static String readBinaryFileScript = null; private static Element dispatchStack = null; private static Transformer nullTransformer = null; private static Logger logger = Logger.getLogger(DataFlowRecorder.class.getName()); @@ -238,7 +242,7 @@ return portEl; } - private Element createWorkflowInputElement(String name, MobyPrimaryData sampleData, Document doc){ + private Element createWorkflowInputElement(String name, MobyNamespace ns, String id, MobyPrimaryData[] sampleData, Document doc){ Element portEl = doc.createElementNS(T2FLOW_NS, "port"); Element nameEl = doc.createElementNS(T2FLOW_NS, "name"); @@ -253,15 +257,29 @@ granularDepthEl.appendChild(doc.createTextNode("0")); portEl.appendChild(granularDepthEl); - MobyNamespace ns = null; - if(sampleData.getNamespaces() != null && - sampleData.getNamespaces().length > 0){ - ns = sampleData.getNamespaces()[0]; + String descText = "File/Spreadsheet of one or more lines, " + + (sampleData.length == 1 ? + "each line containing one ": + "with the following "+sampleData.length+" fields in order:"); + for(MobyPrimaryData sampleDatum: sampleData){ + descText += sampleDatum.getName()+" ("+sampleDatum.getDataType().getName()+"),"; + } + if(ns != null && !ns.getName().equals("unknown")){ + descText += ns.getName()+" (ID)"; + } + else{ + descText = descText.substring(0, descText.length()-1); + } + String exampleText = ""; + for(MobyPrimaryData sampleDatum: sampleData){ + exampleText += ((MobyDataObject) sampleDatum).getObject().toString()+","; + } + if(ns != null && !ns.getName().equals("unknown")){ + exampleText += id; + } + else{ + exampleText = exampleText.substring(0, exampleText.length()-1); } - - String descText = "File of one or more"+(ns == null ? "" : " "+ - ns.getName())+" IDs, one per line"; - String exampleText = sampleData.getId(); Element annotations = doc.createElementNS(T2FLOW_NS, "annotations"); portEl.appendChild(annotations); annotations.appendChild(createAnnotationChain("net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription", descText, doc)); @@ -475,14 +493,9 @@ mobifyingProcessorNameAndPorts = input2Processor.get(inputKey); } else{ - if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT)){ - mobifyingProcessorNameAndPorts = addIdMobifyingProcessor(processors, datalinks, inputPorts, - sampleData, doc); - input2Processor.put(inputKey, mobifyingProcessorNameAndPorts); - } - else{ - // TODO: Need to build complex input from MOB rule or spreadsheet fields? - } + mobifyingProcessorNameAndPorts = addDataMobifyingProcessor(processors, datalinks, inputPorts, + sampleData, doc); + input2Processor.put(inputKey, mobifyingProcessorNameAndPorts); } // link the created data to the workflow service datalinks.appendChild(createDataLinkElement(mobifyingProcessorNameAndPorts[0], @@ -503,22 +516,86 @@ return inputKey.replaceFirst(MobyTags.ARTICLENAME+"\\s*=\\s*(['\"]).*?\\1", ""); } - // Actually adds a few processors, but only one needs to be returned and connected to an input port. - // The others are constant values. By default we assume that you want to run a bunch of IDs - // in a file, we also link in a Taverna spreadsheet importer. - // Returns [spreadsheetReadingProcName, outputPort] - private String[] addIdMobifyingProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, - MobyPrimaryData sampleData, Document doc) throws Exception{ - String processorName = "Create-" + sampleData.getDataType().getName(); + private String[] addDataMobifyingProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, + MobyPrimaryData sampleData, Document doc) throws Exception{ + MobyDataType sampleDataType = sampleData.getDataType(); + + boolean hasBinaryBase = false; + List sampleCompositeProcessors = new ArrayList(); + List sampleComposites = new ArrayList(); + List samplePrimitives = new ArrayList(); + String[] binaryFileReaderProcNameAndPorts = null; + if(sampleData instanceof MobyDataComposite){ + if(sampleData instanceof MobyDataBytes){ // binary data needs special handling + binaryFileReaderProcNameAndPorts = addBinaryFileReaderBeanShell(processors, doc); + + // connect the article name constant to the binary file reader + String[] fileSelectionProcNameAndPorts = addFileSelectionBeanShell(processors, doc); + String constantTitle = createUniqueName("File_dialog_title"); + processors.appendChild(createConstantProcessor(constantTitle, "Load multiple " + MobyDataBytes.ENCODED_MEMBER_NAME + " files", doc)); + datalinks.appendChild(createDataLinkElement(constantTitle, + "value", + fileSelectionProcNameAndPorts[0], + fileSelectionProcNameAndPorts[1], + doc)); + + // connect the dialog title constant to the binary file reader + String constantName = createUniqueName(MobyDataBytes.ENCODED_MEMBER_NAME+"-article_name"); + processors.appendChild(createConstantProcessor(constantName, MobyDataBytes.ENCODED_MEMBER_NAME, doc)); + datalinks.appendChild(createDataLinkElement(constantName, + "value", + binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[1], + doc)); + // link the file selection dialog results to the binary file reader + datalinks.appendChild(createDataLinkElement(fileSelectionProcNameAndPorts[0], + fileSelectionProcNameAndPorts[fileSelectionProcNameAndPorts.length-1], + binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[2], + doc)); + hasBinaryBase = true; + } + // recurse to fill in other fields + for(MobyPrimaryData child: ((MobyDataComposite) sampleData).values()){ + if(hasBinaryBase && child.getName().equals(MobyDataBytes.ENCODED_MEMBER_NAME)){ + continue; // handled this member in an if condition earlier + } + if(child instanceof MobyDataComposite){ + // must recurse because the complex object contains another complex object + sampleCompositeProcessors.add(addDataMobifyingProcessor(processors, + datalinks, + dataFlowInputPorts, + child, + doc)); + sampleComposites.add((MobyDataComposite) child); + } + else{ + samplePrimitives.add(child); + } + } + } + // a Moby primitive + else if(!sampleDataType.getName().equals(MobyTags.MOBYOBJECT)){ + samplePrimitives.add(sampleData); + } + + String processorName = "Create-" + sampleDataType.getName(); MobyNamespace ns = null; MobyNamespace[] nss = ((MobyPrimaryData) sampleData).getNamespaces(); - if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT) && - nss != null && nss.length > 0){ - ns = nss[0]; //we will use only the primary namespace - processorName = "Create-" + ns.getName() + "-ID"; + if(nss != null && nss.length > 0){ + ns = nss[0]; // we will use only the primary namespace for now + if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT)){ + processorName = "Create-" + ns.getName() + "-ID"; + } + else{ //datatype + ns in proc name + processorName += "-"+ns.getName() + "-ID"; + } } processorName = createUniqueName(processorName); + // now we need to merge the primitive object fields with the processors creating binary and other complex objects + + // Create the Mobifying processor Element processor = doc.createElementNS(T2FLOW_NS, "processor"); processors.appendChild(processor); Element name = doc.createElementNS(T2FLOW_NS, "name"); @@ -596,10 +673,41 @@ iteration.appendChild(strategy); Element cross = doc.createElementNS(T2FLOW_NS, "cross"); strategy.appendChild(cross); + Element dot = doc.createElementNS(T2FLOW_NS, "dot"); + cross.appendChild(dot); + + // object members + 3 standard input ports, and one output + String[] portNames = new String[4+sampleCompositeProcessors.size()+samplePrimitives.size()+(binaryFileReaderProcNameAndPorts != null ? 1 :0)]; + portNames[portNames.length-4] = "id"; + portNames[portNames.length-3] = "namespace"; + portNames[portNames.length-2] = "article name"; + portNames[portNames.length-1] = "mobyData"; + + if(binaryFileReaderProcNameAndPorts != null){ + portNames[0] = getPortName(((MobyDataBytes) sampleData).get(MobyDataBytes.ENCODED_MEMBER_NAME), false); + datalinks.appendChild(createDataLinkElement(binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[binaryFileReaderProcNameAndPorts.length-1], + processorName, + portNames[0], + doc)); + } + // fill the new processor's input port list with the composites' output ports + for(int i = (binaryFileReaderProcNameAndPorts != null ? 1 :0); i < sampleCompositeProcessors.size(); i++){ + String[] compositeProcNameAndPorts = sampleCompositeProcessors.get(i); + portNames[i] = getPortName(sampleComposites.get(i), false); + datalinks.appendChild(createDataLinkElement(compositeProcNameAndPorts[0], + compositeProcNameAndPorts[compositeProcNameAndPorts.length-1], + processorName, + portNames[i], + doc)); + } + // then the primitives' output ports... + for(int i = (binaryFileReaderProcNameAndPorts != null ? 1 :0); i < samplePrimitives.size(); i++){ + portNames[sampleCompositeProcessors.size()+i] = getPortName(samplePrimitives.get(i), false); + } - // 3 input ports, one output - String[] portNames = new String[]{"namespace", "article name", "id", "mobyData"}; - for(String portNameString: portNames){ + for(int i = 0; i < portNames.length; i++){ + String portNameString = portNames[i]; // Map them Element map = createMapFromTo(portNameString, portNameString, doc); //identity map if(portNameString.equals("mobyData")){ @@ -607,25 +715,38 @@ outputMap.appendChild(map); } else{ - inputPorts.appendChild(createParamPort(portNameString, "0", doc)); - + inputPorts.appendChild(createParamPort(portNameString, "0", doc)); inputMap.appendChild(map); // Add the iteration strategy Element portRef = doc.createElementNS(T2FLOW_NS, "port"); portRef.setAttribute("name", portNameString); portRef.setAttribute("depth", "0"); - cross.appendChild(portRef); + // last few standard attributes are constants, so cross them instead of dot + if(i >= portNames.length - (ns==null || ns.getName().equals("unknown") ? 4 : 3)){ + cross.appendChild(portRef); + } + else{ + dot.appendChild(portRef); + } } } - // Create the constant value processors for the articlename - // NOTE: WE REPURPOSE THE VARIABLES ABOVE FOR NEW ELEMENTS!!! + // Create the constant value processors for the object Map constants = new HashMap(); Map feeds = new HashMap(); //what port on data creator it maps to - constants.put(ns.getName()+"-namespace-constant", ns.getName()); - feeds.put(ns.getName()+"-namespace-constant", "namespace"); - constants.put("article_name-constant", "unimportant"); + if(ns != null && !ns.getName().equals("unknown")){ + constants.put(ns.getName()+"-namespace-constant", ns.getName()); + feeds.put(ns.getName()+"-namespace-constant", "namespace"); + // id is fed from spreadsheet importer if ns is defined, no need to populate here + } + else{ + constants.put("blank-namespace", ""); + feeds.put("blank-namespace", "namespace"); + constants.put("blank-id", ""); + feeds.put("blank-id", "id"); + } + constants.put("article_name-constant", sampleData.getName()); feeds.put("article_name-constant", "article name"); for(Map.Entry constant: constants.entrySet()){ @@ -638,54 +759,115 @@ doc)); } + if(samplePrimitives.isEmpty() && hasBinaryBase && + sampleCompositeProcessors.isEmpty()){ // just a plain binary object to return, no need for spreadsheet importer + + // return the name of the data creator and output port so it can be hooked up + // to input ports for Moby services + return new String[]{processorName, portNames[portNames.length-1]}; + } + + String[] spreadsheetProcessorNameAndPorts = + addPrimitiveSpreadsheetProcessor(processors, datalinks, dataFlowInputPorts, + sampleDataType, ns, sampleData.getId(), + samplePrimitives.toArray(new MobyPrimaryData[samplePrimitives.size()]), + doc); + + + // link the spreadsheet reader to the Moby data creator + for(int i = 1; i < spreadsheetProcessorNameAndPorts.length; i++){ + datalinks.appendChild(createDataLinkElement(spreadsheetProcessorNameAndPorts[0], + spreadsheetProcessorNameAndPorts[i], + processorName, + portNames[(binaryFileReaderProcNameAndPorts != null ? 1 :0)+sampleCompositeProcessors.size()+i-1], + doc)); + } + + // return the name of the data creator processor and output port so it can be hooked up + // to input ports for Moby services + return new String[]{processorName, portNames[portNames.length-1]}; + } + + // Actually adds a few processors, but only one needs to be returned and connected to an input port. + // The others are constant values. By default we assume that you want to run a bunch of IDs + // in a file, we also link in a Taverna spreadsheet importer. + // Returns [spreadsheetReadingProcName, outputPort1, outputPort2, etc.] + private String[] addPrimitiveSpreadsheetProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, + MobyDataType dataType, MobyNamespace ns, String id, + MobyPrimaryData[] sampleData, Document doc) throws Exception{ + // feed the id input of the Moby data creator with a spreadsheet importer, // so users can easily give a file list of IDs to run. - String importerName = createUniqueName("SpreadsheetImporter-"+ns.getName()+"-IDs"); + String dataTypeName = dataType.getName(); + if(dataTypeName.equals(MobyTags.MOBYOBJECT)){ + dataTypeName = ns.getName()+"-ID"; + } + else{ + dataTypeName += "-fields"; + } + String importerName = createUniqueName("SpreadsheetImporter-"+dataTypeName); Element importProcessor = doc.createElementNS(T2FLOW_NS, "processor"); processors.appendChild(importProcessor); - name = doc.createElementNS(T2FLOW_NS, "name"); + Element name = doc.createElementNS(T2FLOW_NS, "name"); name.appendChild(doc.createTextNode(importerName)); importProcessor.appendChild(name); - inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); + Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); importProcessor.appendChild(inputPorts); inputPorts.appendChild(createParamPort("fileurl", "0", doc)); - outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); + Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); importProcessor.appendChild(outputPorts); - String outputUniqueName = createUniqueName(ns.getName());// output name - outputPorts.appendChild(createParamPort(outputUniqueName, "1", "1", doc)); + String[] outputUniqueNames = new String[sampleData.length+(ns!=null && !ns.getName().equals("unknown")?1:0)]; + for(int i = 0; i < sampleData.length; i++){ + String outputName = sampleData[i].getName(); + if(sampleData[i].getDataType().getName().equals(MobyTags.MOBYOBJECT)){ + outputName += "-"+sampleData[i].getNamespaces()[0].getName()+"-ID"; + } + else{ + outputName += "-"+sampleData[i].getDataType().getName(); + } + outputUniqueNames[i] = createUniqueName(outputName);// output name + outputPorts.appendChild(createParamPort(outputUniqueNames[i], "1", "1", doc)); + } + // special port name case for id field of object, if present + if(ns != null && !ns.getName().equals("unknown")){ + outputUniqueNames[outputUniqueNames.length-1] = "id"; + outputPorts.appendChild(createParamPort("id", "1", "1", doc)); + } importProcessor.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - activities = doc.createElementNS(T2FLOW_NS, "activities"); + Element activities = doc.createElementNS(T2FLOW_NS, "activities"); importProcessor.appendChild(activities); - activity = doc.createElementNS(T2FLOW_NS, "activity"); + Element activity = doc.createElementNS(T2FLOW_NS, "activity"); activities.appendChild(activity); - raven = doc.createElementNS(T2FLOW_NS, "raven"); - group = doc.createElementNS(T2FLOW_NS, "group"); + Element raven = doc.createElementNS(T2FLOW_NS, "raven"); + Element group = doc.createElementNS(T2FLOW_NS, "group"); group.appendChild(doc.createTextNode("net.sf.taverna.t2.activities")); raven.appendChild(group); - artifact = doc.createElementNS(T2FLOW_NS, "artifact"); + Element artifact = doc.createElementNS(T2FLOW_NS, "artifact"); artifact.appendChild(doc.createTextNode("spreadsheet-import-activity")); raven.appendChild(artifact); - version = doc.createElementNS(T2FLOW_NS, "version"); + Element version = doc.createElementNS(T2FLOW_NS, "version"); version.appendChild(doc.createTextNode("1.0")); raven.appendChild(version); activity.appendChild(raven); - clas = doc.createElementNS(T2FLOW_NS, "class"); + Element clas = doc.createElementNS(T2FLOW_NS, "class"); activity.appendChild(clas); clas.appendChild(doc.createTextNode("net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity")); - inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); + Element inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); activity.appendChild(inputMap); inputMap.appendChild(createMapFromTo("fileurl", "fileurl", doc)); //identity map - outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); + Element outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); activity.appendChild(outputMap); - outputMap.appendChild(createMapFromTo(outputUniqueName, outputUniqueName, doc)); + for(int i = 0; i < outputUniqueNames.length; i++){ + outputMap.appendChild(createMapFromTo(outputUniqueNames[i], outputUniqueNames[i], doc)); + } - configBean = doc.createElementNS(T2FLOW_NS, "configBean"); + Element configBean = doc.createElementNS(T2FLOW_NS, "configBean"); configBean.setAttribute("encoding", "xstream"); activity.appendChild(configBean); Element SpreadsheetImportConfiguration = @@ -697,7 +879,7 @@ Element columnRange = doc.createElementNS("", "columnRange"); SpreadsheetImportConfiguration.appendChild(columnRange); columnRange.appendChild(createElWithText(doc,"","start","0")); - columnRange.appendChild(createElWithText(doc,"","end","0")); + columnRange.appendChild(createElWithText(doc,"","end", ""+(sampleData.length-1+(ns!=null && !ns.getName().equals("unknown")?1:0)))); columnRange.appendChild(doc.createElementNS("", "excludes")); Element rowRange = doc.createElementNS("", "rowRange"); @@ -710,10 +892,18 @@ Element columnNames = doc.createElementNS("", "columnNames"); SpreadsheetImportConfiguration.appendChild(columnNames); - Element entry = doc.createElementNS("", "entry"); - columnNames.appendChild(entry); - entry.appendChild(createElWithText(doc,"","string","A")); - entry.appendChild(createElWithText(doc,"","string",outputUniqueName)); + // NOTE: Use 26 column names, if more, name as in Excel, AA, AB, etc + String[] columnLetters = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", + "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z"}; + for(int i = 0; i < outputUniqueNames.length; i++){ + Element entry = doc.createElementNS("", "entry"); + columnNames.appendChild(entry); + entry.appendChild(createElWithText(doc,"","string", + (i >= columnLetters.length ? + columnLetters[i/columnLetters.length-1]: "")+ + columnLetters[i%columnLetters.length])); + entry.appendChild(createElWithText(doc,"","string", outputUniqueNames[i])); + } SpreadsheetImportConfiguration.appendChild(createElWithText(doc,"","allRows","true")); SpreadsheetImportConfiguration.appendChild(createElWithText(doc,"","excludeFirstRow","false")); @@ -726,36 +916,35 @@ importProcessor.appendChild(getDispatchStack(doc)); - iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); + Element iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); importProcessor.appendChild(iterationStrategyStack); - iteration = doc.createElementNS(T2FLOW_NS, "iteration"); + Element iteration = doc.createElementNS(T2FLOW_NS, "iteration"); iterationStrategyStack.appendChild(iteration); - strategy = doc.createElementNS(T2FLOW_NS, "strategy"); + Element strategy = doc.createElementNS(T2FLOW_NS, "strategy"); iteration.appendChild(strategy); - cross = doc.createElementNS(T2FLOW_NS, "cross"); + Element cross = doc.createElementNS(T2FLOW_NS, "cross"); strategy.appendChild(cross); Element port = doc.createElementNS(T2FLOW_NS, "port"); cross.appendChild(port); port.setAttribute("name", "fileurl"); port.setAttribute("depth", "0"); - String uniqueInputName = createUniqueName(getInputName(sampleData)); + String uniqueInputName = createUniqueName(getInputName(dataType, ns)); // todo: sample data may be of more specific type than service requires - dataFlowInputPorts.appendChild(createWorkflowInputElement(uniqueInputName, sampleData, doc)); + dataFlowInputPorts.appendChild(createWorkflowInputElement(uniqueInputName, ns, id, sampleData, doc)); datalinks.appendChild(createWorkflowInputLinkElement(uniqueInputName, importerName, "fileurl", - sampleData, doc)); - // link the spreadsheet reader to the Moby data creator - datalinks.appendChild(createDataLinkElement(importerName, outputUniqueName, - processorName, "id", - doc)); - - // return the name of the spreadsheet reading processor and output port so it can be hooked up - // to input ports for Moby services - return new String[]{processorName, portNames[portNames.length-1]}; + // processor name, output ports (same number as sampleData length) + String[] procAndPortNames = new String[outputUniqueNames.length+1]; + procAndPortNames[0] = importerName; + System.arraycopy(outputUniqueNames, 0, procAndPortNames, 1, outputUniqueNames.length); + + // return the name of the spreadsheet reading processor and output ports so it can be hooked up + // to input ports for Moby data creator + return procAndPortNames; } private Element createConstantProcessor(String constantName, String constantValue, Document doc) @@ -1287,142 +1476,8 @@ } return endpoint; } - - // Returns the name of the moby object building processor and its ports, so we can create the data links in the caller - private String[] addMobyDataCreatorProcessor(MobyPrimaryData mobyData, Element processors, Document doc) - throws Exception{ - String dataType = null; - boolean primitiveDataType = false; - if(mobyData instanceof MobyPrimaryDataSet){ - dataType = "Collections - unimplemented"; - } - else if(mobyData instanceof MobyPrimaryDataSimple){ - if(mobyData instanceof MobyDataComposite){ - dataType = "Composite datatype - unimplemented"; - } - // a Moby primitive - else if(mobyData instanceof MobyDataString){ - dataType = MobyTags.MOBYSTRING; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataBoolean){ - dataType = MobyTags.MOBYBOOLEAN; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataDateTime){ - dataType = MobyTags.MOBYDATETIME; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataFloat){ - dataType = MobyTags.MOBYFLOAT; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataInt){ - dataType = MobyTags.MOBYINTEGER; - primitiveDataType = true; - } - // base object or xref - else{ - MobyNamespace[] nss = ((MobyPrimaryDataSimple) mobyData).getNamespaces(); - if(nss.length != 0){ - dataType = nss[0].getName()+"_ID"; - } - else{ - dataType = "Object"; - } - } - } - - String builderProcName = createUniqueName("Create_"+dataType+"s"); - Element builderProcessor = doc.createElementNS(T2FLOW_NS, "processor"); - processors.appendChild(builderProcessor); - builderProcessor.appendChild(createElWithText(doc, T2FLOW_NS, "name", builderProcName)); - - Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); - builderProcessor.appendChild(inputPorts); - inputPorts.appendChild(createParamPort("id", "0", doc)); - inputPorts.appendChild(createParamPort("namespace", "0", doc)); - if(primitiveDataType){ - inputPorts.appendChild(createParamPort("value", "0", doc)); - } - - Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); - builderProcessor.appendChild(outputPorts); - outputPorts.appendChild(createParamPort("mobyData", "0", "0", doc)); - - builderProcessor.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - - Element activities = doc.createElementNS(T2FLOW_NS, "activities"); - builderProcessor.appendChild(activities); - Element activity = doc.createElementNS(T2FLOW_NS, "activity"); - activities.appendChild(activity); - Element raven = doc.createElementNS(T2FLOW_NS, "raven"); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "group", "net.sf.taverna.t2.activities")); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "artifact", "biomoby-activity")); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "version", "1.0")); - activity.appendChild(raven); - - activity.appendChild(createElWithText(doc, T2FLOW_NS, "class", - "net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity")); - - Element inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); - activity.appendChild(inputMap); - inputMap.appendChild(createMapFromTo("id", "id", doc)); - inputMap.appendChild(createMapFromTo("namespace", "namespace", doc)); - if(primitiveDataType){ - inputMap.appendChild(createMapFromTo("value", "value", doc)); - } - Element outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); - activity.appendChild(outputMap); - outputMap.appendChild(createMapFromTo("mobyData", "mobyData", doc)); - - Element configBean = doc.createElementNS(T2FLOW_NS, "configBean"); - configBean.setAttribute("encoding", "xstream"); - activity.appendChild(configBean); - Element BuildActivityConfigurationBean = - doc.createElementNS("", - "net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean"); - configBean.appendChild(BuildActivityConfigurationBean); - BuildActivityConfigurationBean.appendChild(createElWithText(doc, "", "mobyEndpoint", - getCentralEndpointFromMobyData(mobyData))); - BuildActivityConfigurationBean.appendChild(createElWithText(doc, "", "serviceName", - mobyData.getDataType().getName())); - BuildActivityConfigurationBean.appendChild(doc.createElementNS("", "authorityName")); - - activity.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - - builderProcessor.appendChild(getDispatchStack(doc)); - - Element iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); - builderProcessor.appendChild(iterationStrategyStack); - Element iteration = doc.createElementNS(T2FLOW_NS, "iteration"); - iterationStrategyStack.appendChild(iteration); - Element strategy = doc.createElementNS(T2FLOW_NS, "strategy"); - iteration.appendChild(strategy); - Element dot = doc.createElementNS(T2FLOW_NS, "dot"); - strategy.appendChild(dot); - - Element port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "id"); - port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "namespace"); - if(primitiveDataType){ - port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "value"); - return new String[]{builderProcName, "id", "namespace", "value", "mobyData"}; - } - else{ - return new String[]{builderProcName, "id", "namespace", "mobyData"}; - } - } - - private String[] addListFlattenBeanShell(Element processors, Document doc) + + private String[] addListFlattenBeanShell(Element processors, Document doc) throws Exception{ String beanShellProcName = createUniqueName("Create_Pass_Fail_List"); @@ -1434,13 +1489,52 @@ inputTypes.put("inputlist", "text/plain"); Map outputsMap = new LinkedHashMap(); outputsMap.put("outputlist", "1"); - + return addBeanShell(beanShellProcName, "dot", inputsMap, inputTypes, outputsMap, getListFlattenScript(), new String[]{}, processors, doc); } + + private String[] addFileSelectionBeanShell(Element processors, Document doc) + throws Exception{ + String beanShellProcName = createUniqueName("Select_Files"); + + // Now do all the param-specific stuff below (inserts into various parts of the elements defined above) + Map inputsMap = new LinkedHashMap(); + // linked because order is important to line up port connections + Map inputTypes = new LinkedHashMap(); + inputsMap.put("title", "0"); + inputTypes.put("title", "text/plain"); + Map outputsMap = new LinkedHashMap(); + outputsMap.put("selectedFiles", "1"); + + return addBeanShell(beanShellProcName, "cross", + inputsMap, inputTypes, outputsMap, + getFileSelectionScript(), new String[]{}, + processors, doc); + } + private String[] addBinaryFileReaderBeanShell(Element processors, Document doc) + throws Exception{ + String beanShellProcName = createUniqueName("Load_Binary_File"); + + // Now do all the param-specific stuff below (inserts into various parts of the elements defined above) + Map inputsMap = new LinkedHashMap(); + // linked because order is important to line up port connections + Map inputTypes = new LinkedHashMap(); + inputsMap.put("articleName", "0"); + inputTypes.put("articleName", "text/plain"); + inputsMap.put("absoluteFilePath", "0"); + inputTypes.put("absoluteFilePath", "text/plain"); + Map outputsMap = new LinkedHashMap(); + outputsMap.put("encodedString", "0"); + + return addBeanShell(beanShellProcName, "cross", + inputsMap, inputTypes, outputsMap, + getBinaryFileReaderScript(), new String[]{}, + processors, doc); + } private String[] addPassFilterBeanShell(Element processors, Document doc) throws Exception{ String beanShellProcName = createUniqueName("IfPassesContentFilter"); @@ -1667,7 +1761,7 @@ private Element createWorkflowInputLinkElement(String inputName, String processorName, String processorParamPortName, - MobyPrimaryData sampleData, Document doc){ + Document doc){ Element datalink = doc.createElementNS(T2FLOW_NS, "datalink"); Element sink = doc.createElementNS(T2FLOW_NS, "sink"); @@ -1770,6 +1864,25 @@ return preferredName; } + // same as next function, but takes service data type into account (e.g. if data is DNASequence, but + // equivalent service param is GenericSequence, use GenericSequence) + private String getPortName(MobyPrimaryData data, MobyService service, boolean asCollection){ + String dataName = data.getName(); + for(MobyPrimaryData param: service.getPrimaryInputs()){ + if(param.getName().equals(dataName)){ + if(!param.getDataType().getName().equals(data.getDataType().getName())){ + MobyPrimaryData superTypedData = ((data instanceof MobyPrimaryDataSet) ? (new MobyPrimaryDataSet(dataName)) : (new MobyPrimaryDataSimple(dataName))); + superTypedData.setDataType(param.getDataType()); + return getPortName(superTypedData, asCollection); + } + else{ + break; + } + } + } + return getPortName(data, asCollection); + } + // dataType(articleName) as required by the Taverna Moby plugin private String getPortName(MobyPrimaryData data, boolean asCollection){ if(data instanceof MobyPrimaryDataSet){ @@ -1786,22 +1899,20 @@ } // A useful human-legible name for a workflow input - private String getInputName(MobyPrimaryData data){ - String dataType = data.getDataType().getName(); - if(dataType.equals(MobyTags.MOBYOBJECT)){ - MobyNamespace[] namespaces = data.getNamespaces(); - if(namespaces.length == 0){ - return "FileOf"+dataType+"-"+data.getName()+"-IDs"; + private String getInputName(MobyDataType dataType, MobyNamespace ns){ + if(dataType.getName().equals(MobyTags.MOBYOBJECT)){ + if(ns == null){ + return "FileOfObjects"; //???? } else{ // Note: we could concatenate all allowed namespaces, but the service wouldn't // necessarily return the same results for all input namespaces, so we'll be // safe and stick to the primary one. - return "FileOf"+namespaces[0].getName()+"-"+data.getName()+"IDs"; + return "FileOf"+ns.getName()+"-IDs"; } } else{ - return dataType+"-"+data.getName(); + return "FileOf"+dataType.getName()+"-fields"; } } @@ -1993,6 +2104,28 @@ return listFlattenScript; } + private synchronized String getBinaryFileReaderScript() throws Exception{ + if(readBinaryFileScript == null){ + URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_READBINARYFILE_BEANSHELL); + if(scriptURL == null){ + throw new Exception("Cannot find resource " + T2FLOW_READBINARYFILE_BEANSHELL); + } + readBinaryFileScript = HTMLUtils.getURLContents(scriptURL); + } + return readBinaryFileScript; + } + + private synchronized String getFileSelectionScript() throws Exception{ + if(fileSelectionScript == null){ + URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_SELECTFILES_BEANSHELL); + if(scriptURL == null){ + throw new Exception("Cannot find resource " + T2FLOW_SELECTFILES_BEANSHELL); + } + fileSelectionScript = HTMLUtils.getURLContents(scriptURL); + } + return fileSelectionScript; + } + private synchronized String getPassFilterScript() throws Exception{ if(passFilterScript == null){ URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_PASSFILTER_BEANSHELL); From gordonp at dev.open-bio.org Thu Feb 3 16:58:48 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:58:48 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032158.p13LwmrX020906@dev.open-bio.org> gordonp Thu Feb 3 16:58:47 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv20870/src/main/ca/ucalgary/seahawk/util Modified Files: DataUtils.java Log Message: Trim element contents so user filters with leading and trailing regex anchors work nicely moby-live/Java/src/main/ca/ucalgary/seahawk/util DataUtils.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java 2010/05/04 16:14:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java 2011/02/03 21:58:47 1.9 @@ -947,14 +947,14 @@ Pattern.MULTILINE | Pattern.DOTALL | (filter.getCaseSensitivity() ? 0 : Pattern.CASE_INSENSITIVE)); for(int i = 0; i < currentSelectedData.getLength(); i++){ - Node node = currentSelectedData.item(i); + Node node = currentSelectedData.item(i); if(node instanceof Element){ String elementXPtr = getXPtr(node); if(matchingXPtrs.containsKey(elementXPtr) && matchingXPtrs.get(elementXPtr).booleanValue()){ continue; // already true, no } - else if(regex.matcher(((Element) node).getTextContent()).find()){ + else if(regex.matcher(((Element) node).getTextContent().trim()).find()){ matchingXPtrs.put(elementXPtr, Boolean.TRUE); //System.err.println("Adding " + elementXPtr + " as " + matchingXPtrs.get(elementXPtr)); } @@ -1027,7 +1027,7 @@ * Create a temp file that populates the MobyContentInstance from the sample data * for all missing fields in peerJobs. This is used to populate a bunch of jobs * at once, iterating over some list of values popped into the peerJobs payload. - * Used after service wrapping demo to call new service fopr all demo input peers. + * Used after service wrapping demo to call new service for all demo input peers. */ public static URL createServiceInputFileForPeers(MobyContentInstance peerJobs, MobyDataJob sampleJob) throws Exception{ for(MobyDataJob peerJob: peerJobs.values()){ From gordonp at dev.open-bio.org Thu Feb 3 17:00:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:00:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032200.p13M0ZWJ021334@dev.open-bio.org> gordonp Thu Feb 3 17:00:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv21298/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Added support for font resizing (accessibility), and disabling highlight-while-typing (can cause app to freeze on some machines) moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.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/util/SeahawkOptions.java 2007/12/06 18:47:58 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2011/02/03 22:00:35 1.6 @@ -19,6 +19,8 @@ public static final String REGISTRY_NAMESPACE_PROP = "registryNamespace"; public static final String CONVERTER_HOST_PROP = "documentConverterHost"; public static final String CONVERTER_PORT_PROP = "documentConverterPort"; + public static final String FONT_SIZE_PROP = "fontSize"; + public static final String FILTER_INTERACTIVE_PROP = "filterInteractive"; public static final String CUSTOM_REGISTRY_SYNONYM = "custom"; public static final String PROPS_FILE_NAME = "seahawkUserPrefs.xml"; @@ -30,10 +32,12 @@ private static Registry registry = null; private static File tmpDir = new File(System.getProperty("java.io.tmpdir")); private static boolean referrerPolicy = true; + private static boolean filterInteractive = true; private static double cacheExpiryInHours = 24.0; // Used OpenOffice to convert MS Office docs to RTF, currently a Solaris zone on moby.ucalgary.ca private static String documentConverterHost = "136.159.169.81"; private static int documentConverterPort = 8100; + private static String fontSize = "100%"; /** * Sets the options based on a shortcircuiting set of @@ -123,6 +127,17 @@ "(will send referrer service header to services)."); } + boolString = properties.getProperty(FILTER_INTERACTIVE_PROP); + if(boolString != null && boolString.length() > 0){ + filterInteractive = Boolean.parseBoolean(boolString); + } + else{ + System.err.println("No filter interactivity policy (" +FILTER_INTERACTIVE_PROP+ + ") provided in the Seahawk config file (" + + u + "), using default of \"true\" " + + "(matches highlighted while the filter criteria are being typed)."); + } + String floatString = properties.getProperty(CACHE_POLICY_PROP); if(floatString != null && floatString.length() > 0){ double hours = cacheExpiryInHours; @@ -138,6 +153,25 @@ setCacheExpiry(hours); } + String fontString = properties.getProperty(FONT_SIZE_PROP); + if(fontString != null && fontString.length() > 0){ + String size = fontSize; + boolean relative = fontString.endsWith("%"); + if(relative){ + fontString = fontString.substring(0, fontString.length()-1); // lop off '%' sign + } + try{ + size = ""+Double.parseDouble(fontString); + } catch(NumberFormatException nfe){ + nfe.printStackTrace(); + System.err.println("Ignoring the font size policy (" +FONT_SIZE_PROP+ + ") provided in the Seahawk config file (" + + u + "), it is not in valid floating-point number format or a relative(trailing %) one: " + + fontString); + } + setFontSize(relative ? size+"%" : ""+size); + } + String dirPath = properties.getProperty(TEMP_DIR_PROP); if(dirPath != null && dirPath.length() > 0){ try{ @@ -240,6 +274,8 @@ properties.setProperty(TEMP_DIR_PROP, tmpDir.getCanonicalFile().getPath()); properties.setProperty(CONVERTER_HOST_PROP, documentConverterHost); properties.setProperty(CONVERTER_PORT_PROP, ""+documentConverterPort); + properties.setProperty(FONT_SIZE_PROP, fontSize); + properties.setProperty(FILTER_INTERACTIVE_PROP, ""+filterInteractive); if(registry != null){ properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); @@ -395,16 +431,30 @@ } /** - * For more details on how to run your own file converter, see http://www.artofsolving.com/node/10 + * @return the relative size of the display font compared to the system default e.g. 120% + */ + public static String getFontSize(){ + return fontSize; + } + /** 100% = 1.0 */ + public static double getFontSizeAsDouble(){ + return Double.parseDouble(fontSize.substring(0, fontSize.length()-1))/100.0; // lop off % sign, convert to ratio + } + + /** + * Sets the display font size for documents. * - * @param hostname machine on which an OpenOffice file converter is running + * @param size how big the display font should be relative to the system default */ - public static void setDocConverterHost(String hostname){ - if(hostname == null || - hostname.length() == 0){ - hostname = null; - } - documentConverterHost = hostname; + public static void setFontSize(String size){ + fontSize = size; + } + + /** + * @param port positive number representing where the OpenOffice file converter is listening + */ + public static void setDocConverterHost(String host){ + documentConverterHost = host; } /** @@ -413,4 +463,14 @@ public static String getDocConverterHost(){ return documentConverterHost; } + + /** + * @param b whether the document should be updated as the filter widget is being typed into (can cause freezing problems on some systems) + */ + public static void setFilterInteractive(boolean b){ + filterInteractive = b; + } + public static boolean isFilterInteractive(){ + return filterInteractive; + } } From gordonp at dev.open-bio.org Thu Feb 3 17:03:23 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:03:23 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032203.p13M3Nqh021468@dev.open-bio.org> gordonp Thu Feb 3 17:03:23 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util In directory dev.open-bio.org:/tmp/cvs-serv21432/src/main/ca/ucalgary/util Modified Files: SingletonApplication.java Log Message: Added support for jar-based app launching moby-live/Java/src/main/ca/ucalgary/util SingletonApplication.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java 2010/05/19 17:38:56 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java 2011/02/03 22:03:23 1.2 @@ -12,26 +12,48 @@ * Utility to launch a Java application if not running, or pass a new file for * opening if the app is already open (per user). To use this class, call it as your * main class, and pass the real main class name as the first argument. Subsequent - * arguments are passed to the real main class's main(argv) method. + * arguments are passed to the real main class's main(argv) method. If you are + * launching the app using the java -jar myapp.jar technique, you should define + * this class as thr Main-Class in META-INF/MANIFEST.MF, and specify your app's main class + * in the file META-INF/services/ca.ucalgary.util.SingletonApplication. + * + * The modifications required to the atrget application are as follows: + *
  1. Call the static method SingletonApplication.setArgumentListener(ArgumentListener) + * in your app's static void main() method.
  2. + *
  3. Have whatever class that opens files/URLs/etc in your app implement the method + * processArgument(String), and hence the interface ArgumentListener.
+ * + * @author Paul Gordon (gordonp at ucagary.ca) */ public class SingletonApplication{ private static ListenerThread listenerThread; public static void main(String[] args){ - if(args.length == 0 || args[0].matches("-{1,2}(h(elp)?)?")){ + if(args.length > 0 && args[0].matches("-{1,2}(h(elp)?)?")){ System.err.println("Usage: java "+SingletonApplication.class.getName()+ "
[file name or url to open #1] ..."); System.exit(1); } // Get the main class of the target program - Class mainClass = null; - try{ - mainClass = Class.forName(args[0]); - } catch(Exception e){ - System.err.println("Could not find main class "+args[0]); - System.exit(2); - } + Class mainClass = findMainClass(args.length == 0); + if(mainClass == null && args.length == 0){ + System.err.println("Usage: java "+SingletonApplication.class.getName()+ + "
[file name or url to open #1] ..."); + System.exit(15); + } + if(mainClass == null){ + try{ + mainClass = Class.forName(args[0]); + } catch(Exception e){ + System.err.println("Could not find main class "+args[0]); + System.exit(2); + } + // Pass along all args except the first, the main class name + String programArgs[] = new String[args.length-1]; + System.arraycopy(args, 1, programArgs, 0, programArgs.length); + args = programArgs; + } Class mainArgs[] = {String[].class}; Method main = null; try{ @@ -65,19 +87,6 @@ System.exit(10); } - // Pass along all args except the first, the main class name - String programArgs[] = new String[args.length-1]; - System.arraycopy(args, 1, programArgs, 0, programArgs.length); - -// FileOutputStream fos = null; -// try{ -// fos = new FileOutputStream(lockFile); -// } catch(Exception e){ -// System.err.println("Failed to get output stream for file " + lockFile.getAbsolutePath()+": "+e.getMessage()); -// e.printStackTrace(); -// System.exit(12); -// } - FileLock lock = null; try{ lock = lockFile.getChannel().tryLock(); @@ -106,7 +115,7 @@ System.exit(4); } try{ - callOpen(port, programArgs); + callOpen(port, args); } catch(Exception e){ System.err.println("While calling open on existing "+main.getName()+" process: " + e.getMessage()); e.printStackTrace(); @@ -127,7 +136,7 @@ // first instance, or the app doesn't implement the right interface (why are you using this, then?) (new File(lockFileAbsolutePath)).deleteOnExit(); try{ - callMain(main, programArgs, lock); + callMain(main, args, lock); } catch(Exception e){ System.err.println("While calling main method of "+main.getName()+": " + e.getMessage()); e.printStackTrace(); @@ -135,6 +144,49 @@ } } + private static Class findMainClass(boolean require){ + String className = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + String resourceName = "META-INF/services/"+SingletonApplication.class.getName(); + URL resURL = classLoader.getResource(resourceName); + if(resURL == null){ + if(require){ + System.err.println("NNo command line arg for the main class was provided, and the "+ + "resource " + resourceName + " could not be found"); + System.exit(16); + } + else{ + return null; + } + } + try{ + LineNumberReader reader = new LineNumberReader(new InputStreamReader(resURL.openStream())); + for(String line = reader.readLine(); line != null; line = reader.readLine()){ + if(!line.trim().startsWith("#")){ + className = line.trim(); + break; + } + } + } catch(Exception e){ + System.err.println("Error reading " + resURL+": "+e.getMessage()); + e.printStackTrace(); + System.exit(14); + } + if(className == null){ + System.err.println("Could not find main class name in " + resURL); + System.exit(15); + } + + try{ + return Class.forName(className); + } catch(Exception e){ + System.err.println("Could not load class " + className + ": " + e.getMessage()); + e.printStackTrace(); + System.exit(15); + } + return null; //should never get here + } + // Start the target program, passing the command-line arguments private static void callMain(Method main, String[] programArgs, FileLock lock) throws Exception{ // Write to the lock file the port on which we'll listen for "file open" requests From gordonp at dev.open-bio.org Thu Feb 3 17:05:37 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:05:37 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032205.p13M5bPb021662@dev.open-bio.org> gordonp Thu Feb 3 17:05:37 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv21626/src/main/org/biomoby/shared/data Modified Files: MobyDataFloat.java Log Message: Unparseable floats are not set to zero instead of causing exception moby-live/Java/src/main/org/biomoby/shared/data MobyDataFloat.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2008/01/07 22:11:36 1.11 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2011/02/03 22:05:37 1.12 @@ -2,6 +2,7 @@ package org.biomoby.shared.data; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.logging.*; import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; @@ -21,6 +22,7 @@ public class MobyDataFloat extends MobyDataObject{ private BigDecimal value; + private static Logger logger = Logger.getLogger(MobyDataFloat.class.getName()); /** * Construct the object using a DOM fragment. @@ -102,7 +104,12 @@ public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName, registry); setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); - value = new BigDecimal(stringNumber.trim()); + try{ + value = new BigDecimal(stringNumber.trim()); + } catch(Exception e){ + logger.log(Level.WARNING, "Could not parse '"+stringNumber+"' as a decimal number, using zero instead"); + value = BigDecimal.ZERO; + } } public MobyDataFloat(String stringNumber){ From gordonp at dev.open-bio.org Fri Feb 4 13:36:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 4 Feb 2011 13:36:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102041836.p14IaZ1S011991@dev.open-bio.org> gordonp Fri Feb 4 13:36:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv11955/src/main/ca/ucalgary/seahawk/util Modified Files: CloseTabIcon.java Added Files: CloseTabListener.java Log Message: Implemented 'Undo close tab' for Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabListener.java,NONE,1.1 CloseTabIcon.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/06/16 00:27:44 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2011/02/04 18:36:35 1.3 @@ -9,6 +9,7 @@ import java.awt.Graphics; import java.awt.Component; import java.net.URL; +import java.util.Vector; public class CloseTabIcon extends CombinedIcon{ public static final String CLOSE_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/tabclose.gif"; @@ -17,6 +18,7 @@ private JTabbedPane tabbedPane = null; private Rectangle closeIconArea; + private Vector listeners; public CloseTabIcon() throws Exception{ this(new NullIcon()); @@ -34,6 +36,14 @@ super(getIcon(), otherIcon, spacerWidth, orient); } + public CloseTabIcon addCloseTabListener(CloseTabListener listener){ + if(listeners == null){ + listeners = new Vector(); + } + listeners.add(listener); + return this; + } + public Rectangle getCloseIconArea(){ return closeIconArea; } @@ -102,9 +112,18 @@ // Don't respond unless the close tab icon is actually showing return; } + Component tab = tabbedPane.getComponentAt(tabIndex); + if(listeners != null){ + for(CloseTabListener listener: listeners){ + listener.tabClosing(tab); + } + } + tabbedPane.remove(tabIndex); e.consume(); // so other tabs aren't closed by mistake tabbedPane.removeMouseListener(this); + tabbedPane = null; // so if the tab is added back at some point, the listen is readded in paintIcon() + } } } From gordonp at dev.open-bio.org Fri Feb 4 13:36:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 4 Feb 2011 13:36:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102041836.p14IaZIT012013@dev.open-bio.org> gordonp Fri Feb 4 13:36:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11955/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java MobyContentGUI.java Log Message: Implemented 'Undo close tab' for Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.34,1.35 MobyContentGUI.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/03 21:50:50 1.34 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/04 18:36:35 1.35 @@ -243,12 +243,12 @@ tabbedPane.getTabCount() > 1){ try{ if(currentIcon == null){ - tabbedPane.setIconAt(tabIndex, new CloseTabIcon()); + tabbedPane.setIconAt(tabIndex, (new CloseTabIcon()).addCloseTabListener(getContentGUI())); return; } // If there's a real (non-close-tab) single icon, add the close tab icon if(!(currentIcon instanceof CloseTabIcon)){ - try{tabbedPane.setIconAt(tabIndex, new CloseTabIcon(currentIcon, TAB_ICON_SPACER));} + try{tabbedPane.setIconAt(tabIndex, (new CloseTabIcon(currentIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace();} tabbedPane.setDisabledIconAt(tabIndex, currentIcon); } @@ -257,7 +257,7 @@ e.printStackTrace(); } - } else{ + } else{ //Don't display X widget (closer) unless it's the active tab if(currentIcon != null && currentIcon instanceof CloseTabIcon){ tabbedPane.setIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); tabbedPane.setDisabledIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); @@ -982,7 +982,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(failedIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(failedIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, failedIcon);} } @@ -1005,7 +1005,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1 && tabbedPane.getTabCount() > 1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(loadedIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(loadedIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, loadedIcon);} } @@ -1476,7 +1476,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, hourglassIcon);} } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/03 21:47:57 1.24 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/04 18:36:35 1.25 @@ -37,7 +37,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener, CloseTabListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -63,9 +63,11 @@ public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl"; public final static int MAX_TAB_NAME_LENGTH = 25; public final static String CLIPBOARD_TAB_TOOLTIP = "Right-click for clipboard options"; - public final static String TAB_TOOLTIP = "Right-click for tab options, or Ctrl-T for new tab"; + public final static String TAB_TOOLTIP = "Right-click tabs for options, or Ctrl-T for new tab"; public final static String CLOSE_TAB_OPTION = "Close This Tab"; public final static String CLOSE_OTHERS_OPTION = "Close Other Tabs"; + public final static String UNDO_CLOSE_TAB_OPTION = "Undo Close Tab"; + public final static String UNDO_CLOSE_TABS_OPTION = "Undo Close Tabs"; public final static String FILE_OPEN_OPTION = "Open File"; public final static String WEB_OPEN_OPTION = "Open Web Page"; @@ -96,6 +98,9 @@ private MobyContentHelpPane helpPane; private DataFlowRecorder dataRecorder; // used for workflow export, etc. private SeahawkOptionsGUI settingsGUI; + private java.util.List closedTabs; + private java.util.List closedTabTitles; + private java.util.List closedTabIcons; private boolean setup; private Map request2tab; @@ -231,7 +236,7 @@ // See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour) tabbedPane.setUI(new OptionsTabbedPaneUI(this)); tabbedPane.setSize(getContentSize()); - tabbedPane.setToolTipText("Hit to display a new tab"); + tabbedPane.setToolTipText(TAB_TOOLTIP); tabbedPane.addKeyListener(this); try{ @@ -249,6 +254,10 @@ tabbedPane.add(clipboard); clipboard.init(); + closedTabs = new ArrayList(); + closedTabTitles = new ArrayList(); + closedTabIcons = new ArrayList(); + settingsGUI = new SeahawkOptionsGUI(this, this); // params are frame owner, font change listener } @@ -1015,9 +1024,33 @@ // Don't close clipboard, if somehow we were asked... } else{ + closedTabs.add(tabbedPane.getComponentAt(activeTabIndex)); + closedTabTitles.add(tabbedPane.getTitleAt(activeTabIndex)); + closedTabIcons.add(tabbedPane.getIconAt(activeTabIndex)); tabbedPane.remove(activeTabIndex); } } + else if(UNDO_CLOSE_TAB_OPTION.equals(cmd)){ + Object lastClose = closedTabs.get(closedTabs.size()-1); + if(lastClose instanceof java.util.List){ // Closed more than one tab last time + java.util.List tabsList = (java.util.List) lastClose; + java.util.List tabTitlesList = (java.util.List) closedTabTitles.get(closedTabTitles.size()-1); + java.util.List tabIconsList = (java.util.List) closedTabIcons.get(closedTabIcons.size()-1); + for(int i = 0; i < tabsList.size(); i++){ + tabbedPane.addTab((String) tabTitlesList.get(i), + (Icon) tabIconsList.get(i), + (Component) tabsList.get(i)); + } + } + else{ // Single tab being unclosed + tabbedPane.addTab((String) closedTabTitles.get(closedTabTitles.size()-1), + (Icon) closedTabIcons.get(closedTabIcons.size()-1), + (Component) lastClose); + } + closedTabs.remove(closedTabs.size()-1); // no longer in close history + closedTabTitles.remove(closedTabTitles.size()-1); // no longer in close history + closedTabIcons.remove(closedTabIcons.size()-1); // no longer in close history + } else if(MobyContentClipboard.CLEAR_CLIPBOARD_OPTION.equals(cmd)){ clipboard.clearData(); } @@ -1027,13 +1060,32 @@ return; } Component keeper = tabbedPane.getComponentAt(activeTabIndex); + ArrayList otherTabs = new ArrayList(); + ArrayList otherTabTitles = new ArrayList(); + ArrayList otherTabIcons = new ArrayList(); for(int i = 0; i < tabbedPane.getTabCount(); i++){ Component comp = tabbedPane.getComponentAt(i); - if(comp != keeper && comp != clipboard){ + if(comp != keeper && comp != clipboard){ + // This is slightly lazy, we could actually destroy the component + // and save the tab's history rather than put the component in the history. + // If memory becomes an issue, this would be a place to start saving... + otherTabs.add(comp); + otherTabTitles.add(tabbedPane.getTitleAt(i)); + otherTabIcons.add(tabbedPane.getIconAt(i)); tabbedPane.remove(comp); i--; } } + if(otherTabs.size() == 1){ // Was it just one tab? + closedTabs.add(otherTabs.get(0)); + closedTabTitles.add(otherTabTitles.get(0)); + closedTabIcons.add(otherTabIcons.get(0)); + } + else{ + closedTabs.add(otherTabs); + closedTabTitles.add(otherTabTitles); + closedTabIcons.add(otherTabIcons); + } } else{ logger.warn(getClass().getName() + " ignoring unrecognized action command: " + cmd); @@ -1139,8 +1191,8 @@ tabOptions.add(item); } else if(tabbedPane.getTabCount() > 1){ - item = new JMenuItem(MobyContentGUI.CLOSE_TAB_OPTION); - item.setActionCommand(MobyContentGUI.CLOSE_TAB_OPTION); + item = new JMenuItem(CLOSE_TAB_OPTION); + item.setActionCommand(CLOSE_TAB_OPTION); item.addActionListener(gui); tabOptions.add(item); } @@ -1148,13 +1200,29 @@ if(tabbedPane.getComponentAt(index) == clipboard && tabbedPane.getTabCount() > 1 || tabbedPane.getTabCount() > 2 || tabbedPane.indexOfComponent(clipboard) == -1 && tabbedPane.getTabCount() >= 2){ - item = new JMenuItem(MobyContentGUI.CLOSE_OTHERS_OPTION); - item.setActionCommand(MobyContentGUI.CLOSE_OTHERS_OPTION); + item = new JMenuItem(CLOSE_OTHERS_OPTION); + item.setActionCommand(CLOSE_OTHERS_OPTION); item.addActionListener(gui); tabOptions.add(item); } - - tabOptions.show(gui, e.getX(), e.getY()); + item = new JMenuItem(UNDO_CLOSE_TAB_OPTION); + item.setActionCommand(UNDO_CLOSE_TAB_OPTION); + if(closedTabs.isEmpty()){ + item.setEnabled(false); // show just so they know this is an option later... + } + else{ + item.addActionListener(gui); + // more than one tab closed last time + if(closedTabs.get(closedTabs.size()-1) instanceof java.util.List){ + System.err.println("Set unclose tabS"); + item.setText(UNDO_CLOSE_TABS_OPTION); + } + // else nothing more needs to be done, the default menu + // label for the task to reopen just one tab + } + tabOptions.add(item); + + tabOptions.show(gui, e.getX()+7, e.getY()+12); } else{ // Otherwise do whatever this handler normally does @@ -1342,4 +1410,11 @@ ((MobyContentPane) tabbedPane.getComponentAt(i)).setFontSize(fontSize); } } + + public void tabClosing(Component closingTab){ + closedTabs.add(closingTab); + int closingTabIndex = tabbedPane.indexOfComponent(closingTab); + closedTabTitles.add(tabbedPane.getTitleAt(closingTabIndex)); + closedTabIcons.add(tabbedPane.getIconAt(closingTabIndex)); + } } From drepchevski at dev.open-bio.org Thu Feb 24 08:35:40 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Thu, 24 Feb 2011 08:35:40 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102241335.p1ODZe05000346@dev.open-bio.org> drepchevski Thu Feb 24 08:35:40 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache In directory dev.open-bio.org:/tmp/cvs-serv310 Modified Files: CacheConfig.java Log Message: Added a posibility to save a cache without XML Document event generation. moby-live/Java/src/main/org/inb/biomoby/central/cache CacheConfig.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache/CacheConfig.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/inb/biomoby/central/cache/CacheConfig.java 2009/12/16 15:24:36 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache/CacheConfig.java 2011/02/24 13:35:39 1.2 @@ -151,15 +151,21 @@ } } + public void save(List entities, Writer writer) throws Exception + { + save(entities, writer, true); + } + /** * Generic method to save BioMoby entities to the provided writer * * @param - the entity type to save * @param entities - the list of entities to be saved * @param writer - the writer where entities are saved + * @param isFragment - whether or not document level events will be generated * @throws Exception */ - public void save(List entities, Writer writer) throws Exception + public void save(List entities, Writer writer, boolean isFragment) throws Exception { CacheListWrapper wrapper = new CacheListWrapper(entities); @@ -171,6 +177,7 @@ Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.valueOf(isFragment)); BufferedWriter out = new BufferedWriter(writer); From drepchevski at dev.open-bio.org Wed Feb 2 13:23:41 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Wed, 2 Feb 2011 08:23:41 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102021323.p12DNfTJ016946@dev.open-bio.org> drepchevski Wed Feb 2 08:23:41 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry In directory dev.open-bio.org:/tmp/cvs-serv16893/registry Modified Files: RegisterServiceOperation.java Log Message: registerService() was broken in MobyCentral library moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry RegisterServiceOperation.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.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/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.java 2009/09/09 19:47:48 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/registry/RegisterServiceOperation.java 2011/02/02 13:23:41 1.2 @@ -194,27 +194,27 @@ @XmlTransient protected static class Data { - private List collection; - private List simple; + private List collections; + private List simples; @XmlElement(name = "Collection") - public List getCollection() + public List getCollections() { - if (collection == null) + if (collections == null) { - collection = new ArrayList(); + collections = new ArrayList(); } - return this.collection; + return this.collections; } @XmlElement(name = "Simple") - public List getSimple() + public List getSimples() { - if (simple == null) + if (simples == null) { - simple = new ArrayList(); + simples = new ArrayList(); } - return this.simple; + return this.simples; } } @@ -269,7 +269,7 @@ public static class Simple { private String objectType; - private List namespace; + private List namespaces; private String articleName; @XmlElement(required = true) @@ -284,14 +284,14 @@ } @XmlElement(name = "Namespace") - public List getNamespace() + public List getNamespaces() { - if (namespace == null) + if (namespaces == null) { - namespace = new ArrayList(); + namespaces = new ArrayList(); } - return this.namespace; + return namespaces; } @XmlAttribute(required = true) From drepchevski at dev.open-bio.org Wed Feb 2 13:23:41 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Wed, 2 Feb 2011 08:23:41 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102021323.p12DNfP2016928@dev.open-bio.org> drepchevski Wed Feb 2 08:23:41 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb In directory dev.open-bio.org:/tmp/cvs-serv16893 Modified Files: JAXBMobyCentralImpl.java Log Message: registerService() was broken in MobyCentral library moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb JAXBMobyCentralImpl.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.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/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.java 2009/09/09 19:47:48 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/factory/jaxb/JAXBMobyCentralImpl.java 2011/02/02 13:23:40 1.2 @@ -71,7 +71,168 @@ request.setAuthURI(service.getAuthURI()); request.setContactEmail(service.getContactEmail()); request.setDescription(service.getDescription()); - + + request.setURL(service.getUrl()); + request.setCategory(service.getCategory().name()); + + request.setAuthoritativeService(service.isAuthoritative() ? 1 : 0); + + ServiceType serviceType = service.getServiceType(); + request.setServiceType(serviceType == null ? "" : serviceType.getName()); + + Input input = service.getInput(); + + if (input != null) + { + RegisterServiceOperation.Input in = new RegisterServiceOperation.Input(); + + for (Simple simple : input.getSimples()) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + in.getSimples().add(sm); + } + + for (Collection collection : input.getCollections()) + { + RegisterServiceOperation.Collection cl = new RegisterServiceOperation.Collection(); + + cl.setArticleName(collection.getArticleName()); + + Simple simple = collection.getSimple(); + + if (simple != null) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + cl.setSimple(sm); + } + + in.getCollections().add(cl); + } + + request.setInput(in); + } + + Output output = service.getOutput(); + + if (output != null) + { + RegisterServiceOperation.Output out = new RegisterServiceOperation.Output(); + + for (Simple simple : output.getSimples()) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + out.getSimples().add(sm); + } + + for (Collection collection : output.getCollections()) + { + RegisterServiceOperation.Collection cl = new RegisterServiceOperation.Collection(); + + cl.setArticleName(collection.getArticleName()); + + Simple simple = collection.getSimple(); + + if (simple != null) + { + RegisterServiceOperation.Simple sm = new RegisterServiceOperation.Simple(); + sm.setArticleName(simple.getArticleName()); + + ObjectType objectType = simple.getObjectType(); + + if (objectType != null) + { + sm.setObjectType(objectType.getName()); + } + + for (Namespace namespace : simple.getNamespaces()) + { + sm.getNamespaces().add(namespace.getName()); + } + + cl.setSimple(sm); + } + + out.getCollections().add(cl); + } + + request.setOutput(out); + } + + List parameters = service.getSecondaryArticles(); + + if (!parameters.isEmpty()) + { + RegisterServiceOperation.SecondaryArticles sa = new RegisterServiceOperation.SecondaryArticles(); + + for (Parameter parameter :service.getSecondaryArticles()) + { + RegisterServiceOperation.Parameter p = new RegisterServiceOperation.Parameter(); + + p.setDatatype(parameter.getDatatype().name()); + p.setArticleName(parameter.getArticleName()); + p.setDefault(parameter.getDefault()); + p.setDescription(parameter.getDescription()); + p.setMin(parameter.getMin()); + p.setMax(parameter.getMax()); + + List enums = parameter.getEnum(); + + if (!enums.isEmpty()) + { + for (String _enum : enums) + { + p.getEnum().add(_enum); + } + } + + sa.getParameter().add(p); + } + + request.setSecondaryArticles(sa); + } + MobyRegistration response = endpoint.call(request); Registration registration = new Registration(); From drepchevski at dev.open-bio.org Thu Feb 3 17:34:01 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Thu, 3 Feb 2011 12:34:01 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102031734.p13HY153015378@dev.open-bio.org> drepchevski Thu Feb 3 12:34:00 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv15343 Modified Files: MobyDispatch.java Log Message: fixed argument parsing when it is specified as soap type instead of schema (string/base64Binary) moby-live/Java/src/main/org/inb/biomoby/client MobyDispatch.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client/MobyDispatch.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/inb/biomoby/client/MobyDispatch.java 2010/08/31 16:15:44 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/client/MobyDispatch.java 2011/02/03 17:34:00 1.3 @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; +import javax.xml.XMLConstants; import org.inb.biomoby.MobyMessageContext; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; @@ -61,6 +62,7 @@ import org.inb.wsrf.rp2.QueryResourceProperties; import org.inb.wsrf.rp2.QueryResourcePropertiesResponse; import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** @@ -287,6 +289,37 @@ Node method = body.getFirstChild(); // check mobyService.getName() + "Response"? Node argument = method.getFirstChild(); + // fixing method argument type {http://schemas.xmlsoap.org/soap/encoding/}string => {http://www.w3.org/2001/XMLSchema}string + // Actually JAXB shouldn't support soap types in a first place... + + NamedNodeMap attributes = argument.getAttributes(); + if (attributes != null) + { + Node attribute = attributes.getNamedItemNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "type"); + + if (attribute != null) + { + String soapencPrefix = argument.lookupPrefix(SOAPConstants.URI_NS_SOAP_ENCODING); + + if (soapencPrefix != null) + { + String type = attribute.getNodeValue(); + + if (type.startsWith(soapencPrefix)) + { + String xsdPrefix = argument.lookupPrefix(XMLConstants.W3C_XML_SCHEMA_NS_URI); + + if (xsdPrefix != null) + { + type = xsdPrefix + type.substring(soapencPrefix.length()); + + attribute.setNodeValue(type); + } + } + } + } + } + Unmarshaller u = MobyMessageContext.getContext().createUnmarshaller(); JAXBElement jel = u.unmarshal(argument, byte[].class); From gordonp at dev.open-bio.org Thu Feb 3 21:38:27 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:38:27 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032138.p13LcRoM019912@dev.open-bio.org> gordonp Thu Feb 3 16:38:27 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv19880/src/main/ca/ucalgary/seahawk/gui Added Files: FontSizeChangeListener.java Log Message: Added capability to change document font size, for accessibility moby-live/Java/src/main/ca/ucalgary/seahawk/gui FontSizeChangeListener.java,NONE,1.1 From gordonp at dev.open-bio.org Thu Feb 3 21:39:18 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:39:18 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032139.p13LdIex019952@dev.open-bio.org> gordonp Thu Feb 3 16:39:18 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv19920/src/main/ca/ucalgary/seahawk/resources Added Files: SelectFilesBeanShell BinaryFileLoaderBeanShell Log Message: Taverna helper processors to facilitate use of binary input into a Moby workflow moby-live/Java/src/main/ca/ucalgary/seahawk/resources SelectFilesBeanShell,NONE,1.1 BinaryFileLoaderBeanShell,NONE,1.1 From gordonp at dev.open-bio.org Thu Feb 3 21:40:36 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:40:36 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032140.p13Leaji020018@dev.open-bio.org> gordonp Thu Feb 3 16:40:36 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv19982/src/main/ca/ucalgary/seahawk/gui Modified Files: DataImportChoiceDialog.java Log Message: Fixed javadoc and enabled multi-selection (import more than one item to the clipboard at a time) moby-live/Java/src/main/ca/ucalgary/seahawk/gui DataImportChoiceDialog.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java 2010/04/11 02:25:03 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/DataImportChoiceDialog.java 2011/02/03 21:40:36 1.2 @@ -1,11 +1,8 @@ package ca.ucalgary.seahawk.gui; /** - * Generates a preview of a Taverna2 workflow and shows it in a dialog where - * metadata such as title, author, and description can be entered. - * - * Renders the workflow using a remote CGI and asks the user if they want to - * proceed with the export of the workflow. + * Generates a dialog for the user to select what Moby object(s) should be + * imported from the legacy data being pasted into Seahawk. */ import java.awt.*; @@ -42,6 +39,7 @@ // Default select items inheriting from the preferred data type, or choiceList = new JList(this.dataChoices); + choiceList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); Vector initialSelectionIndices = new Vector(); if(preferredDataType != null && !preferredDataType.getName().equals(MobyTags.MOBYOBJECT)){ for(int i = 0; i < dataChoices.length; i++){ From gordonp at dev.open-bio.org Thu Feb 3 21:42:11 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:42:11 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032142.p13LgAbS020084@dev.open-bio.org> gordonp Thu Feb 3 16:42:10 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20048/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Added ability to export text selections from Seahawk to the clipboard moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.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/gui/FileAndTextTransferHandler.java 2010/05/13 16:03:59 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2011/02/03 21:42:10 1.12 @@ -246,7 +246,14 @@ protected Transferable createTransferable(JComponent c) { if(c instanceof MobyContentPane){ - return new SeahawkTransferable((MobyContentPane) c); + // Can export Moby data (via hyperlink drag) + if(((MobyContentPane) c).isDraggingHyperlink()){ + return new SeahawkTransferable((MobyContentPane) c); + } + // or text selection as string + else{ + return new StringSelection(((MobyContentPane) c).getSelectedText()); + } } else{ return null; From gordonp at dev.open-bio.org Thu Feb 3 21:45:38 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:45:38 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032145.p13LjcT4020152@dev.open-bio.org> gordonp Thu Feb 3 16:45:38 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20116/src/main/ca/ucalgary/seahawk/gui Modified Files: FilterSearchWidget.java Log Message: Several fixes including ability to not have highlight-as-you-type (can cause freezing), suspending matching when regex has trailing pipe, and search input field that responds to user preference for font size (accessibility) moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.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/FilterSearchWidget.java 2010/06/15 22:20:51 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FilterSearchWidget.java 2011/02/03 21:45:38 1.8 @@ -4,6 +4,8 @@ import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; +import java.awt.geom.AffineTransform; import java.awt.event.*; import java.net.URL; import java.util.concurrent.*; @@ -15,12 +17,13 @@ * Displays an editable SearchFilter within a MobyContentPane. */ -public class FilterSearchWidget extends JPanel implements ActionListener, DocumentListener{ +public class FilterSearchWidget extends JPanel implements ActionListener, DocumentListener, FontSizeChangeListener{ private FilterSearch currentFilterSearch; private JLabel closeIcon; private JToggleButton caseButton; private JButton inverseButton; // decides whether filter is "if" or "unless" + private JButton applyButton; // used when filter is in "non-interactive" mode private JTextField searchField; private JComboBox docPartOptions; private MobyContentPane contentPane; @@ -28,6 +31,7 @@ public static final String CASE_SENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_sensitive.png"; public static final String CASE_INSENSITIVE_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/case_insensitive.png"; + private static final String APPLY_TEXT = "Apply Filter"; private static final String IF_TEXT = "if"; private static final String UNLESS_TEXT = "unless"; private static final String CASE_INSENSITIVE_MSG = "The filter is case insensitive,
click to make case sensitive"; @@ -80,20 +84,41 @@ add(new JLabel("Show data ")); add(inverseButton); add(Box.createRigidArea(new Dimension(5,0))); + searchField = new JTextField(25); + setSearchFieldFontSize(SeahawkOptions.getFontSizeAsDouble()); searchField.setToolTipText("A literal string, or a regular expression"); searchField.getDocument().addDocumentListener(this); add(searchField); + add(Box.createRigidArea(new Dimension(5,0))); add(new JLabel("in")); add(Box.createRigidArea(new Dimension(5,0))); docPartOptions = new JComboBox(); docPartOptions.addActionListener(this); add(docPartOptions); + add(Box.createRigidArea(new Dimension(5,0))); + + if(!SeahawkOptions.isFilterInteractive()){ + // Normally we update any time the user types a letter. + // On some systems this freezes the system randomly, so there is the option to + // type, then press a button to apply the filter... + applyButton = new JButton(APPLY_TEXT); + applyButton.setEnabled(true); + applyButton.addActionListener(this); + add(applyButton); + } add(Box.createHorizontalGlue()); setFilter(null); } + private void setSearchFieldFontSize(double scale){ // Proportion of font compared to default + AffineTransform scaler = new AffineTransform(); + scaler.setToScale(scale, scale); + Font preferredFont = (new JTextField(1)).getFont().deriveFont(scaler); + searchField.setFont(preferredFont); + } + /** * The filter to display as editable right now. */ @@ -104,6 +129,7 @@ inverseButton.setEnabled(false); searchField.setEnabled(false); docPartOptions.setEnabled(false); + if(applyButton != null){applyButton.setEnabled(false);} return; } @@ -119,6 +145,9 @@ docPartOptions.setEnabled(true); docPartOptions.setModel(new DefaultComboBoxModel(fs.getXPathOptions())); docPartOptions.setSelectedItem(fs.getSelectedXPath()); + + if(applyButton != null){applyButton.setEnabled(true);} + currentFilterSearch = fs; // done in this order so no feedback as DocumentEvents while setting fields programmatically } @@ -153,6 +182,14 @@ contentPane.applyFilter(true); return; } + else if(e.getSource() == applyButton){ + StringBuffer sb = currentFilterSearch.getFilterRegex(); + synchronized(searchField){ + sb.replace(0, sb.length(), searchField.getText()); + } + applyFilterWhenSuitable(); + return; + } else if(currentFilterSearch == null || e.getSource() != docPartOptions){ return; } @@ -164,7 +201,7 @@ * Called when the regex has been changed by the user */ public void changedUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -175,7 +212,7 @@ } public void insertUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -186,7 +223,7 @@ } public void removeUpdate(DocumentEvent e){ - if(currentFilterSearch == null){ + if(currentFilterSearch == null || !SeahawkOptions.isFilterInteractive() || danglingPipe()){ return; } StringBuffer sb = currentFilterSearch.getFilterRegex(); @@ -196,6 +233,22 @@ applyFilterWhenSuitable(); } + // Check if the user is typing a regex and current has a | operator at the end. + // Don't update the matches at this point because of course the empty right side of the regex + // will match between every character, causing hardship for matching and highlight update + // on some machines. + private boolean danglingPipe(){ + String currentText = searchField.getText(); + // Running a regex on a regex to see if there is a trailing unescaped '|'...trippy + if(currentText.matches("(^|.*[^\\\\])(\\\\\\\\)*\\|")){ + searchField.setBackground(Color.YELLOW); + return true; + } + else{ + return false; + } + } + // Waits 600 milliseconds to see if the user is typing a phrase, rather than // filtering for each letter added, which can be slow private void applyFilterWhenSuitable(){ @@ -211,7 +264,7 @@ } catch(Exception e){ logger.log(Level.WARNING, - "Delay less than 400ms on search input due to interrupt", + "Delay less than 500ms on search input due to interrupt", e); } synchronized(sf){ @@ -245,6 +298,12 @@ // else, it's going to be updated soon anyway with the latest string buffer...just return } + public void fontSizeChanged(String size){ + // Data coming in is 110%, etc., convert to decimal scale required by + double scale = Double.parseDouble(size.substring(0, size.length()-1))/100.0; // lop off % sign, convert to ratio + setSearchFieldFontSize(scale); + } + class Closer extends MouseAdapter{ boolean active = false; private FilterSearchWidget widget; From gordonp at dev.open-bio.org Thu Feb 3 21:46:40 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:46:40 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032146.p13Lkee1020218@dev.open-bio.org> gordonp Thu Feb 3 16:46:40 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20182/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java Log Message: Make empty but well-formed clipboard file on startup to avoid exceptions in various widgets like the filter moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.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/gui/MobyContentClipboard.java 2010/04/16 20:36:17 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2011/02/03 21:46:40 1.12 @@ -92,6 +92,12 @@ return; } clipboardFile.deleteOnExit(); + try{ + writeClipboardDataToFile(); // Set up empty clipboard doc + } + catch(Exception e){ + logger.log(Level.SEVERE, "Clipboard failed to initialize, cannot write or load temp file", e); + } // The dfeault is to open a new tab when contents is transfered (dropped/pasted) onto the tab, // we want to override that behaviour to a collation for the clipboard @@ -270,7 +276,7 @@ logger.log(Level.FINE, urlContents); MobyDataType targetDataType = null; - if(collection != null){ + if(collection != null && !collection.isEmpty()){ targetDataType = collection.getDataType(); } MobyDataObject[] mobyDataFound = client.getMobyObjects(urlContents, targetDataType); @@ -341,21 +347,24 @@ } } - public void updateDisplay(){ + private void writeClipboardDataToFile() throws Exception{ // Write to temp file + FileOutputStream os = new FileOutputStream(clipboardFile); + MobyDataUtils.toXMLDocument(os, content); + os.close(); + } + + public void updateDisplay(){ try{ - FileOutputStream os = new FileOutputStream(clipboardFile); - MobyDataUtils.toXMLDocument(os, content); - os.close(); + writeClipboardDataToFile(); gotoURL(clipboardFile.toURI().toURL(), false); - } - catch(Exception e){ + tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), CLIPBOARD_TAB_NAME + + ": " + getResponseType(content)); + contentGUI.setVisible(true); + } catch(Exception e){ logger.log(Level.SEVERE, "Clipboard failed to update the display, cannot write or load temp file", e); return; } - tabbedPane.setTitleAt(tabbedPane.indexOfComponent(this), CLIPBOARD_TAB_NAME + - ": " + getResponseType(content)); - contentGUI.setVisible(true); } /** From gordonp at dev.open-bio.org Thu Feb 3 21:47:57 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:47:57 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032147.p13LlvQl020284@dev.open-bio.org> gordonp Thu Feb 3 16:47:57 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20248/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: Implement font resizing, and singleton application launching moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/05/13 16:13:21 1.23 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/03 21:47:57 1.24 @@ -26,6 +26,7 @@ import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; +import ca.ucalgary.util.*; import ca.ucalgary.seahawk.util.*; import ca.ucalgary.seahawk.services.MobyClient; @@ -36,7 +37,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -248,7 +249,7 @@ tabbedPane.add(clipboard); clipboard.init(); - settingsGUI = new SeahawkOptionsGUI(this); + settingsGUI = new SeahawkOptionsGUI(this, this); // params are frame owner, font change listener } public Acme.Serve.Serve getServletContainer(){ @@ -1189,15 +1190,17 @@ new Thread(){ public void run(){ for(;;) { - renderSplashFrame(g); - splash.update(); try { + renderSplashFrame(g); + splash.update(); Thread.sleep(100); } - catch(InterruptedException e) { + catch(Exception e) { } if(killSplash.tryAcquire()){ - splash.close(); + // Okay, we don't need to close the splash screen + // because it autocloses when a Java Window is shown. + //splash.close(); return; } } @@ -1277,6 +1280,24 @@ gui.loadPaneFromURL(startURL, true); } } + SingletonApplication.setArgumentListener(gui); + } + + // Called when user attempts to launch Seahawk again while its running + public void processArgument(String arg){ + try{ + loadPaneFromURL(new URL(arg), true); + } + catch(Exception e){ + System.err.println("Could not load "+arg+" as a URL, trying as a file"); + try{ + File f = new File(arg); + loadPaneFromURL(f.toURI().toURL(), true); + } catch(Exception fe){ + logger.error("Could not load "+arg+" as a URL or file: "+fe.getMessage()); + e.printStackTrace(); + } + } } protected static void cacheOntologies(){ @@ -1314,4 +1335,11 @@ public JLabel getStatusComponent() { return status; } + + public void fontSizeChanged(String fontSize) { + // Update font in all Seahawk-generated documents + for(int i = 0; i < tabbedPane.getTabCount(); i++){ + ((MobyContentPane) tabbedPane.getComponentAt(i)).setFontSize(fontSize); + } + } } From gordonp at dev.open-bio.org Thu Feb 3 21:49:01 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:49:01 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032149.p13Ln1mG020350@dev.open-bio.org> gordonp Thu Feb 3 16:49:01 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20314/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentHelpPane.java Log Message: Tiny fix so fot resizing can happen properly (requires help document URL be in history) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentHelpPane.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.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/MobyContentHelpPane.java 2010/03/29 19:55:22 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2011/02/03 21:49:01 1.6 @@ -68,7 +68,7 @@ } } - gotoURL(helpHTMLURL, false); + gotoURL(helpHTMLURL, true); editorPane.scrollToReference("start"); // use anchor at top of doc: pane scrolls to bottom normally... } From gordonp at dev.open-bio.org Thu Feb 3 21:50:51 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:50:51 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032150.p13LopH7020516@dev.open-bio.org> gordonp Thu Feb 3 16:50:50 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20460/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Fixes for font resizing, copying of data from Seahawk to the clipboard moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.33,1.34 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/05/13 16:12:19 1.33 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/03 21:50:50 1.34 @@ -31,9 +31,11 @@ import javax.swing.text.SimpleAttributeSet; import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; +import javax.swing.text.MutableAttributeSet; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; +import javax.swing.text.html.CSS; import javax.swing.text.html.HTML; import javax.swing.text.html.HTMLDocument; @@ -81,6 +83,7 @@ /** The name of the param in the stylesheet that will hold the Moby doc URL for XPointer usage */ public final static String XSL_DOC_SOURCE_PARAM = "sourceURL"; + public final static String XSL_DOC_FONTSIZE_PARAM = "fontSize"; private JScrollPane scrollPane; protected JTabbedPane tabbedPane; @@ -110,6 +113,7 @@ private Map jobXPtrs = null; // Map private List origStyles = null; private boolean firstDocRendering = true; + private String tempFontSize = null; // Next two items used for service wrapping private JMenuItem createServicePopupItem; @@ -485,6 +489,20 @@ } /** + * Used to temporarily change the font size of the displayed document. + * Normally the SeahawkOptions values are used. + * + * @param fontSize an absolute or relative font size as per HTML's basefont size specification. If null, document default size is used. + */ + public synchronized void setFontSize(String fontSize){ + tempFontSize = fontSize == null ? "100%" : fontSize; + gotoURL(getCurrentURL(), false); + // Also notify filter widget since the text input field will need resizing + filterSearchWidget.fontSizeChanged(tempFontSize); + tempFontSize = null; + } + + /** * This is the URLLoader callback method the MOBY data fetcher * will call when MOBY XML data is ready to be seen. */ @@ -534,7 +552,12 @@ } // Tell the stylesheet the URL of the moby data (it will create xpointers to it) - contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, url.toString()); + contentGUI.getTransformer().setParameter(XSL_DOC_SOURCE_PARAM, + url.toString()); + //String fontSize = tempFontSize != null ? tempFontSize : SeahawkOptions.getFontSize(); + //System.err.println("Font size for XML doc will be "+fontSize); + //contentGUI.getTransformer().setParameter(XSL_DOC_FONTSIZE_PARAM, + // fontSize); // Do the actual transformation String htmlContents = "[Seahawk Internal Error]"; try{ @@ -542,6 +565,9 @@ contentGUI.getTransformer().transform(new StreamSource(url.openStream()), new StreamResult(stringWriter)); htmlContents = stringWriter.toString(); + if(htmlContents == null || htmlContents.length() == 0){ + htmlContents = "[Empty]"; + } // NOTE: If you switch the registry in the middle of using Seahawk, // the following might fail on documents in the history, as they were // encoded according to a different registry than the current value of @@ -549,7 +575,9 @@ // registries, there has to be a way to note the source registry for the data in the // document (preferred), or we must maintain a hash of the document:registry mappings // for the session. - htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents, SeahawkOptions.getRegistry()); + else{ + htmlContents = HTMLUtils.encapsulateBinaryData(url, htmlContents, SeahawkOptions.getRegistry()); + } } catch(TransformerException te){ status.setText("Sorry! Could not transform the MOBY data into presentation form"); @@ -710,6 +738,16 @@ e.printStackTrace(); } + // Adjust font size if necessary in HTML docs + if((tempFontSize != null || !SeahawkOptions.getFontSize().equals("100%")) && + editorPane.getDocument() instanceof HTMLDocument){ + HTMLDocument doc = (HTMLDocument) editorPane.getDocument(); + MutableAttributeSet attr = new SimpleAttributeSet(); + String fontSize = tempFontSize != null ? tempFontSize : SeahawkOptions.getFontSize(); + doc.getStyleSheet().addCSSAttribute(attr, CSS.Attribute.FONT_SIZE, fontSize); + doc.setCharacterAttributes(0, editorPane.getDocument().getLength(), attr, false); + } + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if(addToHistory){ @@ -854,6 +892,7 @@ * PBE recorder. */ public void exportDone(String valuePasted, String transformRuleURI){ + System.err.println("Export done, notifying wrapping servlet (if any)"); if(cgiServlet != null && cgiServlet.getRecorder() != null && (cgiServlet.getRecorder() instanceof PBERecorder)){ ((PBERecorder) cgiServlet.getRecorder()).dataCopied(getDraggedData(), valuePasted, transformRuleURI); } @@ -1124,6 +1163,8 @@ public void hyperlinkUpdate(HyperlinkEvent he){ URL targetURL = he.getURL(); if(he.getEventType() == HyperlinkEvent.EventType.ACTIVATED){ + overHyperlink = true; + lastHyperlinkHovered = targetURL; // Internal moby pseudo-URL if(targetURL == null){ String desc = he.getDescription(); @@ -1554,6 +1595,9 @@ } FilterSearch filter = filterHistory.get(getCurrentURL()); + if(getCurrentDoc() == null){ + return; + } filterableNodes = DataUtils.findFilteredNodes(getCurrentDoc(), filter, filterableNodes, filteredData, jobXPtrs, currentSelectedData, currentSelectionXPath, apply); @@ -1660,7 +1704,7 @@ javax.swing.text.Element el = d.getElement(filterable); String fragment = d.getText(el.getStartOffset(), el.getEndOffset() - el.getStartOffset()); - Matcher matcher = p.matcher(fragment); + Matcher matcher = p.matcher(fragment.trim()); while (matcher.find()) { // Only count match if not already highlighted in a containing filterable node // todo: in future, avoid looking in text bits already checked, for efficiency @@ -1880,6 +1924,10 @@ return; } else{ // keep track of the previous selection so we can use it once it's gone + if(dragging){ //if a hyperlink is being dragged, don't highlight too + System.err.println("Ignoring highlight while dragging hyperlink"); + return; + } oldMark = mark; oldDot = dot; } @@ -1904,13 +1952,29 @@ tab.getDisplay().setText("Use the file/globe icon at the bottom of this window to load data," + "or drag'n'drop/paste data from your desktop or Web browser."); } + // Ctrl+C copy of selection if any + if(e.getKeyCode() == KeyEvent.VK_C && e.isControlDown() && selectedTextData != null){ + getTransferHandler().exportToClipboard(this, + Toolkit.getDefaultToolkit().getSystemClipboard(), + TransferHandler.COPY); + } } public void keyReleased(KeyEvent e){} public void keyTyped(KeyEvent e){} + public boolean isDraggingHyperlink(){ + return dragging; + } + + public String getSelectedText(){ + return selectedTextData; + } + public void paste(){ - getTransferHandler().importData(this, Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this)); + if(!dragging){ //don't allow drag onto self... + getTransferHandler().importData(this, Toolkit.getDefaultToolkit().getSystemClipboard().getContents(this)); + } } public void mouseDragged(MouseEvent e){ @@ -1919,13 +1983,14 @@ dragging = true; // so we don't export many times in a row while dragging lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - getTransferHandler().exportToClipboard(this, - Toolkit.getDefaultToolkit().getSystemClipboard(), - TransferHandler.COPY); + System.err.println("Dragging initiated via mouseDragged for "+lastHyperlinkDragged); + //getTransferHandler().exportToClipboard(this, + // Toolkit.getDefaultToolkit().getSystemClipboard(), + // TransferHandler.COPY); getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); } else if(!dragging){ - //System.err.println("Dragging with no hyperlink activated"); + System.err.println("Dragging with no hyperlink activated"); } } @@ -1935,18 +2000,24 @@ // mouse button being down here. if(overHyperlink && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK){ //System.err.println("Got wonky drag"); - lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - //System.err.println("Dragging "+lastHyperlinkDragged); - getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); + if(lastHyperlinkDragged != lastHyperlinkHovered){ + System.err.println("Dragging initiated via mouseMoved for "+lastHyperlinkDragged); + lastHyperlinkDragged = lastHyperlinkHovered; + //getTransferHandler().exportToClipboard(this, + // Toolkit.getDefaultToolkit().getSystemClipboard(), + // TransferHandler.COPY); + getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); + } } else if(dragging){ + System.err.println("Dragging stopped...no mouse down on mouseMoved"); dragging = false; } } public void lostOwnership(Clipboard clipboard, Transferable contents){ - //System.err.println("Lost clipboard ownership"); + System.err.println("Lost clipboard ownership"); } } From gordonp at dev.open-bio.org Thu Feb 3 21:52:05 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:52:05 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032152.p13Lq5W0020642@dev.open-bio.org> gordonp Thu Feb 3 16:52:05 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv20606/src/main/ca/ucalgary/seahawk/gui Modified Files: SeahawkOptionsGUI.java Log Message: Added support for disabling highlight-while-typing (may cause freezing), and font resizing moby-live/Java/src/main/ca/ucalgary/seahawk/gui SeahawkOptionsGUI.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2007/12/06 18:47:31 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/SeahawkOptionsGUI.java 2011/02/03 21:52:05 1.7 @@ -34,8 +34,12 @@ private JTextField converterPortTextField; private JTextField cacheExpiryTextField; private JFileChooser cacheDirFileChooser; + private JComboBox fontComboBox; + private String[] fontSizes = new String[]{"50%","75%","90%","100%","110%","125%","150%","200%"}; + private FontSizeChangeListener fontSizeChangeListener; private JCheckBox sendReferrerCheckBox; + private JCheckBox filterInteractiveCheckBox; private JButton resetButton; private JButton okButton; @@ -49,14 +53,15 @@ /** * @param owner the frame that launches this dialog */ - public SeahawkOptionsGUI(Frame owner){ + public SeahawkOptionsGUI(Frame owner, FontSizeChangeListener listener){ super(owner, DIALOG_TITLE, DIALOG_MODAL); // Custom handling of window close operation setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(this); + fontSizeChangeListener = listener; - // The dreaded GridBagLayout... + // The dreaded GridBagLayout...see http://madbean.com/anim/totallygridbag/ GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; @@ -72,6 +77,16 @@ registryNames[i] = CUSTOM_REGISTRY_SYNONYM; c.insets = new Insets(3,2,3,2); + + // Font size widget + + //........................................ + //c.gridx = 0; + //c.gridy = 4; + //c.gridwidth = 5; + //JSeparator line = new JSeparator(); + //add(line, c); + //........................................ c.gridwidth = 2; @@ -185,20 +200,50 @@ //........................................ c.gridx = 0; c.gridy = 7; - c.gridwidth = 4; + c.gridwidth = 2; c.gridheight = 1; sendReferrerCheckBox = new JCheckBox("Send referrer data to services"); add(sendReferrerCheckBox, c); + c.gridx = 2; + c.gridwidth = 2; + c.gridheight = 1; + filterInteractiveCheckBox = new JCheckBox("Highlight filter matches while typing"); + add(filterInteractiveCheckBox, c); //........................................ + c.gridx = 0; c.gridy = 8; c.gridwidth = 5; line = new JSeparator(); add(line, c); - //........................................ + c.gridx = 0; c.gridy = 9; c.gridwidth = 2; + c.weightx = 0.0; + c.weighty = 0.0; + c.fill = GridBagConstraints.HORIZONTAL; + label = new JLabel("Document Font Size:", JLabel.RIGHT); + add(label, c); + c.gridx = 2; + c.gridwidth = 1; + + adjustFontSizesIfNecessary(); + fontComboBox = new JComboBox(fontSizes); + fontComboBox.setSelectedItem(SeahawkOptions.getFontSize()); // do this here to avoid unnecessary callback + fontComboBox.addActionListener(this); + add(fontComboBox, c); + + //........................................ + c.gridx = 0; + c.gridy = 10; + c.gridwidth = 5; + line = new JSeparator(); + add(line, c); + + c.gridy = 11; + c.gridx = 0; + c.gridwidth = 2; label = new JLabel("Cache expiry (in hours)", JLabel.RIGHT); add(label, c); @@ -232,10 +277,54 @@ pack(); } + // If the value of the user preferred font size is not one of the standard presets + // (e.g. they set it manually in the config file), + // add that custom value to the list of options. + private void adjustFontSizesIfNecessary(){ + String currentFontSize = SeahawkOptions.getFontSize(); + double currentSizeDouble = convertFontSizeToDouble(currentFontSize); + for(String presetChoice: fontSizes){ + if(convertFontSizeToDouble(presetChoice) == currentSizeDouble){ + SeahawkOptions.setFontSize(presetChoice); // avoids confusion in parts of app looking for 100%, not 100.000% etc. + return; // it's an existing choice + } + } + + // If we got here, it's a custom value + System.err.println("Inserting custom value (" + currentFontSize + ") into font size choices"); + String[] newFontSizes = new String[fontSizes.length+1]; + // Insertion of custom value into ordered presets list assumes existing font sizes and ordered small to large + boolean customValuePlaced = false; + for(int i = 0; i < fontSizes.length; i++){ + if(customValuePlaced){ + newFontSizes[i+1] = fontSizes[i]; + } + else if(currentSizeDouble < convertFontSizeToDouble(fontSizes[i])){ + newFontSizes[i] = currentFontSize; + customValuePlaced = true; + i--; + } + else{ + newFontSizes[i] = fontSizes[i]; // verbatim 'cause custom value not encountered yet + } + } + // Bigger than any preset? append to new list + if(!customValuePlaced){ + newFontSizes[fontSizes.length] = currentFontSize; + } + fontSizes = newFontSizes; + } + + // "100%" -> 100.0 + private double convertFontSizeToDouble(String fontSize){ + return Double.parseDouble(fontSize.substring(0, fontSize.length()-1)); // lop off % sign + } + public void actionPerformed(ActionEvent event){ Object source = event.getSource(); if(source == cancelButton){ setCurrentValues(); + updateDocumentFont(SeahawkOptions.getFontSize()); setVisible(false); } else if(source == okButton){ @@ -257,6 +346,9 @@ else if(source == registryComboBox){ updateRegistryFields(); } + else if(source == fontComboBox){ + updateDocumentFont(fontComboBox.getSelectedItem().toString()); + } } /** @@ -279,8 +371,9 @@ converterHostTextField.setText(""+SeahawkOptions.getDocConverterHost()); converterPortTextField.setText(""+SeahawkOptions.getDocConverterPort()); sendReferrerCheckBox.setSelected(SeahawkOptions.getSendReferrerPolicy()); + filterInteractiveCheckBox.setSelected(SeahawkOptions.isFilterInteractive()); cacheExpiryTextField.setText(""+SeahawkOptions.getCacheExpiry()); - cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); + cacheDirFileChooser.setSelectedFile(SeahawkOptions.getTempDir()); } private void saveSettings(){ @@ -350,6 +443,15 @@ SeahawkOptions.setDocConverterHost(converterHostTextField.getText().trim()); SeahawkOptions.setSendReferrerPolicy(sendReferrerCheckBox.isSelected()); SeahawkOptions.setCacheExpiry(expiry); + if(filterInteractiveCheckBox.isSelected() != SeahawkOptions.isFilterInteractive()){ + JOptionPane.showMessageDialog(null, + "Please restart Seahawk to fully apply the filter behaviour change.", + "Filter behaviour change requires restart", + JOptionPane.INFORMATION_MESSAGE); + } + SeahawkOptions.setFilterInteractive(filterInteractiveCheckBox.isSelected()); + SeahawkOptions.setFontSize(fontComboBox.getSelectedItem().toString()); + updateDocumentFont(fontComboBox.getSelectedItem().toString()); // Saves the new values to a file, so they will perpetuate themselves between sessions if(!SeahawkOptions.saveSettings()){ @@ -377,6 +479,12 @@ setVisible(false); } + private void updateDocumentFont(String fontSize){ + if(fontSizeChangeListener != null){ + fontSizeChangeListener.fontSizeChanged(fontSize); + } + } + private void updateRegistryFields(){ // Update all the registry fields if the name switches String selectedRegistryName = registryComboBox.getSelectedItem().toString(); @@ -446,7 +554,7 @@ JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - SeahawkOptionsGUI dialog = new SeahawkOptionsGUI(frame); + SeahawkOptionsGUI dialog = new SeahawkOptionsGUI(frame, null); frame.pack(); frame.setVisible(true); From gordonp at dev.open-bio.org Thu Feb 3 21:54:51 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:54:51 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032154.p13Lsp92020752@dev.open-bio.org> gordonp Thu Feb 3 16:54:51 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv20716/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: New and improved protein recognition rule moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,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/resources/mobyBuilderRules.xml 2010/04/11 02:20:46 1.11 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2011/02/03 21:54:51 1.12 @@ -55,8 +55,8 @@ urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareAA2AminoAcidSequence (?:^|[^A-Za-z]) # some non-alphabetical boundary - (\P*\s*(?:\P{10,}(?:\x20|\r|\t|\n){2,})+\P*) # iupac or spacing - (?![A-Za-z]) # should not be followed by letters + (\P*[^ACGTNacgtn]\s*(?:\P{10,}(?:\x20|\r|\t|\n)+)+\P*) # iupac or spacing, at least one non-DNA char + (?![A-Za-z]|\Z) # should not be followed by letters (try not to recognize free text as protein) From gordonp at dev.open-bio.org Thu Feb 3 21:57:23 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:57:23 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032157.p13LvNgT020840@dev.open-bio.org> gordonp Thu Feb 3 16:57:23 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv20804/src/main/ca/ucalgary/seahawk/util Modified Files: DataFlowRecorder.java Log Message: Numerous improvements to port labelling, input data support, removing cruft code moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/04/18 00:23:42 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2011/02/03 21:57:23 1.7 @@ -33,6 +33,8 @@ public static final String T2FLOW_XPATHFILTER_BEANSHELL = "ca/ucalgary/seahawk/resources/XPathFilterBeanShell"; public static final String T2FLOW_PASSFILTER_BEANSHELL = "ca/ucalgary/seahawk/resources/PassFilterBeanShell"; // = if condition public static final String T2FLOW_LISTFLATTEN_BEANSHELL = "ca/ucalgary/seahawk/resources/FlattenListBeanShell"; + public static final String T2FLOW_SELECTFILES_BEANSHELL = "ca/ucalgary/seahawk/resources/SelectFilesBeanShell"; + public static final String T2FLOW_READBINARYFILE_BEANSHELL = "ca/ucalgary/seahawk/resources/BinaryFileLoaderBeanShell"; private Central mobyCentral; private Map namesUsed; // keep count of workflow element name usage so as not to duplicate an ID @@ -47,6 +49,8 @@ private static String xpathFilterScript = null; private static String passFilterScript = null; private static String listFlattenScript = null; + private static String fileSelectionScript = null; + private static String readBinaryFileScript = null; private static Element dispatchStack = null; private static Transformer nullTransformer = null; private static Logger logger = Logger.getLogger(DataFlowRecorder.class.getName()); @@ -238,7 +242,7 @@ return portEl; } - private Element createWorkflowInputElement(String name, MobyPrimaryData sampleData, Document doc){ + private Element createWorkflowInputElement(String name, MobyNamespace ns, String id, MobyPrimaryData[] sampleData, Document doc){ Element portEl = doc.createElementNS(T2FLOW_NS, "port"); Element nameEl = doc.createElementNS(T2FLOW_NS, "name"); @@ -253,15 +257,29 @@ granularDepthEl.appendChild(doc.createTextNode("0")); portEl.appendChild(granularDepthEl); - MobyNamespace ns = null; - if(sampleData.getNamespaces() != null && - sampleData.getNamespaces().length > 0){ - ns = sampleData.getNamespaces()[0]; + String descText = "File/Spreadsheet of one or more lines, " + + (sampleData.length == 1 ? + "each line containing one ": + "with the following "+sampleData.length+" fields in order:"); + for(MobyPrimaryData sampleDatum: sampleData){ + descText += sampleDatum.getName()+" ("+sampleDatum.getDataType().getName()+"),"; + } + if(ns != null && !ns.getName().equals("unknown")){ + descText += ns.getName()+" (ID)"; + } + else{ + descText = descText.substring(0, descText.length()-1); + } + String exampleText = ""; + for(MobyPrimaryData sampleDatum: sampleData){ + exampleText += ((MobyDataObject) sampleDatum).getObject().toString()+","; + } + if(ns != null && !ns.getName().equals("unknown")){ + exampleText += id; + } + else{ + exampleText = exampleText.substring(0, exampleText.length()-1); } - - String descText = "File of one or more"+(ns == null ? "" : " "+ - ns.getName())+" IDs, one per line"; - String exampleText = sampleData.getId(); Element annotations = doc.createElementNS(T2FLOW_NS, "annotations"); portEl.appendChild(annotations); annotations.appendChild(createAnnotationChain("net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription", descText, doc)); @@ -475,14 +493,9 @@ mobifyingProcessorNameAndPorts = input2Processor.get(inputKey); } else{ - if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT)){ - mobifyingProcessorNameAndPorts = addIdMobifyingProcessor(processors, datalinks, inputPorts, - sampleData, doc); - input2Processor.put(inputKey, mobifyingProcessorNameAndPorts); - } - else{ - // TODO: Need to build complex input from MOB rule or spreadsheet fields? - } + mobifyingProcessorNameAndPorts = addDataMobifyingProcessor(processors, datalinks, inputPorts, + sampleData, doc); + input2Processor.put(inputKey, mobifyingProcessorNameAndPorts); } // link the created data to the workflow service datalinks.appendChild(createDataLinkElement(mobifyingProcessorNameAndPorts[0], @@ -503,22 +516,86 @@ return inputKey.replaceFirst(MobyTags.ARTICLENAME+"\\s*=\\s*(['\"]).*?\\1", ""); } - // Actually adds a few processors, but only one needs to be returned and connected to an input port. - // The others are constant values. By default we assume that you want to run a bunch of IDs - // in a file, we also link in a Taverna spreadsheet importer. - // Returns [spreadsheetReadingProcName, outputPort] - private String[] addIdMobifyingProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, - MobyPrimaryData sampleData, Document doc) throws Exception{ - String processorName = "Create-" + sampleData.getDataType().getName(); + private String[] addDataMobifyingProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, + MobyPrimaryData sampleData, Document doc) throws Exception{ + MobyDataType sampleDataType = sampleData.getDataType(); + + boolean hasBinaryBase = false; + List sampleCompositeProcessors = new ArrayList(); + List sampleComposites = new ArrayList(); + List samplePrimitives = new ArrayList(); + String[] binaryFileReaderProcNameAndPorts = null; + if(sampleData instanceof MobyDataComposite){ + if(sampleData instanceof MobyDataBytes){ // binary data needs special handling + binaryFileReaderProcNameAndPorts = addBinaryFileReaderBeanShell(processors, doc); + + // connect the article name constant to the binary file reader + String[] fileSelectionProcNameAndPorts = addFileSelectionBeanShell(processors, doc); + String constantTitle = createUniqueName("File_dialog_title"); + processors.appendChild(createConstantProcessor(constantTitle, "Load multiple " + MobyDataBytes.ENCODED_MEMBER_NAME + " files", doc)); + datalinks.appendChild(createDataLinkElement(constantTitle, + "value", + fileSelectionProcNameAndPorts[0], + fileSelectionProcNameAndPorts[1], + doc)); + + // connect the dialog title constant to the binary file reader + String constantName = createUniqueName(MobyDataBytes.ENCODED_MEMBER_NAME+"-article_name"); + processors.appendChild(createConstantProcessor(constantName, MobyDataBytes.ENCODED_MEMBER_NAME, doc)); + datalinks.appendChild(createDataLinkElement(constantName, + "value", + binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[1], + doc)); + // link the file selection dialog results to the binary file reader + datalinks.appendChild(createDataLinkElement(fileSelectionProcNameAndPorts[0], + fileSelectionProcNameAndPorts[fileSelectionProcNameAndPorts.length-1], + binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[2], + doc)); + hasBinaryBase = true; + } + // recurse to fill in other fields + for(MobyPrimaryData child: ((MobyDataComposite) sampleData).values()){ + if(hasBinaryBase && child.getName().equals(MobyDataBytes.ENCODED_MEMBER_NAME)){ + continue; // handled this member in an if condition earlier + } + if(child instanceof MobyDataComposite){ + // must recurse because the complex object contains another complex object + sampleCompositeProcessors.add(addDataMobifyingProcessor(processors, + datalinks, + dataFlowInputPorts, + child, + doc)); + sampleComposites.add((MobyDataComposite) child); + } + else{ + samplePrimitives.add(child); + } + } + } + // a Moby primitive + else if(!sampleDataType.getName().equals(MobyTags.MOBYOBJECT)){ + samplePrimitives.add(sampleData); + } + + String processorName = "Create-" + sampleDataType.getName(); MobyNamespace ns = null; MobyNamespace[] nss = ((MobyPrimaryData) sampleData).getNamespaces(); - if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT) && - nss != null && nss.length > 0){ - ns = nss[0]; //we will use only the primary namespace - processorName = "Create-" + ns.getName() + "-ID"; + if(nss != null && nss.length > 0){ + ns = nss[0]; // we will use only the primary namespace for now + if(sampleData.getDataType().getName().equals(MobyTags.MOBYOBJECT)){ + processorName = "Create-" + ns.getName() + "-ID"; + } + else{ //datatype + ns in proc name + processorName += "-"+ns.getName() + "-ID"; + } } processorName = createUniqueName(processorName); + // now we need to merge the primitive object fields with the processors creating binary and other complex objects + + // Create the Mobifying processor Element processor = doc.createElementNS(T2FLOW_NS, "processor"); processors.appendChild(processor); Element name = doc.createElementNS(T2FLOW_NS, "name"); @@ -596,10 +673,41 @@ iteration.appendChild(strategy); Element cross = doc.createElementNS(T2FLOW_NS, "cross"); strategy.appendChild(cross); + Element dot = doc.createElementNS(T2FLOW_NS, "dot"); + cross.appendChild(dot); + + // object members + 3 standard input ports, and one output + String[] portNames = new String[4+sampleCompositeProcessors.size()+samplePrimitives.size()+(binaryFileReaderProcNameAndPorts != null ? 1 :0)]; + portNames[portNames.length-4] = "id"; + portNames[portNames.length-3] = "namespace"; + portNames[portNames.length-2] = "article name"; + portNames[portNames.length-1] = "mobyData"; + + if(binaryFileReaderProcNameAndPorts != null){ + portNames[0] = getPortName(((MobyDataBytes) sampleData).get(MobyDataBytes.ENCODED_MEMBER_NAME), false); + datalinks.appendChild(createDataLinkElement(binaryFileReaderProcNameAndPorts[0], + binaryFileReaderProcNameAndPorts[binaryFileReaderProcNameAndPorts.length-1], + processorName, + portNames[0], + doc)); + } + // fill the new processor's input port list with the composites' output ports + for(int i = (binaryFileReaderProcNameAndPorts != null ? 1 :0); i < sampleCompositeProcessors.size(); i++){ + String[] compositeProcNameAndPorts = sampleCompositeProcessors.get(i); + portNames[i] = getPortName(sampleComposites.get(i), false); + datalinks.appendChild(createDataLinkElement(compositeProcNameAndPorts[0], + compositeProcNameAndPorts[compositeProcNameAndPorts.length-1], + processorName, + portNames[i], + doc)); + } + // then the primitives' output ports... + for(int i = (binaryFileReaderProcNameAndPorts != null ? 1 :0); i < samplePrimitives.size(); i++){ + portNames[sampleCompositeProcessors.size()+i] = getPortName(samplePrimitives.get(i), false); + } - // 3 input ports, one output - String[] portNames = new String[]{"namespace", "article name", "id", "mobyData"}; - for(String portNameString: portNames){ + for(int i = 0; i < portNames.length; i++){ + String portNameString = portNames[i]; // Map them Element map = createMapFromTo(portNameString, portNameString, doc); //identity map if(portNameString.equals("mobyData")){ @@ -607,25 +715,38 @@ outputMap.appendChild(map); } else{ - inputPorts.appendChild(createParamPort(portNameString, "0", doc)); - + inputPorts.appendChild(createParamPort(portNameString, "0", doc)); inputMap.appendChild(map); // Add the iteration strategy Element portRef = doc.createElementNS(T2FLOW_NS, "port"); portRef.setAttribute("name", portNameString); portRef.setAttribute("depth", "0"); - cross.appendChild(portRef); + // last few standard attributes are constants, so cross them instead of dot + if(i >= portNames.length - (ns==null || ns.getName().equals("unknown") ? 4 : 3)){ + cross.appendChild(portRef); + } + else{ + dot.appendChild(portRef); + } } } - // Create the constant value processors for the articlename - // NOTE: WE REPURPOSE THE VARIABLES ABOVE FOR NEW ELEMENTS!!! + // Create the constant value processors for the object Map constants = new HashMap(); Map feeds = new HashMap(); //what port on data creator it maps to - constants.put(ns.getName()+"-namespace-constant", ns.getName()); - feeds.put(ns.getName()+"-namespace-constant", "namespace"); - constants.put("article_name-constant", "unimportant"); + if(ns != null && !ns.getName().equals("unknown")){ + constants.put(ns.getName()+"-namespace-constant", ns.getName()); + feeds.put(ns.getName()+"-namespace-constant", "namespace"); + // id is fed from spreadsheet importer if ns is defined, no need to populate here + } + else{ + constants.put("blank-namespace", ""); + feeds.put("blank-namespace", "namespace"); + constants.put("blank-id", ""); + feeds.put("blank-id", "id"); + } + constants.put("article_name-constant", sampleData.getName()); feeds.put("article_name-constant", "article name"); for(Map.Entry constant: constants.entrySet()){ @@ -638,54 +759,115 @@ doc)); } + if(samplePrimitives.isEmpty() && hasBinaryBase && + sampleCompositeProcessors.isEmpty()){ // just a plain binary object to return, no need for spreadsheet importer + + // return the name of the data creator and output port so it can be hooked up + // to input ports for Moby services + return new String[]{processorName, portNames[portNames.length-1]}; + } + + String[] spreadsheetProcessorNameAndPorts = + addPrimitiveSpreadsheetProcessor(processors, datalinks, dataFlowInputPorts, + sampleDataType, ns, sampleData.getId(), + samplePrimitives.toArray(new MobyPrimaryData[samplePrimitives.size()]), + doc); + + + // link the spreadsheet reader to the Moby data creator + for(int i = 1; i < spreadsheetProcessorNameAndPorts.length; i++){ + datalinks.appendChild(createDataLinkElement(spreadsheetProcessorNameAndPorts[0], + spreadsheetProcessorNameAndPorts[i], + processorName, + portNames[(binaryFileReaderProcNameAndPorts != null ? 1 :0)+sampleCompositeProcessors.size()+i-1], + doc)); + } + + // return the name of the data creator processor and output port so it can be hooked up + // to input ports for Moby services + return new String[]{processorName, portNames[portNames.length-1]}; + } + + // Actually adds a few processors, but only one needs to be returned and connected to an input port. + // The others are constant values. By default we assume that you want to run a bunch of IDs + // in a file, we also link in a Taverna spreadsheet importer. + // Returns [spreadsheetReadingProcName, outputPort1, outputPort2, etc.] + private String[] addPrimitiveSpreadsheetProcessor(Element processors, Element datalinks, Element dataFlowInputPorts, + MobyDataType dataType, MobyNamespace ns, String id, + MobyPrimaryData[] sampleData, Document doc) throws Exception{ + // feed the id input of the Moby data creator with a spreadsheet importer, // so users can easily give a file list of IDs to run. - String importerName = createUniqueName("SpreadsheetImporter-"+ns.getName()+"-IDs"); + String dataTypeName = dataType.getName(); + if(dataTypeName.equals(MobyTags.MOBYOBJECT)){ + dataTypeName = ns.getName()+"-ID"; + } + else{ + dataTypeName += "-fields"; + } + String importerName = createUniqueName("SpreadsheetImporter-"+dataTypeName); Element importProcessor = doc.createElementNS(T2FLOW_NS, "processor"); processors.appendChild(importProcessor); - name = doc.createElementNS(T2FLOW_NS, "name"); + Element name = doc.createElementNS(T2FLOW_NS, "name"); name.appendChild(doc.createTextNode(importerName)); importProcessor.appendChild(name); - inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); + Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); importProcessor.appendChild(inputPorts); inputPorts.appendChild(createParamPort("fileurl", "0", doc)); - outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); + Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); importProcessor.appendChild(outputPorts); - String outputUniqueName = createUniqueName(ns.getName());// output name - outputPorts.appendChild(createParamPort(outputUniqueName, "1", "1", doc)); + String[] outputUniqueNames = new String[sampleData.length+(ns!=null && !ns.getName().equals("unknown")?1:0)]; + for(int i = 0; i < sampleData.length; i++){ + String outputName = sampleData[i].getName(); + if(sampleData[i].getDataType().getName().equals(MobyTags.MOBYOBJECT)){ + outputName += "-"+sampleData[i].getNamespaces()[0].getName()+"-ID"; + } + else{ + outputName += "-"+sampleData[i].getDataType().getName(); + } + outputUniqueNames[i] = createUniqueName(outputName);// output name + outputPorts.appendChild(createParamPort(outputUniqueNames[i], "1", "1", doc)); + } + // special port name case for id field of object, if present + if(ns != null && !ns.getName().equals("unknown")){ + outputUniqueNames[outputUniqueNames.length-1] = "id"; + outputPorts.appendChild(createParamPort("id", "1", "1", doc)); + } importProcessor.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - activities = doc.createElementNS(T2FLOW_NS, "activities"); + Element activities = doc.createElementNS(T2FLOW_NS, "activities"); importProcessor.appendChild(activities); - activity = doc.createElementNS(T2FLOW_NS, "activity"); + Element activity = doc.createElementNS(T2FLOW_NS, "activity"); activities.appendChild(activity); - raven = doc.createElementNS(T2FLOW_NS, "raven"); - group = doc.createElementNS(T2FLOW_NS, "group"); + Element raven = doc.createElementNS(T2FLOW_NS, "raven"); + Element group = doc.createElementNS(T2FLOW_NS, "group"); group.appendChild(doc.createTextNode("net.sf.taverna.t2.activities")); raven.appendChild(group); - artifact = doc.createElementNS(T2FLOW_NS, "artifact"); + Element artifact = doc.createElementNS(T2FLOW_NS, "artifact"); artifact.appendChild(doc.createTextNode("spreadsheet-import-activity")); raven.appendChild(artifact); - version = doc.createElementNS(T2FLOW_NS, "version"); + Element version = doc.createElementNS(T2FLOW_NS, "version"); version.appendChild(doc.createTextNode("1.0")); raven.appendChild(version); activity.appendChild(raven); - clas = doc.createElementNS(T2FLOW_NS, "class"); + Element clas = doc.createElementNS(T2FLOW_NS, "class"); activity.appendChild(clas); clas.appendChild(doc.createTextNode("net.sf.taverna.t2.activities.spreadsheet.SpreadsheetImportActivity")); - inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); + Element inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); activity.appendChild(inputMap); inputMap.appendChild(createMapFromTo("fileurl", "fileurl", doc)); //identity map - outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); + Element outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); activity.appendChild(outputMap); - outputMap.appendChild(createMapFromTo(outputUniqueName, outputUniqueName, doc)); + for(int i = 0; i < outputUniqueNames.length; i++){ + outputMap.appendChild(createMapFromTo(outputUniqueNames[i], outputUniqueNames[i], doc)); + } - configBean = doc.createElementNS(T2FLOW_NS, "configBean"); + Element configBean = doc.createElementNS(T2FLOW_NS, "configBean"); configBean.setAttribute("encoding", "xstream"); activity.appendChild(configBean); Element SpreadsheetImportConfiguration = @@ -697,7 +879,7 @@ Element columnRange = doc.createElementNS("", "columnRange"); SpreadsheetImportConfiguration.appendChild(columnRange); columnRange.appendChild(createElWithText(doc,"","start","0")); - columnRange.appendChild(createElWithText(doc,"","end","0")); + columnRange.appendChild(createElWithText(doc,"","end", ""+(sampleData.length-1+(ns!=null && !ns.getName().equals("unknown")?1:0)))); columnRange.appendChild(doc.createElementNS("", "excludes")); Element rowRange = doc.createElementNS("", "rowRange"); @@ -710,10 +892,18 @@ Element columnNames = doc.createElementNS("", "columnNames"); SpreadsheetImportConfiguration.appendChild(columnNames); - Element entry = doc.createElementNS("", "entry"); - columnNames.appendChild(entry); - entry.appendChild(createElWithText(doc,"","string","A")); - entry.appendChild(createElWithText(doc,"","string",outputUniqueName)); + // NOTE: Use 26 column names, if more, name as in Excel, AA, AB, etc + String[] columnLetters = new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", + "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "X", "Y", "Z"}; + for(int i = 0; i < outputUniqueNames.length; i++){ + Element entry = doc.createElementNS("", "entry"); + columnNames.appendChild(entry); + entry.appendChild(createElWithText(doc,"","string", + (i >= columnLetters.length ? + columnLetters[i/columnLetters.length-1]: "")+ + columnLetters[i%columnLetters.length])); + entry.appendChild(createElWithText(doc,"","string", outputUniqueNames[i])); + } SpreadsheetImportConfiguration.appendChild(createElWithText(doc,"","allRows","true")); SpreadsheetImportConfiguration.appendChild(createElWithText(doc,"","excludeFirstRow","false")); @@ -726,36 +916,35 @@ importProcessor.appendChild(getDispatchStack(doc)); - iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); + Element iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); importProcessor.appendChild(iterationStrategyStack); - iteration = doc.createElementNS(T2FLOW_NS, "iteration"); + Element iteration = doc.createElementNS(T2FLOW_NS, "iteration"); iterationStrategyStack.appendChild(iteration); - strategy = doc.createElementNS(T2FLOW_NS, "strategy"); + Element strategy = doc.createElementNS(T2FLOW_NS, "strategy"); iteration.appendChild(strategy); - cross = doc.createElementNS(T2FLOW_NS, "cross"); + Element cross = doc.createElementNS(T2FLOW_NS, "cross"); strategy.appendChild(cross); Element port = doc.createElementNS(T2FLOW_NS, "port"); cross.appendChild(port); port.setAttribute("name", "fileurl"); port.setAttribute("depth", "0"); - String uniqueInputName = createUniqueName(getInputName(sampleData)); + String uniqueInputName = createUniqueName(getInputName(dataType, ns)); // todo: sample data may be of more specific type than service requires - dataFlowInputPorts.appendChild(createWorkflowInputElement(uniqueInputName, sampleData, doc)); + dataFlowInputPorts.appendChild(createWorkflowInputElement(uniqueInputName, ns, id, sampleData, doc)); datalinks.appendChild(createWorkflowInputLinkElement(uniqueInputName, importerName, "fileurl", - sampleData, doc)); - // link the spreadsheet reader to the Moby data creator - datalinks.appendChild(createDataLinkElement(importerName, outputUniqueName, - processorName, "id", - doc)); - - // return the name of the spreadsheet reading processor and output port so it can be hooked up - // to input ports for Moby services - return new String[]{processorName, portNames[portNames.length-1]}; + // processor name, output ports (same number as sampleData length) + String[] procAndPortNames = new String[outputUniqueNames.length+1]; + procAndPortNames[0] = importerName; + System.arraycopy(outputUniqueNames, 0, procAndPortNames, 1, outputUniqueNames.length); + + // return the name of the spreadsheet reading processor and output ports so it can be hooked up + // to input ports for Moby data creator + return procAndPortNames; } private Element createConstantProcessor(String constantName, String constantValue, Document doc) @@ -1287,142 +1476,8 @@ } return endpoint; } - - // Returns the name of the moby object building processor and its ports, so we can create the data links in the caller - private String[] addMobyDataCreatorProcessor(MobyPrimaryData mobyData, Element processors, Document doc) - throws Exception{ - String dataType = null; - boolean primitiveDataType = false; - if(mobyData instanceof MobyPrimaryDataSet){ - dataType = "Collections - unimplemented"; - } - else if(mobyData instanceof MobyPrimaryDataSimple){ - if(mobyData instanceof MobyDataComposite){ - dataType = "Composite datatype - unimplemented"; - } - // a Moby primitive - else if(mobyData instanceof MobyDataString){ - dataType = MobyTags.MOBYSTRING; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataBoolean){ - dataType = MobyTags.MOBYBOOLEAN; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataDateTime){ - dataType = MobyTags.MOBYDATETIME; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataFloat){ - dataType = MobyTags.MOBYFLOAT; - primitiveDataType = true; - } - else if(mobyData instanceof MobyDataInt){ - dataType = MobyTags.MOBYINTEGER; - primitiveDataType = true; - } - // base object or xref - else{ - MobyNamespace[] nss = ((MobyPrimaryDataSimple) mobyData).getNamespaces(); - if(nss.length != 0){ - dataType = nss[0].getName()+"_ID"; - } - else{ - dataType = "Object"; - } - } - } - - String builderProcName = createUniqueName("Create_"+dataType+"s"); - Element builderProcessor = doc.createElementNS(T2FLOW_NS, "processor"); - processors.appendChild(builderProcessor); - builderProcessor.appendChild(createElWithText(doc, T2FLOW_NS, "name", builderProcName)); - - Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); - builderProcessor.appendChild(inputPorts); - inputPorts.appendChild(createParamPort("id", "0", doc)); - inputPorts.appendChild(createParamPort("namespace", "0", doc)); - if(primitiveDataType){ - inputPorts.appendChild(createParamPort("value", "0", doc)); - } - - Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); - builderProcessor.appendChild(outputPorts); - outputPorts.appendChild(createParamPort("mobyData", "0", "0", doc)); - - builderProcessor.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - - Element activities = doc.createElementNS(T2FLOW_NS, "activities"); - builderProcessor.appendChild(activities); - Element activity = doc.createElementNS(T2FLOW_NS, "activity"); - activities.appendChild(activity); - Element raven = doc.createElementNS(T2FLOW_NS, "raven"); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "group", "net.sf.taverna.t2.activities")); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "artifact", "biomoby-activity")); - raven.appendChild(createElWithText(doc, T2FLOW_NS, "version", "1.0")); - activity.appendChild(raven); - - activity.appendChild(createElWithText(doc, T2FLOW_NS, "class", - "net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivity")); - - Element inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); - activity.appendChild(inputMap); - inputMap.appendChild(createMapFromTo("id", "id", doc)); - inputMap.appendChild(createMapFromTo("namespace", "namespace", doc)); - if(primitiveDataType){ - inputMap.appendChild(createMapFromTo("value", "value", doc)); - } - Element outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); - activity.appendChild(outputMap); - outputMap.appendChild(createMapFromTo("mobyData", "mobyData", doc)); - - Element configBean = doc.createElementNS(T2FLOW_NS, "configBean"); - configBean.setAttribute("encoding", "xstream"); - activity.appendChild(configBean); - Element BuildActivityConfigurationBean = - doc.createElementNS("", - "net.sf.taverna.t2.activities.biomoby.BiomobyObjectActivityConfigurationBean"); - configBean.appendChild(BuildActivityConfigurationBean); - BuildActivityConfigurationBean.appendChild(createElWithText(doc, "", "mobyEndpoint", - getCentralEndpointFromMobyData(mobyData))); - BuildActivityConfigurationBean.appendChild(createElWithText(doc, "", "serviceName", - mobyData.getDataType().getName())); - BuildActivityConfigurationBean.appendChild(doc.createElementNS("", "authorityName")); - - activity.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); - - builderProcessor.appendChild(getDispatchStack(doc)); - - Element iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); - builderProcessor.appendChild(iterationStrategyStack); - Element iteration = doc.createElementNS(T2FLOW_NS, "iteration"); - iterationStrategyStack.appendChild(iteration); - Element strategy = doc.createElementNS(T2FLOW_NS, "strategy"); - iteration.appendChild(strategy); - Element dot = doc.createElementNS(T2FLOW_NS, "dot"); - strategy.appendChild(dot); - - Element port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "id"); - port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "namespace"); - if(primitiveDataType){ - port = doc.createElementNS(T2FLOW_NS, "port"); - dot.appendChild(port); - port.setAttribute("depth", "0"); - port.setAttribute("name", "value"); - return new String[]{builderProcName, "id", "namespace", "value", "mobyData"}; - } - else{ - return new String[]{builderProcName, "id", "namespace", "mobyData"}; - } - } - - private String[] addListFlattenBeanShell(Element processors, Document doc) + + private String[] addListFlattenBeanShell(Element processors, Document doc) throws Exception{ String beanShellProcName = createUniqueName("Create_Pass_Fail_List"); @@ -1434,13 +1489,52 @@ inputTypes.put("inputlist", "text/plain"); Map outputsMap = new LinkedHashMap(); outputsMap.put("outputlist", "1"); - + return addBeanShell(beanShellProcName, "dot", inputsMap, inputTypes, outputsMap, getListFlattenScript(), new String[]{}, processors, doc); } + + private String[] addFileSelectionBeanShell(Element processors, Document doc) + throws Exception{ + String beanShellProcName = createUniqueName("Select_Files"); + + // Now do all the param-specific stuff below (inserts into various parts of the elements defined above) + Map inputsMap = new LinkedHashMap(); + // linked because order is important to line up port connections + Map inputTypes = new LinkedHashMap(); + inputsMap.put("title", "0"); + inputTypes.put("title", "text/plain"); + Map outputsMap = new LinkedHashMap(); + outputsMap.put("selectedFiles", "1"); + + return addBeanShell(beanShellProcName, "cross", + inputsMap, inputTypes, outputsMap, + getFileSelectionScript(), new String[]{}, + processors, doc); + } + private String[] addBinaryFileReaderBeanShell(Element processors, Document doc) + throws Exception{ + String beanShellProcName = createUniqueName("Load_Binary_File"); + + // Now do all the param-specific stuff below (inserts into various parts of the elements defined above) + Map inputsMap = new LinkedHashMap(); + // linked because order is important to line up port connections + Map inputTypes = new LinkedHashMap(); + inputsMap.put("articleName", "0"); + inputTypes.put("articleName", "text/plain"); + inputsMap.put("absoluteFilePath", "0"); + inputTypes.put("absoluteFilePath", "text/plain"); + Map outputsMap = new LinkedHashMap(); + outputsMap.put("encodedString", "0"); + + return addBeanShell(beanShellProcName, "cross", + inputsMap, inputTypes, outputsMap, + getBinaryFileReaderScript(), new String[]{}, + processors, doc); + } private String[] addPassFilterBeanShell(Element processors, Document doc) throws Exception{ String beanShellProcName = createUniqueName("IfPassesContentFilter"); @@ -1667,7 +1761,7 @@ private Element createWorkflowInputLinkElement(String inputName, String processorName, String processorParamPortName, - MobyPrimaryData sampleData, Document doc){ + Document doc){ Element datalink = doc.createElementNS(T2FLOW_NS, "datalink"); Element sink = doc.createElementNS(T2FLOW_NS, "sink"); @@ -1770,6 +1864,25 @@ return preferredName; } + // same as next function, but takes service data type into account (e.g. if data is DNASequence, but + // equivalent service param is GenericSequence, use GenericSequence) + private String getPortName(MobyPrimaryData data, MobyService service, boolean asCollection){ + String dataName = data.getName(); + for(MobyPrimaryData param: service.getPrimaryInputs()){ + if(param.getName().equals(dataName)){ + if(!param.getDataType().getName().equals(data.getDataType().getName())){ + MobyPrimaryData superTypedData = ((data instanceof MobyPrimaryDataSet) ? (new MobyPrimaryDataSet(dataName)) : (new MobyPrimaryDataSimple(dataName))); + superTypedData.setDataType(param.getDataType()); + return getPortName(superTypedData, asCollection); + } + else{ + break; + } + } + } + return getPortName(data, asCollection); + } + // dataType(articleName) as required by the Taverna Moby plugin private String getPortName(MobyPrimaryData data, boolean asCollection){ if(data instanceof MobyPrimaryDataSet){ @@ -1786,22 +1899,20 @@ } // A useful human-legible name for a workflow input - private String getInputName(MobyPrimaryData data){ - String dataType = data.getDataType().getName(); - if(dataType.equals(MobyTags.MOBYOBJECT)){ - MobyNamespace[] namespaces = data.getNamespaces(); - if(namespaces.length == 0){ - return "FileOf"+dataType+"-"+data.getName()+"-IDs"; + private String getInputName(MobyDataType dataType, MobyNamespace ns){ + if(dataType.getName().equals(MobyTags.MOBYOBJECT)){ + if(ns == null){ + return "FileOfObjects"; //???? } else{ // Note: we could concatenate all allowed namespaces, but the service wouldn't // necessarily return the same results for all input namespaces, so we'll be // safe and stick to the primary one. - return "FileOf"+namespaces[0].getName()+"-"+data.getName()+"IDs"; + return "FileOf"+ns.getName()+"-IDs"; } } else{ - return dataType+"-"+data.getName(); + return "FileOf"+dataType.getName()+"-fields"; } } @@ -1993,6 +2104,28 @@ return listFlattenScript; } + private synchronized String getBinaryFileReaderScript() throws Exception{ + if(readBinaryFileScript == null){ + URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_READBINARYFILE_BEANSHELL); + if(scriptURL == null){ + throw new Exception("Cannot find resource " + T2FLOW_READBINARYFILE_BEANSHELL); + } + readBinaryFileScript = HTMLUtils.getURLContents(scriptURL); + } + return readBinaryFileScript; + } + + private synchronized String getFileSelectionScript() throws Exception{ + if(fileSelectionScript == null){ + URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_SELECTFILES_BEANSHELL); + if(scriptURL == null){ + throw new Exception("Cannot find resource " + T2FLOW_SELECTFILES_BEANSHELL); + } + fileSelectionScript = HTMLUtils.getURLContents(scriptURL); + } + return fileSelectionScript; + } + private synchronized String getPassFilterScript() throws Exception{ if(passFilterScript == null){ URL scriptURL = getClass().getClassLoader().getResource(T2FLOW_PASSFILTER_BEANSHELL); From gordonp at dev.open-bio.org Thu Feb 3 21:58:48 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 16:58:48 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032158.p13LwmrX020906@dev.open-bio.org> gordonp Thu Feb 3 16:58:47 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv20870/src/main/ca/ucalgary/seahawk/util Modified Files: DataUtils.java Log Message: Trim element contents so user filters with leading and trailing regex anchors work nicely moby-live/Java/src/main/ca/ucalgary/seahawk/util DataUtils.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java 2010/05/04 16:14:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java 2011/02/03 21:58:47 1.9 @@ -947,14 +947,14 @@ Pattern.MULTILINE | Pattern.DOTALL | (filter.getCaseSensitivity() ? 0 : Pattern.CASE_INSENSITIVE)); for(int i = 0; i < currentSelectedData.getLength(); i++){ - Node node = currentSelectedData.item(i); + Node node = currentSelectedData.item(i); if(node instanceof Element){ String elementXPtr = getXPtr(node); if(matchingXPtrs.containsKey(elementXPtr) && matchingXPtrs.get(elementXPtr).booleanValue()){ continue; // already true, no } - else if(regex.matcher(((Element) node).getTextContent()).find()){ + else if(regex.matcher(((Element) node).getTextContent().trim()).find()){ matchingXPtrs.put(elementXPtr, Boolean.TRUE); //System.err.println("Adding " + elementXPtr + " as " + matchingXPtrs.get(elementXPtr)); } @@ -1027,7 +1027,7 @@ * Create a temp file that populates the MobyContentInstance from the sample data * for all missing fields in peerJobs. This is used to populate a bunch of jobs * at once, iterating over some list of values popped into the peerJobs payload. - * Used after service wrapping demo to call new service fopr all demo input peers. + * Used after service wrapping demo to call new service for all demo input peers. */ public static URL createServiceInputFileForPeers(MobyContentInstance peerJobs, MobyDataJob sampleJob) throws Exception{ for(MobyDataJob peerJob: peerJobs.values()){ From gordonp at dev.open-bio.org Thu Feb 3 22:00:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:00:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032200.p13M0ZWJ021334@dev.open-bio.org> gordonp Thu Feb 3 17:00:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv21298/src/main/ca/ucalgary/seahawk/util Modified Files: SeahawkOptions.java Log Message: Added support for font resizing (accessibility), and disabling highlight-while-typing (can cause app to freeze on some machines) moby-live/Java/src/main/ca/ucalgary/seahawk/util SeahawkOptions.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.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/util/SeahawkOptions.java 2007/12/06 18:47:58 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/SeahawkOptions.java 2011/02/03 22:00:35 1.6 @@ -19,6 +19,8 @@ public static final String REGISTRY_NAMESPACE_PROP = "registryNamespace"; public static final String CONVERTER_HOST_PROP = "documentConverterHost"; public static final String CONVERTER_PORT_PROP = "documentConverterPort"; + public static final String FONT_SIZE_PROP = "fontSize"; + public static final String FILTER_INTERACTIVE_PROP = "filterInteractive"; public static final String CUSTOM_REGISTRY_SYNONYM = "custom"; public static final String PROPS_FILE_NAME = "seahawkUserPrefs.xml"; @@ -30,10 +32,12 @@ private static Registry registry = null; private static File tmpDir = new File(System.getProperty("java.io.tmpdir")); private static boolean referrerPolicy = true; + private static boolean filterInteractive = true; private static double cacheExpiryInHours = 24.0; // Used OpenOffice to convert MS Office docs to RTF, currently a Solaris zone on moby.ucalgary.ca private static String documentConverterHost = "136.159.169.81"; private static int documentConverterPort = 8100; + private static String fontSize = "100%"; /** * Sets the options based on a shortcircuiting set of @@ -123,6 +127,17 @@ "(will send referrer service header to services)."); } + boolString = properties.getProperty(FILTER_INTERACTIVE_PROP); + if(boolString != null && boolString.length() > 0){ + filterInteractive = Boolean.parseBoolean(boolString); + } + else{ + System.err.println("No filter interactivity policy (" +FILTER_INTERACTIVE_PROP+ + ") provided in the Seahawk config file (" + + u + "), using default of \"true\" " + + "(matches highlighted while the filter criteria are being typed)."); + } + String floatString = properties.getProperty(CACHE_POLICY_PROP); if(floatString != null && floatString.length() > 0){ double hours = cacheExpiryInHours; @@ -138,6 +153,25 @@ setCacheExpiry(hours); } + String fontString = properties.getProperty(FONT_SIZE_PROP); + if(fontString != null && fontString.length() > 0){ + String size = fontSize; + boolean relative = fontString.endsWith("%"); + if(relative){ + fontString = fontString.substring(0, fontString.length()-1); // lop off '%' sign + } + try{ + size = ""+Double.parseDouble(fontString); + } catch(NumberFormatException nfe){ + nfe.printStackTrace(); + System.err.println("Ignoring the font size policy (" +FONT_SIZE_PROP+ + ") provided in the Seahawk config file (" + + u + "), it is not in valid floating-point number format or a relative(trailing %) one: " + + fontString); + } + setFontSize(relative ? size+"%" : ""+size); + } + String dirPath = properties.getProperty(TEMP_DIR_PROP); if(dirPath != null && dirPath.length() > 0){ try{ @@ -240,6 +274,8 @@ properties.setProperty(TEMP_DIR_PROP, tmpDir.getCanonicalFile().getPath()); properties.setProperty(CONVERTER_HOST_PROP, documentConverterHost); properties.setProperty(CONVERTER_PORT_PROP, ""+documentConverterPort); + properties.setProperty(FONT_SIZE_PROP, fontSize); + properties.setProperty(FILTER_INTERACTIVE_PROP, ""+filterInteractive); if(registry != null){ properties.setProperty(REGISTRY_SYNONYM_PROP, registry.getSynonym()); properties.setProperty(REGISTRY_ENDPOINT_PROP, registry.getEndpoint()); @@ -395,16 +431,30 @@ } /** - * For more details on how to run your own file converter, see http://www.artofsolving.com/node/10 + * @return the relative size of the display font compared to the system default e.g. 120% + */ + public static String getFontSize(){ + return fontSize; + } + /** 100% = 1.0 */ + public static double getFontSizeAsDouble(){ + return Double.parseDouble(fontSize.substring(0, fontSize.length()-1))/100.0; // lop off % sign, convert to ratio + } + + /** + * Sets the display font size for documents. * - * @param hostname machine on which an OpenOffice file converter is running + * @param size how big the display font should be relative to the system default */ - public static void setDocConverterHost(String hostname){ - if(hostname == null || - hostname.length() == 0){ - hostname = null; - } - documentConverterHost = hostname; + public static void setFontSize(String size){ + fontSize = size; + } + + /** + * @param port positive number representing where the OpenOffice file converter is listening + */ + public static void setDocConverterHost(String host){ + documentConverterHost = host; } /** @@ -413,4 +463,14 @@ public static String getDocConverterHost(){ return documentConverterHost; } + + /** + * @param b whether the document should be updated as the filter widget is being typed into (can cause freezing problems on some systems) + */ + public static void setFilterInteractive(boolean b){ + filterInteractive = b; + } + public static boolean isFilterInteractive(){ + return filterInteractive; + } } From gordonp at dev.open-bio.org Thu Feb 3 22:03:23 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:03:23 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032203.p13M3Nqh021468@dev.open-bio.org> gordonp Thu Feb 3 17:03:23 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util In directory dev.open-bio.org:/tmp/cvs-serv21432/src/main/ca/ucalgary/util Modified Files: SingletonApplication.java Log Message: Added support for jar-based app launching moby-live/Java/src/main/ca/ucalgary/util SingletonApplication.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java 2010/05/19 17:38:56 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/util/SingletonApplication.java 2011/02/03 22:03:23 1.2 @@ -12,26 +12,48 @@ * Utility to launch a Java application if not running, or pass a new file for * opening if the app is already open (per user). To use this class, call it as your * main class, and pass the real main class name as the first argument. Subsequent - * arguments are passed to the real main class's main(argv) method. + * arguments are passed to the real main class's main(argv) method. If you are + * launching the app using the java -jar myapp.jar technique, you should define + * this class as thr Main-Class in META-INF/MANIFEST.MF, and specify your app's main class + * in the file META-INF/services/ca.ucalgary.util.SingletonApplication. + * + * The modifications required to the atrget application are as follows: + *
  1. Call the static method SingletonApplication.setArgumentListener(ArgumentListener) + * in your app's static void main() method.
  2. + *
  3. Have whatever class that opens files/URLs/etc in your app implement the method + * processArgument(String), and hence the interface ArgumentListener.
+ * + * @author Paul Gordon (gordonp at ucagary.ca) */ public class SingletonApplication{ private static ListenerThread listenerThread; public static void main(String[] args){ - if(args.length == 0 || args[0].matches("-{1,2}(h(elp)?)?")){ + if(args.length > 0 && args[0].matches("-{1,2}(h(elp)?)?")){ System.err.println("Usage: java "+SingletonApplication.class.getName()+ "
[file name or url to open #1] ..."); System.exit(1); } // Get the main class of the target program - Class mainClass = null; - try{ - mainClass = Class.forName(args[0]); - } catch(Exception e){ - System.err.println("Could not find main class "+args[0]); - System.exit(2); - } + Class mainClass = findMainClass(args.length == 0); + if(mainClass == null && args.length == 0){ + System.err.println("Usage: java "+SingletonApplication.class.getName()+ + "
[file name or url to open #1] ..."); + System.exit(15); + } + if(mainClass == null){ + try{ + mainClass = Class.forName(args[0]); + } catch(Exception e){ + System.err.println("Could not find main class "+args[0]); + System.exit(2); + } + // Pass along all args except the first, the main class name + String programArgs[] = new String[args.length-1]; + System.arraycopy(args, 1, programArgs, 0, programArgs.length); + args = programArgs; + } Class mainArgs[] = {String[].class}; Method main = null; try{ @@ -65,19 +87,6 @@ System.exit(10); } - // Pass along all args except the first, the main class name - String programArgs[] = new String[args.length-1]; - System.arraycopy(args, 1, programArgs, 0, programArgs.length); - -// FileOutputStream fos = null; -// try{ -// fos = new FileOutputStream(lockFile); -// } catch(Exception e){ -// System.err.println("Failed to get output stream for file " + lockFile.getAbsolutePath()+": "+e.getMessage()); -// e.printStackTrace(); -// System.exit(12); -// } - FileLock lock = null; try{ lock = lockFile.getChannel().tryLock(); @@ -106,7 +115,7 @@ System.exit(4); } try{ - callOpen(port, programArgs); + callOpen(port, args); } catch(Exception e){ System.err.println("While calling open on existing "+main.getName()+" process: " + e.getMessage()); e.printStackTrace(); @@ -127,7 +136,7 @@ // first instance, or the app doesn't implement the right interface (why are you using this, then?) (new File(lockFileAbsolutePath)).deleteOnExit(); try{ - callMain(main, programArgs, lock); + callMain(main, args, lock); } catch(Exception e){ System.err.println("While calling main method of "+main.getName()+": " + e.getMessage()); e.printStackTrace(); @@ -135,6 +144,49 @@ } } + private static Class findMainClass(boolean require){ + String className = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + String resourceName = "META-INF/services/"+SingletonApplication.class.getName(); + URL resURL = classLoader.getResource(resourceName); + if(resURL == null){ + if(require){ + System.err.println("NNo command line arg for the main class was provided, and the "+ + "resource " + resourceName + " could not be found"); + System.exit(16); + } + else{ + return null; + } + } + try{ + LineNumberReader reader = new LineNumberReader(new InputStreamReader(resURL.openStream())); + for(String line = reader.readLine(); line != null; line = reader.readLine()){ + if(!line.trim().startsWith("#")){ + className = line.trim(); + break; + } + } + } catch(Exception e){ + System.err.println("Error reading " + resURL+": "+e.getMessage()); + e.printStackTrace(); + System.exit(14); + } + if(className == null){ + System.err.println("Could not find main class name in " + resURL); + System.exit(15); + } + + try{ + return Class.forName(className); + } catch(Exception e){ + System.err.println("Could not load class " + className + ": " + e.getMessage()); + e.printStackTrace(); + System.exit(15); + } + return null; //should never get here + } + // Start the target program, passing the command-line arguments private static void callMain(Method main, String[] programArgs, FileLock lock) throws Exception{ // Write to the lock file the port on which we'll listen for "file open" requests From gordonp at dev.open-bio.org Thu Feb 3 22:05:37 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 3 Feb 2011 17:05:37 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102032205.p13M5bPb021662@dev.open-bio.org> gordonp Thu Feb 3 17:05:37 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv21626/src/main/org/biomoby/shared/data Modified Files: MobyDataFloat.java Log Message: Unparseable floats are not set to zero instead of causing exception moby-live/Java/src/main/org/biomoby/shared/data MobyDataFloat.java,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2008/01/07 22:11:36 1.11 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2011/02/03 22:05:37 1.12 @@ -2,6 +2,7 @@ package org.biomoby.shared.data; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.logging.*; import org.biomoby.registry.meta.Registry; import org.biomoby.shared.MobyDataType; @@ -21,6 +22,7 @@ public class MobyDataFloat extends MobyDataObject{ private BigDecimal value; + private static Logger logger = Logger.getLogger(MobyDataFloat.class.getName()); /** * Construct the object using a DOM fragment. @@ -102,7 +104,12 @@ public MobyDataFloat(String articleName, String stringNumber, Registry registry) throws NumberFormatException{ super(articleName, registry); setDataType(MobyDataType.getDataType(MobyTags.MOBYFLOAT, registry)); - value = new BigDecimal(stringNumber.trim()); + try{ + value = new BigDecimal(stringNumber.trim()); + } catch(Exception e){ + logger.log(Level.WARNING, "Could not parse '"+stringNumber+"' as a decimal number, using zero instead"); + value = BigDecimal.ZERO; + } } public MobyDataFloat(String stringNumber){ From gordonp at dev.open-bio.org Fri Feb 4 18:36:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 4 Feb 2011 13:36:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102041836.p14IaZ1S011991@dev.open-bio.org> gordonp Fri Feb 4 13:36:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv11955/src/main/ca/ucalgary/seahawk/util Modified Files: CloseTabIcon.java Added Files: CloseTabListener.java Log Message: Implemented 'Undo close tab' for Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/util CloseTabListener.java,NONE,1.1 CloseTabIcon.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2007/06/16 00:27:44 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/CloseTabIcon.java 2011/02/04 18:36:35 1.3 @@ -9,6 +9,7 @@ import java.awt.Graphics; import java.awt.Component; import java.net.URL; +import java.util.Vector; public class CloseTabIcon extends CombinedIcon{ public static final String CLOSE_TAB_ICON_RESOURCE = "ca/ucalgary/seahawk/resources/images/tabclose.gif"; @@ -17,6 +18,7 @@ private JTabbedPane tabbedPane = null; private Rectangle closeIconArea; + private Vector listeners; public CloseTabIcon() throws Exception{ this(new NullIcon()); @@ -34,6 +36,14 @@ super(getIcon(), otherIcon, spacerWidth, orient); } + public CloseTabIcon addCloseTabListener(CloseTabListener listener){ + if(listeners == null){ + listeners = new Vector(); + } + listeners.add(listener); + return this; + } + public Rectangle getCloseIconArea(){ return closeIconArea; } @@ -102,9 +112,18 @@ // Don't respond unless the close tab icon is actually showing return; } + Component tab = tabbedPane.getComponentAt(tabIndex); + if(listeners != null){ + for(CloseTabListener listener: listeners){ + listener.tabClosing(tab); + } + } + tabbedPane.remove(tabIndex); e.consume(); // so other tabs aren't closed by mistake tabbedPane.removeMouseListener(this); + tabbedPane = null; // so if the tab is added back at some point, the listen is readded in paintIcon() + } } } From gordonp at dev.open-bio.org Fri Feb 4 18:36:35 2011 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 4 Feb 2011 13:36:35 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102041836.p14IaZIT012013@dev.open-bio.org> gordonp Fri Feb 4 13:36:35 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11955/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java MobyContentGUI.java Log Message: Implemented 'Undo close tab' for Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.34,1.35 MobyContentGUI.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/03 21:50:50 1.34 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2011/02/04 18:36:35 1.35 @@ -243,12 +243,12 @@ tabbedPane.getTabCount() > 1){ try{ if(currentIcon == null){ - tabbedPane.setIconAt(tabIndex, new CloseTabIcon()); + tabbedPane.setIconAt(tabIndex, (new CloseTabIcon()).addCloseTabListener(getContentGUI())); return; } // If there's a real (non-close-tab) single icon, add the close tab icon if(!(currentIcon instanceof CloseTabIcon)){ - try{tabbedPane.setIconAt(tabIndex, new CloseTabIcon(currentIcon, TAB_ICON_SPACER));} + try{tabbedPane.setIconAt(tabIndex, (new CloseTabIcon(currentIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace();} tabbedPane.setDisabledIconAt(tabIndex, currentIcon); } @@ -257,7 +257,7 @@ e.printStackTrace(); } - } else{ + } else{ //Don't display X widget (closer) unless it's the active tab if(currentIcon != null && currentIcon instanceof CloseTabIcon){ tabbedPane.setIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); tabbedPane.setDisabledIconAt(tabIndex, ((CloseTabIcon) currentIcon).getSecondIcon()); @@ -982,7 +982,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(failedIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(failedIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, failedIcon);} } @@ -1005,7 +1005,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1 && tabbedPane.getTabCount() > 1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(loadedIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(loadedIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, loadedIcon);} } @@ -1476,7 +1476,7 @@ int tabIndex = tabbedPane.indexOfComponent(this); if(tabIndex > -1){ try{tabbedPane.setIconAt(tabIndex, - new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER));} + (new CloseTabIcon(hourglassIcon, TAB_ICON_SPACER)).addCloseTabListener(getContentGUI()));} catch(Exception e){e.printStackTrace(); tabbedPane.setIconAt(tabIndex, hourglassIcon);} } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/03 21:47:57 1.24 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2011/02/04 18:36:35 1.25 @@ -37,7 +37,7 @@ * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener{ +public class MobyContentGUI extends JFrame implements ActionListener, ComponentListener, KeyListener, MobyRequestEventHandler, MouseListener, FontSizeChangeListener, ArgumentListener, CloseTabListener{ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; @@ -63,9 +63,11 @@ public final static String DEFAULT_XSLT_CONVERTER_URL = "ca/ucalgary/seahawk/resources/moby2HTML.xsl"; public final static int MAX_TAB_NAME_LENGTH = 25; public final static String CLIPBOARD_TAB_TOOLTIP = "Right-click for clipboard options"; - public final static String TAB_TOOLTIP = "Right-click for tab options, or Ctrl-T for new tab"; + public final static String TAB_TOOLTIP = "Right-click tabs for options, or Ctrl-T for new tab"; public final static String CLOSE_TAB_OPTION = "Close This Tab"; public final static String CLOSE_OTHERS_OPTION = "Close Other Tabs"; + public final static String UNDO_CLOSE_TAB_OPTION = "Undo Close Tab"; + public final static String UNDO_CLOSE_TABS_OPTION = "Undo Close Tabs"; public final static String FILE_OPEN_OPTION = "Open File"; public final static String WEB_OPEN_OPTION = "Open Web Page"; @@ -96,6 +98,9 @@ private MobyContentHelpPane helpPane; private DataFlowRecorder dataRecorder; // used for workflow export, etc. private SeahawkOptionsGUI settingsGUI; + private java.util.List closedTabs; + private java.util.List closedTabTitles; + private java.util.List closedTabIcons; private boolean setup; private Map request2tab; @@ -231,7 +236,7 @@ // See OptionsTabbedPaneUI class definiton at the end of this file (overrides right-click behaviour) tabbedPane.setUI(new OptionsTabbedPaneUI(this)); tabbedPane.setSize(getContentSize()); - tabbedPane.setToolTipText("Hit to display a new tab"); + tabbedPane.setToolTipText(TAB_TOOLTIP); tabbedPane.addKeyListener(this); try{ @@ -249,6 +254,10 @@ tabbedPane.add(clipboard); clipboard.init(); + closedTabs = new ArrayList(); + closedTabTitles = new ArrayList(); + closedTabIcons = new ArrayList(); + settingsGUI = new SeahawkOptionsGUI(this, this); // params are frame owner, font change listener } @@ -1015,9 +1024,33 @@ // Don't close clipboard, if somehow we were asked... } else{ + closedTabs.add(tabbedPane.getComponentAt(activeTabIndex)); + closedTabTitles.add(tabbedPane.getTitleAt(activeTabIndex)); + closedTabIcons.add(tabbedPane.getIconAt(activeTabIndex)); tabbedPane.remove(activeTabIndex); } } + else if(UNDO_CLOSE_TAB_OPTION.equals(cmd)){ + Object lastClose = closedTabs.get(closedTabs.size()-1); + if(lastClose instanceof java.util.List){ // Closed more than one tab last time + java.util.List tabsList = (java.util.List) lastClose; + java.util.List tabTitlesList = (java.util.List) closedTabTitles.get(closedTabTitles.size()-1); + java.util.List tabIconsList = (java.util.List) closedTabIcons.get(closedTabIcons.size()-1); + for(int i = 0; i < tabsList.size(); i++){ + tabbedPane.addTab((String) tabTitlesList.get(i), + (Icon) tabIconsList.get(i), + (Component) tabsList.get(i)); + } + } + else{ // Single tab being unclosed + tabbedPane.addTab((String) closedTabTitles.get(closedTabTitles.size()-1), + (Icon) closedTabIcons.get(closedTabIcons.size()-1), + (Component) lastClose); + } + closedTabs.remove(closedTabs.size()-1); // no longer in close history + closedTabTitles.remove(closedTabTitles.size()-1); // no longer in close history + closedTabIcons.remove(closedTabIcons.size()-1); // no longer in close history + } else if(MobyContentClipboard.CLEAR_CLIPBOARD_OPTION.equals(cmd)){ clipboard.clearData(); } @@ -1027,13 +1060,32 @@ return; } Component keeper = tabbedPane.getComponentAt(activeTabIndex); + ArrayList otherTabs = new ArrayList(); + ArrayList otherTabTitles = new ArrayList(); + ArrayList otherTabIcons = new ArrayList(); for(int i = 0; i < tabbedPane.getTabCount(); i++){ Component comp = tabbedPane.getComponentAt(i); - if(comp != keeper && comp != clipboard){ + if(comp != keeper && comp != clipboard){ + // This is slightly lazy, we could actually destroy the component + // and save the tab's history rather than put the component in the history. + // If memory becomes an issue, this would be a place to start saving... + otherTabs.add(comp); + otherTabTitles.add(tabbedPane.getTitleAt(i)); + otherTabIcons.add(tabbedPane.getIconAt(i)); tabbedPane.remove(comp); i--; } } + if(otherTabs.size() == 1){ // Was it just one tab? + closedTabs.add(otherTabs.get(0)); + closedTabTitles.add(otherTabTitles.get(0)); + closedTabIcons.add(otherTabIcons.get(0)); + } + else{ + closedTabs.add(otherTabs); + closedTabTitles.add(otherTabTitles); + closedTabIcons.add(otherTabIcons); + } } else{ logger.warn(getClass().getName() + " ignoring unrecognized action command: " + cmd); @@ -1139,8 +1191,8 @@ tabOptions.add(item); } else if(tabbedPane.getTabCount() > 1){ - item = new JMenuItem(MobyContentGUI.CLOSE_TAB_OPTION); - item.setActionCommand(MobyContentGUI.CLOSE_TAB_OPTION); + item = new JMenuItem(CLOSE_TAB_OPTION); + item.setActionCommand(CLOSE_TAB_OPTION); item.addActionListener(gui); tabOptions.add(item); } @@ -1148,13 +1200,29 @@ if(tabbedPane.getComponentAt(index) == clipboard && tabbedPane.getTabCount() > 1 || tabbedPane.getTabCount() > 2 || tabbedPane.indexOfComponent(clipboard) == -1 && tabbedPane.getTabCount() >= 2){ - item = new JMenuItem(MobyContentGUI.CLOSE_OTHERS_OPTION); - item.setActionCommand(MobyContentGUI.CLOSE_OTHERS_OPTION); + item = new JMenuItem(CLOSE_OTHERS_OPTION); + item.setActionCommand(CLOSE_OTHERS_OPTION); item.addActionListener(gui); tabOptions.add(item); } - - tabOptions.show(gui, e.getX(), e.getY()); + item = new JMenuItem(UNDO_CLOSE_TAB_OPTION); + item.setActionCommand(UNDO_CLOSE_TAB_OPTION); + if(closedTabs.isEmpty()){ + item.setEnabled(false); // show just so they know this is an option later... + } + else{ + item.addActionListener(gui); + // more than one tab closed last time + if(closedTabs.get(closedTabs.size()-1) instanceof java.util.List){ + System.err.println("Set unclose tabS"); + item.setText(UNDO_CLOSE_TABS_OPTION); + } + // else nothing more needs to be done, the default menu + // label for the task to reopen just one tab + } + tabOptions.add(item); + + tabOptions.show(gui, e.getX()+7, e.getY()+12); } else{ // Otherwise do whatever this handler normally does @@ -1342,4 +1410,11 @@ ((MobyContentPane) tabbedPane.getComponentAt(i)).setFontSize(fontSize); } } + + public void tabClosing(Component closingTab){ + closedTabs.add(closingTab); + int closingTabIndex = tabbedPane.indexOfComponent(closingTab); + closedTabTitles.add(tabbedPane.getTitleAt(closingTabIndex)); + closedTabIcons.add(tabbedPane.getIconAt(closingTabIndex)); + } } From drepchevski at dev.open-bio.org Thu Feb 24 13:35:40 2011 From: drepchevski at dev.open-bio.org (Dmitry Repchevski) Date: Thu, 24 Feb 2011 08:35:40 -0500 Subject: [MOBY-guts] biomoby commit Message-ID: <201102241335.p1ODZe05000346@dev.open-bio.org> drepchevski Thu Feb 24 08:35:40 EST 2011 Update of /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache In directory dev.open-bio.org:/tmp/cvs-serv310 Modified Files: CacheConfig.java Log Message: Added a posibility to save a cache without XML Document event generation. moby-live/Java/src/main/org/inb/biomoby/central/cache CacheConfig.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache/CacheConfig.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/inb/biomoby/central/cache/CacheConfig.java 2009/12/16 15:24:36 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/inb/biomoby/central/cache/CacheConfig.java 2011/02/24 13:35:39 1.2 @@ -151,15 +151,21 @@ } } + public void save(List entities, Writer writer) throws Exception + { + save(entities, writer, true); + } + /** * Generic method to save BioMoby entities to the provided writer * * @param - the entity type to save * @param entities - the list of entities to be saved * @param writer - the writer where entities are saved + * @param isFragment - whether or not document level events will be generated * @throws Exception */ - public void save(List entities, Writer writer) throws Exception + public void save(List entities, Writer writer, boolean isFragment) throws Exception { CacheListWrapper wrapper = new CacheListWrapper(entities); @@ -171,6 +177,7 @@ Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.valueOf(isFragment)); BufferedWriter out = new BufferedWriter(writer);