本文整理匯總了Java中org.netbeans.api.project.Project.getLookup方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.getLookup方法的具體用法?Java Project.getLookup怎麽用?Java Project.getLookup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.netbeans.api.project.Project
的用法示例。
在下文中一共展示了Project.getLookup方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCanBeReclaimed
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public void testCanBeReclaimed() throws Exception {
Project prj1 = new DummyProject();
Project prj2 = new DummyProject();
Lookup projects = new TestProxyLookup(new Lookup[] {
prj1.getLookup(),
prj2.getLookup(),
});
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);
}
示例2: runAction
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private void runAction(String action) {
Project project = getProject();
if (project != null) {
Lookup lookup = project.getLookup();
if (fileForDocument != null) {
try {
DataObject dobj = DataObject.find(fileForDocument);
lookup = dobj.getLookup();
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
}
ActionProvider provider = project.getLookup().lookup(ActionProvider.class);
if (provider != null) {
if (provider.isActionEnabled(action, lookup)) {
provider.invokeAction(action, lookup);
}
}
}
}
示例3: findDelegate
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private Lookup findDelegate() {
if (closed) {
return null;
}
final Project currentOwner = getNonConvertorOwner(projectDirectory);
return currentOwner == null ?
null :
currentOwner.getLookup();
}
示例4: createAdditionalLookup
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public Lookup createAdditionalLookup(Lookup lkp) {
Project p = lkp.lookup(Project.class);
assertNotNull(p);
Lookup base = p.getLookup();
assertNotNull(base);
final AuxiliaryConfiguration aux = base.lookup(AuxiliaryConfiguration.class);
assertNotNull(aux);
return Lookups.singleton(new Callable<AuxiliaryConfiguration>() {
public AuxiliaryConfiguration call() throws Exception {
return aux;
}
});
}
示例5: createLookup
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private static Lookup createLookup(Project p, SourceGroup group, DataFolder dataFolder, boolean isProjectDir) {
return new ProxyLookup(
dataFolder.getNodeDelegate().getLookup(),
Lookups.fixed(p, new PathFinder(group), new GroupNodeInfo(isProjectDir)),
p.getLookup());
}
示例6: testCacheUpdatesCorrectly
import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public void testCacheUpdatesCorrectly() throws Exception {
Project prj1 = new DummyProject();
Project prj2 = new DummyProject();
TestProxyLookup projects = new TestProxyLookup(new Lookup[] {
prj1.getLookup(),
prj2.getLookup(),
});
Set<Project> bothProjects = new HashSet<Project>(Arrays.asList(prj1, prj2));
Set<Project> result = new HashSet<Project>(Arrays.asList(ActionsUtil.getProjectsFromLookup(projects, null)));
assertTrue(bothProjects.equals(result));
//make sure cache is somehow updated even after hard GC:
//and try really hard to reclaim even (potential) SoftReferences:
boolean wasThrown = false;
try {
assertGC("", new WeakReference<Object>(o));
} catch (AssertionFailedError e) {
//ignore
wasThrown = true;
}
assertTrue(wasThrown);
projects.setLookupsOverride(new Lookup[] {prj1.getLookup()});
Set<Project> firstProject = new HashSet<Project>(Arrays.asList(prj1));
result = new HashSet<Project>(Arrays.asList(ActionsUtil.getProjectsFromLookup(projects, null)));
assertTrue(firstProject.equals(result));
projects.setLookupsOverride(new Lookup[] {});
result = new HashSet<Project>(Arrays.asList(ActionsUtil.getProjectsFromLookup(projects, null)));
assertTrue(Collections.EMPTY_SET.equals(result));
projects.setLookupsOverride(new Lookup[] {prj1.getLookup(), prj2.getLookup()});
result = new HashSet<Project>(Arrays.asList(ActionsUtil.getProjectsFromLookup(projects, null)));
assertTrue(bothProjects.equals(result));
}