X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FJabaParamStore.java;h=7ce1115d25346c9243e4f820dc7d066b53f25174;hb=b2f9a8d7bce642ff4011bc6d49e02bb0569fbb11;hp=50f43684468c08251d484edea08387a1b2cdb81a;hpb=445459c0de00fb5fdb82e818c551950ff90069fe;p=jalview.git diff --git a/src/jalview/ws/jws2/JabaParamStore.java b/src/jalview/ws/jws2/JabaParamStore.java index 50f4368..7ce1115 100644 --- a/src/jalview/ws/jws2/JabaParamStore.java +++ b/src/jalview/ws/jws2/JabaParamStore.java @@ -1,31 +1,31 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) - * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - * + * * Jalview 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 General Public License for more details. * * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.ws.jws2; -import java.io.BufferedReader; import java.io.IOException; -import java.io.Reader; -import java.io.Writer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Hashtable; import java.util.List; import java.util.StringTokenizer; +import org.jmol.util.ArrayUtil; import compbio.metadata.Argument; import compbio.metadata.Option; import compbio.metadata.Parameter; @@ -140,12 +140,28 @@ public class JabaParamStore implements ParamDatastoreI public static List getJwsArgsfromJaba(List jabargs) { + return getJwsArgsfromJaba(jabargs, true); + } + + public static List getJwsArgsfromJaba(List jabargs, + boolean sortByOpt) + { List rgs = new ArrayList(); + List rgnames = new ArrayList(); for (Object rg : jabargs) { - ArgumentI narg = (rg instanceof Parameter) ? new JabaParameter( - (Parameter) rg) : (rg instanceof Option) ? new JabaOption( - (Option) rg) : null; + ArgumentI narg = null; + String nargstring = null; + if (rg instanceof Parameter) + { + narg = new JabaParameter((Parameter) rg); + nargstring = narg.getName(); // just sort by name for this + } + else if (rg instanceof Option) + { + narg = new JabaOption((Option) rg); + nargstring = (String) ((Option) rg).getOptionNames().get(0); + } if (narg == null) { throw new Error( @@ -155,9 +171,25 @@ public class JabaParamStore implements ParamDatastoreI else { rgs.add(narg); + rgnames.add(nargstring); } } - return rgs; + if (!sortByOpt) + { + return rgs; + } + ArgumentI[] rgssort = rgs.toArray(new ArgumentI[rgs.size()]); + String[] rgssorton = rgnames.toArray(new String[rgs.size()]); + jalview.util.QuickSort.sort(rgssorton, rgssort); + ArgumentI tmp1; + int i=0; + while (rgssort.length-i>i) + { + tmp1=rgssort[rgssort.length-i-1]; + rgssort[rgssort.length-i-1] = rgssort[i]; + rgssort[i++]=tmp1; + } + return Arrays.asList(rgssort); } public static List getJabafromJwsArgs(List jwsargs) @@ -272,7 +304,8 @@ public class JabaParamStore implements ParamDatastoreI boolean found = false; for (String url : urls) { - if (service.getServiceTypeURI().equals(url) || service.getUri().equalsIgnoreCase(url)) + if (service.getServiceTypeURI().equals(url) + || service.getUri().equalsIgnoreCase(url)) { found = true; break;