/** Getter for cookies. * @return the set of cookies for this */ private Class<?>[] getCookies() { Class[] ret = (Class[]) getProperty(PROP_COOKIES); if (ret != null) { return ret; } ret = cookieClasses(); putProperty(PROP_COOKIES, ret); return ret; }
/** Test for enablement based on the cookies of selected nodes. * Generally subclasses should not override this except for strange * purposes, and then only calling the super method and adding a check. * Just use {@link #cookieClasses} and {@link #mode} to specify * the enablement logic. * @param activatedNodes the set of activated nodes * @return <code>true</code> to enable */ protected boolean enable(Node[] activatedNodes) { if (activatedNodes.length == 0) { return false; } // sets new nodes to cookie change listener listener.setNodes(activatedNodes); // perform enable / disable logic return doEnable(activatedNodes); }
public void run() { a.setEnabled(a.enable(nodes2)); } }
/** Helper, actually performs enable / disable logic */ boolean doEnable(Node[] activatedNodes) { int supported = resolveSupported(activatedNodes); if (supported == 0) { return false; } int mode = mode(); return // [PENDING] shouldn't MODE_ONE also say: && supported == 1? --jglick ((mode & MODE_ONE) != 0) || (((mode & MODE_ALL) != 0) && (supported == activatedNodes.length)) || (((mode & MODE_EXACTLY_ONE) != 0) && (activatedNodes.length == 1)) || (((mode & MODE_SOME) != 0) && (supported < activatedNodes.length)); }
@Override protected void initialize() { super.initialize(); // see org.openide.util.actions.SystemAction.iconResource() javadoc for more details putValue("noIconInMenu", Boolean.TRUE); // NOI18N }
/** * Implementation of the above method. * * @param activatedNodes gives array of actually activated nodes. * @return number of supported classes */ private int resolveSupported(Node[] activatedNodes) { int ret = 0; Class<?>[] cookies = getCookies(); for (Node n : activatedNodes) { for (Class<?> cookie : cookies) { // test for supported cookies @SuppressWarnings("unchecked") Lookup.Template<?> templ = new Lookup.Template(cookie); if (n.getLookup().lookupItem(templ) != null) { ret++; break; } } } return ret; }
protected @Override boolean enable(Node[] activatedNodes) { if (!super.enable(activatedNodes)) { return false; } FileObject f = PickNameAction.findFile(activatedNodes); if (f == null) { return false; } NbModuleProvider p = PickNameAction.findProject(f); if (p == null) { return false; } return true; }
/** Helper, actually performs enable / disable logic */ boolean doEnable (Node[] activatedNodes) { int supported = resolveSupported(activatedNodes); if (supported == 0) return false; int mode = mode (); return // [PENDING] shouldn't MODE_ONE also say: && supported == 1? --jglick ((mode & MODE_ONE) != 0) || (((mode & MODE_ALL) != 0) && (supported == activatedNodes.length)) || (((mode & MODE_EXACTLY_ONE) != 0) && (activatedNodes.length == 1)) || (((mode & MODE_SOME) != 0) && (supported < activatedNodes.length)); }
@Override protected void initialize() { super.initialize(); putValue("noIconInMenu", Boolean.TRUE); // NOI18N }
/** * Implementation of the above method. * * @param activatedNodes gives array of actually activated nodes. * @return number of supported classes */ private int resolveSupported (Node[] activatedNodes) { int total = activatedNodes.length; int ret = 0; Class[] cookies = getCookies(); for (int i = 0; i < total; i++) { for (int j = 0; j < cookies.length; j++) { // test for supported cookies if (activatedNodes[i].getLookup().lookupItem(new Lookup.Template(cookies[j])) != null) { ret++; break; } } } return ret; }
protected final boolean enable(Node[] nodes) { return nodes != null && super.enable(nodes) && XAMUtils.getViewCookie(XAMUtils.getComponent( nodes[0]), getView()) != null; }
/** Getter for cookies. * @return the set of cookies for this */ private Class[] getCookies () { Class[] ret = (Class[])getProperty (PROP_COOKIES); if (ret != null) return ret; ret = cookieClasses (); putProperty (PROP_COOKIES, ret); return ret; }
/** Helper, actually performs enable / disable logic */ boolean doEnable (Node[] activatedNodes) { int supported = resolveSupported(activatedNodes); if (supported == 0) return false; int mode = mode (); return // [PENDING] shouldn't MODE_ONE also say: && supported == 1? --jglick ((mode & MODE_ONE) != 0) || (((mode & MODE_ALL) != 0) && (supported == activatedNodes.length)) || (((mode & MODE_EXACTLY_ONE) != 0) && (activatedNodes.length == 1)) || (((mode & MODE_SOME) != 0) && (supported < activatedNodes.length)); }
@Override protected void initialize() { super.initialize(); putValue("noIconInMenu", Boolean.TRUE); // NOI18N }
/** Test for enablement based on the cookies of selected nodes. * Generally subclasses should not override this except for strange * purposes, and then only calling the super method and adding a check. * Just use {@link #cookieClasses} and {@link #mode} to specify * the enablement logic. * @param activatedNodes the set of activated nodes * @return <code>true</code> to enable */ protected boolean enable (Node[] activatedNodes) { if (activatedNodes.length == 0) { return false; } // sets new nodes to cookie change listener listener.setNodes(activatedNodes); // perform enable / disable logic return doEnable(activatedNodes); }
/** * Implementation of the above method. * * @param activatedNodes gives array of actually activated nodes. * @return number of supported classes */ private int resolveSupported (Node[] activatedNodes) { int total = activatedNodes.length; int ret = 0; Class[] cookies = getCookies(); for (int i = 0; i < total; i++) { for (int j = 0; j < cookies.length; j++) { // test for supported cookies if (activatedNodes[i].getLookup().lookupItem(new Lookup.Template(cookies[j])) != null) { ret++; break; } } } return ret; }
@Override protected boolean enable(Node[] activatedNodes) { if (!super.enable(activatedNodes)) { return false; } FileObject f = findFile(activatedNodes); if (f == null) { return false; } NbModuleProvider p = findProject(f); if (p == null) { return false; } return findBundlePath(p) != null; }
/** Getter for cookies. * @return the set of cookies for this */ private Class[] getCookies () { Class[] ret = (Class[])getProperty (PROP_COOKIES); if (ret != null) return ret; ret = cookieClasses (); putProperty (PROP_COOKIES, ret); return ret; }
@Override protected void initialize() { super.initialize(); // see org.openide.util.actions.SystemAction.iconResource() Javadoc for more details putValue("noIconInMenu", Boolean.TRUE); // NOI18N }
/** Test for enablement based on the cookies of selected nodes. * Generally subclasses should not override this except for strange * purposes, and then only calling the super method and adding a check. * Just use {@link #cookieClasses} and {@link #mode} to specify * the enablement logic. * @param activatedNodes the set of activated nodes * @return <code>true</code> to enable */ protected boolean enable (Node[] activatedNodes) { if (activatedNodes.length == 0) { return false; } // sets new nodes to cookie change listener listener.setNodes(activatedNodes); // perform enable / disable logic return doEnable(activatedNodes); }