當前位置: 首頁>>代碼示例>>Java>>正文


Java Project.getLookup方法代碼示例

本文整理匯總了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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ActionsUtilTest.java

示例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);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:CoverageSideBar.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ProjectConvertors.java

示例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;
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:J2SEProjectTest.java

示例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());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:PhysicalView.java

示例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));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:ActionsUtilTest.java


注:本文中的org.netbeans.api.project.Project.getLookup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。