use of org.openide.nodes.Index 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.Index in project ACS by ACS-Community.
the class MoveDownActionCopiedFromNetbeans method performAction.
/* Actually performs the action of moving the node down
* in the order.
* @param activatedNodes The nodes on which to perform the action.
*/
protected void performAction(Node[] activatedNodes) {
// we need to check activatedNodes, because there's no
// guarantee that they not changed between enable() and
// performAction calls
Index cookie = getIndexCookie(activatedNodes);
if (cookie == null)
return;
int nodeIndex = cookie.indexOf(activatedNodes[0]);
if ((nodeIndex >= 0) && (nodeIndex < (cookie.getNodesCount() - 1))) {
cookie.moveDown(nodeIndex);
}
}
use of org.openide.nodes.Index in project ACS by ACS-Community.
the class MoveDownActionCopiedFromNetbeans method enable.
/* Manages enable - disable logic of this action */
protected boolean enable(Node[] activatedNodes) {
// remove old listener, if any
Index idx = getCurIndexCookie();
if (idx != null) {
idx.removeChangeListener((ChangeListener) getProperty(PROP_ORDER_LISTENER));
idx = null;
}
Index cookie = getIndexCookie(activatedNodes);
if (cookie == null)
return false;
int nodeIndex = cookie.indexOf(activatedNodes[0]);
// now start listening to reordering changes
cookie.addChangeListener((OrderingListener) getProperty(PROP_ORDER_LISTENER));
curIndexCookie = new WeakReference(cookie);
return (nodeIndex >= 0) && (nodeIndex < (cookie.getNodesCount() - 1));
}
use of org.openide.nodes.Index in project ACS by ACS-Community.
the class MoveUpActionCopiedFromNetbeans method performAction.
/* Actually performs the action of moving up
* in the order.
* @param activatedNodes The nodes on which to perform the action.
*/
protected void performAction(Node[] activatedNodes) {
// we need to check activatedNodes, because there's no
// guarantee that they not changed between enable() and
// performAction calls
Index cookie = getIndexCookie(activatedNodes);
if (cookie == null)
return;
int nodeIndex = cookie.indexOf(activatedNodes[0]);
if (nodeIndex > 0) {
cookie.moveUp(nodeIndex);
}
}
Aggregations