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);
}
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 = "<" + classString(clazz.getSimpleName()) + " (";
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 += ")>";
return fixedSpan(str);
}
} else if (clazz.equals(ListMultipleSelection.class)) {
if (object != null) {
ListMultipleSelection lss = (ListMultipleSelection) object;
String str = "<" + classString(clazz.getSimpleName()) + " [";
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 += "]>";
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("<" + classString(clazz.getSimpleName()) + ">");
}
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);
}
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);
}
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);
}
Aggregations