Search in sources :

Example 1 with ListMultipleSelection

use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.

the class MapTableToNetworkTablesTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyTable globalTable, boolean selectedNetworksOnly, List<CyNetwork> networksList, Class<? extends CyIdentifiable> type) {
    TableType tableType = getTableType(type);
    if (tableType == null)
        throw new IllegalArgumentException("The specified type " + type + " is not acceptable.");
    ListSingleSelection<TableType> tableTypes = new ListSingleSelection<TableType>(tableType);
    tableTypes.setSelectedValue(tableType);
    List<String> networkNames = new ArrayList<String>();
    for (CyNetwork net : networksList) {
        networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
    }
    ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
    networksListTunable.setSelectedValues(networkNames);
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("dataTypeOptions", tableTypes);
    m.put("selectedNetworksOnly", selectedNetworksOnly);
    m.put("networkList", networksListTunable);
    return tunableSetter.createTaskIterator(createTaskIterator(globalTable), m);
}
Also used : TableType(org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) CyNetwork(org.cytoscape.model.CyNetwork) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Example 2 with ListMultipleSelection

use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.

the class HelpGenerator method getTypeString.

private String getTypeString(String namespace, String command, String arg) {
    Class<?> clazz = availableCommands.getArgType(namespace, command, arg);
    Object object = availableCommands.getArgValue(namespace, command, arg);
    String keywords = keyword("all") + "|" + keyword("selected") + "|" + keyword("unselected");
    // Special handling for various types
    if (clazz.equals(NodeList.class)) {
        String args = "[" + variable("nodeColumn:value") + "|" + variable("node name") + keyword(",") + "...]|" + keywords;
        return fixedSpan(args);
    } else if (clazz.equals(EdgeList.class)) {
        String args = "[" + variable("edgeColumn:value") + "|" + variable("edge name") + keyword(",") + "...]|" + keywords;
        return fixedSpan(args);
    } else if (clazz.equals(CyNetwork.class)) {
        return fixedSpan(keyword("current") + "|[" + variable("column:value") + "|" + variable("network name") + "]");
    } else if (clazz.equals(CyTable.class)) {
        String args = keyword("Node:") + variable("network name") + "|" + keyword("Edge:") + variable("network name") + "|" + keyword("Network:") + variable("network name") + "|" + variable("table name");
        return fixedSpan(args);
    } else if (clazz.equals(boolean.class) || clazz.equals(Boolean.class)) {
        return fixedSpan(keyword("true") + "|" + keyword("false"));
    } else if (clazz.equals(ListSingleSelection.class)) {
        if (object != null) {
            ListSingleSelection lss = (ListSingleSelection) object;
            String str = "&lt;" + classString(clazz.getSimpleName()) + "&nbsp(";
            List<Object> list = lss.getPossibleValues();
            for (int index = 0; index < list.size() - 1; index++) {
                str += keyword(list.get(index).toString()) + "|";
            }
            if (!list.isEmpty())
                str += keyword(list.get(list.size() - 1).toString());
            str += ")&gt;";
            return fixedSpan(str);
        }
    } else if (clazz.equals(ListMultipleSelection.class)) {
        if (object != null) {
            ListMultipleSelection lss = (ListMultipleSelection) object;
            String str = "&lt;" + classString(clazz.getSimpleName()) + "&nbsp[";
            List<Object> list = lss.getPossibleValues();
            for (int index = 0; index < list.size() - 1; index++) {
                str += keyword(list.get(index).toString()) + ",";
            }
            if (!list.isEmpty())
                str += keyword(list.get(list.size() - 1).toString());
            str += "]&gt;";
            return fixedSpan(str);
        }
    } else if (clazz.equals(BoundedDouble.class) || clazz.equals(BoundedFloat.class) || clazz.equals(BoundedInteger.class) || clazz.equals(BoundedLong.class)) {
        if (object != null)
            return boundedTypeString(clazz, object);
    }
    return fixedSpan("&lt;" + classString(clazz.getSimpleName()) + "&gt;");
}
Also used : CyTable(org.cytoscape.model.CyTable) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) BoundedInteger(org.cytoscape.work.util.BoundedInteger) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) NodeList(org.cytoscape.command.util.NodeList) List(java.util.List) EdgeList(org.cytoscape.command.util.EdgeList) EdgeList(org.cytoscape.command.util.EdgeList)

Example 3 with ListMultipleSelection

use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.

the class JoinTablesTask method initTunable.

private final void initTunable(CyNetworkManager networkManage) {
    selectedNetworksOnly = false;
    final List<TableType> options = new ArrayList<TableType>();
    for (TableType type : TableType.values()) options.add(type);
    dataTypeOptions = new ListSingleSelection<TableType>(options);
    dataTypeOptions.setSelectedValue(TableType.NODE_ATTR);
    for (CyNetwork net : networkManage.getNetworkSet()) {
        String netName = net.getRow(net).get(CyNetwork.NAME, String.class);
        name2NetworkMap.put(netName, net);
    }
    List<String> names = new ArrayList<String>();
    names.addAll(name2NetworkMap.keySet());
    if (names.isEmpty())
        networkList = new ListMultipleSelection<String>(NO_NETWORKS);
    else
        networkList = new ListMultipleSelection<String>(names);
    for (CyNetwork net : networkManager.getNetworkSet()) {
        final CyRootNetwork rootNet = rootNetworkManager.getRootNetwork(net);
        if (!name2RootMap.containsValue(rootNet))
            name2RootMap.put(rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class), rootNet);
    }
    List<String> rootNames = new ArrayList<String>();
    rootNames.addAll(name2RootMap.keySet());
    rootNetworkList = new ListSingleSelection<String>(rootNames);
    rootNetworkList.setSelectedValue(rootNames.get(0));
    columnList = getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()), dataTypeOptions.getSelectedValue(), CyRootNetwork.SHARED_ATTRS);
}
Also used : ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) CyNetwork(org.cytoscape.model.CyNetwork) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 4 with ListMultipleSelection

use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.

the class MapGlobalToLocalTableTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyTable globalTable, Collection<CyTable> localTables) {
    final Map<String, Object> m = new HashMap<String, Object>();
    List<String> localTableTitles = new ArrayList<String>();
    for (CyTable local : localTables) {
        localTableTitles.add(local.getTitle());
    }
    ListMultipleSelection<String> localTablesTunable = new ListMultipleSelection<String>(localTableTitles);
    localTablesTunable.setSelectedValues(localTableTitles);
    m.put("localTables", localTablesTunable);
    return tunableSetter.createTaskIterator(this.createTaskIterator(globalTable), m);
}
Also used : CyTable(org.cytoscape.model.CyTable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection)

Example 5 with ListMultipleSelection

use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.

the class TunablePropertySerializerTest method testBadListSelection.

@Test(expected = IllegalArgumentException.class)
public void testBadListSelection() {
    class Tunables {

        @Tunable
        public ListMultipleSelection<String> lms = new ListMultipleSelection<>("A", "B", "C");
    }
    ;
    Properties props = new Properties();
    props.setProperty("lms", "A,B,What");
    Tunables tunables = new Tunables();
    getSerializer().setTunables(tunables, props);
}
Also used : ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

ListMultipleSelection (org.cytoscape.work.util.ListMultipleSelection)13 ArrayList (java.util.ArrayList)10 CyNetwork (org.cytoscape.model.CyNetwork)7 ListSingleSelection (org.cytoscape.work.util.ListSingleSelection)6 HashMap (java.util.HashMap)5 CyTable (org.cytoscape.model.CyTable)4 TableType (org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType)3 List (java.util.List)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 Properties (java.util.Properties)1 EdgeList (org.cytoscape.command.util.EdgeList)1 NodeList (org.cytoscape.command.util.NodeList)1 CyColumn (org.cytoscape.model.CyColumn)1 TableType (org.cytoscape.task.internal.table.ImportTableDataTask.TableType)1 TunableSetter (org.cytoscape.work.TunableSetter)1 BoundedInteger (org.cytoscape.work.util.BoundedInteger)1 Test (org.junit.Test)1