本文整理了Java中org.openide.util.Lookup.lookup()
方法的一些代码示例,展示了Lookup.lookup()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lookup.lookup()
方法的具体详情如下:
包路径:org.openide.util.Lookup
类名称:Lookup
方法名:lookup
[英]Look up an object matching a given interface. This is the simplest method to use. If more than one object matches, the first will be returned. The template class may be a class or interface; the instance is guaranteed to be assignable to it.
[中]查找与给定接口匹配的对象。这是最简单的方法。如果有多个对象匹配,将返回第一个对象。模板类可以是类或接口;实例保证可分配给它。
代码示例来源:origin: org.netbeans.api/org-openide-util
/** Lazy create default NB classloader for use during deserialization. */
private static ClassLoader getNBClassLoader() {
ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class);
return (c != null) ? c : ClassLoader.getSystemClassLoader();
}
代码示例来源:origin: org.netbeans.api/org-openide-util
private static Provider getPreferencesProvider() {
Provider retval = Lookup.getDefault().lookup(Provider.class);
if (retval == null) {
retval = new Provider() {
public Preferences preferencesForModule(Class cls) {
return Preferences.userNodeForPackage(cls);
}
public Preferences preferencesRoot() {
return Preferences.userRoot();
}
};
// Avoided warning in case it is set
//(e.g. from NbTestCase - org.netbeans.junit.internal.MemoryPreferencesFactory).
String prefsFactory = System.getProperty("java.util.prefs.PreferencesFactory");//NOI18N
if (!"org.netbeans.junit.internal.MemoryPreferencesFactory".equals(prefsFactory)) {//NOI18N
Logger logger = Logger.getLogger(NbPreferences.class.getName());
logger.log(prefsFactory == null ? Level.WARNING : Level.FINE,
"NetBeans implementation of Preferences not found");//NOI18N
}
}
return retval;
}
代码示例来源:origin: org.netbeans.api/org-openide-util-lookup
return defaultLookup;
LOG.log(Level.FINER, "About to initialize Lookup@{0}.getDefault() by {1}",
new Object[] { Lookup.class.getClassLoader(), Thread.currentThread() }
);
LOG.log(Level.FINER, "Specified by property? Value: {0}", className);
LOG.log(Level.FINER, "Searching in classloader {0}", l);
try {
if (className != null) {
defaultLookup = misl.lookup(Lookup.class);
LOG.log(Level.FINER, "Searching for {0} in {1} yields {2}", new Object[]{Lookup.class, misl, defaultLookup});
if (defaultLookup != null) {
Lookup.Provider prov = misl.lookup(Lookup.Provider.class);
LOG.log(Level.FINER, "Searching for {0} in {1} yields {2}", new Object[]{Lookup.Provider.class, misl, defaultLookup});
if (prov != null) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project
private Set<File> loadPlatformJars() {
Set<File> jars = new HashSet<File>();
PlatformJarProvider pjp = prj.getLookup().lookup(PlatformJarProvider.class);
if (pjp != null) {
try {
jars.addAll(pjp.getPlatformJars());
} catch (IOException x) {
LOG.log(Level.INFO, null, x);
}
}
return jars;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-docker-ui
@Override
protected boolean enable(Node[] activatedNodes) {
for (Node node : activatedNodes) {
if (node.getLookup().lookup(DockerTag.class) == null) {
return false;
}
}
return true;
}
代码示例来源:origin: dcaoyuan/nbscala
public NodeList createNodes(Project p) {
J2SEProject project = p.getLookup().lookup(J2SEProject.class);
assert project != null;
return new LibrariesNodeList(project);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject
private boolean hasBrokenIncludes(Project project) {
BrokenIncludes biProvider = Lookup.getDefault().lookup(BrokenIncludes.class);
if (biProvider != null) {
NativeProject id = project.getLookup().lookup(NativeProject.class);
if (id != null) {
return biProvider.isBroken(id);
}
}
return false;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
public static boolean getGlobalExpandTabs(){
Preferences global = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
if (global != null) {
return global.getBoolean(SimpleValueNames.EXPAND_TABS, expandTabToSpacesDefault);
}
return expandTabToSpacesDefault;
}
代码示例来源:origin: org.netbeans.api/org-openide-util
serviceTypeClass = Class.forName(className, true, Lookup.getDefault().lookup(ClassLoader.class));
clazz = serviceTypeClass.asSubclass(ServiceType.class);
err.log(Level.FINE, "Service not found", ex); //NOI18N
ServiceType.Registry r = Lookup.getDefault().lookup(ServiceType.Registry.class);
Enumeration en = r.services(clazz);
ServiceType some = r.find(clazz);
代码示例来源:origin: org.netbeans.api/org-openide-awt
/** Implementation of {@link Savable#save} contract. Calls
* {@link #handleSave} and {@link #unregister}.
*
* @throws IOException if call to {@link #handleSave} throws IOException
*/
@Override
public final void save() throws IOException {
Template<AbstractSavable> t = new Template<AbstractSavable>(AbstractSavable.class, null, this);
for (Savable s : Savable.REGISTRY.lookup(t).allInstances()) {
if (s == this) {
handleSave();
unregister();
return;
}
}
LOG.log(Level.WARNING, "Savable {0} is not in Savable.REGISTRY! " // NOI18N
+ "Have not you forgotten to call register() in constructor?", getClass()); // NOI18N
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-junit-ui
public FileObject getTestcaseFileObject() {
LineConvertors.FileLocator fileLocator = getProject().getLookup().lookup(LineConvertors.FileLocator.class);
if(fileLocator == null) {
Logger.getLogger(MavenJUnitTestMethodNode.class.getName()).log(Level.WARNING, "no LineConvertors.FileLocator available for project {0}", getProject().getProjectDirectory());
}
if(testcase == null) {
Logger.getLogger(MavenJUnitTestMethodNode.class.getName()).log(Level.WARNING, "null tescase in MavenJUnitTestMethodNode for project {0}", getProject().getProjectDirectory());
}
String location = testcase != null ? testcase.getLocation() : null;
return fileLocator != null && location != null ? fileLocator.find(location) : null;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-util
/** @return default class loader which is used, when we don't have
* any other class loader. (in function getBundle(String), getLocalizedFile(String),
* and so on...
*/
private static ClassLoader getLoader() {
ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class);
return (c != null) ? c : ClassLoader.getSystemClassLoader();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-docker-ui
@Override
protected boolean enable(Node[] activatedNodes) {
if (activatedNodes.length != 1) {
return false;
}
return activatedNodes[0].getLookup().lookup(DockerContainer.class) != null;
}
代码示例来源:origin: dcaoyuan/nbscala
public NodeList createNodes(Project p) {
J2SEProject project = (J2SEProject)p.getLookup().lookup(J2SEProject.class);
assert project != null;
return new SourcesNodeList(project);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler-projectsupport
public static void invokeAction(Project project, String s) {
ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
if (ap == null) {
return; // fail early
}
ap.invokeAction(s, Lookup.getDefault());
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
/**
* Returns true if bracket completion is enabled in options.
*/
private boolean completionSettingEnabled() {
Preferences prefs = MimeLookup.getLookup(MIMENames.FORTRAN_MIME_TYPE).lookup(Preferences.class);
return prefs.getBoolean(SimpleValueNames.COMPLETION_PAIR_CHARACTERS, true);
}
代码示例来源:origin: org.netbeans.api/org-openide-awt
/**
* Looks for an implementation in global Lookup, if none is found then it falls
* back to a primitive implementation which displays the notifications in main
* window's status line.
* @return Default implementation.
*/
public static NotificationDisplayer getDefault() {
NotificationDisplayer res = Lookup.getDefault().lookup(NotificationDisplayer.class);
if( null == res ) {
Logger.getLogger( NotificationDisplayer.class.getName()).log( Level.INFO, "No NotificationDisplayer implementation available."); //NOI18N
res = new SimpleNotificationDisplayer();
}
return res;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-j2eeserver
public synchronized RegistryNodeProvider getNodeProvider() {
if (nodeProvider != null) {
return nodeProvider;
}
RegistryNodeFactory nodeFact = (RegistryNodeFactory) lkp.lookup(RegistryNodeFactory.class);
if (nodeFact == null) {
String msg = NbBundle.getMessage(Server.class, "MSG_NoInstance", name, RegistryNodeFactory.class);
LOGGER.log(Level.INFO, msg);
}
nodeProvider = new RegistryNodeProvider(nodeFact); //null is acceptable
return nodeProvider;
}
代码示例来源:origin: org.netbeans.api/org-openide-filesystems
private static ClassLoader loader() {
ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
if (l == null) {
l = FOItem.class.getClassLoader();
}
return l;
}
代码示例来源:origin: eu.agrosense.client/grid-api
private boolean accept(Node node) {
return node.getLookup().lookup(FileObject.class) == null
|| !node.getLookup().lookup(FileObject.class).isFolder();
}
}
内容来源于网络,如有侵权,请联系作者删除!