Lines 442-447
Link Here
|
442 |
return WeakListeners.create(NodeListener.class, l, source); |
442 |
return WeakListeners.create(NodeListener.class, l, source); |
443 |
} |
443 |
} |
444 |
|
444 |
|
|
|
445 |
/** Creates a <q>lazy node</q> - a node that displays basic information |
446 |
* about the original node behind it, without touching it. As soon as |
447 |
* the node is expanded, or a pop up menu is invoked on it, it switches |
448 |
* to the real delegates and since then everything is being bridged to |
449 |
* the real node. |
450 |
* <p> |
451 |
* This method is especially useful when used from |
452 |
* <a href="@org-openide-modules@/org/openide/modules/doc-files/api.html#how-layer">layers</a>. |
453 |
* Use following |
454 |
* XML snippet to register your node into Services tab: |
455 |
* <pre> |
456 |
* <folder name="UI"> |
457 |
* <folder name="Runtime"> |
458 |
* <file name="org-yourorg-yourpgk-YourNode.instance"> |
459 |
* <attr name="instanceCreate" methodvalue="org.openide.nodes.NodeOp.factory"/> |
460 |
* <attr name="name" stringvalue="YourNode"/> |
461 |
* <attr name="displayName" bundlevalue="org.yourorg.yourpkg.Bundle#NAME-KEY"/> |
462 |
* <attr name="shortDescription" bundlevalue="org.yourorg.yourpkg.Bundle#SHORT-KEY"/> |
463 |
* <attr name="iconResource" stringvalue="org/yourorg/yourpkg/image.png"/> |
464 |
* <attr name="original" newvalue="org.yourorg.yourpkg.YourNode"/> |
465 |
* <file/> |
466 |
* <folder/> |
467 |
* <folder/> |
468 |
* </pre> |
469 |
* |
470 |
* @param original the real node behind the one created |
471 |
* @param name programatic name of the node |
472 |
* @param displayName human readable name of the node |
473 |
* @param shortDescription short description for the node |
474 |
* @param iconResource path to icon to use as in {@link AbstractNode#setIconBaseWithExtension(java.lang.String)} |
475 |
* @return new node with preset defaults that can delegate to original |
476 |
* |
477 |
* @since 7.9 |
478 |
*/ |
479 |
public static Node factory( |
480 |
Node original, |
481 |
String name, String displayName, String shortDescription, |
482 |
String iconResource |
483 |
) { |
484 |
Map<Object,Object> map = new HashMap<Object,Object>(); |
485 |
map.put("original", original); // NOI18N |
486 |
map.put("name", name); // NOI18N |
487 |
map.put("displayName", displayName); // NOI18N |
488 |
map.put("shortDescription", shortDescription); // NOI18N |
489 |
map.put("iconResource", iconResource); // NOI18N |
490 |
return new LazyNode(map); |
491 |
} |
492 |
|
493 |
static Node factory(Map<?,?> map) { |
494 |
return new LazyNode(map); |
495 |
} |
496 |
|
445 |
/** Utility method to remove dependency of this package on |
497 |
/** Utility method to remove dependency of this package on |
446 |
* org.openide.actions. This method takes names of classes from |
498 |
* org.openide.actions. This method takes names of classes from |
447 |
* that package and creates their instances. |
499 |
* that package and creates their instances. |