http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/SearchResults.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/SearchResults.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/SearchResults.java deleted file mode 100644 index 3263653..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/SearchResults.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.apache.taverna.biocatalogue.model.search; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.apache.taverna.biocatalogue.model.LoadingResource; -import org.apache.taverna.biocatalogue.model.Resource.TYPE; -import org.apache.taverna.biocatalogue.model.connectivity.BeansForJSONLiteAPI; -import org.apache.taverna.biocatalogue.model.connectivity.BeansForJSONLiteAPI.ResourceIndex; -import org.apache.taverna.biocatalogue.model.connectivity.BeansForJSONLiteAPI.ResourceLinkWithName; - -import org.apache.log4j.Logger; - -import org.biocatalogue.x2009.xml.rest.ResourceLink; - - -/** - * Generic class for any kinds of search results. - * - * @author Sergejs Aleksejevs - */ -public class SearchResults implements Serializable -{ - private static final long serialVersionUID = 6994685875323246165L; - - private transient Logger logger; // don't want to serialise the logger... - - private final TYPE typeOfResourcesInTheResultSet; - private final int totalResultCount; - - // Data store for found items - protected ArrayList<ResourceLink> foundItems; - private int fullyFetchedItemCount; - - - - public SearchResults(TYPE typeOfResourcesInTheResultSet, BeansForJSONLiteAPI.ResourceIndex resourceIndex) - { - this.typeOfResourcesInTheResultSet = typeOfResourcesInTheResultSet; - this.totalResultCount = resourceIndex.getResources().length; - this.fullyFetchedItemCount = 0; - - this.logger = Logger.getLogger(this.getClass()); - - initialiseSearchResultCollection(resourceIndex); - } - - - /** - * The collection of results is initialised to cater for the expected number of - * values - placeholder with just a name and URL for each of the expected result entries is stored. - * - * @param resourceIndex - */ - protected void initialiseSearchResultCollection(ResourceIndex resourceIndex) - { - foundItems = new ArrayList<ResourceLink>(); - foundItems.ensureCapacity(getTotalMatchingItemCount()); - - ResourceLinkWithName resourceLink = null; - for (int i = 0; i < getTotalMatchingItemCount(); i++) { - resourceLink = resourceIndex.getResources()[i]; - this.foundItems.add(new LoadingResource(resourceLink.getURL(), resourceLink.getName())); - } - } - - - public synchronized void addSearchResults(List<ResourceLink> searchResultsData, int positionToStartAddingResults) - { - // only update a specific portion of results - for (int i = 0; i < searchResultsData.size(); i++) { - this.foundItems.set(i + positionToStartAddingResults, searchResultsData.get(i)); - } - - fullyFetchedItemCount += searchResultsData.size(); - } - - - public TYPE getTypeOfResourcesInTheResultSet() { - return typeOfResourcesInTheResultSet; - } - - - /** - * @return List of resources that have matched the search query - * and/or specified filtering criteria. - */ - public List<ResourceLink> getFoundItems() { - return (this.foundItems); - } - - - /** - * @return Number of resources that have matched the search query - * (and/or specified filtering criteria) that have already been - * fetched. - */ - public int getFetchedItemCount() { - return (this.fullyFetchedItemCount); - } - - - /** - * @return Total number of resources that have matched the search query - * (and/or specified filtering criteria) - most of these will - * likely not be fetched yet. - */ - public int getTotalMatchingItemCount() { - return (this.totalResultCount); - } - - - /** - * @return Total number of pages in the current result set. - */ - public int getTotalResultPageNumber() { - int numberOfResourcesPerPageForThisResourceType = this.getTypeOfResourcesInTheResultSet().getApiResourceCountPerIndexPage(); - return (int)(Math.ceil((double)getTotalMatchingItemCount() / numberOfResourcesPerPageForThisResourceType)); - } - - - /** - * List of matching items will be partial and populated sequentially - * based on user actions. Therefore, this method helps to check - * which list entries are still not populated. - * - * @param startIndex Beginning of the range to check. - * @param endIndex End of the range to check. - * @return Zero-based index of the first entry in the list of - * matching resources that hasn't been fetched yet. - * Will return <code>-1</code> if the provided range - * parameters are incorrect or if all items in the - * specified range are already available. - */ - public int getFirstMatchingItemIndexNotYetFetched(int startIndex, int endIndex) - { - // check the specified range is correct - if (startIndex < 0 || endIndex > getTotalMatchingItemCount() - 1) { - return (-1); - } - - // go through the search results in the specified range - // in an attempt to find an item that hasn't been fetched - // just yet - for (int i = startIndex; i <= endIndex; i++) { - ResourceLink item = this.foundItems.get(i); - if (item != null && item instanceof LoadingResource && !((LoadingResource)item).isLoading()) { - return (i); - } - } - - // apparently, all items in the provided range are fetched - return (-1); - } - - - - /** - * @param matchingItemIndex Index of the matching item from search results. - * @return Index (starting from "1") of page in the search results, where - * the matching item with a specified index is located. If the - * <code>matchingItemIndex</code> is wrong, <code>-1</code> is returned. - */ - public int getMatchingItemPageNumberFor(int matchingItemIndex) - { - // check the specified index is correct - if (matchingItemIndex < 0 || matchingItemIndex > getTotalMatchingItemCount() - 1) { - return (-1); - } - - int resultsPerPageForThisType = this.getTypeOfResourcesInTheResultSet().getApiResourceCountPerIndexPage(); - return (matchingItemIndex / resultsPerPageForThisType + 1); - } - - - /** - * @param resultPageNumber Number of the page, for which the calculations are to be done. - * @return Index of the first result entry on the specified result page. If <code>resultPageNumber</code> - * is less than <code>1</code> or greater than the total number of pages in the result set, - * a value of <code>-1</code> will be returned. - */ - public int getFirstItemIndexOn(int resultPageNumber) - { - // page number must be in a valid range - starting with 1..onwards - if (resultPageNumber < 1 || resultPageNumber > getTotalResultPageNumber()) { - return (-1); - } - - int numberOfResourcesPerPageForThisResourceType = this.getTypeOfResourcesInTheResultSet().getApiResourceCountPerIndexPage(); - return ((resultPageNumber - 1) * numberOfResourcesPerPageForThisResourceType); - } - - - - /** - * Mainly for testing - outputs number of search results per item type. - */ - public String toString() - { - // FIXME - -// StringBuilder out = new StringBuilder("Breakdown of item counts by type:\n"); -// for (Map.Entry<Integer,String> itemTypeNamePair : Resource.ALL_SUPPORTED_RESOURCE_COLLECTION_NAMES.entrySet()) { -// out.append(itemTypeNamePair.getValue() + ": " +getFetchedItemCount(itemTypeNamePair.getKey()) + -// "/" + getTotalItemCount(itemTypeNamePair.getKey()) + "\n"); -// } -// -// return (out.toString()); - - return ("search results... not implemented!!!"); - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/ServiceFilteringSettings.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/ServiceFilteringSettings.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/ServiceFilteringSettings.java deleted file mode 100644 index 30570ad..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/model/search/ServiceFilteringSettings.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.apache.taverna.biocatalogue.model.search; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; - -import javax.swing.tree.TreePath; - -import org.apache.taverna.biocatalogue.model.Util; -import org.apache.taverna.biocatalogue.ui.filtertree.FilterTreeNode; -import org.apache.taverna.biocatalogue.ui.tristatetree.JTriStateTree; - -/** - * This class provides functionality to deal with service filtering settings. - * Particularly used to save the current state of the filtering tree as a - * favourite filter. - * - * Instances of this class hold all necessary information to restore the - * filtering state at a later point. - * - * @author Sergejs Aleksejevs - */ -public class ServiceFilteringSettings implements Comparable<ServiceFilteringSettings>, Serializable -{ - private static final long serialVersionUID = -5706169924295062628L; - - private String filterName; - private int filteringCriteriaNumber; - private List<TreePath> filterTreeRootsOfCheckedPaths; - - - - /** - * Stores current filtering selection in the provided JTriStateTree - * instance into the instance of this class. - * - * @param filterTree The JTriStateTree instance to get the current selection from. - */ - public ServiceFilteringSettings(JTriStateTree filterTree) - { - this(null, filterTree); - } - - - /** - * Stores current filtering selection in the provided JTriStateTree - * instance into the instance of this class. - * - * @param filterName The name to associate with this filter. - * @param filterTree The JTriStateTree instance to get the current selection from. - */ - @SuppressWarnings("unchecked") - public ServiceFilteringSettings(String filterName, JTriStateTree filterTree) - { - this.filterName = filterName; - - this.filteringCriteriaNumber = filterTree.getLeavesOfCheckedPaths().size(); - - // a deep copy of the data from the filter tree is created, so that the data stored in this instance - // is fully independent of the filter tree itself; therefore local copy of this data may be modified - // as needed and will not affect the main filter (and vice versa) - this.filterTreeRootsOfCheckedPaths = (List<TreePath>)Util.deepCopy(filterTree.getRootsOfCheckedPaths()); - } - - - /** - * Analyses the filter tree and produces part of the request URL containing settings regarding filters. - */ - @SuppressWarnings("unchecked") - public Map<String,String[]> getFilteringURLParameters() - { - // analyse filter tree to get checked elements - Map<String,HashSet<String>> selections = new HashMap<String,HashSet<String>>(); - - // cycle through the deepest selected nodes; - // NB! the CheckboxTree acts in a way that if A contains B,C -- - // 1) if only B is checked, tp.getLastPathComponent() will be B; - // 2) if both B,C are checked, tp.getLastPathComponent() will be A; - for (TreePath selectedRootNodePath : getFilterTreeRootsOfCheckedPaths()) { - FilterTreeNode selectedNode = (FilterTreeNode)selectedRootNodePath.getLastPathComponent(); - - // identify affected nodes - HashSet<FilterTreeNode> affectedNodes = new HashSet<FilterTreeNode>(); - if (selectedNode.isFilterCategory()) { - // case as in example 2) -- need to "extract" nodes that are one level deeper - for (Enumeration children = selectedNode.children(); children.hasMoreElements(); ) { - affectedNodes.add((FilterTreeNode)children.nextElement()); - } - } - else { - // case as in example 1) - affectedNodes.add(selectedNode); - } - - // walk through the identified collection of nodes and build the data structure with URL values - for (FilterTreeNode node : affectedNodes) { - if (selections.containsKey(node.getType())) { - selections.get(node.getType()).add(node.getUrlValue()); - } - else { - HashSet<String> newSet = new HashSet<String>(); - newSet.add(node.getUrlValue()); - - selections.put(node.getType(), newSet); - } - } - } - - - // now use the constructed set of data to build the map of filtering URL parameters - Map<String,String[]> filterUrlParameters = new HashMap<String,String[]>(); - for(String key : selections.keySet()) - { - List<String> categoryValues = new ArrayList<String>(); - for (String value : selections.get(key)) { - categoryValues.add(value); - } - - filterUrlParameters.put(key, categoryValues.toArray(new String[0])); - } - - return (filterUrlParameters); - } - - - // *** Getters *** - - public String getFilterName() { - return (this.filterName == null || filterName.length() == 0 ? "untitled filter" : this.filterName); - } - - public List<TreePath> getFilterTreeRootsOfCheckedPaths() { - return filterTreeRootsOfCheckedPaths; - } - - /** - * @return Number of filtering criteria within the current filter. - */ - public int getNumberOfFilteringCriteria() { - return filteringCriteriaNumber; - } - - // *** End of getters *** - - - public boolean equals(Object other) - { - if (other instanceof ServiceFilteringSettings) - { - ServiceFilteringSettings o = (ServiceFilteringSettings)other; - return (this.filterName.equals(o.filterName) && - this.filterTreeRootsOfCheckedPaths.equals(o.filterTreeRootsOfCheckedPaths)); - } - else { - return false; - } - } - - - public int compareTo(ServiceFilteringSettings other) - { - int iOrdering = this.filterName.compareTo(other.filterName); - if (iOrdering == 0) { - iOrdering = this.getNumberOfFilteringCriteria() - other.getNumberOfFilteringCriteria(); - } - - // inverse order, as the traversal of lists in the favourite filters panel is - // done this way round - return (-1 * iOrdering); - } - - - public String toString() { - return ("Filter: '" + getFilterName() + "' [" + detailsAsString() + "]"); - } - - public String detailsAsString() { - return (getNumberOfFilteringCriteria() + " filtering criteria"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/AnnotationBean.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/AnnotationBean.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/AnnotationBean.java deleted file mode 100644 index d1d8dca..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/AnnotationBean.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -public class AnnotationBean -{ - public AnnotationBean() { } - - public String self; - private int version; - private String created; - public Annotatable annotatable; - private Source source; - private Attribute attribute; - private Value value; - - - public static class Annotatable - { - private Annotatable() { } - - private String name; - public String resource; - private String type; - } - - public static class Source - { - private Source() { } - - private String name; - private String resource; - private String type; - } - - public static class Attribute - { - private Attribute() { } - - private String name; - private String resource; - private String identifier; - } - - public static class Value - { - private Value() { } - - private String resource; - private String type; - private String content; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/DrawDefaultIconTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/DrawDefaultIconTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/DrawDefaultIconTest.java deleted file mode 100644 index d6acb16..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/DrawDefaultIconTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.image.BufferedImage; - -import javax.swing.ImageIcon; -import javax.swing.JOptionPane; - -public class DrawDefaultIconTest { - - /** - * @param args - */ - public static void main(String[] args) - { - int w = 16; - int h = 16; - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice gd = ge.getDefaultScreenDevice(); - GraphicsConfiguration gc = gd.getDefaultConfiguration(); - - BufferedImage image = gc.createCompatibleImage(w, h, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = image.createGraphics(); - g.setColor(Color.RED); - g.setStroke(new BasicStroke(3, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); - g.drawLine(4, 4, 12, 12); - g.drawLine(12, 4, 4, 12); - g.dispose(); - - JOptionPane.showMessageDialog(null, new ImageIcon(image)); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest.java deleted file mode 100644 index ade0309..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.google.gson.Gson; - -public class GSONTest -{ - - public static void main(String[] args) throws Exception - { - String json = "[{\"annotatable\":{\"name\":\"IndexerService\",\"resource\":\"http://sandbox.biocatalogue.org/services/2158\",\"type\":\"Service\"},\"self\":\"http://sandbox.biocatalogue.org/annotations/47473\",\"value\":{\"resource\":\"http://sandbox.biocatalogue.org/tags/indexing\",\"type\":\"Tag\",\"content\":\"indexing\"},\"version\":1,\"created\":\"2010-01-13T09:24:04Z\",\"source\":{\"name\":\"Marco Roos\",\"resource\":\"http://sandbox.biocatalogue.org/users/48\",\"type\":\"User\"},\"attribute\":{\"name\":\"Tag\",\"resource\":\"http://sandbox.biocatalogue.org/annotation_attributes/2\",\"identifier\":\"http://www.biocatalogue.org/attribute#Category\"}}]"; - - Gson gson = new Gson(); - AnnotationBean[] a = gson.fromJson(json, AnnotationBean[].class); - - System.out.println("Self URL: " + a[0].self); - System.out.println("Annotatable resource: " + a[0].annotatable.resource); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_exportingJSON.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_exportingJSON.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_exportingJSON.java deleted file mode 100644 index 3fce711..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_exportingJSON.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.HashMap; -import java.util.Map; - -import org.apache.taverna.biocatalogue.model.connectivity.BeanForPOSTToFilteredIndex; - -import com.google.gson.Gson; - -public class GSONTest_exportingJSON -{ - - /** - * @param args - */ - public static void main(String[] args) - { - Map<String, String[]> m = new HashMap<String, String[]>(); - m.put("a", new String[] {"b","c"}); - m.put("d", new String[] {"e","f"}); - - BeanForPOSTToFilteredIndex b = new BeanForPOSTToFilteredIndex(); - b.filters = m; - - Gson gson = new Gson(); - System.out.println(gson.toJson(b)); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_forSoapOperationsIndex.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_forSoapOperationsIndex.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_forSoapOperationsIndex.java deleted file mode 100644 index ae0409e..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/GSONTest_forSoapOperationsIndex.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.taverna.biocatalogue.model.Resource; -import org.apache.taverna.biocatalogue.model.connectivity.BeansForJSONLiteAPI; -import org.apache.taverna.biocatalogue.model.connectivity.BioCatalogueClient; - -public class GSONTest_forSoapOperationsIndex -{ - - /** - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception - { - BioCatalogueClient client = BioCatalogueClient.getInstance(); - - String url = BioCatalogueClient.API_SOAP_OPERATIONS_URL; -// url = Util.appendURLParameter(url, "q", "blast"); - BeansForJSONLiteAPI.ResourceIndex soapOpIndex = client.getBioCatalogueResourceLiteIndex(Resource.TYPE.SOAPOperation, url); - - System.out.println("result count: " + soapOpIndex.getResources().length + "\n\n"); -// System.out.println(soapOpIndex.soap_operations[1].getName() + "\n" + soapOpIndex.soap_operations[1].getURL() + "\n\n"); - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/JWaitDialogTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/JWaitDialogTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/JWaitDialogTest.java deleted file mode 100644 index a9b815f..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/JWaitDialogTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.taverna.biocatalogue.ui.JWaitDialog; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponent; - -public class JWaitDialogTest -{ - - public static void main(String[] args) - { - System.out.println("start test"); - - final JWaitDialog jwd = new JWaitDialog(MainComponent.dummyOwnerJFrame, "Old title", "Please wait... Please wait... Please wait... Please wait..."); - - // NB! Background process must be started before the modal dialog box - // is made visible - otherwise processing freezes. - new Thread("testing delayed update of JWaitDialog") - { - public void run() - { - // wait for some time - try { Thread.sleep(3000); } - catch (InterruptedException e) { /* do nothing */ } - - // update the dialog - jwd.setTitle("New title"); - jwd.waitFinished("Great, all done!"); - - System.out.println("end test"); - } - }.start(); - - jwd.setVisible(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/LinkedListEqualsTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/LinkedListEqualsTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/LinkedListEqualsTest.java deleted file mode 100644 index 02d5d09..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/LinkedListEqualsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.LinkedList; - -public class LinkedListEqualsTest -{ - public static void main(String[] args) - { - LinkedList l = new LinkedList(); - - String a = new String("test1"); - String b = new String("test2"); - - System.out.println(a == b); - System.out.println(a.equals(b)); - - l.add(a); - l.add(b); - - System.out.println(l); - System.out.println(l.indexOf(a)); - System.out.println(l.indexOf(b)); - - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestAPICaller.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestAPICaller.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestAPICaller.java deleted file mode 100644 index 4625e0a..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestAPICaller.java +++ /dev/null @@ -1,257 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import javax.swing.JFrame; -import java.awt.Dimension; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import javax.swing.JTextField; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JOptionPane; -import javax.swing.JTextPane; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; - -import org.apache.taverna.biocatalogue.model.connectivity.BioCatalogueClient; - -import java.awt.GridBagLayout; -import java.awt.GridBagConstraints; -import java.awt.Insets; -import java.io.BufferedReader; -import java.io.InputStreamReader; - -/** - * @author Sergejs Aleksejevs - */ -public class TestAPICaller extends JFrame implements ActionListener { - - private JPanel jContentPane = null; - private JTextField tfURL = null; - private JButton bSubmitRequest = null; - private JButton bClear = null; - private JScrollPane spOutputPane = null; - private JTextPane tpOutputPane = null; - - /** - * This method initializes - * - */ - public TestAPICaller() { - super(); - initialize(); - } - - /** - * This method initializes this - * - */ - private void initialize() { - this.setSize(new Dimension(515, 321)); - this.setTitle("Test Service Catalogue API Caller"); - this.setContentPane(getJContentPane()); - - this.bSubmitRequest.setDefaultCapable(true); - this.getRootPane().setDefaultButton(bSubmitRequest); - } - - /** - * This method initializes jContentPane - * - * @return javax.swing.JPanel - */ - private JPanel getJContentPane() { - if (jContentPane == null) { - GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); - gridBagConstraints3.fill = GridBagConstraints.BOTH; - gridBagConstraints3.gridwidth = 2; - gridBagConstraints3.gridx = 0; - gridBagConstraints3.gridy = 2; - gridBagConstraints3.ipadx = 459; - gridBagConstraints3.ipady = 182; - gridBagConstraints3.weightx = 1.0; - gridBagConstraints3.weighty = 1.0; - gridBagConstraints3.insets = new Insets(4, 12, 9, 12); - GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); - gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints2.gridy = 1; - gridBagConstraints2.ipadx = 0; - gridBagConstraints2.ipady = 0; - gridBagConstraints2.insets = new Insets(0, 5, 7, 12); - gridBagConstraints2.weightx = 0.5; - gridBagConstraints2.gridx = 1; - GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); - gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints1.gridy = 1; - gridBagConstraints1.ipadx = 0; - gridBagConstraints1.ipady = 0; - gridBagConstraints1.insets = new Insets(0, 12, 7, 5); - gridBagConstraints1.weightx = 0.5; - gridBagConstraints1.gridx = 0; - GridBagConstraints gridBagConstraints = new GridBagConstraints(); - gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; - gridBagConstraints.gridwidth = 2; - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 0; - gridBagConstraints.ipadx = 466; - gridBagConstraints.weightx = 1.0; - gridBagConstraints.ipady = 3; - gridBagConstraints.insets = new Insets(13, 12, 8, 12); - jContentPane = new JPanel(); - jContentPane.setLayout(new GridBagLayout()); - jContentPane.add(getTfURL(), gridBagConstraints); - jContentPane.add(getBSubmitRequest(), gridBagConstraints1); - jContentPane.add(getBClear(), gridBagConstraints2); - jContentPane.add(getSpOutputPane(), gridBagConstraints3); - } - return jContentPane; - } - - /** - * This method initializes tfURL - * - * @return javax.swing.JTextField - */ - private JTextField getTfURL() { - if (tfURL == null) { - tfURL = new JTextField(); - tfURL.setText(BioCatalogueClient.DEFAULT_API_SANDBOX_BASE_URL); - } - return tfURL; - } - - /** - * This method initializes tfSubmitRequest - * - * @return javax.swing.JButton - */ - private JButton getBSubmitRequest() { - if (bSubmitRequest == null) { - bSubmitRequest = new JButton(); - bSubmitRequest.setText("Submit Request"); - bSubmitRequest.addActionListener(this); - } - return bSubmitRequest; - } - - - /** - * This method initializes bClear - * - * @return javax.swing.JButton - */ - private JButton getBClear() { - if (bClear == null) { - bClear = new JButton(); - bClear.setText("Clear Output"); - bClear.addActionListener(this); - } - return bClear; - } - - - /** - * This method initializes tpOutputPane - * - * @return javax.swing.JTextPane - */ - private JTextPane getTpOutputPane() { - if (tpOutputPane == null) { - tpOutputPane = new JTextPane(); - tpOutputPane.setContentType("text/plain"); - } - return tpOutputPane; - } - - - /** - * This method initializes spOutputPane - * - * @return javax.swing.JScrollPane - */ - private JScrollPane getSpOutputPane() { - if (spOutputPane == null) { - spOutputPane = new JScrollPane(); - spOutputPane.setViewportView(getTpOutputPane()); - } - return spOutputPane; - } - - - // ACTION LISTENER - - public void actionPerformed(ActionEvent e) { - if (e.getSource().equals(bSubmitRequest)) { - tfURL.selectAll(); - - // call the actual test method - runBioCatalogueAPITest(tfURL.getText()); - } - else if (e.getSource().equals(bClear)) { - this.tpOutputPane.setText(""); - } - - } - - - // ACTUAL TEST CLASS - - private void runBioCatalogueAPITest(String url) { - final String urlFinal = url; - new Thread("making request") { - public void run() { - tpOutputPane.setText("Initialising Service Catalogue client..."); - BioCatalogueClient client = null; - try { - client = BioCatalogueClient.getInstance(); - } - catch (Exception e) { - e.printStackTrace(); - } - - final StringBuilder text = new StringBuilder(); - try { - tpOutputPane.setText("Sending request..."); - BufferedReader br = new BufferedReader(new InputStreamReader(client.doBioCatalogueGET(urlFinal).getResponseStream())); - String str = ""; - - while ((str = br.readLine()) != null) { - text.append(str + "\n"); - } - - br.close(); - } - catch (Exception e) { - text.append(e); - } - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - tpOutputPane.setText(text.toString()); - } - }); - } - }.start(); - - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestDoubleUsageOfSameSwingElement.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestDoubleUsageOfSameSwingElement.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestDoubleUsageOfSameSwingElement.java deleted file mode 100644 index 6056550..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestDoubleUsageOfSameSwingElement.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; -import javax.swing.JFrame; - -public class TestDoubleUsageOfSameSwingElement extends JFrame -{ - private String text = "abc"; - boolean bLowerCase = true; - - public TestDoubleUsageOfSameSwingElement() - { - final JButton bBtn = new JButton(text); - bBtn.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - bLowerCase = !bLowerCase; - bBtn.setText(bLowerCase ? text.toLowerCase() : text.toUpperCase()); - } - }); - - this.setLayout(new BorderLayout()); - this.add(bBtn, BorderLayout.WEST); - this.add(bBtn, BorderLayout.EAST); - - this.pack(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestUtilURLHandling.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestUtilURLHandling.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestUtilURLHandling.java deleted file mode 100644 index 473668d..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestUtilURLHandling.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.taverna.biocatalogue.model.Util; - -public class TestUtilURLHandling -{ - public static void main(String[] args) - { - String url1 = "http://sandbox.biocatalogue.org/search"; - String url2 = "http://sandbox.biocatalogue.org/search?"; - String url3 = "http://sandbox.biocatalogue.org/search?q="; - String url4 = "http://sandbox.biocatalogue.org/search?q=franck"; - String url5 = "http://sandbox.biocatalogue.org/services?tag=%5Bbiology%5D"; - String url6 = "http://sandbox.biocatalogue.org/services?tag=%5B%3Chttp%3A%2F%2Fwww.mygrid.org.uk%2Fontology%23DDBJ%3E%5D"; - - - System.out.println("----------------------------"); - System.out.println("Extracting URL parameters:\n"); - - - System.out.println(url1 + "\nParameter map:\n" + Util.extractURLParameters(url1)); - System.out.println("Reconstructed query string from parameter map: " + Util.constructURLQueryString(Util.extractURLParameters(url1)) + "\n"); - - - System.out.println(url2 + "\nParameter map:\n" + Util.extractURLParameters(url2)); - System.out.println("Reconstructed query string from parameter map: " + Util.constructURLQueryString(Util.extractURLParameters(url2)) + "\n"); - - - System.out.println(url3 + "\nParameter map:\n" + Util.extractURLParameters(url3)); - System.out.println("Reconstructed query string from parameter map: " + Util.constructURLQueryString(Util.extractURLParameters(url3)) + "\n"); - - - System.out.println(url4 + "\nParameter map:\n" + Util.extractURLParameters(url4)); - System.out.println("Reconstructed query string from parameter map: " + Util.constructURLQueryString(Util.extractURLParameters(url4)) + "\n"); - - - System.out.println(url5 + "\nParameter map:\n" + Util.extractURLParameters(url5)); - System.out.println("Reconstructed query string from parameter map: " + Util.constructURLQueryString(Util.extractURLParameters(url5)) + "\n"); - - - System.out.println("\n\n----------------------------"); - System.out.println("Adding parameters:\n"); - - String newUrl = Util.appendURLParameter(url1, "testParam", "testValue"); - System.out.println(url1 + "\n" + newUrl + "\n"); - - newUrl = Util.appendURLParameter(url2, "testParam", "testValue"); - System.out.println(url2 + "\n" + newUrl + "\n"); - - newUrl = Util.appendURLParameter(url3, "testParam", "testValue"); - System.out.println(url3 + "\n" + newUrl + "\n"); - - newUrl = Util.appendURLParameter(url4, "testParam", "testValue"); - System.out.println(url4 + "\n" + newUrl + "\n"); - - newUrl = Util.appendURLParameter(url5, "testParam", "testValue"); - System.out.println(url5 + "\n" + newUrl + "\n"); - - - System.out.println("\n\n----------------------------"); - System.out.println("Getting parameter values:\n"); - - System.out.println("Value of '" + "testParam" + "' in the URL: " + url1 + " -- " + Util.extractURLParameter(url1, "testParam")); - System.out.println("Value of '" + "testParam" + "' in the URL: " + url2 + " -- " + Util.extractURLParameter(url2, "testParam")); - System.out.println("Value of '" + "q" + "' in the URL: " + url3 + " -- " + Util.extractURLParameter(url3, "q")); - System.out.println("Value of '" + "q" + "' in the URL: " + url4 + " -- " + Util.extractURLParameter(url4, "q")); - System.out.println("Value of '" + "tag" + "' in the URL: " + url5 + " -- " + Util.extractURLParameter(url5, "tag")); - - - System.out.println("\n\n----------------------------"); - System.out.println("URL decoding:\n"); - - System.out.println("Original URL: " + url6 + "\nDecoded URL: " + Util.urlDecodeQuery(url6)); - - - System.out.println("\n\n----------------------------"); - System.out.println("Appending a string before URL parameters:\n"); - - String strToAppend = ".xml"; - System.out.println("Appending '" + strToAppend + "' in the URL: " + url1 + " -- " + Util.appendStringBeforeParametersOfURL(url1, strToAppend)); - System.out.println("Appending '" + strToAppend + "' in the URL: " + url2 + " -- " + Util.appendStringBeforeParametersOfURL(url2, strToAppend)); - System.out.println("Appending '" + strToAppend + "' in the URL: " + url3 + " -- " + Util.appendStringBeforeParametersOfURL(url3, strToAppend)); - System.out.println("Appending '" + strToAppend + "' in the URL: " + url4 + " -- " + Util.appendStringBeforeParametersOfURL(url4, strToAppend)); - System.out.println("Appending '" + strToAppend + "' in the URL: " + url5 + " -- " + Util.appendStringBeforeParametersOfURL(url5, strToAppend)); - System.out.println("Appending '" + strToAppend + "' in the URL: " + url6 + " -- " + Util.appendStringBeforeParametersOfURL(url6, strToAppend)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestXHTMLRenderer.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestXHTMLRenderer.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestXHTMLRenderer.java deleted file mode 100644 index 81b13a0..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/TestXHTMLRenderer.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.Container; -import java.io.File; - -import javax.swing.JFrame; - -import org.xhtmlrenderer.simple.FSScrollPane; -import org.xhtmlrenderer.simple.XHTMLPanel; - -public class TestXHTMLRenderer extends JFrame { - public TestXHTMLRenderer() { - try { - init(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void init() throws Exception { - Container contentPane = this.getContentPane(); - - XHTMLPanel panel = new XHTMLPanel(); - panel.getSharedContext().getTextRenderer().setSmoothingThreshold(0); // Anti-aliasing for all font sizes - panel.setDocument(new File("c:\\Temp\\MyExperiment\\T2 BioCatalogue Plugin\\BioCatalogue Plugin\\resources\\test.html")); - - FSScrollPane scroll = new FSScrollPane(panel); - contentPane.add(scroll); - - this.setTitle("XHTML rendered test"); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.pack(); - this.setSize(1024, 768); - } - - - public static void main(String[] args) { - JFrame f = new TestXHTMLRenderer(); - f.setVisible(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/WrappableJLabelTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/WrappableJLabelTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/WrappableJLabelTest.java deleted file mode 100644 index 5be8ae7..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/WrappableJLabelTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.BorderLayout; -import java.awt.Dimension; - -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; - -public class WrappableJLabelTest extends JFrame -{ - public WrappableJLabelTest() { - - // depending on the LayoutManager of the container, JLabel may - // be resized or simply "cut off" on the edges - e.g. FlowLayout - // cuts it off, BorderLayout does the resizing - JPanel jpTestPanel = new JPanel(new BorderLayout()); - jpTestPanel.add(new JLabel("<html><span color=\"red\">a very long</span> text that <b>is just</b> " + - "showing how the whole thing looks - will it wrap text or not; this " + - "is the question</html>"), BorderLayout.CENTER); - - this.getContentPane().add(jpTestPanel); - - this.pack(); - } - - public static void main(String[] args) - { - WrappableJLabelTest f = new WrappableJLabelTest(); - f.setLocationRelativeTo(null); - f.setPreferredSize(new Dimension(400, 300)); - f.setVisible(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/XStreamTest.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/XStreamTest.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/XStreamTest.java deleted file mode 100644 index 293ef9d..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/test/XStreamTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.taverna.biocatalogue.test; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.xml.DomDriver; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; - - -public class XStreamTest -{ - - public static void main(String[] args) - { - List<SoapOperationIdentity> processors = new ArrayList<SoapOperationIdentity>(); - processors.add(new SoapOperationIdentity("http://www.test.com/test.wsdl", "aa", null)); - processors.add(new SoapOperationIdentity("http://www.example.com/example.wsdl", "bb", null)); - - XStream xstream = new XStream(new DomDriver()); - String xml = xstream.toXML(processors); - - System.out.println(xml); - - List<SoapOperationIdentity> processorsFromXML = (List<SoapOperationIdentity>)xstream.fromXML(xml); - System.out.println("\n\n"); - System.out.println(processorsFromXML.get(0).getWsdlLocation() + " - " + processorsFromXML.get(0).getOperationName()); - System.out.println(processorsFromXML.get(1).getWsdlLocation() + " - " + processorsFromXML.get(1).getOperationName()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/BioCatalogueExplorationTab.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/BioCatalogueExplorationTab.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/BioCatalogueExplorationTab.java deleted file mode 100644 index e1b5162..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/BioCatalogueExplorationTab.java +++ /dev/null @@ -1,147 +0,0 @@ -package org.apache.taverna.biocatalogue.ui; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; - -import javax.swing.BorderFactory; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.LayoutFocusTraversalPolicy; - -import org.apache.taverna.biocatalogue.model.connectivity.BioCatalogueClient; -import org.apache.taverna.biocatalogue.ui.search_results.SearchResultsMainPanel; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponent; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponentFactory; - -import org.apache.log4j.Logger; - - -/** - * - * @author Sergejs Aleksejevs - */ -@SuppressWarnings("serial") -public class BioCatalogueExplorationTab extends JPanel implements HasDefaultFocusCapability -{ - private final MainComponent pluginPerspectiveMainComponent; - private final BioCatalogueClient client; - private final Logger logger; - - - // COMPONENTS - private BioCatalogueExplorationTab thisPanel; - - private SearchOptionsPanel searchOptionsPanel; - private SearchResultsMainPanel tabbedSearchResultsPanel; - - - public BioCatalogueExplorationTab() - { - this.thisPanel = this; - - this.pluginPerspectiveMainComponent = MainComponentFactory.getSharedInstance(); - this.client = BioCatalogueClient.getInstance(); - this.logger = Logger.getLogger(this.getClass()); - - initialiseUI(); - - // this is to make sure that search will get focused when this tab is opened - // -- is a workaround to a bug in JVM - setFocusCycleRoot(true); - setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() { - public Component getDefaultComponent(Container cont) { - return (thisPanel.getDefaultComponent()); - } - }); - } - - - private void initialiseUI() - { - this.tabbedSearchResultsPanel = new SearchResultsMainPanel(); - this.searchOptionsPanel = new SearchOptionsPanel(tabbedSearchResultsPanel); - - - this.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.gridx = 0; - c.gridy = 0; - c.weightx = 0.0; - c.anchor = GridBagConstraints.WEST; - c.insets = new Insets(3,10,3,10); - String baseString= "<html><b>Using service catalogue at </b>" + client.getBaseURL() + "</html>"; - this.add(new JLabel(baseString), c); - - - c.gridx = 1; - c.gridy = 0; - c.weightx = 0.1; - c.fill = GridBagConstraints.HORIZONTAL; - c.anchor = GridBagConstraints.EAST; - c.insets = new Insets(3,30,3,10); - - this.add(searchOptionsPanel, c); - - c.insets = new Insets(0,0,0,0); - c.gridy++; - c.gridx = 0; - c.gridwidth = 2; - c.weightx = c.weighty = 1.0; - c.fill = GridBagConstraints.BOTH; - c.anchor = GridBagConstraints.CENTER; - this.add(tabbedSearchResultsPanel, c); - - this.setBorder(BorderFactory.createEmptyBorder(20, 10, 10, 10)); - } - - - public SearchResultsMainPanel getTabbedSearchResultsPanel() { - return tabbedSearchResultsPanel; - } - - - - // *** Callbacks for HasDefaultFocusCapability interface *** - - public void focusDefaultComponent() { - this.searchOptionsPanel.focusDefaultComponent(); - } - - public Component getDefaultComponent() { - return (this.searchOptionsPanel.getDefaultComponent()); - } - - // ********************************************************* - - - public static void main(String[] args) { - JFrame f = new JFrame(); - f.getContentPane().add(new BioCatalogueExplorationTab()); - f.setSize(1000, 800); - f.setLocationRelativeTo(null); - - f.setVisible(true); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/HasDefaultFocusCapability.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/HasDefaultFocusCapability.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/HasDefaultFocusCapability.java deleted file mode 100644 index 1dc45f2..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/HasDefaultFocusCapability.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.taverna.biocatalogue.ui; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.Component; - -/** - * Indicates that the class which implements this interface will focus default - * component (as if the component represented by that class was activated). - * - * @author Sergejs Aleksejevs - */ -public interface HasDefaultFocusCapability -{ - public void focusDefaultComponent(); - public Component getDefaultComponent(); -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JClickableLabel.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JClickableLabel.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JClickableLabel.java deleted file mode 100644 index b6906e9..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JClickableLabel.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.apache.taverna.biocatalogue.ui; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.EventListener; - -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.SwingUtilities; - -/** - * @author Sergejs Aleksejevs - */ -@SuppressWarnings("serial") -public class JClickableLabel extends JLabel implements MouseListener -{ - /** - * Default height of the JClickableLabel - calculated based on 16-pixel - * standard square icon and 3-pixel thick padding on top / bottom of element. - */ - public static final int DEFAULT_HEIGHT = 22; - - public static final Color DEFAULT_REGULAR_FOREGROUND_COLOR = Color.BLUE; - public static final Color DEFAULT_HOVER_FOREGROUND_COLOR = new Color(133, 53, 53); - - - // This will hold the data which is relevant to processing the 'click' event on this label - private final String strData; - - // This will hold a reference to ResourcePreviewBrowser instance that is supposed to process the clicks - // on JClickableLabels - private ActionListener clickHandler; - - - private Color REGULAR_FOREGROUND_COLOR = DEFAULT_REGULAR_FOREGROUND_COLOR; - private Color HOVER_FOREGROUND_COLOR = DEFAULT_HOVER_FOREGROUND_COLOR; - - - public JClickableLabel(String strLabel, String strDataForAction, EventListener eventHandler) - { - this(strLabel, strDataForAction, eventHandler, null); - } - - public JClickableLabel(String strLabel, String strDataForAction, EventListener eventHandler, Icon icon) - { - this(strLabel, strDataForAction, eventHandler, icon, SwingUtilities.LEFT); - } - - public JClickableLabel(String strLabel, String strDataForAction, EventListener eventHandler, Icon icon, int horizontalAlignment) - { - this(strLabel, strDataForAction, eventHandler, icon, horizontalAlignment, null); - } - - /** - * - * @param strLabel Textual label that will be visible in the UI. - * @param strDataForAction Data that will be passed to eventHandler when click on the label is made. - * @param eventHandler ActionListener that will process clicks on this label. - * @param icon Icon to display in the label. - * @param horizontalAlignment This is one of SwingConstants: LEFT, CENTER, RIGHT, LEADING or TRAILING - * @param strTooltip Tooltip to show over the label - if none is provided (e.g. null value), the strLabel will be used as a tooltip. - */ - public JClickableLabel(String strLabel, String strDataForAction, EventListener eventHandler, Icon icon, int horizontalAlignment, String strTooltip) - { - super(strLabel, icon, horizontalAlignment); - - this.strData = strDataForAction; - this.clickHandler = (ActionListener)eventHandler; - - // empty border at the top and bottom will simulate "line-spacing" - // (this is only needed when an icon is displayed) - if (icon != null) { - this.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); - } - - // the tooltip for now only shows the full label text - this.setToolTipText(strTooltip == null ? strLabel : strTooltip); - this.setForeground(REGULAR_FOREGROUND_COLOR); - this.addMouseListener(this); - } - - - public void setRegularForegroundColor(Color regularForegroundColor) - { - REGULAR_FOREGROUND_COLOR = regularForegroundColor; - - // apply the new foreground color immediately - this.setForeground(REGULAR_FOREGROUND_COLOR); - } - - public Color getRegularForegroundColor() { - return REGULAR_FOREGROUND_COLOR; - } - - - public void setHoverForegroundColor(Color hoverForegroundColor) - { - // will be applied the next time mouse hovers over this label - HOVER_FOREGROUND_COLOR = hoverForegroundColor; - } - - public Color getHoverForegroundColor() { - return HOVER_FOREGROUND_COLOR; - } - - - /** - * @return The "hidden" string value that is normally sent as an <code>ActionCommand</code> - * within <code>ActionEvent</code> when JClickableLabel is clicked. - */ - public String getData() { - return (this.strData); - } - - - /** - * @return String value of the label that this JClickableLabel would have in the UI. - */ - public String toString() { - return (this.getText()); - } - - - /* This class extends JLabel, so it can't extend MouseAdapter; - * therefore, empty methods will be added for not useful callbacks - * from the MouseListener interface. - */ - public void mouseClicked(MouseEvent e) - { - // call 'actionPerformed' method on the clickHandler instance that was supplied - // on creation of the JClickableLabel instance - this.clickHandler.actionPerformed(new ActionEvent(this, e.getID(), this.strData)); - } - - public void mouseEntered(MouseEvent e) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)) ; - this.setForeground(HOVER_FOREGROUND_COLOR); - } - - public void mouseExited(MouseEvent e) - { - this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)) ; - this.setForeground(REGULAR_FOREGROUND_COLOR); - } - - public void mousePressed(MouseEvent e) - { - // do nothing - } - - public void mouseReleased(MouseEvent e) - { - // do nothing - } - - - /** - * @return A dummy instance of JClickable label - only intended to - * represent an object of this class; doesn't have a click handler, - * so a click on it will result in a <code>NullPointerException</code>. - */ - public static JClickableLabel getDummyInstance() { - return (new JClickableLabel("dummy", "", null)); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JWaitDialog.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JWaitDialog.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JWaitDialog.java deleted file mode 100644 index 956635e..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/biocatalogue/ui/JWaitDialog.java +++ /dev/null @@ -1,250 +0,0 @@ -package org.apache.taverna.biocatalogue.ui; -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.awt.BorderLayout; -//import java.awt.Dimension; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.UIManager; - -import org.apache.taverna.biocatalogue.model.ResourceManager; -import org.apache.taverna.workbench.MainWindow; - -/** - * Creates a modal non-resizable dialog window. - * - * Intended to be used for operations that consume some - * time, but the user must wait for them to complete before - * proceeding. - * - * Initially the dialog shows a specified string message or - * component and a "loader" bar - dynamic GIF image that - * displays "activity" going on. At this stage the window - * cannot be closed. - * - * When the operation completes, the caller notifies the dialog - * that it has finished, provides a new message / component to - * display and allows the dialog to be closed. - * - * If the operation doesn't complete within the specified time, - * a timeout occurs and the dialog windows lets to close itself. - * - * @author Sergejs Aleksejevs - */ -@SuppressWarnings("serial") -public class JWaitDialog extends JDialog -{ - private static final int DEFAULT_TIMEOUT = 10000; - private static final ImageIcon LOADER_ICON = ResourceManager.getImageIcon(ResourceManager.BAR_LOADER_ORANGE); - - private JPanel jpInformationPanel; - private JLabel jlLoaderIcon; - - private JButton bOK; - private JPanel jpOKButton; - - private Timer timeoutTimer; - private boolean hasTimedOut; - - - /** - * Creates a new Wait Dialog with no parent and default timeout on - * operation - <code>JWaitDialog.DEFAULT_TIMEOUT</code>. - * - * @param dialogTitle Title to set for the dialog window. - * @param waitMessage Text to be displayed in the body of this dialog while - * the user waits. - */ - public JWaitDialog(String dialogTitle, String waitMessage) { - this(null, dialogTitle, new JLabel(waitMessage, JLabel.CENTER), DEFAULT_TIMEOUT); - } - - - /** - * Creates a new Wait Dialog with specified parent and default timeout on - * operation - <code>JWaitDialog.DEFAULT_TIMEOUT</code>. - * - * @param owner Specified JFrame is set as an owner for this Wait Dialog. - * @param dialogTitle Title to set for the dialog window. - * @param waitMessage Text to be displayed in the body of this dialog while - * the user waits. - */ - public JWaitDialog(JFrame owner, String dialogTitle, String waitMessage) { - this(owner, dialogTitle, new JLabel(waitMessage, JLabel.CENTER), DEFAULT_TIMEOUT); - } - - - /** - * Creates a new Wait Dialog with specified parent and timeout on - * operation. - * - * @param owner Specified JFrame is set as an owner for this Wait Dialog. - * @param dialogTitle Title to set for the dialog window. - * @param waitMessage Text to be displayed in the body of this dialog while - * the user waits. - * @param timeoutMillis Duration of the timeout on the operation - after this - * time has passed the window will notify of the timeout - * and allow to close itself. Value of 0 indicates that the timeout will never occur. - */ - public JWaitDialog(JFrame owner, String dialogTitle, String waitMessage, int timeoutMillis) { - this(owner, dialogTitle, new JLabel(waitMessage, JLabel.CENTER), timeoutMillis); - } - - - /** - * Creates a new Wait Dialog with parent JFrame. - * - * @param owner Specified JFrame is set as an owner for this Wait Dialog. - * @param dialogTitle Title to set for the dialog window. - * @param waitInformationComponent Component to be shown in the body of this - * dialog windows while the user waits for an operation to complete. - * @param timeoutMillis Duration of the timeout on the operation - after this - * time has passed the window will notify of the timeout - * and allow to close itself. Value of 0 indicates that the timeout will never occur. - */ - public JWaitDialog(JFrame owner, String dialogTitle, JComponent waitInformationComponent, int timeoutMillis) - { - super(owner); - this.setModal(true); - this.setTitle(dialogTitle); - - // this will show the wait message to the user - jpInformationPanel = new JPanel(new GridLayout()); - jpInformationPanel.add(waitInformationComponent); - jpInformationPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 20)); - - // some graphical indication that the loading activity is going on - jlLoaderIcon = new JLabel(LOADER_ICON); - jlLoaderIcon.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20)); - - // put components into the dialog box - this.getContentPane().setLayout(new BorderLayout()); - this.getContentPane().add(jpInformationPanel, BorderLayout.CENTER); - this.getContentPane().add(jlLoaderIcon, BorderLayout.SOUTH); - - this.pack(); - // Set the height of the dialog not to be more than 500; the message is in the scroll pane so that should be OK - this.setSize(new Dimension(this.getPreferredSize().width, this.getPreferredSize().height > 500 ? 500 : this.getPreferredSize().height)); - // this.setResizable(false); - this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - - // center this window within the main Taverna Workbench window - this.setLocationRelativeTo(MainWindow.getMainWindow()); - - - // start the timer - on timeout it will produce the - // timeout message and allow to close the window - hasTimedOut = false; - if (timeoutMillis > 0) - { - timeoutTimer = new Timer(); - timeoutTimer.schedule( - new TimerTask() { - public void run() { - waitFinished(new JLabel("<html><center>The operation did not complete within the " + - "allocated time.</center></html>", - UIManager.getIcon("OptionPane.warningIcon"), JLabel.CENTER)); - hasTimedOut = true; - } - }, - timeoutMillis); - } - } - - - public void waitFinished(String resultMessage) { - waitFinished(new JLabel(resultMessage, JLabel.CENTER)); - } - - public void waitFinished(JComponent resultInformationComponent) - { - // this prevents the real response to be set after the - // timeout message was already displayed - if (!hasTimedOut) - { - // first of all stop the timeout timer: if this - // method was called by the application explicitly, not on - // timeout, we don't want the timeout message to appear after that - if (timeoutTimer != null) { timeoutTimer.cancel(); } - - // change the information component - jpInformationPanel.removeAll(); - jpInformationPanel.add(resultInformationComponent); - - // the OK button will allow closing the window - bOK = new JButton("OK"); - //bOK.setPreferredSize(new Dimension(LOADER_ICON.getIconWidth(), (int) (1.5 * LOADER_ICON.getIconHeight()))); - bOK.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - // just remove the window - dispose(); - } - }); - bOK.addKeyListener(new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - // a fallback mechanism - default button doesn't work for some reason - // when the button is added into the dialog not in the constructor - bOK.doClick(); - } - } - }); - bOK.setDefaultCapable(true); - this.getRootPane().setDefaultButton(bOK); - - // wrap OK button into a panel to add empty borders - jpOKButton = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); - jpOKButton.add(bOK); - jpOKButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 20 - (bOK.getPreferredSize().height - LOADER_ICON.getIconHeight()), 20)); - - - // add OK button instead of the loader icon - this.getContentPane().remove(jlLoaderIcon); - this.getContentPane().add(jpOKButton, BorderLayout.SOUTH); - this.bOK.requestFocusInWindow(); - - // re-enable (X) button in the title bar - this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); - - // update the size of this window - as the inner sizes of components have - // been likely to change; then center the dialog box within its parent - this.pack(); - // Set the height of the dialog not to be more than 500; the message is in the scroll pane so that should be OK - this.setSize(new Dimension(this.getPreferredSize().width, this.getPreferredSize().height > 500 ? 500 : this.getPreferredSize().height)); - this.setLocationRelativeTo(MainWindow.getMainWindow()); - } - } - - -}