org.openide.nodes.Node.getCookie()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.openide.nodes.Node.getCookie()方法的一些代码示例,展示了Node.getCookie()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getCookie()方法的具体详情如下:
包路径:org.openide.nodes.Node
类名称:Node
方法名:getCookie

Node.getCookie介绍

[英]Get a cookie for this node.

The set of cookies can change. If a node changes its set of cookies, it fires a property change event with #PROP_COOKIE.

If the Node was constructed with a Lookup in constructor than this method delegates to the provided lookup object.
[中]获取此节点的cookie。
这组cookie可以更改。如果节点更改其COOKIE集,它将使用#PROP_COOKIE触发属性更改事件。
如果节点是用Lookupin构造函数构造的,则此方法将委托给提供的查找对象。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-nodes

/** 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);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-nodes

/** 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);
}

代码示例来源:origin: org.netbeans.api/org-openide-nodes

/** 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);
}

代码示例来源:origin: org.netbeans.api/org-openide-nodes

@SuppressWarnings("unchecked")
  Class<? extends Node.Cookie> fake = (Class<? extends Node.Cookie>)c;
  res = node.getCookie(fake);
} finally {
  pairs = CookieSet.exitQueryMode(prev);

代码示例来源:origin: org.netbeans.api/org-openide-nodes

/** 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);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver

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);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf-navigation

@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);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5

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;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

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();
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver

public org.openide.nodes.Node.Cookie getCookie(Class type) {
  org.openide.nodes.Node.Cookie c = null;
  if (xnode != null)
    c = xnode.getCookie(type);
  if (c == null)
    c = getOriginal().getCookie(type);
  if (c == null) 
    c = super.getCookie(type);
  return c;
}

代码示例来源:origin: dcaoyuan/nbscala

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 ()]));
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver

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;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver

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;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project

@Override
  public void open() {
    EditCookie originalEC = getOriginal().getCookie(EditCookie.class);
    if (null != originalEC)
      originalEC.edit();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf-navigation

public static void openPageFlowSceneElement(PageFlowSceneElement element) {
  OpenCookie openCookie = (element).getNode().getCookie(OpenCookie.class);
  if (openCookie != null) {
    openCookie.open();
  }
}
public static Action handleNewWebForm = new AbstractAction() {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-sun-appsrv81

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){

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

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;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5

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();
    }
  }
}

相关文章

微信公众号

最新文章

更多