Java Code Examples for org.openide.util.lookup.Lookups#fixed()
The following examples show how to use
org.openide.util.lookup.Lookups#fixed() .
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: CompilerOptionsQueryMergerTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testUnmergedResults() { final CompilerOptionsQueryImpl impl1 = new CompilerOptionsQueryImpl(); final CompilerOptionsQueryImpl impl2 = new CompilerOptionsQueryImpl(); impl1.addRoot(root1).addArgs("a1", "a2"); //NOI18N impl2.addRoot(root2).addArgs("b1", "b2"); //NOI18N final Lookup baseLkp = Lookups.fixed( impl1, impl2); final CompilerOptionsQueryImplementation merged = LookupMergerSupport.createCompilerOptionsQueryMerger() .merge(baseLkp); final CompilerOptionsQueryImplementation.Result res1 = merged.getOptions(root1); assertEquals( Arrays.asList("a1","a2"), //NOI18N res1.getArguments()); final CompilerOptionsQueryImplementation.Result res2 = merged.getOptions(root2); assertEquals( Arrays.asList("b1","b2"), //NOI18N res2.getArguments()); }
Example 2
Source File: ActionsUtilTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testCanBeReclaimedWithSimpleLookup() throws Exception { Project prj1 = new DummyProject(); Project prj2 = new DummyProject(); Lookup projects = Lookups.fixed(new Object[] { prj1, prj2, }); ActionsUtil.getProjectsFromLookup(projects, null); WeakReference<?> ref1 = new WeakReference<Object>(prj1); WeakReference<?> ref2 = new WeakReference<Object>(prj2); WeakReference<?> lookup = new WeakReference<Object>(projects); prj1 = null; prj2 = null; projects = null; assertGC("the projects can be reclaimed", ref1); assertGC("the projects can be reclaimed", ref2); assertGC("the lookup can be reclaimed", lookup); }
Example 3
Source File: NbMavenProjectImpl.java From netbeans with Apache License 2.0 | 6 votes |
private Lookup createBasicLookup(ProjectState state, M2AuxilaryConfigImpl auxiliary) { return Lookups.fixed( this, fileObject, auxiliary, auxiliary.getProblemProvider(), auxprops, new MavenProjectPropsImpl.Merger(auxprops), profileHandler, configProvider, problemReporter, watcher, state, UILookupMergerSupport.createPrivilegedTemplatesMerger(), UILookupMergerSupport.createRecommendedTemplatesMerger(), UILookupMergerSupport.createProjectProblemsProviderMerger(), LookupProviderSupport.createSourcesMerger(), LookupProviderSupport.createSharabilityQueryMerger(), ProjectClassPathModifier.extenderForModifier(this), LookupMergerSupport.createClassPathModifierMerger(), new UnitTestsCompilerOptionsQueryImpl(this), new PomCompilerOptionsQueryImpl(this), LookupMergerSupport.createCompilerOptionsQueryMerger() ); }
Example 4
Source File: RandomErrorAttribute.java From BART with MIT License | 5 votes |
public RandomErrorAttribute(EGTask egt,EGTaskDataObjectDataObject dto,String att) { super(Children.LEAF, new ProxyLookup(Lookups.fixed(egt,dto),dto.getAbstractLookup())); this.attribute=att; setName(NodeResource.NODE_RandomErrorAttribute); setShortDescription(Bundle.HINT_RandomErrorAttribute()); setIconBaseWithExtension(R.IMAGE_AUTORITATIVE); }
Example 5
Source File: FileSensitivePerformer.java From netbeans with Apache License 2.0 | 5 votes |
private static Lookup getContext(FileObject file, Project p, String command) { ProfilerLauncher.Command _command = new ProfilerLauncher.Command(command); try { return Lookups.fixed(file, p, DataObject.find(file), _command); } catch (DataObjectNotFoundException e) {} return Lookups.fixed(file, p, _command); }
Example 6
Source File: DependencyNode.java From BART with MIT License | 5 votes |
public DependencyNode(EGTask egt,EGTaskDataObjectDataObject dto,Dependency dc) { super(Children.create(new VioGenQueryFactory(dc,egt,dto), true), new ProxyLookup(Lookups.fixed(egt,dto,dc),dto.getAbstractLookup())); setName(NodeResource.NODE_DependencyNode); setIconBaseWithExtension(R.IMAGE_LINK); DependencyNotifier.addChangeListener(listener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fireDisplayNameChange(null, ""); DependencyNode.this.setSheet(createSheet()); } }); }
Example 7
Source File: MavenNodeFactory.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of VersionNode */ public VersionNode(NBVersionInfo versionInfo, boolean fromDepMng) { super(Children.LEAF, fromDepMng ? Lookups.fixed(versionInfo, new DependencyManagement()) : Lookups.fixed(versionInfo)); this.nbvi = versionInfo; this.fromDepMng = fromDepMng; setName(versionInfo.getVersion()); StringBuilder sb = new StringBuilder(); if (fromDepMng) { sb.append(nbvi.getGroupId()); sb.append(DELIMITER); sb.append(nbvi.getArtifactId()); sb.append(DELIMITER); } else { sb.append(nbvi.getVersion()); } sb.append(" [ "); sb.append(nbvi.getType()); String classifier = nbvi.getClassifier(); if (classifier != null) { sb.append(","); sb.append(classifier); } sb.append(" ] "); String repo = nbvi.getRepoId(); if (repo != null) { sb.append(" - "); sb.append(repo); } setDisplayName(sb.toString()); setIconBaseWithExtension(IconResources.ICON_DEPENDENCY_JAR); }
Example 8
Source File: GitUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static VCSContext getContextForFiles (final File[] roots) { Node[] nodes = new Node[roots.length]; for (int i = 0; i < roots.length; ++i) { final File root = roots[i]; nodes[i] = new AbstractNode(Children.LEAF, Lookups.fixed(root)) { @Override public String getName () { return root.getName(); } }; } return VCSContext.forNodes(nodes); }
Example 9
Source File: NbGuardedMarker.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Lookup forDocument(BaseDocument doc) { if (!(doc instanceof StyledDocument)) { return null; } return Lookups.fixed(new NbGuardedMarker((StyledDocument)doc)); }
Example 10
Source File: DirtyStrategyAttributeNode.java From BART with MIT License | 5 votes |
public DirtyStrategyAttributeNode(EGTask egt, EGTaskDataObjectDataObject dto, AttributeRef attribute) { super(Children.LEAF,new ProxyLookup(Lookups.fixed(attribute,egt,dto),dto.getAbstractLookup())); setName(attribute.getName().trim()); setIconBaseWithExtension(R.IMAGE_NODE_DIRTYSTRGATTRB); setShortDescription(Bundle.HINT_DirtyStrategyAttributeNode()); DirtyStrategyAttributeNodeNotifier.addChangeListener(listener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fireDisplayNameChange(null, ""); } }); }
Example 11
Source File: LookupProviderImpl.java From netbeans with Apache License 2.0 | 5 votes |
private static Lookup initLookup(Project project, AntProjectHelper projectHelper, PropertyEvaluator projectEvaluator, AuxiliaryConfiguration aux) { WebClasspath webcp = new WebClasspath(projectHelper, projectEvaluator, aux, project); return Lookups.fixed(new Object[] { new ProjectOpenedHookImpl(webcp), // register webroots as source classpath new PrivilegedTemplatesImpl(), // List of templates in New action popup new WebModules(project, projectHelper, projectEvaluator, aux), // WebModuleProvider, ClassPathProvider new WebFreeFormActionProvider(project, projectHelper, aux), //ActionProvider new HelpIDFragmentProviderImpl(), new JsfSupportHandle() }); }
Example 12
Source File: BaseParserResult.java From netbeans with Apache License 2.0 | 5 votes |
BaseParserResult( Snapshot snapshot, boolean success, @NonNull final Lookup additionalLkp) { super(snapshot); errors = Collections.emptyList(); this.success = success; embedded = isEmbedded(snapshot); final Lookup baseLkp = Lookups.fixed(this, modelContainer, documentationContainer); lookup = new ProxyLookup(baseLkp, additionalLkp); }
Example 13
Source File: POMModelVisitor.java From netbeans with Apache License 2.0 | 5 votes |
@Override Node createNode() { if (type == null) { return new ObjectNode(Lookups.fixed(this, qname), Children.LEAF, display); } return new ObjectNode(Lookups.fixed(this, qname), new PomChildren(this, getPOMQNames(), type, configuration), display); }
Example 14
Source File: AndroidPlatformNode.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
AndroidPlatformNode(AndroidPlatformInfo aPackage, AndroidSdk platform, XMLDataObject holder) { super(Children.LEAF, Lookups.fixed(new Object[]{platform, holder, aPackage})); this.aPackage = aPackage; this.platform = platform; }
Example 15
Source File: ProjectWebServiceNodeFactory.java From netbeans with Apache License 2.0 | 4 votes |
private Lookup createLookup(Project project, PrivilegedTemplates privilegedTemplates) { return Lookups.fixed(new Object[]{project, privilegedTemplates}); }
Example 16
Source File: ProjectConvertorFactory.java From netbeans with Apache License 2.0 | 4 votes |
@Override @NonNull public DynamicLookup getLookup() { DynamicLookup dynLkp = underConstruction.get(); if (dynLkp != null) { return dynLkp; } synchronized (this) { dynLkp = projectLkp; } if (dynLkp != null) { return dynLkp; } dynLkp = new DynamicLookup(Lookups.singleton(this)); try { underConstruction.set(dynLkp); final Lookup preLkp = Lookups.fixed(new OpenHook(), this); final Lookup convertorLkp = this.result.getLookup(); if (convertorLkp == null) { throw new IllegalStateException(String.format( "Convertor: %s returned null lookup.", //NOI18N this.result)); } final Queue<Object> postServices = new ArrayDeque<>(); for (ProjectConvertorServiceFactory f : services.allInstances()) { postServices.addAll(f.createServices(this, result)); } final Lookup postLkp = Lookups.fixed(postServices.toArray()); dynLkp.setBaseLookups(preLkp, convertorLkp, postLkp); synchronized (this) { if (projectLkp == null) { projectLkp = dynLkp; } else { dynLkp = projectLkp; } } return dynLkp; } finally { underConstruction.remove(); } }
Example 17
Source File: PHPRenameFileRefactoringUI.java From netbeans with Apache License 2.0 | 4 votes |
public PHPRenameFileRefactoringUI(FileObject file, String newName) { this.file = file; this.newName = newName; this.refactoring = new RenameRefactoring(Lookups.fixed(file)); }
Example 18
Source File: SafeDeleteUI.java From netbeans with Apache License 2.0 | 4 votes |
/** * Creates a new instance of SafeDeleteUI * @param selectedElements An array of selected Elements that need to be * safely deleted */ private SafeDeleteUI(TreePathHandle[] selectedElements) { this.elementsToDelete = selectedElements; refactoring = new SafeDeleteRefactoring(Lookups.fixed(elementsToDelete)); refactoring.getContext().add(RefactoringUtils.getClasspathInfoFor(selectedElements[0])); }
Example 19
Source File: PhpProject.java From netbeans with Apache License 2.0 | 4 votes |
private Lookup createLookup(AuxiliaryConfiguration configuration, PhpModule phpModule) { PhpProjectEncodingQueryImpl phpProjectEncodingQueryImpl = new PhpProjectEncodingQueryImpl(getEvaluator()); Lookup base = Lookups.fixed(new Object[] { this, CopySupport.getInstance(this), new SeleniumProvider(), new PhpCoverageProvider(this), new Info(), configuration, new PhpOpenedHook(), new PhpProjectXmlSavedHook(), new PhpActionProvider(this), new PhpConfigurationProvider(this), phpModule, PhpLanguagePropertiesAccessor.getDefault().createForProject(this), new PhpEditorExtender(this), helper.createCacheDirectoryProvider(), helper.createAuxiliaryProperties(), new ClassPathProviderImpl(this, getSourceRoots(), getTestRoots(), getSeleniumRoots()), new PhpLogicalViewProvider(this), new CustomizerProviderImpl(this), PhpSharabilityQuery.create(helper, getEvaluator(), getSourceRoots(), getTestRoots(), getSeleniumRoots()), LookupProviderSupport.createSharabilityQueryMerger(), new PhpProjectOperations(this) , phpProjectEncodingQueryImpl, new CreateFromTemplateAttributesImpl(getHelper(), phpProjectEncodingQueryImpl), new PhpTemplates(), new PhpSources(this, getHelper(), getEvaluator(), getSourceRoots(), getTestRoots(), getSeleniumRoots()), getHelper(), getEvaluator(), PhpSearchInfo.create(this), new PhpSubTreeSearchOptions(), new PhpTestingProvidersImpl(testingProviders), InternalWebServer.createForProject(this), CssPreprocessorsUI.getDefault().createProjectProblemsProvider(this), ProjectPropertiesProblemProvider.createForProject(this), UILookupMergerSupport.createProjectProblemsProviderMerger(), new ProjectWebRootProviderImpl(), ClientSideDevelopmentSupport.create(this), ProjectBrowserProviderImpl.create(this), new PhpVisibilityQuery.PhpVisibilityQueryImpl(this), new UsageLogging(), new ImportantFilesImpl(this), new ProjectUserAnnotationsProvider(this), // ?? getRefHelper() }); return LookupProviderSupport.createCompositeLookup(base, "Projects/org-netbeans-modules-php-project/Lookup"); // NOI18N }
Example 20
Source File: CustomScopePanel.java From netbeans with Apache License 2.0 | 4 votes |
public CustomNode(Children children, Lookup lookup, CustomScopePanel panel, final Data data) { super(children, new ProxyLookup(lookup, Lookups.fixed(new CheckableNode() { /** * Tell the view to display a check-box for this node. * * @return <code>true</code> if the check-box should be displayed, <code>false</code> otherwise. */ @Override public boolean isCheckable() { return true; } /** * Provide the enabled state of the check-box. * * @return <code>true</code> if the check-box should be enabled, <code>false</code> otherwise. */ @Override public boolean isCheckEnabled() { return true; } /** * Provide the selected state of the check-box. * * @return <code>true</code> if the check-box should be selected, * <code>false</code> if it should be unselected and * <code>null</code> if the state is unknown. */ @Override public Boolean isSelected() { return data.isSelected(); } /** * Called by the view when the check-box gets selected/unselected * * @param selected <code>true</code> if the check-box was selected, * <code>false</code> if the check-box was unselected. */ @Override public void setSelected(Boolean selected) { data.setSelected(selected); } }))); data.addPropertyChangeListener(WeakListeners.propertyChange(this, data)); this.panel = panel; this.data = data; }