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

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

本文整理了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

  1. /** Get a cookie from the node.
  2. * Uses the cookie set as determined by {@link #getCookieSet}.
  3. *
  4. * @param type the representation class
  5. * @return the cookie or <code>null</code>
  6. */
  7. @Override
  8. public <T extends Node.Cookie> T getCookie(Class<T> type) {
  9. if (lookup instanceof CookieSet) {
  10. CookieSet c = (CookieSet) lookup;
  11. return c.getCookie(type);
  12. } else {
  13. return super.getCookie(type);
  14. }
  15. }

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

  1. /** Obtain a cookie instance from the copied node in a transferable.
  2. * <P>
  3. * First of all it checks whether the given transferable contains
  4. * a node and then asks for the cookie.
  5. * <p>If you wish to specially support multiple-node transfers, please use {@link #nodes}
  6. * and manually check for the desired combination of cookies.
  7. *
  8. * @param t transferable to check in
  9. * @param cookie cookie representation class to look for
  10. * @param action the action which was used to store the node
  11. *
  12. * @return cookie or <code>null</code> if it does not exist
  13. */
  14. public static <T extends Node.Cookie> T cookie(Transferable t, int action, Class<T> cookie) {
  15. Node n = node(t, action);
  16. return (n == null) ? null : n.getCookie(cookie);
  17. }

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

  1. /** Delegates to original, if no special lookup provided in constructor,
  2. * Otherwise it delegates to the lookup. Never override this method
  3. * if the lookup is provided in constructor.
  4. *
  5. * @param type the class to look for
  6. * @return instance of that class or null if this class of cookie
  7. * is not supported
  8. * @see Node#getCookie
  9. */
  10. @Override
  11. public <T extends Node.Cookie> T getCookie(Class<T> type) {
  12. Lookup l = internalLookup(true);
  13. if (l != null) {
  14. Object res = l.lookup(type);
  15. return type.isInstance(res) && res instanceof Node.Cookie ? type.cast(res) : null;
  16. }
  17. return original.getCookie(type);
  18. }

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

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

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

  1. /** Notifies subclasses that a query is about to be processed.
  2. * @param template the template
  3. */
  4. @Override
  5. protected final void beforeLookup(Template template) {
  6. Class type = template.getType();
  7. if (type == Object.class) {
  8. // ok, this is likely query for everything
  9. java.util.Set all;
  10. Object prev = null;
  11. try {
  12. prev = CookieSet.entryAllClassesMode();
  13. Object ignoreResult = node.getCookie(Node.Cookie.class);
  14. } finally {
  15. all = CookieSet.exitAllClassesMode(prev);
  16. }
  17. Iterator it = all.iterator();
  18. while (it.hasNext()) {
  19. Class c = (Class) it.next();
  20. updateLookupAsCookiesAreChanged(c);
  21. }
  22. // update Node.Cookie if not yet
  23. if (!queriedCookieClasses.contains(Node.Cookie.class)) {
  24. updateLookupAsCookiesAreChanged(Node.Cookie.class);
  25. }
  26. }
  27. if (!queriedCookieClasses.contains(type)) {
  28. updateLookupAsCookiesAreChanged(type);
  29. }
  30. }

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

  1. private static void performActionImpl(Node[] nodes) {
  2. for (int i = 0; i < nodes.length; i++) {
  3. final ServerInstance si = (ServerInstance) nodes[i].getCookie(ServerInstance.class);
  4. performActionImpl(si);
  5. }
  6. }

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

  1. @Override
  2. public <T extends Cookie> T getCookie(Class<T> type) {
  3. if (type.equals(DataFolder.class)) {
  4. assert srcFolderNode != null;
  5. return srcFolderNode.getCookie(type);
  6. }
  7. return super.getCookie(type);
  8. }
  9. }

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

  1. protected boolean enable(Node[] nodes) {
  2. for (int i = 0; i < nodes.length; i++) {
  3. TomcatWebModuleCookie cookie = (TomcatWebModuleCookie)nodes[i].getCookie(TomcatWebModuleCookie.class);
  4. if (cookie == null || !cookie.hasLogger()) {
  5. return false;
  6. }
  7. }
  8. return true;
  9. }

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

  1. protected boolean enable(final Node[] activatedNodes) {
  2. if (activatedNodes == null || activatedNodes.length != 1)
  3. return false;
  4. DataObject dao = activatedNodes[0].getCookie(DataObject.class);
  5. if ((dao != null) && MIMENames.ELF_CORE_MIME_TYPE.equals(IpeUtils.getMime(dao))) {
  6. return true;
  7. }
  8. return false;
  9. }

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

  1. protected boolean enable(Node[] nodes) {
  2. for (int i = 0; i < nodes.length; i++) {
  3. TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class);
  4. if (cookie == null || !cookie.hasServerLog()) {
  5. return false;
  6. }
  7. }
  8. return true;
  9. }

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

  1. protected void performAction(final Node[] activatedNodes) {
  2. for (int i = 0; i < activatedNodes.length; i++) {
  3. PrintCookie pc = (PrintCookie)activatedNodes[i].getCookie (PrintCookie.class);
  4. if (pc != null) {
  5. pc.print();
  6. }
  7. }
  8. }

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

  1. public org.openide.nodes.Node.Cookie getCookie(Class type) {
  2. org.openide.nodes.Node.Cookie c = null;
  3. if (xnode != null)
  4. c = xnode.getCookie(type);
  5. if (c == null)
  6. c = getOriginal().getCookie(type);
  7. if (c == null)
  8. c = super.getCookie(type);
  9. return c;
  10. }

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

  1. private Lookup getLookup () {
  2. Node[] nodes = TopComponent.getRegistry ().getActivatedNodes ();
  3. int i, k = nodes.length;
  4. ArrayList l = new ArrayList ();
  5. for (i = 0; i < k; i++) {
  6. Object o = nodes [i].getCookie (DataObject.class);
  7. if (o != null)
  8. l.add (o);
  9. }
  10. return Lookups.fixed (l.toArray (new DataObject [l.size ()]));
  11. }

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

  1. protected boolean enable (Node[] nodes) {
  2. for (int i = 0; i < nodes.length; i++) {
  3. ServerInstance instance = (ServerInstance)nodes[i].getCookie(ServerInstance.class);
  4. if (instance == null || instance.isRemoveForbidden()
  5. || instance.getServerState() == ServerInstance.STATE_WAITING) {
  6. return false;
  7. }
  8. }
  9. return true;
  10. }

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

  1. private static boolean enableImpl(Node[] nodes) {
  2. if (nodes.length != 1) {
  3. return false;
  4. }
  5. ServerInstance si = (ServerInstance)nodes[0].getCookie(ServerInstance.class);
  6. if (si == null || si.getServerState() != ServerInstance.STATE_STOPPED
  7. || !si.isProfileSupported()) {
  8. return false;
  9. }
  10. return true;
  11. }
  12. }

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

  1. @Override
  2. public void open() {
  3. EditCookie originalEC = getOriginal().getCookie(EditCookie.class);
  4. if (null != originalEC)
  5. originalEC.edit();
  6. }
  7. }

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

  1. public static void openPageFlowSceneElement(PageFlowSceneElement element) {
  2. OpenCookie openCookie = (element).getNode().getCookie(OpenCookie.class);
  3. if (openCookie != null) {
  4. openCookie.open();
  5. }
  6. }
  7. public static Action handleNewWebForm = new AbstractAction() {

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

  1. protected void performAction(Node[] nodes) {
  2. if(nodes[0].getLookup().lookup(ManagerNode.class) != null){
  3. ManagerNode node = (ManagerNode)nodes[0].getCookie(ManagerNode.class);
  4. SunDeploymentManagerInterface sdm = node.getDeploymentManager();
  5. viewLog(sdm,true,true);//entire file and forced
  6. }
  7. }
  8. public static InputOutput viewLog(SunDeploymentManagerInterface sdm){

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

  1. private EditorCookie activatedEditorCookie(Node[] nodes) {
  2. if (nodes == null) {
  3. nodes = WindowManager.getDefault().getRegistry().getActivatedNodes();
  4. }
  5. if (nodes.length == 1) {
  6. Node node = nodes[0];
  7. return (EditorCookie) node.getCookie(EditorCookie.class);
  8. }
  9. return null;
  10. }

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

  1. protected void performAction(Node[] nodes) {
  2. for (int i = 0; i < nodes.length; i++) {
  3. TomcatInstanceNode cookie = (TomcatInstanceNode)nodes[i].getCookie(TomcatInstanceNode.class);
  4. if (cookie == null) {
  5. continue;
  6. }
  7. TomcatManager tm = cookie.getTomcatManager();
  8. if (tm != null) {
  9. tm.logManager().openSharedContextLog();
  10. }
  11. }
  12. }

相关文章