Java Code Examples for org.openide.nodes.Children#LEAF

The following examples show how to use org.openide.nodes.Children#LEAF . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TopComponentGetLookupTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testFilterNodeProblems() {
    class CookieN extends AbstractNode implements Node.Cookie {
        public CookieN() {
            super(Children.LEAF);
            getCookieSet().add(this);
        }
        
    }
    
    CookieN n = new CookieN();
    FilterNode fn = new FilterNode(n);
    top.setActivatedNodes(new Node[] { fn });
    assertTrue("CookieN is in FilterNode lookup", n == fn.getLookup().lookup(CookieN.class));
    assertTrue("CookieN is in TopComponent", n == lookup.lookup(CookieN.class));
    assertEquals("Just one node", 1, lookup.lookup(new Lookup.Template<Node>(Node.class)).allItems().size());
    assertTrue("Plain cookie found", n == lookup.lookup(Node.Cookie.class));
}
 
Example 2
Source File: FilterNode.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<FilterChain>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);
}
 
Example 3
Source File: ProjectNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
ProjectNode (
            @NonNull final AntArtifact antArtifact,
            @NonNull final URI artifactLocation,
            @NonNull final UpdateHelper helper,
            @NonNull final String classPathId,
            @NonNull final String entryId,
            @NullAllowed final String webModuleElementName, 
            @NonNull final ClassPathSupport cs,
            @NonNull final ReferenceHelper rh,
            @NullAllowed final Consumer<Pair<String,String>> preRemoveAction,
            @NullAllowed final Consumer<Pair<String,String>> postRemoveAction,
            boolean removeFromProject) {
    super (Children.LEAF, createLookup (
            antArtifact, artifactLocation, 
            helper, classPathId, entryId, webModuleElementName,
            cs, rh, preRemoveAction, postRemoveAction, removeFromProject));
    this.antArtifact = antArtifact;
    this.artifactLocation = artifactLocation;
}
 
Example 4
Source File: RepositoryBrowserPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public TagNode (File repository, GitTag tag) {
    super(Children.LEAF, repository, Lookups.singleton(new Revision(tag.getTaggedObjectId(), tag.getTagName())));
    tagName = tag.getTagName();
    message = tag.getMessage();
    revisionId = tag.getTaggedObjectId();
    setIconBaseWithExtension("org/netbeans/modules/git/resources/icons/tag.png"); //NOI18N
    RepositoryInfo info = RepositoryInfo.getInstance(repository);
    if (info == null) {
        LOG.log(Level.INFO, "TagNode() : Null info for {0}", repository); //NOI18N
        list = null;
    } else {
        info.addPropertyChangeListener(WeakListeners.propertyChange(list = new PropertyChangeListener() {
            @Override
            public void propertyChange (PropertyChangeEvent evt) {
                if (RepositoryInfo.PROPERTY_ACTIVE_BRANCH.equals(evt.getPropertyName()) || RepositoryInfo.PROPERTY_HEAD.equals(evt.getPropertyName())) {
                    refreshActiveBranch((GitBranch) evt.getNewValue());
                }
            }
        }, info));
        refreshActiveBranch(info.getActiveBranch());
    }
}
 
Example 5
Source File: BytecodeNode.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) {

        super(Children.LEAF);
        this.setDisplayName(bytecode.getBci() + " " + bytecode.getName());

        bciValue = bytecode.getBci() + " " + bciValue;
        bciValue = bciValue.trim();

        Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<InputNode>(graph.getNodes());
        StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue);
        List<InputNode> nodeList = selector.selectMultiple(matcher);
        if (nodeList.size() > 0) {
            nodes = new HashSet<InputNode>();
            for (InputNode n : nodeList) {
                nodes.add(n);
            }
            this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)");
        }
    }
 
Example 6
Source File: JmeVehicleWheel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JmeVehicleWheel(VehicleControl vehicle, VehicleWheel wheel) {
    super(Children.LEAF);
    this.vehicle=vehicle;
    this.wheel = wheel;
    getLookupContents().add(wheel);
    getLookupContents().add(this);
    setName("Wheel");
}
 
Example 7
Source File: CallstackFrameNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of CallstackFrameNode
 *
 * @param  frameInfo  line of a callstack, e.g. <code>foo.bar.Baz:314</code>
 * @param  displayName  display name for the node, or <code>null</code>
 *                      to use the default display name for the given
 *                      callstack frame info
 */
public CallstackFrameNode(final String frameInfo,
                          final String displayName) {
    super(Children.LEAF);
    setDisplayName(displayName != null
                   ? displayName
                   : frameInfo);                            //NOI18N

    this.frameInfo = frameInfo;
}
 
Example 8
Source File: Util.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Node createInfoNode() {
    AbstractNode n = new AbstractNode(Children.LEAF);
    n.setName(NbBundle.getMessage(WildflyItemNode.class, "LBL_InfoNode_DisplayName")); //NOI18N
    n.setShortDescription(NbBundle.getMessage(WildflyItemNode.class, "LBL_InfoNode_ToolTip")); //NOI18N
    n.setIconBaseWithExtension("org/netbeans/core/resources/exception.gif"); // NOI18N
    return n;
}
 
Example 9
Source File: JBEjbModuleNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JBEjbModuleNode(String fileName, Lookup lookup, boolean isEJB3) {
    super(Children.LEAF);
    setDisplayName(fileName.substring(0, fileName.lastIndexOf('.')));
    if (isEJB3) {
        getCookieSet().add(new UndeployModuleCookieImpl(fileName, lookup));
    }
    else {
        getCookieSet().add(new UndeployModuleCookieImpl(fileName, ModuleType.EJB, lookup));
    }
}
 
Example 10
Source File: DerbyDatabaseNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public DerbyDatabaseNode(String dbName, DerbyDatabasesImpl server) {
    super(Children.LEAF);
    this.database = dbName;
    this.server = server;
    setName(dbName);
    setDisplayName(dbName);
    setShortDescription(NbBundle.getMessage(DerbyDatabaseNode.class, "DerbyDatabaseNode_ShortDescription", dbName, DerbyOptions.getDefault().getLocation()));
    setIconBaseWithExtension(ICON_BASE);
}
 
Example 11
Source File: AddDependencyUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public OpenProjectNode(Project project) {
    super(Children.LEAF, Lookups.singleton(project));
    pi = ProjectUtils.getInformation(project);
}
 
Example 12
Source File: VCSContextTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public DummyFileNode(File file) {
    super(Children.LEAF, Lookups.fixed(file));
}
 
Example 13
Source File: EjbSectionNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public EjbSectionNode(SectionNodeView sectionNodeView, boolean isLeaf, Object key, String title, String iconBase) {
    super(sectionNodeView, isLeaf ? Children.LEAF : new Children.Array(), key, title, iconBase);
}
 
Example 14
Source File: XSLDataObject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Create new XSLDataNode. */
public XSLDataNode (XSLDataObject obj) {
    super (obj, Children.LEAF);
    setIconBase (XSL_ICON_BASE);
    setShortDescription(NbBundle.getMessage(XSLDataObject.class, "PROP_XSLDataNode_desc"));
}
 
Example 15
Source File: SQLNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public SQLNode(SQLDataObject dataObject, Lookup lookup) {
    super(dataObject, Children.LEAF, lookup);
    setIconBaseWithExtension(ICON_BASE);
}
 
Example 16
Source File: SimpleNode.java    From BART with MIT License 4 votes vote down vote up
public SimpleNode(DataObject obj,Lookup look) {
    super(obj,Children.LEAF,look);
    this.obj=obj;
    setShortDescription(Bundle.HINT_SimpleNode());      
}
 
Example 17
Source File: ExplorerPanelTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public SerializableNode () {
    super (Children.LEAF);
}
 
Example 18
Source File: SpringXMLConfigDataNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public SpringXMLConfigDataNode(SpringXMLConfigDataObject obj) {
    super(obj, Children.LEAF);
}
 
Example 19
Source File: WaitNode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WaitNode(String name) {
    super(Children.LEAF);
    setDisplayName(name);
    setIconBaseWithExtension("org/netbeans/modules/subversion/ui/browser/wait.gif");  // NOI18N
}
 
Example 20
Source File: TopComponentGetLookupTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void doTestNoChangeWhenSomethingIsChangedOnNotActivatedNode(int initialSize) {
    Object obj = new OpenCookie() { public void open() {} };
    
    Lookup.Result<OpenCookie> res = lookup.lookup(new Lookup.Template<OpenCookie>(OpenCookie.class));
    Lookup.Result<Node> nodeRes = lookup.lookup(new Lookup.Template<Node>(Node.class));
    
    InstanceContent ic = new InstanceContent();
    CountingLookup cnt = new CountingLookup(ic);
    AbstractNode ac = new AbstractNode(Children.LEAF, cnt);
    for (int i = 0; i < initialSize; i++) {
        ic.add(new Integer(i));
    }
    
    top.setActivatedNodes(new Node[] { ac });
    assertEquals("One node there", 1, get.getActivatedNodes().length);
    assertEquals("It is the ac one", ac, get.getActivatedNodes()[0]);
    ic.add(obj);
    
    L listener = new L();
    
    res.allItems();
    nodeRes.allItems();
    res.addLookupListener(listener);
    
    Collection allListeners = cnt.listeners;
    
    assertEquals("Has the cookie", 1, res.allItems().size());
    listener.check("No changes yet", 0);
    
    ic.remove(obj);
    
    assertEquals("Does not have the cookie", 0, res.allItems().size());
    listener.check("One change", 1);
    
    top.setActivatedNodes(new N[0]);
    assertEquals("The nodes are empty", 0, get.getActivatedNodes().length);
    listener.check("No change", 0);
    
    cnt.queries = 0;
    ic.add(obj);
    ic.add(ac);
    listener.check("Removing the object or node from not active node does not send any event", 0);
    
    nodeRes.allItems();
    listener.check("Queriing for node does generate an event", 0);
    assertEquals("No Queries to the not active node made", 0, cnt.queries);
    assertEquals("No listeneners on cookies", allListeners, cnt.listeners);
}