Java Code Examples for org.openide.nodes.Node#getLookup()
The following examples show how to use
org.openide.nodes.Node#getLookup() .
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: ProjectServicesImpl.java From netbeans with Apache License 2.0 | 6 votes |
@Override public FileObject[] getCurrentSelection() { Node[] nodes = TopComponent.getRegistry().getActivatedNodes(); if(nodes == null) { return null; } List<FileObject> ret = new ArrayList<FileObject>(); for(Node node : nodes) { Lookup nodeLookup = node.getLookup(); Collection<? extends Project> projects = nodeLookup.lookupAll(Project.class); if(projects != null && !projects.isEmpty()) { for (Project project : projects) { ret.add(project.getProjectDirectory()); } } else { DataObject dataObj = nodeLookup.lookup(DataObject.class); if (dataObj != null) { FileObject fileObj = dataObj.getPrimaryFile(); if (fileObj != null) { ret.add(fileObj); } } } } return ret.toArray(new FileObject[ret.size()]); }
Example 2
Source File: TestDataDirsNodeFactory.java From netbeans with Apache License 2.0 | 6 votes |
public Node node(final SourceGroup key) { try { Node nodeDelegate = DataObject.find(key.getRootFolder()).getNodeDelegate(); return new FilterNode(nodeDelegate, null, new ProxyLookup(nodeDelegate.getLookup(), Lookups.singleton(new PathFinder(key)))) { @Override public String getName() { return key.getName(); } @Override public String getDisplayName() { return key.getDisplayName(); } }; } catch (DataObjectNotFoundException ex) { throw new AssertionError(ex); } }
Example 3
Source File: TreeRootNode.java From netbeans with Apache License 2.0 | 6 votes |
private TreeRootNode(Node originalNode, SourceGroup group, GrailsProject project, Type type) { super(originalNode, new PackageFilterChildren(originalNode), new ProxyLookup( originalNode.getLookup(), Lookups.fixed( new PathFinder(group), // no need for explicit search info // Adding TemplatesImpl to Node's lookup to narrow-down // number of displayed templates with the NewFile action. // see # 122942 new TemplatesImpl(project, group) ) )); String pathName = group.getName(); setShortDescription(pathName.substring(project.getProjectDirectory().getPath().length() + 1)); this.group = group; this.visualType = type; group.addPropertyChangeListener(WeakListeners.propertyChange(this, group)); }
Example 4
Source File: SrcNodeTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testSubfolderLookup() throws Exception { PhpProject phpProject = TestUtils.createPhpProject(getWorkDir()); FileObject sources = ProjectPropertiesSupport.getSourcesDirectory(phpProject); final FileObject subfolder = sources.createFolder("emptyFolder"); NodeList<SourceGroup> nodes = new SourcesNodeFactory().createNodes(phpProject); List<SourceGroup> sourceGroups = nodes.keys(); assertFalse("Source groups should be found", sourceGroups.isEmpty()); for (SourceGroup sourceGroup : sourceGroups) { Node node = nodes.node(sourceGroup); Lookup lookup = node.getLookup(); assertNotNull("Fileobject should be found", lookup.lookup(FileObject.class)); Children children = node.getChildren(); assertTrue("Should have subnodes", children.getNodesCount(true) > 0); for (Node subnode : children.getNodes(true)) { Lookup sublookup = subnode.getLookup(); FileObject fileObject = sublookup.lookup(FileObject.class); assertNotNull("Fileobject should be found", fileObject); assertEquals("Fileobjects should be same", subfolder, fileObject); } } }
Example 5
Source File: ActionFilterNode.java From netbeans with Apache License 2.0 | 5 votes |
private static Lookup createLookup(final Node original, Object... toAdd) { final Lookup lookup = original.getLookup(); final org.netbeans.spi.project.ui.PathFinder pathFinder = lookup.lookup(org.netbeans.spi.project.ui.PathFinder.class); final Lookup lkp = new ProxyLookup( Lookups.exclude(lookup, org.netbeans.spi.project.ui.PathFinder.class), Lookups.fixed (toAdd), Lookups.singleton(new PathFinder(pathFinder))); return lkp; }
Example 6
Source File: ApkDataObject.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public ApkFilterNode(Node original) { super(original, org.openide.nodes.Children.LEAF, new ProxyLookup(original.getLookup(), Lookups.fixed(new SignInfoHolder()))); holder = getLookup().lookup(SignInfoHolder.class); project = FileOwnerQuery.getOwner(pf); pf.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, pf)); refreshIcons(); }
Example 7
Source File: NbAndroidRootProjectImpl.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public ProjectNode(Node node) throws DataObjectNotFoundException { super(node, new ProjectNodes(), new ProxyLookup( new Lookup[]{ Lookups.singleton(NbAndroidRootProjectImpl.this), node.getLookup(), Lookups.singleton(new RootGoalsNavigatorHint()), lookupModels })); }
Example 8
Source File: NbAndroidProjectImpl.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public ProjectNode(Node node) throws DataObjectNotFoundException { super(node, new ProjectNodes(), new ProxyLookup( new Lookup[]{ Lookups.singleton(NbAndroidProjectImpl.this), node.getLookup(), Lookups.singleton(new RootGoalsNavigatorHint()), lookupModels })); }
Example 9
Source File: CategoryNode.java From netbeans with Apache License 2.0 | 5 votes |
private CategoryNode( Node originalNode, InstanceContent content, Lookup lkp ) { super( originalNode, new Children( originalNode, lkp ), new ProxyLookup( new Lookup[] { lkp, new AbstractLookup(content), originalNode.getLookup() } ) ); DataFolder folder = (DataFolder)originalNode.getCookie( DataFolder.class ); if( null != folder ) { content.add( new DataFolder.Index( folder, this ) ); FileObject fob = folder.getPrimaryFile(); Object catName = fob.getAttribute( CAT_NAME ); if (catName instanceof String) setDisplayName((String)catName); } content.add( this ); }
Example 10
Source File: SrcNode.java From netbeans with Apache License 2.0 | 5 votes |
public PackageNode(PhpProject project, final Node originalNode, boolean isTest) { super(originalNode, new FolderChildren(project, originalNode, isTest), new ProxyLookup(originalNode.getLookup())); this.project = project; this.isTest = isTest; ProjectPropertiesSupport.addWeakProjectPropertyChangeListener(project, propertyChangeListener); }
Example 11
Source File: ProjectAssetsNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static Lookup createLookupProxy(ProjectAssetManager manager, Node node) { DataObject obj = node.getLookup().lookup(DataObject.class); if (obj instanceof AssetDataObject && obj.getLookup().lookup(ProjectAssetManager.class) == null) { ((AssetDataObject) obj).getLookupContents().add(manager); } return new ProxyLookup( new Lookup[]{ node.getLookup() /*,Lookups.fixed(manager)*/ }); }
Example 12
Source File: LibrariesNode.java From netbeans with Apache License 2.0 | 5 votes |
LibraryDependencyNode(final ModuleDependency dep, final NbModuleProject project, final Node original) { super(original, null, new ProxyLookup(original.getLookup(), Lookups.fixed(dep, project))); this.dep = dep; this.project = project; setShortDescription(LibrariesNode.createHtmlDescription(dep)); }
Example 13
Source File: UnitTestLibrariesNode.java From netbeans with Apache License 2.0 | 5 votes |
LibraryDependencyNode(final TestModuleDependency dep, String testType, final NbModuleProject project, final Node original) { super(original, null, new ProxyLookup(new Lookup[] { original.getLookup(), Lookups.fixed(new Object[] { dep, project, testType }) })); this.dep = dep; this.testType = testType; this.project = project; }
Example 14
Source File: AssetNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public static Lookup createLookupProxy(ProjectAssetManager manager, Node node) { DataObject obj = node.getLookup().lookup(DataObject.class); if (obj instanceof AssetDataObject && obj.getLookup().lookup(ProjectAssetManager.class) == null) { ((AssetDataObject) obj).getLookupContents().add(manager); } return new ProxyLookup( new Lookup[]{ node.getLookup() /*,Lookups.fixed(manager)*/ }); }
Example 15
Source File: TreeRootNode.java From netbeans with Apache License 2.0 | 5 votes |
private TreeRootNode (Node originalNode, DataFolder folder, SourceGroup g, boolean reduced) { super(originalNode, reduced ? Children.create(new ReducedChildren(folder, new GroupDataFilter(g), g), true) : new PackageFilterChildren(originalNode), new ProxyLookup( originalNode.getLookup(), Lookups.singleton(new PathFinder(g, reduced)) // no need for explicit search info )); this.g = g; g.addPropertyChangeListener(WeakListeners.propertyChange(this, g)); }
Example 16
Source File: MVCNode.java From cakephp3-netbeans with Apache License 2.0 | 4 votes |
public PackageNode(final Node originalNode, boolean isTest) { super(originalNode, new MVCNode.FolderChildren(originalNode, isTest), new ProxyLookup(originalNode.getLookup())); }
Example 17
Source File: TopComponentGetLookupTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testBug32470FilterNodeAndANodeImplementingACookie() { class NY extends AbstractNode implements SaveCookie { public NY() { super(Children.LEAF); getCookieSet().add(this); } public void save() { } } Node ny = new NY(); Node node = new FilterNode(new FilterNode(ny, null, ny.getLookup())); top.setActivatedNodes(new Node[] { node }); Lookup.Template<Node> nodeTemplate = new Lookup.Template<Node>(Node.class); Lookup.Template<SaveCookie> saveTemplate = new Lookup.Template<SaveCookie>(SaveCookie.class); Collection<? extends Node> res; res = lookup.lookup(nodeTemplate).allInstances(); assertEquals("just one returned", res.size(), 1); assertEquals("node is node", node, res.iterator().next()); //MK - the above 2 tests should test the same.. // assertEquals ("FilterNode is the only node there", // Collections.singletonList(node), res // ); Collection<? extends SaveCookie> res2 = lookup.lookup(saveTemplate).allInstances(); assertEquals("just one returned", res2.size(), 1); assertEquals("node is node", ny, res2.iterator().next()); //MK - the above 2 tests should test the same.. // assertEquals ("SaveCookie is there only once", // Collections.singletonList(ny), res // ); res = lookup.lookup(nodeTemplate).allInstances(); assertEquals("just one returned", res.size(), 1); assertEquals("node is node", node, res.iterator().next()); //MK - the above 2 tests should test the same.. // assertEquals ("FilterNode is still the only node there", // Collections.singletonList(node), res // ); }
Example 18
Source File: ActionFilterNode.java From netbeans with Apache License 2.0 | 4 votes |
private ActionFilterNode (Node original, Mode mode, FileObject cpRoot, FileObject resource) { this (original, mode, cpRoot, new ProxyLookup(new Lookup[] {original.getLookup(),Lookups.singleton(new JavadocProvider(cpRoot,resource))})); }
Example 19
Source File: PackageNode.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
public PackageNode (final Project project, final Node originalNode) { super(originalNode, new FolderChildren(project, originalNode), new ProxyLookup(originalNode.getLookup())); }
Example 20
Source File: SvnUtils.java From netbeans with Apache License 2.0 | 2 votes |
/** * @return <code>true</code> if * <ul> * <li> the node contains a project in its lookup and * <li> the project contains at least one SVN versioned source group * </ul> * otherwise <code>false</code>. * @param project * @param checkStatus if set to true, cache.getStatus is called and can take significant amount of time */ public static boolean isVersionedProject(Node node, boolean checkStatus) { Lookup lookup = node.getLookup(); Project project = (Project) lookup.lookup(Project.class); return isVersionedProject(project, checkStatus); }