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


Java Lookup類代碼示例

本文整理匯總了Java中org.openide.util.Lookup的典型用法代碼示例。如果您正苦於以下問題:Java Lookup類的具體用法?Java Lookup怎麽用?Java Lookup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Lookup類屬於org.openide.util包,在下文中一共展示了Lookup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Request

import org.openide.util.Lookup; //導入依賴的package包/類
private Request () {
    this (
        new ParserResultTask(){
            @Override
            public int getPriority() {
                return 0;
            }
            @Override
            public Class<? extends Scheduler> getSchedulerClass() {
                return null;
            }
            @Override
            public void cancel() {
            }
            @Override
            public void run(Result result, SchedulerEvent event) {
            }
        }, Lookup.EMPTY);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TaskProcessor.java

示例2: testReadAccess

import org.openide.util.Lookup; //導入依賴的package包/類
public void testReadAccess() throws Exception {
    ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
    try {
        Class<?> c = Class.forName("javax.help.HelpSet", true, l);
    } catch (ClassNotFoundException ex) {
        LOG.log(Level.FINE, "Can't pre-load JavaHelp", ex);
    }
    try {
        if (CountingSecurityManager.isEnabled()) {
            CountingSecurityManager.assertCounts("No reads during startup", 0);
        } else {
            System.out.println("Initialization mode, counting is disabled");
        }
    } catch (Error e) {
        e.printStackTrace(getLog("file-reads-report.txt"));
        throw e;
    }
    assertEnabled("org.netbeans.core.windows");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:CachingPreventsFileTouchesTest.java

示例3: get

import org.openide.util.Lookup; //導入依賴的package包/類
/**
 * Gets IOProvider of selected name or delegates to getDefault() if none was
 * found.
 *
 * @param id ID of provider.
 * @return The instance corresponding to provided name or default instance
 * if not found.
 */
@NonNull
public static IOProvider get(@NonNull String id) {
    Parameters.notNull("id", id);

    @SuppressWarnings("rawtypes")
    Collection<? extends InputOutputProvider> providers
            = Lookup.getDefault().lookupAll(InputOutputProvider.class);

    for (InputOutputProvider<?, ?, ?, ?> p : providers) {
        if (p.getId().equals(id)) {
            return wrapProvider(p);
        }
    }
    InputOutputProvider<?,?,?,?> bridgingImpl = getBridging(id);
    if (bridgingImpl != null) {
        return wrapProvider(bridgingImpl);
    } else {
        return getDefault();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:IOProvider.java

示例4: createTestModelSource

import org.openide.util.Lookup; //導入依賴的package包/類
public ModelSource createTestModelSource(FileObject fo, boolean editable) throws CatalogModelException{
    final DataObject dobj;
    final CatalogModel catalogModel = createCatalogModel(fo);
    try {
        dobj = DataObject.find(fo);
    } catch (DataObjectNotFoundException ex) {
        throw new CatalogModelException(ex);
    }
    Lookup lookup = Lookups.proxy(new Lookup.Provider() {
        public Lookup getLookup() {
                    return Lookups.fixed(new Object[] {
                        dobj.getPrimaryFile(),
                        getDocument(dobj.getPrimaryFile()),
                        dobj,
                        catalogModel
                    });
        }
    } );
    return new ModelSource(lookup, editable);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:TestCatalogModel.java

示例5: ContextBuildInstaller

import org.openide.util.Lookup; //導入依賴的package包/類
public ContextBuildInstaller(Lookup actionContext) {
    this.actionContext = actionContext;
    putValue(NAME, NbBundle.getMessage(BuildInstallersAction.class, "CTL_BuildInstallers"));
    putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
    Project project = actionContext.lookup(Project.class);
    if (project == null) {
        setEnabled(false); //#224115
    } else {
        NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class);
        if (watcher == null
                || !NbMavenProject.TYPE_NBM_APPLICATION.equalsIgnoreCase(watcher.getPackagingType())) {
            setEnabled(false);
        } else {
            String version = PluginPropertyUtils.getPluginVersion(watcher.getMavenProject(), "org.codehaus.mojo", "nbm-maven-plugin");
            if (version == null || new ComparableVersion(version).compareTo(new ComparableVersion("3.7-SNAPSHOT")) >= 0) {
                setEnabled(false); // now handled by maven.apisupport
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:BuildInstallersAction.java

示例6: main

import org.openide.util.Lookup; //導入依賴的package包/類
public static void main(String[] args) throws FileNotFoundException {

		Lookup.getDefault().lookup(ProjectController.class).newProject();
		CxfNetwork network = new CxfNetwork();

		network.load(new File(
				"/home/ilias/workspace/sg/resources/networks/linear.cxf"));

		NetworkStatistics netStats = new NetworkStatistics();
		netStats.execute();

		System.out.println("~~~ Network Statistics Report ~~~");
		System.out.println(netStats.getReport());
		System.out.println("~~~~~~~~~ End of Report  ~~~~~~~~");

		netStats.getReportUI().setVisible(true);
	}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:18,代碼來源:NetworkStatistics.java

示例7: hasSnapshotsFor

import org.openide.util.Lookup; //導入依賴的package包/類
public boolean hasSnapshotsFor(Lookup.Provider project) {
    try {
        FileObject snapshotsFolder = ProfilerStorage.getProjectFolder(project, false);
        FileObject[] children;
        
        if (snapshotsFolder == null) {
            return false;
        }
        snapshotsFolder.refresh();
        children = snapshotsFolder.getChildren();
        for (FileObject child : children) {
            if (child.getExt().equalsIgnoreCase(SNAPSHOT_EXTENSION)) return true;
            if (checkHprofFile(FileUtil.toFile(child))) return true;
        }
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, Bundle.ResultsManager_ObtainSavedSnapshotsFailedMsg(e.getMessage()), e);            
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:ResultsManager.java

示例8: enabled

import org.openide.util.Lookup; //導入依賴的package包/類
@Override
public boolean enabled() {
    for (EncryptionProvider p : Lookup.getDefault().lookupAll(EncryptionProvider.class)) {
        if (p.enabled()) {
            encryption = p;
            Preferences prefs = prefs();
            Utils.goMinusR(prefs);
            p.encryptionChangingCallback(this);
            if (!testSampleKey(prefs)) {
                continue;
            }
            LOG.log(Level.FINE, "Using provider: {0}", p);
            return true;
        }
    }
    LOG.fine("No provider");
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:FallbackProvider.java

示例9: create

import org.openide.util.Lookup; //導入依賴的package包/類
public static BusyIcon create() {
    Object painter = null;
    ClassLoader cl = Lookup.getDefault().lookup( ClassLoader.class );
    try {
        Class painterClass = cl.loadClass( "org.jdesktop.swingx.painter.BusyPainter" ); //NOI18N
        Constructor ctor = painterClass.getConstructor( int.class );
        int height = getBusyIconSize();
        painter = ctor.newInstance( height );
        Method setFrame = painterClass.getMethod( "setFrame", int.class ); //NOI18N
        Method paint = painterClass.getMethod( "paint", Graphics2D.class, Object.class, int.class, int.class ); //NOI18N
        Method m = painterClass.getMethod( "setPoints", int.class ); //NOI18N
        m.invoke( painter, POINTS );
        return new SwingXBusyIcon( painter, paint, setFrame, height );
    } catch( Exception ex ) {
        Logger.getLogger( BusyIcon.class.getName() ).log( Level.FINE, null, ex );
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:BusyIcon.java

示例10: testLookup

import org.openide.util.Lookup; //導入依賴的package包/類
public void testLookup () {
    final String INSTALLER_REGISTRY_FOLDER = "org-netbeans-api-java/platform/installers"; // NOI18N
    final Lookup lkp = Lookups.forPath(INSTALLER_REGISTRY_FOLDER);
    
    lkp.lookupAll(GeneralPlatformInstall.class);
    assertPlatformInstalls(
        lkp.lookupAll(CustomPlatformInstall.class),
        "org.netbeans.modules.java.j2seembedded.wizard.RemotePlatformInstall"); //NOI18N
    assertPlatformInstalls(
        lkp.lookupAll(PlatformInstall.class),
        "org.netbeans.modules.java.j2seplatform.J2SEInstallImpl");              //NOI18N
    assertPlatformInstalls(
        lkp.lookupAll(GeneralPlatformInstall.class),
        "org.netbeans.modules.java.j2seplatform.J2SEInstallImpl",               //NOI18N
        "org.netbeans.modules.java.j2seembedded.wizard.RemotePlatformInstall"); //NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:PlatformInstallTest.java

示例11: testBuildWithDirtyListFirstTime

import org.openide.util.Lookup; //導入依賴的package包/類
public void testBuildWithDirtyListFirstTime() throws Exception { // #119777
    J2SEProject prj = (J2SEProject) pp;
    EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    ep.put(ProjectProperties.TRACK_FILE_CHANGES, "true");
    helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
    // Use a new instance, since the old one will already have a dirty list from setUp():
    actionProvider = new J2SEActionProvider(prj, prj.getUpdateHelper());
    ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
    ep.put(ProjectProperties.DO_DEPEND, "false");
    helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
    Properties p = new Properties();
    MainClassChooser.unitTestingSupport_hasMainMethodResult = true;
    try {
        assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p)));
        assertEquals("{}", p.toString());
        assertEquals("[run]", Arrays.toString(actionProvider.getTargetNames(ActionProvider.COMMAND_RUN, Lookup.EMPTY, p)));
        assertEquals("{includes=nothing whatsoever}", p.toString());
    } finally {
        MainClassChooser.unitTestingSupport_hasMainMethodResult = null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:J2SEActionProviderTest.java

示例12: cleanUpResult

import org.openide.util.Lookup; //導入依賴的package包/類
/** Cleanup the references
 */
@Override
public AbstractLookup.ReferenceToResult cleanUpResult(Lookup.Template<?> templ) {
    long now = System.currentTimeMillis();
    AbstractLookup.ReferenceIterator it = new AbstractLookup.ReferenceIterator(this.results);

    int cnt = 0;
    while (it.next()) {
        cnt++;
    }
    
    long took = System.currentTimeMillis() - now;
    if (took > 500 && AbstractLookup.LOG != null) {
        AbstractLookup.LOG.log(Level.WARNING, 
            "Too long ({0} ms and {1} references) cleanUpResult for {2}",
            new Object[]{took, cnt, templ != null ? templ.getType() : null}
        );
    }

    return this.results = it.first();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ArrayStorage.java

示例13: resolveSupported

import org.openide.util.Lookup; //導入依賴的package包/類
/**
* Implementation of the above method.
*
* @param activatedNodes gives array of actually activated nodes.
* @return number of supported classes
*/
private int resolveSupported(Node[] activatedNodes) {
    int ret = 0;

    Class<?>[] cookies = getCookies();

    for (Node n : activatedNodes) {
        for (Class<?> cookie : cookies) {
            // test for supported cookies
            @SuppressWarnings("unchecked")
            Lookup.Template<?> templ = new Lookup.Template(cookie);
            if (n.getLookup().lookupItem(templ) != null) {
                ret++;

                break;
            }
        }
    }

    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:CookieAction.java

示例14: InstallConfig

import org.openide.util.Lookup; //導入依賴的package包/類
private InstallConfig() {
    for( ModuleInfo mi : Lookup.getDefault().lookupAll(ModuleInfo.class) ) {

        ergonomics = ergonomics || isErgonomicsPack(mi);

        if( !isPack(mi) )
            continue;

        if( mi.isEnabled() ) {
            enabledPackNames.add(mi.getCodeNameBase());
        } else {
            somePacksDisabled = true;
        }
        availablePackNames.add(mi.getCodeNameBase());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:InstallConfig.java

示例15: configureAttachSettings

import org.openide.util.Lookup; //導入依賴的package包/類
private boolean configureAttachSettings(boolean partially) {
    AttachSettings settings = AttachWizard.getDefault().configure(attachSettings, partially);
    if (settings == null) return false; // cancelled by the user
    
    attachSettings = settings;
    final AttachSettings as = new AttachSettings();
    attachSettings.copyInto(as);
    final Lookup.Provider lp = session.getProject();
    RequestProcessor.getDefault().post(new Runnable() {
        public void run() {
            Properties p = new Properties();
            as.store(p);
            try {
                ProfilerStorage.saveProjectProperties(p, lp, "attach"); // NOI18N
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
        
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ProfilerWindow.java


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