use of org.cytoscape.work.util.ListMultipleSelection 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);
}
use of org.cytoscape.work.util.ListMultipleSelection 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);
}
use of org.cytoscape.work.util.ListMultipleSelection in project cytoscape-impl by cytoscape.
the class FilterIO method applyParameter.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void applyParameter(String name, Object value, Transformer<?, ?> transformer, Map<String, PropertyInfo> properties) {
PropertyInfo info = properties.get(name);
if (info == null) {
return;
}
if (value == null) {
info.set(transformer, value);
return;
}
Class<?> targetType = info.type;
Class<?> sourceType = value.getClass();
if (targetType == ListSingleSelection.class) {
ListSingleSelection list = (ListSingleSelection) info.get(transformer);
if (list != null) {
list.setSelectedValue(value);
}
} else if (targetType == ListMultipleSelection.class && value instanceof List) {
ListMultipleSelection list = (ListMultipleSelection) info.get(transformer);
if (list != null) {
list.setSelectedValues((List) value);
}
} else {
Object convertedValue = convertValue(name, value, sourceType, targetType);
info.set(transformer, convertedValue);
}
}
Aggregations