use of org.gephi.datalab.api.datatables.DataTablesController in project gephi-plugins-bootcamp by gephi.
the class InvertRowSelection method execute.
@Override
public void execute() {
//Note that a function to inverse selection directly in the table with DataTablesController
//would be more efficient than calculating it here, but this example demonstrates some table selection features.
DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
Graph graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
if (dtc.isNodeTableMode()) {
//Get currently selected nodes and calculate inverse set.
Node[] selected = dtc.getNodeTableSelection();
ArrayList<Node> nodes = new ArrayList<Node>();
nodes.addAll(Arrays.asList(graph.getNodes().toArray()));
for (Node node : selected) {
nodes.remove(node);
}
dtc.setNodeTableSelection(nodes.toArray(new Node[0]));
} else if (dtc.isEdgeTableMode()) {
//Get currently selected edges and calculate inverse set.
Edge[] selected = dtc.getEdgeTableSelection();
ArrayList<Edge> edges = new ArrayList<Edge>();
edges.addAll(Arrays.asList(graph.getEdges().toArray()));
for (Edge edge : selected) {
edges.remove(edge);
}
dtc.setEdgeTableSelection(edges.toArray(new Edge[0]));
}
}
use of org.gephi.datalab.api.datatables.DataTablesController in project gephi by gephi.
the class SelectEdgesOnTable method execute.
@Override
public void execute() {
DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
dtc.setEdgeTableSelection(edges);
dtc.selectEdgesTable();
}
use of org.gephi.datalab.api.datatables.DataTablesController in project gephi by gephi.
the class ImportCSVUIWizardAction method performAction.
@Override
public void performAction() {
wizardDescriptor = new WizardDescriptor(getPanels());
step1.setWizardDescriptor(wizardDescriptor);
step2.setWizardDescriptor(wizardDescriptor);
// {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
wizardDescriptor.setTitle(getName());
Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
dialog.setVisible(true);
dialog.toFront();
boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
if (!cancelled) {
//General parameters:
File file = (File) wizardDescriptor.getProperty("file");
Character separator = (Character) wizardDescriptor.getProperty("separator");
Charset charset = (Charset) wizardDescriptor.getProperty("charset");
String[] columnNames = (String[]) wizardDescriptor.getProperty("columns-names");
Class[] columnTypes = (Class[]) wizardDescriptor.getProperty("columns-types");
//Nodes import parameters:
Boolean assignNewNodeIds = (Boolean) wizardDescriptor.getProperty("assign-new-node-ids");
//Edges import parameters:
Boolean createNewNodes = (Boolean) wizardDescriptor.getProperty("create-new-nodes");
Graph graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
dtc.setAutoRefreshEnabled(false);
try {
switch((Mode) wizardDescriptor.getProperty("mode")) {
case NODES_TABLE:
ac.importCSVToNodesTable(graph, file, separator, charset, columnNames, columnTypes, assignNewNodeIds);
break;
case EDGES_TABLE:
ac.importCSVToEdgesTable(graph, file, separator, charset, columnNames, columnTypes, createNewNodes);
break;
}
dtc.refreshCurrentTable();
} catch (Exception e) {
Logger.getLogger("").log(Level.SEVERE, null, e);
} finally {
dtc.setAutoRefreshEnabled(true);
}
}
step1.unSetup();
step2.unSetup();
}
use of org.gephi.datalab.api.datatables.DataTablesController in project gephi by gephi.
the class ExportTable method execute.
@Override
public void execute() {
DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
dtc.exportCurrentTable(DataTablesController.ExportMode.CSV);
}
use of org.gephi.datalab.api.datatables.DataTablesController in project gephi by gephi.
the class SelectNodesOnTable method execute.
@Override
public void execute() {
Node[] nodes = new Node[] { clickedEdge.getSource(), clickedEdge.getTarget() };
DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
dtc.setNodeTableSelection(nodes);
dtc.selectNodesTable();
}
Aggregations