use of org.openide.nodes.Node in project gephi by gephi.
the class QueryExplorer method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
if (uiModel == null) {
return;
}
Node[] nodeArray = (Node[]) evt.getNewValue();
if (nodeArray.length > 0) {
Node node = ((Node[]) evt.getNewValue())[0];
if (node instanceof RootNode) {
uiModel.setSelectedQuery(null);
filterController.setCurrentQuery(null);
return;
}
while (!(node instanceof QueryNode)) {
node = node.getParentNode();
if (node.getParentNode() == null) {
uiModel.setSelectedQuery(null);
filterController.setCurrentQuery(null);
return;
}
}
QueryNode queryNode = (QueryNode) node;
final Query query = queryNode.getQuery();
new Thread(new Runnable() {
@Override
public void run() {
uiModel.setSelectedQuery(query);
model.removeChangeListener(QueryExplorer.this);
filterController.setCurrentQuery(uiModel.getSelectedRoot());
model.addChangeListener(QueryExplorer.this);
}
}).start();
}
}
}
use of org.openide.nodes.Node in project ACS by ACS-Community.
the class MultiListExplorer method selectNthChildren.
protected static void selectNthChildren(ExplorerManager explorerManager, int n) {
Node exploredNode = explorerManager.getExploredContext();
if (exploredNode == null)
return;
Children children = exploredNode.getChildren();
try {
if (children == null || children.getNodesCount() == 0) {
explorerManager.setSelectedNodes(new Node[0]);
} else {
if (n >= children.getNodesCount()) {
explorerManager.setSelectedNodes(new Node[] { children.getNodes()[0] });
} else {
explorerManager.setSelectedNodes(new Node[] { children.getNodes()[n] });
}
}
} catch (java.beans.PropertyVetoException e) {
GPManager.notify(GPManager.WARNING, e);
}
}
use of org.openide.nodes.Node in project ACS by ACS-Community.
the class MoveUpActionCopiedFromNetbeans method enable.
/* Manages enable - disable logic of this action */
protected boolean enable(Node[] activatedNodes) {
initErr();
if (err != null) {
err.log(ErrorManager.UNKNOWN, "enable; activatedNodes=" + (activatedNodes == null ? null : Arrays.asList(activatedNodes)));
}
// remove old listener, if any
Index idx = getCurIndexCookie();
if (idx != null) {
idx.removeChangeListener((ChangeListener) getProperty(PROP_ORDER_LISTENER));
}
Index cookie = getIndexCookie(activatedNodes);
if (err != null) {
err.log(ErrorManager.UNKNOWN, "enable; cookie=" + cookie);
}
if (cookie == null)
return false;
// now start listening to reordering changes
cookie.addChangeListener((OrderingListener) getProperty(PROP_ORDER_LISTENER));
curIndexCookie = new WeakReference(cookie);
int index = cookie.indexOf(activatedNodes[0]);
if (err != null) {
err.log(ErrorManager.UNKNOWN, "enable; index=" + index);
if (index == -1) {
Node parent = activatedNodes[0].getParentNode();
err.log(ErrorManager.UNKNOWN, "enable; parent=" + parent + "; parent.children=" + Arrays.asList(parent.getChildren().getNodes()));
}
}
return index > 0;
}
use of org.openide.nodes.Node in project gephi by gephi.
the class CategoryNode method getDropType.
@Override
public PasteType getDropType(final Transferable t, int action, int index) {
if (category == null || !category.equals(FiltersExplorer.QUERIES)) {
return null;
}
final Node dropNode = NodeTransfer.node(t, DnDConstants.ACTION_COPY_OR_MOVE);
if (dropNode != null && dropNode instanceof QueryNode) {
return new PasteType() {
@Override
public Transferable paste() throws IOException {
QueryNode queryNode = (QueryNode) dropNode;
FilterController filterController = Lookup.getDefault().lookup(FilterController.class);
FilterLibrary library = filterController.getModel().getLibrary();
library.saveQuery(queryNode.getQuery());
return null;
}
};
}
return null;
}
use of org.openide.nodes.Node 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 (UnsupportedFlavorException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} 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;
}
Aggregations