use of org.cytoscape.work.util.ListSingleSelection 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.ListSingleSelection 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.ListSingleSelection in project cytoscape-impl by cytoscape.
the class CombineReaderAndMappingTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
this.taskMonitor = taskMonitor;
// Pass the tunable values from this task to the helper task
final String rootNetName = getRootNetworkList().getSelectedValue();
final String targetColumn = getTargetColumnList().getSelectedValue();
final NetworkViewRenderer renderer = getNetworkViewRendererList().getSelectedValue();
if (rootNetName != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(rootNetName));
ls.setSelectedValue(rootNetName);
collectionHelper.setRootNetworkList(ls);
} else {
collectionHelper.setRootNetworkList(new ListSingleSelection<>(Collections.emptyList()));
collectionHelper.setTargetColumnList(new ListSingleSelection<>(Collections.emptyList()));
}
if (targetColumn != null) {
ListSingleSelection<String> ls = new ListSingleSelection<>(Collections.singletonList(targetColumn));
ls.setSelectedValue(targetColumn);
collectionHelper.setTargetColumnList(ls);
}
if (renderer != null) {
ListSingleSelection<NetworkViewRenderer> ls = new ListSingleSelection<>(Collections.singletonList(renderer));
ls.setSelectedValue(renderer);
collectionHelper.setNetworkViewRendererList(ls);
}
// Run the helper task
collectionHelper.run(taskMonitor);
// Run the Import task
importTask.setNodeMap(collectionHelper.getNodeMap());
importTask.setRootNetwork(collectionHelper.getRootNetwork());
importTask.setNetworkViewFactory(collectionHelper.getNetworkViewFactory());
importTask.run(taskMonitor);
}
use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.
the class LoadMultipleNetworksTask method getTargetColumns.
private final ListSingleSelection<String> getTargetColumns(final CyNetwork network) {
final CyTable selectedTable = network.getTable(CyNode.class, CyRootNetwork.SHARED_ATTRS);
final List<String> colNames = new ArrayList<>();
for (CyColumn col : selectedTable.getColumns()) {
// Exclude SUID from the mapping key list
if (!col.getName().equalsIgnoreCase(CyIdentifiable.SUID) && !col.getName().endsWith(".SUID") && (col.getType() == String.class || col.getType() == Integer.class || col.getType() == Long.class))
colNames.add(col.getName());
}
if (colNames.isEmpty() || (colNames.size() == 1 && colNames.contains(CyRootNetwork.SHARED_NAME)))
return new ListSingleSelection<>();
sort(colNames);
return new ListSingleSelection<>(colNames);
}
use of org.cytoscape.work.util.ListSingleSelection in project cytoscape-impl by cytoscape.
the class LayoutSettingsDialog method setNetworkView.
void setNetworkView(final CyNetworkView view) {
getApplyBtn().setEnabled(view != null);
if (layoutAttrPnl == null)
return;
boolean haveNodeAttribute = (currentLayout.getSupportedNodeAttributeTypes() != null && currentLayout.getSupportedNodeAttributeTypes().size() > 0);
boolean haveEdgeAttribute = (currentLayout.getSupportedEdgeAttributeTypes() != null && currentLayout.getSupportedEdgeAttributeTypes().size() > 0);
layoutAttrPnl.removeAll();
if (currentLayout.getSupportedEdgeAttributeTypes() != null && currentLayout.getSupportedEdgeAttributeTypes().size() > 0)
layoutEdgeAttrTunable = new LayoutEdgeAttributeTunable();
else if (currentLayout.getSupportedNodeAttributeTypes() != null && currentLayout.getSupportedNodeAttributeTypes().size() > 0)
layoutNodeAttrTunable = new LayoutNodeAttributeTunable();
if (view != null) {
List<String> attributeList = getAttributeList(view.getModel(), currentLayout.getSupportedNodeAttributeTypes(), currentLayout.getSupportedEdgeAttributeTypes());
if (attributeList.size() > 0) {
final PanelTaskManager taskMgr = serviceRegistrar.getService(PanelTaskManager.class);
JPanel panel = null;
if (haveEdgeAttribute) {
layoutEdgeAttrTunable = new LayoutEdgeAttributeTunable();
layoutEdgeAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList);
layoutEdgeAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0));
panel = taskMgr.getConfiguration(null, layoutEdgeAttrTunable);
} else if (haveNodeAttribute) {
layoutNodeAttrTunable = new LayoutNodeAttributeTunable();
layoutNodeAttrTunable.layoutAttribute = new ListSingleSelection<String>(attributeList);
layoutNodeAttrTunable.layoutAttribute.setSelectedValue(attributeList.get(0));
panel = taskMgr.getConfiguration(null, layoutNodeAttrTunable);
}
setPanelsTransparent(panel);
layoutAttrPnl.add(panel);
panel.invalidate();
}
}
}
Aggregations