use of org.gephi.filters.api.Query in project gephi by gephi.
the class FiltersPanel method initEvents.
private void initEvents() {
resetButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
for (Query query : filterModel.getQueries()) {
controller.remove(query);
}
// uiModel.setSelectedQuery(null);
controller.selectVisible(null);
controller.filterVisible(null);
((FiltersExplorer) libraryTree).setup(manager, filterModel, uiModel);
stopButton.setVisible(false);
filterButton.setVisible(true);
}
});
filterButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// selectButton.setSelected(false);
if (uiModel.getSelectedQuery() != null) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
controller.filterVisible(uiModel.getSelectedRoot());
stopButton.setSelected(false);
stopButton.setVisible(true);
filterButton.setVisible(false);
}
}
});
stopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
controller.filterVisible(null);
controller.selectVisible(null);
stopButton.setVisible(false);
filterButton.setSelected(true);
filterButton.setVisible(true);
}
});
selectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
if (controller.getModel().isSelecting()) {
controller.selectVisible(null);
} else {
if (uiModel.getSelectedQuery() != null) {
controller.selectVisible(uiModel.getSelectedRoot());
}
}
}
});
exportColumnButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (uiModel.getSelectedQuery() != null) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.exportColumn.input"), NbBundle.getMessage(FiltersPanel.class, "FiltersPanel.exportColumn.input.title"));
if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
String input = question.getInputText();
if (input != null && !input.isEmpty()) {
controller.exportToColumn(input, uiModel.getSelectedRoot());
}
}
}
}
});
exportWorkspaceButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (uiModel.getSelectedQuery() != null) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
controller.exportToNewWorkspace(uiModel.getSelectedRoot());
}
}
});
exportLabelVisible.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (uiModel.getSelectedQuery() != null) {
FilterController controller = Lookup.getDefault().lookup(FilterController.class);
controller.exportToLabelVisible(uiModel.getSelectedRoot());
}
}
});
updateEnabled(false);
}
use of org.gephi.filters.api.Query in project gephi by gephi.
the class RootNode method getDropType.
@Override
public PasteType getDropType(Transferable t, int action, int index) {
final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
if (t.isDataFlavorSupported(FilterBuilderNode.DATA_FLAVOR)) {
try {
final FilterBuilder fb = (FilterBuilder) t.getTransferData(FilterBuilderNode.DATA_FLAVOR);
return new PasteType() {
@Override
public Transferable paste() throws IOException {
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
Query f = filterController.createQuery(fb);
filterController.add(f);
return null;
}
};
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
}
} else if (dropNode != null && dropNode instanceof SavedQueryNode) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
SavedQueryNode node = (SavedQueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.add(node.getQuery());
return null;
}
};
} else if (dropNode != null && dropNode instanceof QueryNode && ((QueryNode) dropNode).getQuery().getParent() != null) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
QueryNode queryNode = (QueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
filterController.removeSubQuery(queryNode.getQuery(), queryNode.getQuery().getParent());
filterController.add(queryNode.getQuery());
return null;
}
};
}
return null;
}
use of org.gephi.filters.api.Query in project gephi by gephi.
the class FilterControllerImpl method add.
@Override
public void add(Query query) {
AbstractQueryImpl absQuery = ((AbstractQueryImpl) query);
absQuery = absQuery.getRoot();
if (!model.hasQuery(absQuery)) {
model.addFirst(absQuery);
// Init filters with default graph
Graph graph;
if (model != null && model.getGraphModel() != null) {
graph = model.getGraphModel().getGraph();
} else {
GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel(model.getWorkspace());
graph = graphModel.getGraph();
}
for (Query q : query.getDescendantsAndSelf()) {
Filter filter = q.getFilter();
if (filter instanceof NodeFilter || filter instanceof EdgeFilter || filter instanceof ElementFilter) {
FilterProcessor filterProcessor = new FilterProcessor();
filterProcessor.init(filter, graph);
}
}
}
}
use of org.gephi.filters.api.Query in project gephi by gephi.
the class FilterControllerImpl method setValue.
@Override
public void setValue(FilterProperty property, Object value, Callback callback) {
if (model != null) {
Query query = model.getQuery(property.getFilter());
if (query == null) {
callback.setValue(value);
return;
}
AbstractQueryImpl rootQuery = ((AbstractQueryImpl) query).getRoot();
FilterThread filterThread;
if ((filterThread = model.getFilterThread()) != null && model.getCurrentQuery() == rootQuery) {
if (Thread.currentThread().equals(filterThread)) {
// Called inside of the thread, in init for instance. Update normally.
callback.setValue(value);
model.updateParameters(query);
} else {
// The query is currently being filtered by the thread, or finished to do it
filterThread.addModifier(new PropertyModifier(query, property, value, callback));
filterThread.setRootQuery(rootQuery);
}
} else {
// Update normally
callback.setValue(value);
model.updateParameters(query);
}
} else {
callback.setValue(value);
}
}
use of org.gephi.filters.api.Query in project gephi by gephi.
the class FilterModelPersistenceProvider method writeXML.
public void writeXML(XMLStreamWriter writer, FilterModelImpl model) throws XMLStreamException {
writer.writeStartElement("autorefresh");
writer.writeAttribute("value", String.valueOf(model.isAutoRefresh()));
writer.writeEndElement();
// Queries
writer.writeStartElement("queries");
queryId = 0;
for (Query query : model.getQueries()) {
writeQuery("query", writer, model, query, -1);
}
writer.writeEndElement();
// Saved queries
writer.writeStartElement("savedqueries");
for (Query query : model.getLibrary().getLookup().lookupAll(Query.class)) {
writeQuery("savedquery", writer, model, query, -1);
}
writer.writeEndElement();
}
Aggregations