Search in sources :

Example 16 with ListSingleSelection

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

the class ListSingleTunableHandler method processArg.

public Object processArg(String arg) throws Exception {
    ListSingleSelection lss = (ListSingleSelection) getValue();
    List<Object> vals = lss.getPossibleValues();
    // hopefully what happens
    for (Object o : vals) {
        if (o.toString().equals(arg)) {
            lss.setSelectedValue(o);
            return lss;
        }
    }
    // hopefully NOT what happens
    // only get here if we can't match one of the possible values
    lss.setSelectedValue((Object) arg);
    return lss;
}
Also used : ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Example 17 with ListSingleSelection

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

the class JoinTablesTask method getColumns.

public ListSingleSelection<String> getColumns(CyNetwork network, TableType tableType, String namespace) {
    CyTable selectedTable = getTable(network, tableType, CyRootNetwork.SHARED_ATTRS);
    List<String> colNames = new ArrayList<String>();
    for (CyColumn col : selectedTable.getColumns()) colNames.add(col.getName());
    ListSingleSelection<String> columns = new ListSingleSelection<String>(colNames);
    columns.setSelectedValue(CyRootNetwork.SHARED_NAME);
    return columns;
}
Also used : CyTable(org.cytoscape.model.CyTable) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection) ArrayList(java.util.ArrayList) CyColumn(org.cytoscape.model.CyColumn)

Example 18 with ListSingleSelection

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

the class MergeTablesTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(final CyTable sourceTable, final CyTable targetTable, List<String> sourceColumnsList, String sourceKeyColumn, boolean mergeColumnVirtual, boolean mapToNetworks, boolean selectedNetworksOnly, List<CyNetwork> networkList, CyRootNetwork rootNetwork, CyColumn targetJoinColumn, 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>();
    if (networkList != null) {
        for (CyNetwork net : networkList) {
            networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
        }
    }
    ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
    networksListTunable.setSelectedValues(networkNames);
    List<String> rootNetworkNames = new ArrayList<String>();
    ListSingleSelection<String> rootNetworkList = new ListSingleSelection<String>();
    if (rootNetwork != null) {
        rootNetworkNames.add(rootNetwork.getRow(rootNetwork).get(CyNetwork.NAME, String.class));
        rootNetworkList = new ListSingleSelection<String>(rootNetworkNames);
        rootNetworkList.setSelectedValue(rootNetworkNames.get(0));
    }
    List<String> columnNames = new ArrayList<String>();
    ListSingleSelection<String> columnNamesList = new ListSingleSelection<String>();
    if (targetJoinColumn != null) {
        columnNames.add(targetJoinColumn.getName());
        columnNamesList = new ListSingleSelection<String>(columnNames);
        columnNamesList.setSelectedValue(columnNames.get(0));
    }
    final Map<String, Object> m = new HashMap<String, Object>();
    ListSingleSelection<String> chooser = new ListSingleSelection<String>(MergeTablesTask.NETWORK_COLLECTION, MergeTablesTask.NETWORK_SELECTION, MergeTablesTask.UNASSIGNED_TABLE);
    if (mapToNetworks) {
        if (selectedNetworksOnly)
            chooser.setSelectedValue(MergeTablesTask.NETWORK_SELECTION);
        else
            chooser.setSelectedValue(MergeTablesTask.NETWORK_COLLECTION);
    } else
        chooser.setSelectedValue(MergeTablesTask.UNASSIGNED_TABLE);
    ListSingleSelection<CyTable> sourceTableList = new ListSingleSelection<CyTable>(sourceTable);
    sourceTableList.setSelectedValue(sourceTable);
    ListSingleSelection<Object> targetTableList;
    if (targetTable != null) {
        targetTableList = new ListSingleSelection<Object>(targetTable);
        targetTableList.setSelectedValue(targetTable);
    } else {
        targetTableList = new ListSingleSelection<Object>(MergeTablesTask.NO_TABLES);
        targetTableList.setSelectedValue(MergeTablesTask.NO_TABLES);
    }
    ListMultipleSelection<String> sourceColNames = new ListMultipleSelection<String>(sourceColumnsList);
    sourceColNames.setSelectedValues(sourceColumnsList);
    ListSingleSelection<String> sourceColumn = new ListSingleSelection<String>(sourceKeyColumn);
    sourceColumn.setSelectedValue(sourceKeyColumn);
    m.put("MergeType", mergeColumnVirtual);
    m.put("SourceMergeKey", sourceColumn);
    m.put("TargetMergeKey", columnNamesList);
    m.put("SourceTable", sourceTableList);
    m.put("UnassignedTable", targetTableList);
    m.put("SourceMergeColumns", sourceColNames);
    m.put("WhereMergeTable", chooser);
    m.put("TargetNetworkList", networksListTunable);
    m.put("TargetKeyNetworkCollection", columnNamesList);
    m.put("TargetNetworkCollection", rootNetworkList);
    m.put("DataTypeTargetForNetworkCollection", tableTypes);
    m.put("DataTypeTargetForNetworkList", tableTypes);
    return tunableSetter.createTaskIterator(createTaskIterator(), 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) CyTable(org.cytoscape.model.CyTable) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Example 19 with ListSingleSelection

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

the class ImportTableDataTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(final CyTable globalTable, final boolean selectedNetworksOnly, final boolean loadToUnassignedTable, final List<CyNetwork> networkList, final CyRootNetwork rootNetwork, final CyColumn targetJoinColumn, final Class<? extends CyIdentifiable> type) {
    ListSingleSelection<String> chooser = new ListSingleSelection<String>(ImportTableDataTask.NETWORK_COLLECTION, ImportTableDataTask.NETWORK_SELECTION, ImportTableDataTask.UNASSIGNED_TABLE);
    final Map<String, Object> m = new HashMap<>();
    if (!loadToUnassignedTable) {
        TableType tableType = getTableType(type);
        if (tableType == null)
            throw new IllegalArgumentException("The specified type " + type + " is not acceptable.");
        ListSingleSelection<TableType> tableTypes = new ListSingleSelection<>(tableType);
        tableTypes.setSelectedValue(tableType);
        List<String> networkNames = new ArrayList<String>();
        for (CyNetwork net : networkList) {
            networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
        }
        ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<>(networkNames);
        networksListTunable.setSelectedValues(networkNames);
        List<String> rootNetworkNames = new ArrayList<>();
        ListSingleSelection<String> rootNetworkList = new ListSingleSelection<>();
        if (rootNetwork != null) {
            rootNetworkNames.add(rootNetwork.getRow(rootNetwork).get(CyNetwork.NAME, String.class));
            rootNetworkList = new ListSingleSelection<String>(rootNetworkNames);
            rootNetworkList.setSelectedValue(rootNetworkNames.get(0));
        }
        List<String> columnNames = new ArrayList<String>();
        ListSingleSelection<String> columnNamesList = new ListSingleSelection<>();
        if (targetJoinColumn != null) {
            columnNames.add(targetJoinColumn.getName());
            columnNamesList = new ListSingleSelection<>(columnNames);
            columnNamesList.setSelectedValue(columnNames.get(0));
        }
        if (selectedNetworksOnly) {
            m.put("DataTypeTargetForNetworkList", tableTypes);
            chooser.setSelectedValue(ImportTableDataTask.NETWORK_SELECTION);
        } else {
            m.put("DataTypeTargetForNetworkCollection", tableTypes);
            chooser.setSelectedValue(ImportTableDataTask.NETWORK_COLLECTION);
        }
        m.put("TargetNetworkList", networksListTunable);
        m.put("KeyColumnForMapping", columnNamesList);
        m.put("TargetNetworkCollection", rootNetworkList);
    } else {
        chooser.setSelectedValue(ImportTableDataTask.UNASSIGNED_TABLE);
    }
    m.put("WhereImportTable", chooser);
    final TunableSetter tunableSetter = serviceRegistrar.getService(TunableSetter.class);
    return tunableSetter.createTaskIterator(createTaskIterator(globalTable), m);
}
Also used : TableType(org.cytoscape.task.internal.table.ImportTableDataTask.TableType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListMultipleSelection(org.cytoscape.work.util.ListMultipleSelection) CyNetwork(org.cytoscape.model.CyNetwork) TunableSetter(org.cytoscape.work.TunableSetter) ListSingleSelection(org.cytoscape.work.util.ListSingleSelection)

Example 20 with ListSingleSelection

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

the class JoinTablesTaskTaskFactoryImpl method createTaskIterator.

@Override
public TaskIterator createTaskIterator(CyTable globalTable, boolean selectedNetworksOnly, List<CyNetwork> networkList, CyRootNetwork rootNetwork, CyColumn targetJoinColumn, 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 : networkList) {
        networkNames.add(net.getRow(net).get(CyNetwork.NAME, String.class));
    }
    ListMultipleSelection<String> networksListTunable = new ListMultipleSelection<String>(networkNames);
    networksListTunable.setSelectedValues(networkNames);
    List<String> rootNetworkNames = new ArrayList<String>();
    ListSingleSelection<String> rootNetworkList = new ListSingleSelection<String>();
    if (rootNetwork != null) {
        rootNetworkNames.add(rootNetwork.getRow(rootNetwork).get(CyNetwork.NAME, String.class));
        rootNetworkList = new ListSingleSelection<String>(rootNetworkNames);
        rootNetworkList.setSelectedValue(rootNetworkNames.get(0));
    }
    List<String> columnNames = new ArrayList<String>();
    ListSingleSelection<String> columnNamesList = new ListSingleSelection<String>();
    if (targetJoinColumn != null) {
        columnNames.add(targetJoinColumn.getName());
        columnNamesList = new ListSingleSelection<String>(columnNames);
        columnNamesList.setSelectedValue(columnNames.get(0));
    }
    final Map<String, Object> m = new HashMap<String, Object>();
    m.put("DataTypeOptions", tableTypes);
    m.put("SelectedNetworksOnly", selectedNetworksOnly);
    m.put("NetworkList", networksListTunable);
    m.put("ColumnList", columnNamesList);
    m.put("RootNetworkList", rootNetworkList);
    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)

Aggregations

ListSingleSelection (org.cytoscape.work.util.ListSingleSelection)24 ArrayList (java.util.ArrayList)14 CyTable (org.cytoscape.model.CyTable)8 CyColumn (org.cytoscape.model.CyColumn)7 CyNetwork (org.cytoscape.model.CyNetwork)7 ListMultipleSelection (org.cytoscape.work.util.ListMultipleSelection)6 NetworkViewRenderer (org.cytoscape.application.NetworkViewRenderer)5 HashMap (java.util.HashMap)4 TableType (org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType)3 List (java.util.List)2 CyApplicationManager (org.cytoscape.application.CyApplicationManager)2 CyRootNetwork (org.cytoscape.model.subnetwork.CyRootNetwork)2 HashSet (java.util.HashSet)1 JPanel (javax.swing.JPanel)1 EdgeList (org.cytoscape.command.util.EdgeList)1 NodeList (org.cytoscape.command.util.NodeList)1 NoneAggregator (org.cytoscape.group.internal.data.aggregators.NoneAggregator)1 AbstractCyNetworkReader (org.cytoscape.io.read.AbstractCyNetworkReader)1 CyNetworkReader (org.cytoscape.io.read.CyNetworkReader)1 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)1