/** Get a cookie from the node. * Uses the cookie set as determined by {@link #getCookieSet}. * * @param type the representation class * @return the cookie or <code>null</code> */ @Override public <T extends Node.Cookie> T getCookie(Class<T> type) { if (lookup instanceof CookieSet) { CookieSet c = (CookieSet) lookup; return c.getCookie(type); } else { return super.getCookie(type); } }
/** Obtain a cookie instance from the copied node in a transferable. * <P> * First of all it checks whether the given transferable contains * a node and then asks for the cookie. * <p>If you wish to specially support multiple-node transfers, please use {@link #nodes} * and manually check for the desired combination of cookies. * * @param t transferable to check in * @param cookie cookie representation class to look for * @param action the action which was used to store the node * * @return cookie or <code>null</code> if it does not exist */ public static <T extends Node.Cookie> T cookie(Transferable t, int action, Class<T> cookie) { Node n = node(t, action); return (n == null) ? null : n.getCookie(cookie); }
/** Delegates to original, if no special lookup provided in constructor, * Otherwise it delegates to the lookup. Never override this method * if the lookup is provided in constructor. * * @param type the class to look for * @return instance of that class or null if this class of cookie * is not supported * @see Node#getCookie */ @Override public <T extends Node.Cookie> T getCookie(Class<T> type) { Lookup l = internalLookup(true); if (l != null) { Object res = l.lookup(type); return type.isInstance(res) && res instanceof Node.Cookie ? type.cast(res) : null; } return original.getCookie(type); }
@SuppressWarnings("unchecked") Class<? extends Node.Cookie> fake = (Class<? extends Node.Cookie>)c; res = node.getCookie(fake); } finally { pairs = CookieSet.exitQueryMode(prev);
/** Notifies subclasses that a query is about to be processed. * @param template the template */ @Override protected final void beforeLookup(Template template) { Class type = template.getType(); if (type == Object.class) { // ok, this is likely query for everything java.util.Set all; Object prev = null; try { prev = CookieSet.entryAllClassesMode(); Object ignoreResult = node.getCookie(Node.Cookie.class); } finally { all = CookieSet.exitAllClassesMode(prev); } Iterator it = all.iterator(); while (it.hasNext()) { Class c = (Class) it.next(); updateLookupAsCookiesAreChanged(c); } // update Node.Cookie if not yet if (!queriedCookieClasses.contains(Node.Cookie.class)) { updateLookupAsCookiesAreChanged(Node.Cookie.class); } } if (!queriedCookieClasses.contains(type)) { updateLookupAsCookiesAreChanged(type); } }
private static void performActionImpl(Node[] nodes) { for (int i = 0; i < nodes.length; i++) { final ServerInstance si = (ServerInstance) nodes[i].getCookie(ServerInstance.class); performActionImpl(si); } }
@Override public <T extends Cookie> T getCookie(Class<T> type) { if (type.equals(DataFolder.class)) { assert srcFolderNode != null; return srcFolderNode.getCookie(type); } return super.getCookie(type); } }
protected boolean enable(Node[] nodes) { for (int i = 0; i < nodes.length; i++) { TomcatWebModuleCookie cookie = (TomcatWebModuleCookie)nodes[i].getCookie(TomcatWebModuleCookie.class); if (cookie == null || !cookie.hasLogger()) { return false; } } return true; }
protected boolean enable(final Node[] activatedNodes) { if (activatedNodes == null || activatedNodes.length != 1) return false; DataObject dao = activatedNodes[0].getCookie(DataObject.class); if ((dao != null) && MIMENames.ELF_CORE_MIME_TYPE.equals(IpeUtils.getMime(dao))) { return true; } return false; }
protected boolean enable(Node[] nodes) { for (int i = 0; i < nodes.length; i++) { TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class); if (cookie == null || !cookie.hasServerLog()) { return false; } } return true; }
protected void performAction(final Node[] activatedNodes) { for (int i = 0; i < activatedNodes.length; i++) { PrintCookie pc = (PrintCookie)activatedNodes[i].getCookie (PrintCookie.class); if (pc != null) { pc.print(); } } }
private Lookup getLookup () { Node[] nodes = TopComponent.getRegistry ().getActivatedNodes (); int i, k = nodes.length; ArrayList l = new ArrayList (); for (i = 0; i < k; i++) { Object o = nodes [i].getCookie (DataObject.class); if (o != null) l.add (o); } return Lookups.fixed (l.toArray (new DataObject [l.size ()])); }
protected boolean enable (Node[] nodes) { for (int i = 0; i < nodes.length; i++) { ServerInstance instance = (ServerInstance)nodes[i].getCookie(ServerInstance.class); if (instance == null || instance.isRemoveForbidden() || instance.getServerState() == ServerInstance.STATE_WAITING) { return false; } } return true; }
private static boolean enableImpl(Node[] nodes) { if (nodes.length != 1) { return false; } ServerInstance si = (ServerInstance)nodes[0].getCookie(ServerInstance.class); if (si == null || si.getServerState() != ServerInstance.STATE_STOPPED || !si.isProfileSupported()) { return false; } return true; } }
@Override public void open() { EditCookie originalEC = getOriginal().getCookie(EditCookie.class); if (null != originalEC) originalEC.edit(); } }
public static void openPageFlowSceneElement(PageFlowSceneElement element) { OpenCookie openCookie = (element).getNode().getCookie(OpenCookie.class); if (openCookie != null) { openCookie.open(); } } public static Action handleNewWebForm = new AbstractAction() {
protected void performAction(Node[] nodes) { if(nodes[0].getLookup().lookup(ManagerNode.class) != null){ ManagerNode node = (ManagerNode)nodes[0].getCookie(ManagerNode.class); SunDeploymentManagerInterface sdm = node.getDeploymentManager(); viewLog(sdm,true,true);//entire file and forced } } public static InputOutput viewLog(SunDeploymentManagerInterface sdm){
private EditorCookie activatedEditorCookie(Node[] nodes) { if (nodes == null) { nodes = WindowManager.getDefault().getRegistry().getActivatedNodes(); } if (nodes.length == 1) { Node node = nodes[0]; return (EditorCookie) node.getCookie(EditorCookie.class); } return null; }
protected void performAction(Node[] nodes) { for (int i = 0; i < nodes.length; i++) { TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class); if (cookie == null) { continue; } TomcatManager tm = cookie.getTomcatManager(); if (tm != null) { tm.logManager().openSharedContextLog(); } } }