org.openide.util.Lookup Java Examples
The following examples show how to use
org.openide.util.Lookup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BuildArtifactMapperImpl.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean protectAgainstErrors(URL targetFolder, FileObject[][] sources, Object context) throws MalformedURLException { Preferences pref = NbPreferences.forModule(BuildArtifactMapperImpl.class).node(BuildArtifactMapperImpl.class.getSimpleName()); if (!pref.getBoolean(UIProvider.ASK_BEFORE_RUN_WITH_ERRORS, true)) { return true; } sources(targetFolder, sources); for (FileObject file : sources[0]) { if (ErrorsCache.isInError(file, true) && !alreadyWarned.contains(context)) { UIProvider uip = Lookup.getDefault().lookup(UIProvider.class); if (uip == null || uip.warnContainsErrors(pref)) { alreadyWarned.add(context); return true; } return false; } } return true; }
Example #2
Source File: NavigatorController.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void beforeLookup(Template<?> template) { super.beforeLookup(template); Lookup[] curNodesLookups; synchronized (CUR_NODES_LOCK) { curNodesLookups = new Lookup[curNodes.size()]; int i = 0; for (Iterator<? extends Node> it = curNodes.iterator(); it.hasNext(); i++) { curNodesLookups[i] = it.next().getLookup(); } } setLookups(curNodesLookups); }
Example #3
Source File: CustomizeProject.java From netbeans with Apache License 2.0 | 6 votes |
protected @Override void refresh(Lookup context, boolean immediate) { super.refresh(context, immediate); Project[] projects = ActionsUtil.getProjectsFromLookup( context, null ); if ( projects.length != 1 || projects[0].getLookup().lookup( CustomizerProvider.class ) == null ) { setEnabled( false ); // setDisplayName( ActionsUtil.formatProjectSensitiveName( namePattern, new Project[0] ) ); } else { setEnabled( true ); // setDisplayName( ActionsUtil.formatProjectSensitiveName( namePattern, projects ) ); } }
Example #4
Source File: AndroidStyleable.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
@Override public void render(Graphics g, Font defaultFont, Color defaultColor, Color backgroundColor, int width, int height, boolean selected) { ImageIcon icon = null; Collection<? extends StyleableIconProvider> iconProviders = Lookup.getDefault().lookupAll(StyleableIconProvider.class); Iterator<? extends StyleableIconProvider> iterator = iconProviders.iterator(); while (iterator.hasNext()) { StyleableIconProvider iconProvider = iterator.next(); try { icon = iconProvider.getIcon(fullClassName, androidStyleableType); } catch (Exception e) { Exceptions.printStackTrace(e); } if (icon != null) { break; } } CompletionUtilities.renderHtml(icon, getFullClassName(), getAndroidStyleableType().name(), g, defaultFont, defaultColor, width, height, selected); Completion c = Completion.get(); c.hideDocumentation(); c.showDocumentation(); }
Example #5
Source File: LafPanel.java From netbeans with Apache License 2.0 | 6 votes |
private void switchEditorColorsProfile() { if( !isChangeEditorColorsPossible() ) return; String preferredProfile = getPreferredColorProfile(); ClassLoader cl = Lookup.getDefault().lookup( ClassLoader.class ); if( null == cl ) cl = LafPanel.class.getClassLoader(); try { Class klz = cl.loadClass( COLOR_MODEL_CLASS_NAME ); Object colorModel = klz.newInstance(); Method m = klz.getDeclaredMethod( "getAnnotations", String.class ); //NOI18N Object annotations = m.invoke( colorModel, preferredProfile ); m = klz.getDeclaredMethod( "setAnnotations", String.class, Collection.class ); //NOI18N m.invoke( colorModel, preferredProfile, annotations ); m = klz.getDeclaredMethod( "setCurrentProfile", String.class ); //NOI18N m.invoke( colorModel, preferredProfile ); } catch( Exception ex ) { //ignore Logger.getLogger( LafPanel.class.getName() ).log( Level.INFO, "Cannot change editor colors profile.", ex ); //NOI18N } }
Example #6
Source File: NetigsoHandle.java From netbeans with Apache License 2.0 | 6 votes |
synchronized void classLoaderUp(NetigsoModule nm) throws IOException { if (toInit != null) { toInit.add(nm); return; } List<Module> clone; synchronized (toEnable) { @SuppressWarnings("unchecked") List<Module> cloneTmp = (List<Module>) toEnable.clone(); clone = cloneTmp; toEnable.clear(); } if (!clone.isEmpty()) { getDefault().prepare(Lookup.getDefault(), clone); } nm.start(); }
Example #7
Source File: TomcatInstanceNode.java From netbeans with Apache License 2.0 | 6 votes |
/** * Overrides the compatible XML DO behaviour for files without data objects * @param context * @return */ @MIMEResolver.Registration( displayName="org.netbeans.modules.tomcat5.resources.Bundle#TomcatResolver", position=380, resource="../../resources/tomcat-mime-resolver.xml" ) @MultiViewElement.Registration( displayName="org.netbeans.modules.tomcat5.ui.nodes.Bundle#CTL_SourceTabCaption", iconBase="org/netbeans/modules/tomcat5/resources/tomcat5.gif", persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED, preferredID="xml.text", mimeType="text/tomcat5+xml", position=1 ) public static MultiViewEditorElement createMultiViewEditorElement(Lookup context) { return new MultiViewEditorElement(context); }
Example #8
Source File: SchemaConceptUtilities.java From constellation with Apache License 2.0 | 5 votes |
/** * Get the highest priority (ie. lowest {@link ServiceProvider} 'position' * value) SchemaConcept using {@link Lookup}. * * @return The highest priority SchemaConcept. */ public static final SchemaConcept getDefaultConcept() { if (DEFAULT_CONCEPT == null) { DEFAULT_CONCEPT = Lookup.getDefault().lookup(SchemaConcept.class); } return DEFAULT_CONCEPT; }
Example #9
Source File: DrawRectangleToolAction.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
public DrawRectangleToolAction(Lookup lookup) { super(lookup); putValue(NAME, Bundle.CTL_DrawRectangleToolActionText()); putValue(SHORT_DESCRIPTION, Bundle.CTL_DrawRectangleToolActionDescription()); putValue(SMALL_ICON, ImageUtilities.loadImageIcon("org/esa/snap/rcp/icons/DrawRectangleTool24.gif", false)); Interactor interactor = new InsertRectangleFigureInteractor(); interactor.addListener(new InsertFigureInteractorInterceptor()); setInteractor(interactor); }
Example #10
Source File: DOMConvertor.java From netbeans with Apache License 2.0 | 5 votes |
/** read an object from String using Convertor.read() */ private static Object readFromString(Convertor c, String s, Lookup ctx) throws IOException, ClassNotFoundException { java.io.Reader r = new java.io.StringReader(s); FileObject fo = (FileObject) ctx.lookup(FileObject.class); if (fo != null) { r = org.netbeans.modules.settings.ContextProvider.createReaderContextProvider(r, fo); } return c.read(r); }
Example #11
Source File: FolderNodeFactory.java From netbeans with Apache License 2.0 | 5 votes |
public Action createContextAwareInstance(Lookup selection) { final Project[] projects = selection.lookupAll(Project.class).toArray(new Project[0]); return new AbstractAction(SystemAction.get(OpenAction.class).getName()) { public void actionPerformed(ActionEvent ev) { OpenProjects.getDefault().open(projects, false); } @Override public boolean isEnabled() { return !Arrays.asList(OpenProjects.getDefault().getOpenProjects()).containsAll(Arrays.asList(projects)); } }; }
Example #12
Source File: DriverNodeProvider.java From netbeans with Apache License 2.0 | 5 votes |
private DriverNodeProvider(Lookup lookup) { super(lookup, driverComparator); JDBCDriverManager mgr = JDBCDriverManager.getDefault(); mgr.addDriverListener( new JDBCDriverListener() { @Override public void driversChanged() { initialize(); } } ); }
Example #13
Source File: AndroidJavaPlatformProvider8.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
@Override protected AndroidJavaPlatform createPlatform(List<JavaPlatform> tmp, AndroidPlatformInfo pkg) { AndroidJavaPlatform javaPlatform = new AndroidJavaPlatform(pkg, "1.8"); tmp.add(javaPlatform); //add ReadOnlyURLMapper as listener, to avoid lookup chaos when addPropertyChangeListener called directly from ReadOnlyURLMapper addPropertyChangeListener(Lookup.getDefault().lookup(ReadOnlyURLMapper.class)); return javaPlatform; }
Example #14
Source File: URLMapper.java From netbeans with Apache License 2.0 | 5 votes |
/** Reset cache, for use from unit tests. */ static void reset() { cache = null; result = Lookup.getDefault().lookupResult(URLMapper.class); result.addLookupListener( new LookupListener() { public void resultChanged(LookupEvent ev) { synchronized (URLMapper.class) { cache = null; } } } ); }
Example #15
Source File: JsonParserResult.java From netbeans with Apache License 2.0 | 5 votes |
@NonNull private static Lookup createAdditionalLookup( @NullAllowed final org.netbeans.modules.javascript2.json.parser.JsonParser.JsonContext parseTree) { return parseTree == null ? Lookup.EMPTY : Lookups.singleton(parseTree); }
Example #16
Source File: JFXProjectProperties.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of JFXProjectProperties */ private JFXProjectProperties(Lookup context) { //defaultInstance = provider.getJFXProjectProperties(); project = context.lookup(Project.class); if (project != null) { j2sePropEval = project.getLookup().lookup(J2SEPropertyEvaluator.class); evaluator = j2sePropEval.evaluator(); // Packaging binaryEncodeCSS = fxPropGroup.createToggleButtonModel(evaluator, JAVAFX_BINARY_ENCODE_CSS); // set true by default in JFXProjectGenerator // Deployment allowOfflineModel = fxPropGroup.createToggleButtonModel(evaluator, ALLOW_OFFLINE); // set true by default in JFXProjectGenerator backgroundUpdateCheck = fxPropGroup.createToggleButtonModel(evaluator, UPDATE_MODE_BACKGROUND); // set true by default in JFXProjectGenerator installPermanently = fxPropGroup.createToggleButtonModel(evaluator, INSTALL_PERMANENTLY); addDesktopShortcut = fxPropGroup.createToggleButtonModel(evaluator, ADD_DESKTOP_SHORTCUT); addStartMenuShortcut = fxPropGroup.createToggleButtonModel(evaluator, ADD_STARTMENU_SHORTCUT); disableProxy = fxPropGroup.createToggleButtonModel(evaluator, DISABLE_PROXY); // CustomizerRun CONFIGS = new JFXConfigs(); CONFIGS.read(); initPreloaderArtifacts(project, CONFIGS); CONFIGS.setActive(evaluator.getProperty(ProjectProperties.PROP_PROJECT_CONFIGURATION_CONFIG)); preloaderClassModel = new PreloaderClassComboBoxModel(); initVersion(evaluator); initIcons(evaluator); initSigning(evaluator); initNativeBundling(evaluator); initResources(evaluator, project, CONFIGS); initJSCallbacks(evaluator); initRest(evaluator); } }
Example #17
Source File: CustomizationTest.java From netbeans with Apache License 2.0 | 5 votes |
private WSDLModel getModel(){ WSDLModel model = null; try{ Document doc = this.getResourceAsDocument(TEST_WSDL); Lookup l = Lookups.fixed(new Object[] { doc }); ModelSource source = new ModelSource(l, true); model = new WSDLModelImpl(source); model.sync(); } catch(Exception e){ System.out.println("Exception class: " + e.getClass().getName()); System.out.println("Unable to load model: " + e.getMessage()); } return model; }
Example #18
Source File: ContextAction.java From netbeans with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public boolean enabled(List<? extends Object> data, Lookup.Provider everything) { Object o = delegate.get("enabler"); // NOI18N if (o == null) { return true; } if (o instanceof ContextActionEnabler) { ContextActionEnabler<Object> en = (ContextActionEnabler<Object>)o; return en.enabled(data); } GeneralAction.LOG.warning("Wrong enabler for " + delegate + ":" + o); return false; }
Example #19
Source File: NodesRegistrationSupport.java From netbeans with Apache License 2.0 | 5 votes |
AbstractRegistrator(Class cls) { this.cls = cls; init(); lookupResult = Lookup.getDefault().lookupResult(cls); register(); lookupResult.addLookupListener(this); }
Example #20
Source File: CustomizeDriverAction.java From netbeans with Apache License 2.0 | 5 votes |
public void performAction(Node[] activatedNodes) { Lookup lookup = activatedNodes[0].getLookup(); final DriverNode node = lookup.lookup(DriverNode.class); if (node != null) { AddDriverDialog.showDialog(node); } }
Example #21
Source File: PhpUnitCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
@NbBundle.Messages("PhpUnitCustomizer.name=PHPUnit") @Override public Category createCategory(Lookup context) { return ProjectCustomizer.Category.create( IDENTIFIER, Bundle.PhpUnitCustomizer_name(), null, (ProjectCustomizer.Category[]) null); }
Example #22
Source File: ActionsTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * Run an action as if it were in the context menu of a project. */ private void runContextMenuAction(Action a, Project p) { if (a instanceof ContextAwareAction) { Lookup l = Lookups.singleton(p); a = ((ContextAwareAction) a).createContextAwareInstance(l); } a.actionPerformed(null); }
Example #23
Source File: LogViewMgr.java From netbeans with Apache License 2.0 | 5 votes |
static public void displayOutput(PayaraInstance instance, Lookup lookup) { String uri = instance.getProperty(PayaraModule.URL_ATTR); if (null != uri && (uri.contains("pfv3ee6wc") || uri.contains("localhost"))) { FetchLog log = getServerLogStream(instance); LogViewMgr mgr = LogViewMgr.getInstance(uri); List<Recognizer> recognizers = new ArrayList<Recognizer>(); if (null != lookup) { recognizers = getRecognizers(lookup.lookupAll(RecognizerCookie.class)); } mgr.ensureActiveReader(recognizers, log, instance); mgr.selectIO(true); } }
Example #24
Source File: MMDDataObject.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
@Override protected Node createNodeDelegate() { final Lookup env = Environment.find(this); Node result = env == null ? null : env.lookup(Node.class); if (result == null){ result = new MMFileDataNode(this, getLookup()); } return result; }
Example #25
Source File: ModuleActions.java From netbeans with Apache License 2.0 | 5 votes |
private FileObject[] findSources(Lookup context, boolean findInPackages, boolean strict) { FileObject srcDir = project.getSourceDirectory(); if (srcDir != null) { FileObject[] files = ActionUtils.findSelectedFiles(context, srcDir, findInPackages ? null : ".java", strict); // NOI18N //System.err.println("findSources: srcDir=" + srcDir + " files=" + (files != null ? java.util.Arrays.asList(files) : null) + " context=" + context); return files; } else { return null; } }
Example #26
Source File: ControlFlowTopComponent.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void resultChanged(LookupEvent lookupEvent) { final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); if (p != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { InputGraph g = p.getGraph(); if (g != null) { scene.setGraph(g); } } }); } }
Example #27
Source File: DecoratedFileSystem.java From visualvm with GNU General Public License v2.0 | 5 votes |
public String getPluginCodeName (FileObject template) { Lookup.Result<PluginInfo> result = consumerVisualVM ().lookupResult (PluginInfo.class); String path = template.getPath (); for (PluginInfo pi : result.allInstances ()) { Internal internal = PluginInfoAccessor.DEFAULT.getInternal (pi); XMLFileSystem fs = internal.getXMLFileSystem (); if (fs.findResource (path) != null) { return PluginInfoAccessor.DEFAULT.getCodeName (pi); } } return null; }
Example #28
Source File: CustomizerDialog.java From netbeans with Apache License 2.0 | 5 votes |
OptionListener(@NonNull ActionListener okOptionListener, @NullAllowed ActionListener storeListener, ProjectCustomizer.Category[] categs, ProjectCustomizer.CategoryComponentProvider componentProvider) { this.okOptionListener = okOptionListener; this.storeListener = storeListener; categories = categs; //#97998 related if (componentProvider instanceof Lookup.Provider) { prov = (Lookup.Provider)componentProvider; } }
Example #29
Source File: MIMESupportLoggingTest.java From netbeans with Apache License 2.0 | 5 votes |
private Lookup getInstanceLookup(final Object... instances) { InstanceContent instanceContent = new InstanceContent(); for(Object i : instances) { instanceContent.add(i); } Lookup instanceLookup = new AbstractLookup(instanceContent); return instanceLookup; }
Example #30
Source File: MicroPropertiesPanelProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public ProjectCustomizer.Category createCategory(Lookup context) { Project project = context.lookup(Project.class); if (MicroApplication.getInstance(project) == null) { return null; } return ProjectCustomizer.Category.create("PayaraMicro", "Payara Micro", null); // NOI18N }