You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:38:21 UTC

[13/17] incubator-taverna-plugin-bioinformatics git commit: Revert "temporarily empty repository"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigController.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigController.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigController.java
new file mode 100644
index 0000000..450b2ba
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigController.java
@@ -0,0 +1,388 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: QueryConfigController.java,v $
+ * Revision           $Revision: 1.4 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/12/13 11:38:57 $
+ *               by   $Author: davidwithers $
+ * Created on 27-Mar-2006
+ *****************************************************************/
+package org.biomart.martservice.config;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.biomart.martservice.MartQuery;
+import org.biomart.martservice.config.event.QueryComponentEvent;
+import org.biomart.martservice.config.event.QueryComponentListener;
+import org.biomart.martservice.config.ui.QueryComponent;
+import org.biomart.martservice.query.Attribute;
+import org.biomart.martservice.query.Dataset;
+import org.biomart.martservice.query.Filter;
+import org.biomart.martservice.query.Query;
+import org.biomart.martservice.query.QueryListener;
+import org.ensembl.mart.lib.config.FilterDescription;
+
+/**
+ * Controls the interaction between graphical <code>QueryComponent</code>s
+ * and <code>Query</code>s.
+ * 
+ * @author David Withers
+ */
+public class QueryConfigController {
+	private static Logger logger = Logger
+			.getLogger("org.biomart.martservice.config");
+
+	private static QueryListener queryListener = new QueryHandler();
+
+	private MartQuery martQuery;
+
+	private Query query;
+
+	private Map<String, Attribute> initialAttributeMap = new HashMap<String, Attribute>();
+
+	private Map<String, Filter> initialFilterMap = new HashMap<String, Filter>();
+
+	private Map<String, Attribute> nameToAttributeMap = new HashMap<String, Attribute>();
+
+	private Map	<String, Filter> nameToFilterMap = new HashMap<String, Filter>();
+
+	private QueryComponentHandler queryComponenHandler = new QueryComponentHandler();
+
+	/**
+	 * Constructs an instance of a <code>QueryConfigController</code>.
+	 * 
+	 * @param martQuery
+	 */
+	public QueryConfigController(MartQuery martQuery) {
+		this.martQuery = martQuery;
+		query = martQuery.getQuery();
+		query.addQueryListener(queryListener);
+
+		for (Attribute attribute : query.getAttributes()) {
+			initialAttributeMap.put(attribute.getQualifiedName(), attribute);
+			nameToAttributeMap.put(attribute.getQualifiedName(), attribute);
+		}
+		for (Filter filter : query.getFilters()) {
+			initialFilterMap.put(filter.getQualifiedName(), filter);
+			nameToFilterMap.put(filter.getQualifiedName(), filter);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Object#finalize()
+	 */
+	protected void finalize() throws Throwable {
+		super.finalize();
+		query.removeQueryListener(queryListener);
+	}
+
+	/**
+	 * Returns the <code>MartQuery</code> under control.
+	 * 
+	 * @return the <code>MartQuery</code> under control
+	 */
+	public MartQuery getMartQuery() {
+		return martQuery;
+	}
+
+	/**
+	 * Removes a <code>QueryComponent</code> from the controller.
+	 * 
+	 * @param queryComponent
+	 *            the <code>QueryComponent</code> to remove
+	 */
+	public void deregister(QueryComponent queryComponent) {
+		queryComponent.removeQueryComponentListener(queryComponenHandler);
+	}
+
+	/**
+	 * Registers a <code>QueryComponent</code> with the controller.
+	 * 
+	 * If the <code>Query</code> already contains an <code>Attribute</code>
+	 * or <code>Filter</code> with the corresponding name the
+	 * <code>QueryComponent</code> is set as selected.
+	 * 
+	 * @param queryComponent
+	 *            the <code>QueryComponent</code> to register
+	 */
+	public void register(QueryComponent queryComponent) {
+		if (queryComponent.getType() == QueryComponent.ATTRIBUTE) {
+			getAttribute(queryComponent);
+
+			// if query already contains attribute then set the component as
+			// selected
+			if (initialAttributeMap.containsKey(queryComponent
+					.getQualifiedName())) {
+				queryComponent.setSelected(true);
+			}
+
+		} else if (queryComponent.getType() == QueryComponent.FILTER) {
+			Filter filter = getFilter(queryComponent);
+
+			String value = filter.getValue();
+			if (value != null) {
+				if (filter.isBoolean()) {
+					if ("excluded".equals(value)) {
+						queryComponent.setValue("excluded");
+					} else {
+						queryComponent.setValue("only");
+					}
+				} else {
+					queryComponent.setValue(value);
+				}
+			}
+
+			if (initialFilterMap.containsKey(queryComponent.getQualifiedName())) {
+				queryComponent.setSelected(true);
+			}
+		} else if (queryComponent.getType() == QueryComponent.LINK) {
+			Iterator<String> linkedDatasets = martQuery.getLinkedDatasets().iterator();
+			// only one linked dataset allowed for now
+			if (linkedDatasets.hasNext()) {
+				String dataset = linkedDatasets.next();
+				queryComponent.setName(dataset);
+				queryComponent.setValue(martQuery.getLink(dataset));
+			}
+		}
+
+		queryComponent.addQueryComponentListener(queryComponenHandler);
+
+	}
+
+	/**
+	 * Returns the <code>Attribute</code> mapped to the
+	 * <code>QueryComponent</code>. If no <code>Attribute</code> is mapped
+	 * a new <code>Attribute</code> is created and added to the map.
+	 * 
+	 * @param queryComponent
+	 * @return
+	 */
+	private Attribute getAttribute(QueryComponent queryComponent) {
+		String internalName = queryComponent.getQualifiedName();
+		Attribute attribute = null;
+		if (nameToAttributeMap.containsKey(internalName)) {
+			attribute = (Attribute) nameToAttributeMap.get(internalName);
+		} else {
+			attribute = new Attribute(queryComponent.getName());
+			if (queryComponent.getValue() != null) {
+				attribute.setAttributes(queryComponent.getValue());
+			}
+			nameToAttributeMap.put(internalName, attribute);
+		}
+		return attribute;
+	}
+
+	/**
+	 * Returns the <code>Filter</code> mapped to the
+	 * <code>QueryComponent</code>. If no <code>Filter</code> is mapped a
+	 * new <code>Filter</code> is created and added to the map.
+	 * 
+	 * @param queryComponent
+	 * @return
+	 */
+	private Filter getFilter(QueryComponent queryComponent) {
+		FilterDescription filterDescription = (FilterDescription) queryComponent
+				.getConfigObject();
+		String internalName = queryComponent.getQualifiedName();
+		Filter filter;
+		if (nameToFilterMap.containsKey(internalName)) {
+			filter = (Filter) nameToFilterMap.get(internalName);
+		} else {
+			if ("boolean".equals(filterDescription.getType())) {
+				if ("excluded".equals(queryComponent.getValue())) {
+					filter = new Filter(queryComponent.getName(), "excluded", true);
+				} else {
+					filter = new Filter(queryComponent.getName(), "only", true);
+				}
+			} else {
+				String defaultValue = filterDescription.getDefaultValue();
+				if (defaultValue == null
+						&& !QueryConfigUtils.isNestedList(filterDescription)) {
+					// if there is no default value but there are options then
+					// choose the first option as the filter value
+//					Option[] options = filterDescription.getOptions();
+//					if (options != null && options.length > 0) {
+//						defaultValue = options[0].getValue();
+//					} else {
+						defaultValue = queryComponent.getValue();
+//					}
+				}
+				filter = new Filter(queryComponent.getName(), defaultValue);
+				if ("id_list".equals(filterDescription.getType())) {
+					filter.setList(true);
+				}
+			}
+			nameToFilterMap.put(internalName, filter);
+		}
+		return filter;
+	}
+
+	class QueryComponentHandler implements QueryComponentListener {
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#attributeAdded(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+		 */
+		public void attributeAdded(QueryComponentEvent event) {
+			Attribute attribute = (Attribute) nameToAttributeMap.get(event
+					.getDataset().getName()
+					+ "." + event.getName());
+			synchronized (query) {
+				martQuery.addAttribute(event.getDataset().getName(), attribute);
+			}
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#attributeRemoved(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+		 */
+		public void attributeRemoved(QueryComponentEvent event) {
+			Attribute attribute = (Attribute) nameToAttributeMap.get(event
+					.getDataset().getName()
+					+ "." + event.getName());
+			synchronized (query) {
+				martQuery.removeAttribute(attribute);
+			}
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterAdded(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+		 */
+		public void filterAdded(QueryComponentEvent event) {
+			Filter filter = (Filter) nameToFilterMap.get(event.getDataset()
+					.getName()
+					+ "." + event.getName());
+			synchronized (query) {
+				martQuery.addFilter(event.getDataset().getName(), filter);
+			}
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterRemoved(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+		 */
+		public void filterRemoved(QueryComponentEvent event) {
+			Filter filter = (Filter) nameToFilterMap.get(event.getDataset()
+					.getName()
+					+ "." + event.getName());
+			synchronized (query) {
+				martQuery.removeFilter(filter);
+			}
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterChanged(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+		 */
+		public void filterChanged(QueryComponentEvent event) {
+			Filter filter = (Filter) nameToFilterMap.get(event.getDataset()
+					.getName()
+					+ "." + event.getName());
+			synchronized (query) {
+				filter.setValue(event.getValue());
+			}
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.biomart.martservice.config.event.QueryComponentListener#linkAdded(org.biomart.martservice.config.event.QueryComponentEvent)
+		 */
+		public void linkAdded(QueryComponentEvent event) {
+			martQuery.addLinkedDataset(event.getName(), event.getValue());
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.biomart.martservice.config.event.QueryComponentListener#linkRemoved(org.biomart.martservice.config.event.QueryComponentEvent)
+		 */
+		public void linkRemoved(QueryComponentEvent event) {
+			martQuery.removeLinkedDataset(event.getName());
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.biomart.martservice.config.QueryComponentListener#linkChanged(org.biomart.martservice.config.QueryComponentEvent)
+		 */
+		public void linkChanged(QueryComponentEvent event) {
+			martQuery.changeLinkedDataset(event.getName(), event.getValue());
+		}
+
+	}
+
+	static class QueryHandler implements QueryListener {
+
+		public void attributeAdded(Attribute attribute, Dataset dataset) {
+			logger.info("Attribute Added " + attribute.getQualifiedName());
+		}
+
+		public void attributeRemoved(Attribute attribute, Dataset dataset) {
+			logger.info("Attribute Removed " + attribute.getQualifiedName());
+		}
+
+		public void filterAdded(Filter filter, Dataset dataset) {
+			logger.info("Filter Added " + filter.getQualifiedName() + " "
+					+ filter.getValue());
+		}
+
+		public void filterRemoved(Filter filter, Dataset dataset) {
+			logger.info("Filter Removed " + filter.getQualifiedName());
+		}
+
+		public void filterChanged(Filter filter, Dataset dataset) {
+			logger.info("Filter Changed " + filter.getQualifiedName() + " "
+					+ filter.getValue());
+		}
+
+		public void formatterAdded(String formatter) {
+			logger.info("Formatter Added " + formatter);
+		}
+
+		public void formatterRemoved(String formatter) {
+			logger.info("Formatter Removed " + formatter);
+		}
+
+		public void formatterChanged(String formatter) {
+			logger.info("Formatter Changed to " + formatter);
+		}
+
+	}
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigUtils.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigUtils.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigUtils.java
new file mode 100644
index 0000000..2bc7d71
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/QueryConfigUtils.java
@@ -0,0 +1,598 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: QueryConfigUtils.java,v $
+ * Revision           $Revision: 1.3 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/12/13 11:38:57 $
+ *               by   $Author: davidwithers $
+ * Created on 30-Mar-2006
+ *****************************************************************/
+package org.biomart.martservice.config;
+
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.border.EtchedBorder;
+
+import org.biomart.martservice.MartDataset;
+import org.biomart.martservice.MartService;
+import org.biomart.martservice.MartServiceException;
+import org.biomart.martservice.config.ui.QueryComponent;
+import org.ensembl.mart.lib.config.AttributeDescription;
+import org.ensembl.mart.lib.config.AttributePage;
+import org.ensembl.mart.lib.config.BaseNamedConfigurationObject;
+import org.ensembl.mart.lib.config.DatasetConfig;
+import org.ensembl.mart.lib.config.FilterDescription;
+import org.ensembl.mart.lib.config.Option;
+
+/**
+ * Utility class for configuration objects.
+ * 
+ * @author David Withers
+ */
+public abstract class QueryConfigUtils {
+	public static final String LINE_END = System.getProperty("line.separator");
+
+	private static int DISPLAY_WIDTH = 35;
+	
+	public static String splitSentence(String sentence) {
+		return splitSentence(sentence, DISPLAY_WIDTH);
+	}
+
+	public static String splitSentence(String sentence, int limit) {
+		StringBuffer sb = new StringBuffer();
+		sb.append("<html>");
+
+		int width = 0;
+		String[] split = sentence.split(" ");
+		for (int i = 0; i < split.length; i++) {
+			if (width == 0) {
+				sb.append(split[i]);
+				width += split[i].length();
+			} else if (width + split[i].length() + 1 > limit) {
+				sb.append("<br>");
+				sb.append(split[i]);
+				width = split[i].length();
+			} else {
+				sb.append(" ");
+				sb.append(split[i]);
+				width += split[i].length() + 1;
+			}
+		}
+
+		return sb.toString();
+	}
+
+	/**
+	 * Returns name truncated to DISPLAY_WIDTH.
+	 * 
+	 * @param name
+	 * @return
+	 */
+	public static String truncateName(String name) {
+		if (name.length() > DISPLAY_WIDTH) {
+			return name.substring(0, DISPLAY_WIDTH);
+		} else {
+			return name;
+		}
+	}
+
+	public static List<String> getOutputFormats(AttributePage attributePage) {
+		List<String> outputFormats = new ArrayList<String>();
+		
+		String[] formats = attributePage.getOutFormats().split(",");
+		for (int i = 0; i < formats.length; i++) {
+			outputFormats.add(formats[i]);
+		}
+		return outputFormats;
+	}
+	
+	/**
+	 * Returns true if filterDescription has no options.
+	 * 
+	 * @param filterDescription
+	 * @return true if filterDescription has no options
+	 */
+	public static boolean isList(FilterDescription filterDescription) {
+		return filterDescription.getOptions().length > 0;
+	}
+
+	/**
+	 * Returns true if filterDescription has options and at least one option
+	 * also has options.
+	 * 
+	 * @param filterDescription
+	 * @return true if filterDescription has options and at least one option
+	 *         also has options
+	 */
+	public static boolean isNestedList(FilterDescription filterDescription) {
+		Option[] options = filterDescription.getOptions();
+		for (int i = 0; i < options.length; i++) {
+			if (options[i].getOptions().length > 0) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Returns true if filterDescription has options and the first option has a
+	 * type equal to "boolean".
+	 * 
+	 * @param filterDescription
+	 * @return true if filterDescription has options and the first option has a
+	 *         type equal to "boolean"
+	 */
+	public static boolean isBooleanList(FilterDescription filterDescription) {
+		Option[] options = filterDescription.getOptions();
+		if (options.length > 0) {
+			if ("boolean".equals(options[0].getType())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Returns true if filterDescription has options and the first option has a
+	 * value equal to null.
+	 * 
+	 * @param filterDescription
+	 * @return true if filterDescription has options and the first option has a
+	 *         value equal to null
+	 */
+	public static boolean isIdList(FilterDescription filterDescription) {
+		Option[] options = filterDescription.getOptions();
+		if (options.length > 0) {
+			if (options[0].getValue() == null) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public static Option[] fixOptionLength(Option[] options, int length) {
+		if (options.length > length) {
+			Option[] firstOptions = new Option[length];
+			Option[] otherOptions = new Option[options.length - (length - 1)];
+			for (int i = 0; i < length - 1; i++) {
+				firstOptions[i] = options[i];
+				fixOptionLength(options[i].getOptions(), length);
+			}
+			for (int i = length - 1; i < options.length; i++) {
+				otherOptions[i - (length - 1)] = options[i];
+			}
+			Option newOption = new Option();
+			newOption.setInternalName("more");
+			newOption.setDisplayName("more");
+			newOption.addOptions(fixOptionLength(otherOptions, length));
+			firstOptions[length - 1] = newOption;
+			return firstOptions;
+		} else {
+			return options;
+		}
+	}
+
+	public static Component getOptionButton(
+			FilterDescription filterDescription, QueryComponent queryComponent) {
+		JMenuBar menuBar = new JMenuBar();
+		menuBar.setBorder(new EtchedBorder());
+		JMenu menu = new JMenu("browse");
+		menu.setFont(menu.getFont().deriveFont(Font.PLAIN));
+		menuBar.add(menu);
+		Option[] options = fixOptionLength(filterDescription.getOptions(), 20);
+		for (int i = 0; i < options.length; i++) {
+			menu.add(getMenuItem(options[i], queryComponent));
+		}
+		return menuBar;
+	}
+
+	public static JMenuItem getMenuItem(final Option option,
+			final QueryComponent queryComponent) {
+		JMenuItem menuItem;
+
+		Option[] options = option.getOptions();
+		if (options.length > 0) {
+			JMenu menu = new JMenu(option.getDisplayName());
+			menu.setFont(menu.getFont().deriveFont(Font.PLAIN));
+			for (int i = 0; i < options.length; i++) {
+				menu.add(getMenuItem(options[i], queryComponent));
+			}
+			menuItem = menu;
+		} else {
+			menuItem = new JMenuItem(option.getDisplayName());
+			menuItem.setFont(menuItem.getFont().deriveFont(Font.PLAIN));
+			menuItem.addActionListener(new ActionListener() {
+
+				public void actionPerformed(ActionEvent e) {
+					queryComponent.setValue(option.getValue());
+				}
+
+			});
+		}
+
+		return menuItem;
+	}
+
+	/**
+	 * Returns the dataset referenced by a configuration object or null if the
+	 * configuration object does not reference a dataset.
+	 * 
+	 * @param martService
+	 *            the MartService to fetch the referenced dataset from
+	 * @param referencedFromDataset
+	 *            the datset containing the configuration object
+	 * @param bnco
+	 *            the configuration object
+	 * @return the dataset referenced by a configuration object or null if the
+	 *         configuration object does not reference a dataset.
+	 * @throws MartServiceException
+	 *             if and exception occurs while fetching the dataset
+	 */
+	public static MartDataset getReferencedDataset(MartService martService,
+			MartDataset referencedFromDataset,
+			BaseNamedConfigurationObject bnco, String softwareVersion)
+			throws MartServiceException {
+		if ("0.5".equals(softwareVersion)) {
+			String pointerDataset = bnco.getAttribute("pointerDataset");
+			if (pointerDataset != null) {
+				return martService.getDataset(referencedFromDataset
+						.getVirtualSchema(), pointerDataset);
+			} else {
+				return null;
+			}
+		} else {
+			String[] splitName = bnco.getInternalName().split("\\.");
+			if (splitName.length > 1) {
+				return martService.getDataset(referencedFromDataset
+						.getVirtualSchema(), splitName[0]);
+			} else {
+				return null;
+			}
+		}
+	}
+
+	/**
+	 * Returns the filter description referenced by the filter description.
+	 * 
+	 * @param martService
+	 *            the MartService to fetch the referenced filter description
+	 *            from
+	 * @param dataset
+	 *            the datset containing the referenced filter description
+	 * @param filterDescription
+	 *            the filter description
+	 * @return the filter description referenced by the filter description
+	 * @throws MartServiceException
+	 *             if and exception occurs while fetching the filter description
+	 */
+	public static FilterDescription getReferencedFilterDescription(
+			MartService martService, MartDataset dataset,
+			FilterDescription filterDescription, String softwareVersion)
+			throws MartServiceException {
+		if ("0.5".equals(softwareVersion)) {
+			String pointerFilter = filterDescription
+					.getAttribute("pointerFilter");
+			if (pointerFilter != null) {
+				return getReferencedFilterDescription(martService, dataset,
+						pointerFilter);
+			} else {
+				return null;
+			}
+		} else {
+			String[] splitName = filterDescription.getInternalName().split(
+					"\\.");
+			FilterDescription ref = getReferencedFilterDescription(martService,
+					dataset, splitName[1]);
+			return ref;
+		}
+	}
+
+	/**
+	 * Returns the filter description referenced by the attribute description.
+	 * 
+	 * @param martService
+	 *            the MartService to fetch the referenced filter description
+	 *            from
+	 * @param dataset
+	 *            the datset containing the referenced filter description
+	 * @param attributeDescription
+	 *            the attribute description
+	 * @return the filter description referenced by the attribute description
+	 * @throws MartServiceException
+	 *             if and exception occurs while fetching the filter description
+	 */
+	public static FilterDescription getReferencedFilterDescription(
+			MartService martService, MartDataset dataset,
+			AttributeDescription attributeDescription, String softwareVersion)
+			throws MartServiceException {
+		if ("0.5".equals(softwareVersion)) {
+			String pointerFilter = attributeDescription
+					.getAttribute("pointerFilter");
+			if (pointerFilter != null) {
+				return getReferencedFilterDescription(martService, dataset,
+						pointerFilter);
+			} else {
+				return null;
+			}
+		} else {
+			String[] splitName = attributeDescription.getInternalName().split(
+					"\\.");
+			return getReferencedFilterDescription(martService, dataset,
+					splitName[2]);
+		}
+	}
+
+	public static FilterDescription getReferencedFilterDescription(
+			MartService martService, MartDataset dataset, String filterName)
+			throws MartServiceException {
+		FilterDescription referencedFilter = null;
+		DatasetConfig datasetConfig = martService.getDatasetConfig(dataset);
+		List<FilterDescription> filterDescriptions = datasetConfig.getAllFilterDescriptions();
+		for (FilterDescription filterDescription : filterDescriptions) {
+			if (filterName.equals(filterDescription.getInternalName())) {
+				if (!"true".equals(filterDescription.getHidden())) {
+					referencedFilter = filterDescription;
+					break;
+				}
+			}
+		}
+		return referencedFilter;
+	}
+
+	public static FilterDescription getReferencedFilterDescription(
+			AttributeDescription attributeDescription, String softwareVersion) {
+		FilterDescription filterDescription = new FilterDescription();
+		if ("0.5".equals(softwareVersion)) {
+			filterDescription.setInternalName(attributeDescription
+					.getInternalName());
+			filterDescription.setAttribute(attributeDescription
+					.getAttribute("pointerDataset"));
+			filterDescription.setAttribute(attributeDescription
+					.getAttribute("pointerFilter"));
+			filterDescription.setAttribute(attributeDescription
+					.getAttribute("pointerInterface"));
+		} else {
+			String[] splitName = attributeDescription.getInternalName().split(
+					"\\.");
+			filterDescription
+					.setInternalName(splitName[0] + "." + splitName[2]);
+		}
+		return filterDescription;
+	}
+
+	public static AttributeDescription getReferencedAttributeDescription(
+			MartService martService, MartDataset dataset,
+			AttributeDescription attributeDescription, String softwareVersion)
+			throws MartServiceException {
+		AttributeDescription referencedAttributeDescription = null;
+		String attributeName = null;
+		if ("0.5".equals(softwareVersion)) {
+			attributeName = attributeDescription
+					.getAttribute("pointerAttribute");
+		} else {
+			String internalName = attributeDescription.getInternalName();
+			String[] splitName = internalName.split("\\.");
+			if (splitName.length == 2) {
+				attributeName = splitName[1];
+			}
+		}
+		if (attributeName != null) {
+			DatasetConfig datasetConfig = martService.getDatasetConfig(dataset);
+			if (datasetConfig.containsAttributeDescription(attributeName)) {
+				referencedAttributeDescription = datasetConfig
+						.getAttributeDescriptionByInternalName(attributeName);
+			}
+		}
+		return referencedAttributeDescription;
+	}
+
+	/**
+	 * Returns true if the internal name of the configuration object contains a
+	 * '.' character.
+	 * 
+	 * @param bnco
+	 *            the configuration object
+	 * @return true if the internal name of the configuration object contains a
+	 *         '.' character
+	 */
+	public static boolean isReference(BaseNamedConfigurationObject bnco,
+			String softwareVersion) {
+		if ("0.5".equals(softwareVersion)) {
+			return bnco.getAttribute("pointerDataset") != null 
+			&& (bnco.getAttribute("pointerAttribute") != null || bnco.getAttribute("pointerFilter") != null);
+		} else {
+			return bnco.getInternalName().indexOf(".") != -1;
+		}
+	}
+
+	/**
+	 * Returns true if the internal name of the AttributeDescription has the
+	 * format "[datasetName].[attributeName]".
+	 * 
+	 * @param attributeDescription
+	 * @return true if the internal name of the AttributeDescription has the
+	 *         format "[datasetName].[attributeName]"
+	 */
+	public static boolean isAttributeReference(
+			AttributeDescription attributeDescription, String softwareVersion) {
+		if ("0.5".equals(softwareVersion)) {
+			return attributeDescription.getAttribute("pointerAttribute") != null;
+		} else {
+			return attributeDescription.getInternalName().split("\\.").length == 2;
+		}
+	}
+
+	/**
+	 * Returns true if the internal name of the AttributeDescription has the
+	 * format "[datasetName].filter.[filterName]".
+	 * 
+	 * @param attributeDescription
+	 * @return true if the internal name of the AttributeDescription has the
+	 *         format "[datasetName].filter.[filterName]"
+	 */
+	public static boolean isFilterReference(
+			AttributeDescription attributeDescription, String softwareVersion) {
+		if ("0.5".equals(softwareVersion)) {
+			return attributeDescription.getAttribute("pointerFilter") != null;
+		} else {
+			return attributeDescription.getInternalName().split("\\.").length == 3;
+		}
+	}
+
+//	/**
+//	 * Returns the qualified name of the AttributeDescription in the format
+//	 * "[datasetName].[attributeName]".
+//	 * 
+//	 * @param dataset
+//	 * @param attributeDescription
+//	 * @return true if the qualified name of the AttributeDescription in the
+//	 *         format "[datasetName].[attributeName]"
+//	 */
+//	public static String getQualifiedName(MartDataset dataset,
+//			AttributeDescription attributeDescription, String softwareVersion) {
+//		if ("0.5".equals(softwareVersion)) {
+//			if (isAttributeReference(attributeDescription, softwareVersion)) {
+//				return attributeDescription.getAttribute("pointerDataset")
+//						+ "."
+//						+ attributeDescription.getAttribute("pointerAttribute");
+//			} else if (isFilterReference(attributeDescription, softwareVersion)) {
+//				return attributeDescription.getAttribute("pointerDataset")
+//						+ "."
+//						+ attributeDescription.getAttribute("pointerFilter");
+//			} else {
+//				return dataset.getName()
+//						+ attributeDescription.getInternalName();
+//			}
+//		} else {
+//			if (isAttributeReference(attributeDescription, softwareVersion)) {
+//				return attributeDescription.getInternalName();
+//			} else if (isFilterReference(attributeDescription, softwareVersion)) {
+//				String[] splitName = attributeDescription.getInternalName()
+//						.split("\\.");
+//				return splitName[0] + "." + splitName[2];
+//			} else {
+//				return dataset.getName()
+//						+ attributeDescription.getInternalName();
+//			}
+//		}
+//	}
+
+	public static String csvToValuePerLine(String csv) {
+		StringBuffer list = new StringBuffer();
+
+		String[] splitString = csv.split(",");
+		for (int i = 0; i < splitString.length; i++) {
+			if (i > 0) {
+				list.append(LINE_END);
+			}
+			list.append(splitString[i].trim());
+		}
+
+		return list.toString();
+	}
+
+	public static String valuePerLineToCsv(String list) {
+		return list.trim().replaceAll("\\s", ",");
+	}
+
+	public static List<String> csvToList(String csv) {
+		List<String> list = new ArrayList<String>();
+
+		String[] splitString = csv.split(",");
+		for (int i = 0; i < splitString.length; i++) {
+			list.add(splitString[i].trim());
+		}
+
+		return list;
+	}
+
+	/**
+	 * Converts a List of objects to a comma separated string of the objects'
+	 * string representations in the order given by the List's iterator. For
+	 * example:
+	 * 
+	 * <blockquote>
+	 * 
+	 * <pre>
+	 *          List list = Arrays.toList(new String[] {&quot;one&quot;, &quot;two&quot;, &quot;three&quot;};
+	 *          System.out.println(listToCsv(list));
+	 * </pre>
+	 * 
+	 * </blockquote> would return the string "one,two,three".
+	 * 
+	 * @param list
+	 * @return a List of objects to a comma separated string of the object's
+	 *         string representations
+	 */
+	public static String listToCsv(List<?> list) {
+		StringBuffer sb = new StringBuffer();
+		for (Iterator<?> iter = list.iterator(); iter.hasNext();) {
+			sb.append(iter.next().toString());
+			if (iter.hasNext()) {
+				sb.append(',');
+			}
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * Returns true iff the 'display' or 'hidden' value of the configuration
+	 * object is not "true".
+	 * 
+	 * @param bnco
+	 *            the configuration object
+	 * @return true iff the 'display' or 'hidden' value of configuration object
+	 *         is "true"
+	 */
+	public static boolean display(BaseNamedConfigurationObject bnco) {
+		boolean display = true;
+		String hideDisplay = bnco.getDisplay();
+		if (hideDisplay != null) {
+			if (hideDisplay.equals("true")) {
+				display = false;
+			}
+		} else {
+			String hidden = bnco.getHidden();
+			if (hidden != null) {
+				if (hidden.equals("true")) {
+					display = false;
+				}
+			}
+		}
+		return display;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentAdapter.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentAdapter.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentAdapter.java
new file mode 100644
index 0000000..201cc1d
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentAdapter.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: QueryComponentAdapter.java,v $
+ * Revision           $Revision: 1.1 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/01/31 14:12:06 $
+ *               by   $Author: davidwithers $
+ * Created on 04-Apr-2006
+ *****************************************************************/
+package org.biomart.martservice.config.event;
+
+/**
+ * An abstract adapter class for receiving <code>QueryComponent</code> events.
+ * The methods in this class are empty. This class exists as convenience for
+ * creating listener objects.
+ * 
+ * @author David Withers
+ */
+public class QueryComponentAdapter implements QueryComponentListener {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#attributeAdded(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+	 */
+	public void attributeAdded(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#attributeRemoved(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+	 */
+	public void attributeRemoved(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterAdded(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+	 */
+	public void filterAdded(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterRemoved(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+	 */
+	public void filterRemoved(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentListener#filterChanged(org.embl.ebi.escience.scuflworkers.biomartservice.config.QueryComponentEvent)
+	 */
+	public void filterChanged(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.biomart.martservice.config.event.QueryComponentListener#linkAdded(org.biomart.martservice.config.event.QueryComponentEvent)
+	 */
+	public void linkAdded(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.biomart.martservice.config.event.QueryComponentListener#linkRemoved(org.biomart.martservice.config.event.QueryComponentEvent)
+	 */
+	public void linkRemoved(QueryComponentEvent event) {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.biomart.martservice.config.QueryComponentListener#linkChanged(org.biomart.martservice.config.QueryComponentEvent)
+	 */
+	public void linkChanged(QueryComponentEvent event) {
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentEvent.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentEvent.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentEvent.java
new file mode 100644
index 0000000..6fc5d18
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentEvent.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: QueryComponentEvent.java,v $
+ * Revision           $Revision: 1.1 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/01/31 14:12:06 $
+ *               by   $Author: davidwithers $
+ * Created on 03-Apr-2006
+ *****************************************************************/
+package org.biomart.martservice.config.event;
+
+import java.util.EventObject;
+
+import org.biomart.martservice.MartDataset;
+
+/**
+ * An event which indicates that a <code>QueryComponent</code> has been
+ * selected, deselected or its value has been modified.
+ * 
+ * @author David Withers
+ */
+public class QueryComponentEvent extends EventObject {
+	private static final long serialVersionUID = -7576317475836030298L;
+
+	private String name;
+
+	private MartDataset dataset;
+
+	private String value;
+
+	/**
+	 * Constructs a new <code>QueryComponentEvent</code> instance.
+	 * 
+	 * @param source
+	 *            the source of the event
+	 * @param name
+	 *            the name of the attribute or filter affected by this event
+	 * @param dataset
+	 *            the dataset containing the attribute or filter affected by
+	 *            this event
+	 */
+	public QueryComponentEvent(Object source, String name, MartDataset dataset) {
+		this(source, name, dataset, null);
+	}
+
+	/**
+	 * Constructs a new <code>QueryComponentEvent</code> instance.
+	 * 
+	 * @param source
+	 *            the source of the event
+	 * @param name
+	 *            the name of the attribute or filter affected by this event
+	 * @param dataset
+	 *            the dataset containing the attribute or filter affected by
+	 *            this event
+	 * @param value
+	 *            the value of the filter affected by this event
+	 */
+	public QueryComponentEvent(Object source, String name, MartDataset dataset,
+			String value) {
+		super(source);
+		this.name = name;
+		this.dataset = dataset;
+		this.value = value;
+	}
+
+	/**
+	 * Returns the name of the attribute or filter affected by this event.
+	 * 
+	 * @return the name of the attribute or filter affected by this event.
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Returns the dataset containing the attribute or filter affected by this
+	 * event.
+	 * 
+	 * @return the dataset containing the attribute or filter affected by this
+	 *         event.
+	 */
+	public MartDataset getDataset() {
+		return dataset;
+	}
+
+	/**
+	 * Returns the value of the filter affected by this event.
+	 * 
+	 * @return the value of the filter affected by this event.
+	 */
+	public String getValue() {
+		return value;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentListener.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentListener.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentListener.java
new file mode 100644
index 0000000..af63326
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/event/QueryComponentListener.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: QueryComponentListener.java,v $
+ * Revision           $Revision: 1.1 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/01/31 14:12:06 $
+ *               by   $Author: davidwithers $
+ * Created on 03-Apr-2006
+ *****************************************************************/
+package org.biomart.martservice.config.event;
+
+import java.util.EventListener;
+
+/**
+ * The listener interface for receiving QueryComponent events.
+ * 
+ * @author David Withers
+ */
+public interface QueryComponentListener extends EventListener {
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for an attribute is
+	 * selected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void attributeAdded(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for an attribute is
+	 * deselected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void attributeRemoved(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a filter is selected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void filterAdded(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a filter is deselected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void filterRemoved(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a filter is changed.
+	 * 
+	 * @param event the query component event
+	 */
+	public void filterChanged(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a link is selected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void linkAdded(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a link is deselected.
+	 * 
+	 * @param event the query component event
+	 */
+	public void linkRemoved(QueryComponentEvent event);
+
+	/**
+	 * Invoked when a <code>QueryComponent</code> for a dataset link id is
+	 * changed.
+	 * 
+	 * @param event the query component event
+	 */
+	public void linkChanged(QueryComponentEvent event);
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ConfigDisplayObject.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ConfigDisplayObject.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ConfigDisplayObject.java
new file mode 100644
index 0000000..89820d3
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ConfigDisplayObject.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: ConfigDisplayObject.java,v $
+ * Revision           $Revision: 1.1 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/01/31 14:12:09 $
+ *               by   $Author: davidwithers $
+ * Created on 17-Mar-2006
+ *****************************************************************/
+package org.biomart.martservice.config.ui;
+
+import java.awt.Component;
+
+import org.ensembl.mart.lib.config.BaseNamedConfigurationObject;
+
+/**
+ * An object containing a configuration object and it's graphical component.
+ * 
+ * @author David Withers
+ */
+public class ConfigDisplayObject {
+	private BaseNamedConfigurationObject configObject;
+
+	private Component component;
+
+	/**
+	 * Constructs an instance of a <code>ConfigDisplayObject</code> with the
+	 * specified configuration object and a <code>null</code> component.
+	 * 
+	 * @param configObject
+	 *            the configuration object; must not be <code>null</code>
+	 */
+	public ConfigDisplayObject(BaseNamedConfigurationObject configObject) {
+		this(configObject, null);
+	}
+
+	/**
+	 * Constructs an instance of a <code>ConfigDisplayObject</code> with the
+	 * specified configuration object and component.
+	 * 
+	 * @param configObject
+	 *            the configuration object; must not be <code>null</code>
+	 * @param component
+	 *            the component
+	 */
+	public ConfigDisplayObject(BaseNamedConfigurationObject configObject,
+			Component component) {
+		if (configObject == null) {
+			throw new IllegalArgumentException(
+					"Parameter 'configObject' must not be null");
+		}
+		this.configObject = configObject;
+		this.component = component;
+	}
+
+	/**
+	 * Returns the display name.
+	 * 
+	 * @return the display name
+	 */
+	public String getDisplayName() {
+		return configObject.getDisplayName();
+	}
+
+	/**
+	 * Returns the internal name.
+	 * 
+	 * @return the internal name
+	 */
+	public String getInternalName() {
+		return configObject.getInternalName();
+	}
+
+	/**
+	 * Returns the display name.
+	 * 
+	 * @return the display name
+	 */
+	public String toString() {
+		return getDisplayName();
+	}
+
+	/**
+	 * Returns the configuration object.
+	 * 
+	 * @return the configuration object
+	 */
+	public BaseNamedConfigurationObject getConfigObject() {
+		return configObject;
+	}
+
+	/**
+	 * Returns the component.
+	 * 
+	 * @return the component.
+	 */
+	public Component getComponent() {
+		return component;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ExpandableBox.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ExpandableBox.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ExpandableBox.java
new file mode 100644
index 0000000..d5ff0dd
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/ExpandableBox.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: ExpandableBox.java,v $
+ * Revision           $Revision: 1.2 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/12/13 11:38:56 $
+ *               by   $Author: davidwithers $
+ * Created on Jun 22, 2007
+ *****************************************************************/
+package org.biomart.martservice.config.ui;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.Timer;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.LineBorder;
+
+/**
+ * A component that when collapsed only shows a title and when expanded shows
+ * the title and contained components.
+ * 
+ * @author David Withers
+ * 
+ */
+public class ExpandableBox extends JPanel {
+	private static final long serialVersionUID = -5678399632577606442L;
+
+	private JButton expandButton;
+
+	private JPanel labelBox;
+
+	private boolean expanded = true;
+
+	private boolean animated = false;
+
+	private Timer timer = new Timer(1, null);
+
+	private Dimension minSize;
+
+	private Dimension maxSize;
+
+	private int height;
+
+	private final int increment = 10;
+
+	private ActionListener openAction = new ActionListener() {
+		public void actionPerformed(ActionEvent evt) {
+			if (height <= maxSize.height) {
+				setPreferredSize(new Dimension(maxSize.width, height));
+				revalidate();
+				repaint();
+				height += increment;
+			} else {
+				timer.removeActionListener(this);
+				timer.stop();
+				setPreferredSize(new Dimension(maxSize.width, maxSize.height));
+				revalidate();
+				repaint();
+			}
+		}
+	};
+
+	private ActionListener closeAction = new ActionListener() {
+		public void actionPerformed(ActionEvent evt) {
+			if (height >= minSize.height) {
+				setPreferredSize(new Dimension(minSize.width, height));
+				revalidate();
+				repaint();
+				height -= increment;
+			} else {
+				timer.removeActionListener(this);
+				timer.stop();
+				height = minSize.height;
+				setPreferredSize(new Dimension(minSize.width, height));
+				revalidate();
+				repaint();
+			}
+		}
+	};
+
+	public ExpandableBox(Component titleComponent, Color backgroundColor,
+			Color borderColor) {
+		this(titleComponent, backgroundColor, borderColor, new Insets(10, 10,
+				10, 10), false);
+	}
+
+	public ExpandableBox(Component titleComponent, Color backgroundColor,
+			Color borderColor, Insets borderInsets) {
+		this(titleComponent, backgroundColor, borderColor, borderInsets, false);
+	}
+
+	public ExpandableBox(Component titleComponent, Color backgroundColor,
+			Color borderColor, boolean animated) {
+		this(titleComponent, backgroundColor, borderColor, new Insets(10, 10,
+				10, 10), animated);
+	}
+
+	public ExpandableBox(Component titleComponent, Color backgroundColor,
+			Color borderColor, Insets borderInsets, boolean animated) {
+		this.animated = animated;
+		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+		setBackground(backgroundColor);
+		setBorder(new CompoundBorder(new LineBorder(borderColor, 1),
+				new EmptyBorder(borderInsets)));
+
+		labelBox = new JPanel();
+		labelBox.setLayout(new BoxLayout(labelBox, BoxLayout.X_AXIS));
+		labelBox.setBackground(backgroundColor);
+
+		expandButton = new JButton(MartServiceIcons.getIcon("contract"));
+		expandButton.setActionCommand("contract");
+		expandButton.setBackground(backgroundColor);
+		expandButton.setBorder(new EmptyBorder(0, 0, 0, 0));
+		expandButton.addActionListener(new ActionListener() {
+
+			public void actionPerformed(ActionEvent e) {
+				if ("contract".equals(e.getActionCommand())) {
+					setExpanded(false);
+				} else {
+					setExpanded(true);
+				}
+			}
+
+		});
+		labelBox.add(expandButton);
+		labelBox.add(Box.createHorizontalStrut(5));
+		labelBox.add(titleComponent);
+		labelBox.add(Box.createHorizontalGlue());
+		add(labelBox);
+		minSize = getPreferredSize();
+	}
+
+	public void setExpanded(boolean expanded) {
+		if (maxSize == null || maxSize.height <= minSize.height) {
+			maxSize = getLayout().preferredLayoutSize(this);
+		}
+		if (this.expanded != expanded) {
+			this.expanded = expanded;
+			if (expanded) {
+				expandButton.setIcon(MartServiceIcons.getIcon("contract"));
+				expandButton.setActionCommand("contract");
+				if (animated) {
+					timer.stop();
+					timer.removeActionListener(closeAction);
+					timer.addActionListener(openAction);
+					timer.start();
+				} else {
+					setPreferredSize(new Dimension(maxSize.width,
+							maxSize.height));
+				}
+			} else {
+				expandButton.setIcon(MartServiceIcons.getIcon("expand"));
+				expandButton.setActionCommand("expand");
+				if (animated) {
+					timer.stop();
+					timer.removeActionListener(openAction);
+					timer.addActionListener(closeAction);
+					timer.start();
+				} else {
+					setPreferredSize(new Dimension(minSize.width,
+							minSize.height));
+				}
+			}
+			revalidate();
+			repaint();
+		}
+		expandButton.setSelected(expanded);
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/a87b4151/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/MartServiceIcons.java
----------------------------------------------------------------------
diff --git a/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/MartServiceIcons.java b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/MartServiceIcons.java
new file mode 100644
index 0000000..15f294a
--- /dev/null
+++ b/taverna-biomart-martservice/src/main/java/org/biomart/martservice/config/ui/MartServiceIcons.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2003 The University of Manchester 
+ *
+ * Modifications to the initial code base are copyright of their
+ * respective authors, or their employers as appropriate.  Authorship
+ * of the modifications may be determined from the ChangeLog placed at
+ * the end of this file.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ ****************************************************************
+ * Source code information
+ * -----------------------
+ * Filename           $RCSfile: MartServiceIcons.java,v $
+ * Revision           $Revision: 1.2 $
+ * Release status     $State: Exp $
+ * Last modified on   $Date: 2007/12/13 11:38:56 $
+ *               by   $Author: davidwithers $
+ * Created on 24-Aug-2006
+ *****************************************************************/
+package org.biomart.martservice.config.ui;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+
+/**
+ * 
+ * @author witherd5
+ */
+public class MartServiceIcons {
+	private static Map<String, Icon> nameToIcon = new HashMap<String, Icon>();
+
+	private static final String imageLocation = "org/biomart/martservice/config/ui/";
+
+	static {
+		ClassLoader loader = MartServiceQueryConfigUIFactory.class
+				.getClassLoader();
+		if (loader == null) {
+			loader = Thread.currentThread().getContextClassLoader();
+		}
+
+		nameToIcon.put("gene_schematic", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic.gif")));
+		nameToIcon.put("gene_schematic_3utr", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_3utr.gif")));
+		nameToIcon.put("gene_schematic_5utr", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_5utr.gif")));
+		nameToIcon.put("gene_schematic_cdna", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_cdna.gif")));
+		nameToIcon.put("gene_schematic_coding_gene_flank", new ImageIcon(loader
+				.getResource(imageLocation
+						+ "gene_schematic_coding_gene_flank.gif")));
+		nameToIcon.put("gene_schematic_coding_transcript_flank", new ImageIcon(
+				loader.getResource(imageLocation
+						+ "gene_schematic_coding_transcript_flank.gif")));
+		nameToIcon.put("gene_schematic_coding", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_coding.gif")));
+		nameToIcon.put("gene_schematic_gene_exon_intron", new ImageIcon(loader
+				.getResource(imageLocation
+						+ "gene_schematic_gene_exon_intron.gif")));
+		nameToIcon.put("gene_schematic_gene_exon", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_gene_exon.gif")));
+		nameToIcon.put("gene_schematic_gene_flank", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_gene_flank.gif")));
+		nameToIcon.put("gene_schematic_peptide", new ImageIcon(loader
+				.getResource(imageLocation + "gene_schematic_peptide.gif")));
+		nameToIcon.put("gene_schematic_transcript_exon_intron", new ImageIcon(
+				loader.getResource(imageLocation
+						+ "gene_schematic_transcript_exon_intron.gif")));
+		nameToIcon.put("gene_schematic_transcript_exon", new ImageIcon(
+				loader.getResource(imageLocation
+						+ "gene_schematic_transcript_exon.gif")));
+		nameToIcon.put("gene_schematic_transcript_flank", new ImageIcon(loader
+				.getResource(imageLocation
+						+ "gene_schematic_transcript_flank.gif")));
+		nameToIcon.put("contract", new ImageIcon(loader
+				.getResource(imageLocation
+						+ "contract.gif")));
+		nameToIcon.put("expand", new ImageIcon(loader
+				.getResource(imageLocation
+						+ "expand.gif")));
+	}
+
+	public static Icon getIcon(String name) {
+		return (Icon) nameToIcon.get(name);
+	}
+
+}