本文整理汇总了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);
}
示例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");
}
示例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();
}
}
示例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);
}
示例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
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
}
示例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();
}
示例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;
}
示例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());
}
}
示例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;
}