Java Code Examples for org.openide.util.Lookup#lookup()
The following examples show how to use
org.openide.util.Lookup#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: ReferencesMultiViewElement.java From netbeans with Apache License 2.0 | 6 votes |
/** Creates a new instance of DDMultiViewElement */ public ReferencesMultiViewElement(Lookup context) { super(context.lookup(DDDataObject.class)); this.dObj=context.lookup(DDDataObject.class); this.index=REFERENCES_ELEMENT_INDEX; comp = new ToolBarDesignEditor(); factory = new ReferencesFactory(comp, dObj); setVisualEditor(comp); repaintingTask = RequestProcessor.getDefault().create(new Runnable() { public void run() { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { repaintView(); } }); } }); }
Example 2
Source File: PackagesPanelProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Category createCategory(Lookup context) { Project project = context.lookup(Project.class); NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); String effPackaging = watcher.getPackagingType(); String[] types = PluginPropertyUtils.getPluginPropertyList(project, OSGiConstants.GROUPID_FELIX, OSGiConstants.ARTIFACTID_BUNDLE_PLUGIN, "supportedProjectTypes", "supportedProjectType", /*"bundle" would not work for GlassFish parent POM*/null); if (types != null) { for (String type : types) { if (effPackaging.equals(type)) { effPackaging = NbMavenProject.TYPE_OSGI; } } } if (NbMavenProject.TYPE_OSGI.equalsIgnoreCase(effPackaging)) { return ProjectCustomizer.Category.create( ModelHandle2.PANEL_COMPILE, org.openide.util.NbBundle.getMessage(PackagesPanelProvider.class, "TIT_Packages"), null); } return null; }
Example 3
Source File: NavigatorController.java From netbeans with Apache License 2.0 | 6 votes |
/** Starts listening to selected nodes and active component */ private void navigatorTCOpened() { if (panelLookupNodesResult != null) { return; } LOG.fine("Entering navigatorTCOpened"); Lookup globalContext = Utilities.actionsGlobalContext(); curNodesRes = globalContext.lookup(CUR_NODES); curNodesRes.addLookupListener(this); curHintsRes = globalContext.lookup(CUR_HINTS); curHintsRes.addLookupListener(this); panelLookupNodesResult = panelLookup.lookup(CUR_NODES); panelLookupNodesResult.addLookupListener(panelLookupListener); updateContext(globalContext.lookup(NavigatorLookupPanelsPolicy.class), globalContext.lookupAll(NavigatorLookupHint.class)); closed = false; }
Example 4
Source File: CPActionsImplementationProvider.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void doRename(Lookup selectedNodes) { EditorCookie ec = selectedNodes.lookup(EditorCookie.class); if (isFromEditor(ec)) { //editor refactoring new TextComponentTask(ec) { @Override protected RefactoringUI createRefactoringUI(RefactoringElementContext context) { return new CPRenameRefactoringUI(context); } }.run(); } else { //file or folder refactoring - not supported } }
Example 5
Source File: ViewAction.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Action createContextAwareInstance(Lookup actionContext) { DataObject dobj = actionContext.lookup(DataObject.class); if (dobj == null) { return this; } Project owner = FileOwnerQuery.getOwner(dobj.getPrimaryFile()); if(owner == null) { return this; } if ("org.netbeans.modules.web.clientproject.ClientSideProject".equals(owner.getClass().getName())) { //NOI18N return this; } final Viewable viewable = dobj.getLookup().lookup(Viewable.class); if (viewable == null) { return this; } return new InnerViewAction(viewable); }
Example 6
Source File: ModelTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * Test of getRoot method, of class org.netbeans.modules.palette.Model. */ public void testGetRoot() throws IOException { PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() ); Model model = pc.getModel(); Lookup rootLookup = model.getRoot(); DataFolder df = (DataFolder)rootLookup.lookup( DataFolder.class ); assertNotNull( df ); FileObject fo = df.getPrimaryFile(); assertNotNull( fo ); assertEquals( getRootFolderName(), fo.getName() ); }
Example 7
Source File: JavaProfilerSource.java From netbeans with Apache License 2.0 | 5 votes |
/** * Factory method for obtaining a {@linkplain JavaProfilerSource} from a file or NULL * @return Returns a {@linkplain JavaProfilerSource} instance or NULL */ public static JavaProfilerSource createFrom(FileObject fo) { if (fo == null || !fo.isValid()) return null; Lookup lkp = MimeLookup.getLookup(fo.getMIMEType()); AbstractJavaProfilerSource impl = lkp.lookup(AbstractJavaProfilerSource.class); if (impl == null && fo.isData() && fo.hasExt("java")) // NOI18N impl = Lookup.getDefault().lookup(AbstractJavaProfilerSource.class); if (impl == null) { return null; } return new JavaProfilerSource(fo, impl); }
Example 8
Source File: MavenCompositePanelProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override public JComponent createComponent(Category category, Lookup context) { String name = category.getName(); ModelHandle2 handle = context.lookup(ModelHandle2.class); final Project project = context.lookup(Project.class); category.setOkButtonListener(listenerAWT); category.setStoreListener(listenerNonAWT); if (FRAMEWORKS.equals(name)) { frameworkCustomizer = new CustomizerFrameworks(category, project); return frameworkCustomizer; } if (RUN.equals(name)) { String projectType = project.getLookup().lookup(NbMavenProject.class).getPackagingType(); if (NbMavenProject.TYPE_WAR.equalsIgnoreCase(projectType)) { runCustomizer = new CustomizerRunWeb(handle, project); } if (NbMavenProject.TYPE_EJB.equalsIgnoreCase(projectType)) { runCustomizer = new CustomizerRunEjb(handle, project); } if (NbMavenProject.TYPE_EAR.equalsIgnoreCase(projectType)) { runCustomizer = new CustomizerRunEar(handle, project); } return runCustomizer; } return null; }
Example 9
Source File: PackagesPanelProvider.java From netbeans with Apache License 2.0 | 5 votes |
@Override @Messages("TIT_Packages=Public Packages") public Category createCategory(Lookup context) { Project project = context.lookup(Project.class); NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class); if (NbMavenProject.TYPE_NBM.equalsIgnoreCase(watcher.getPackagingType())) { return ProjectCustomizer.Category.create( ModelHandle2.PANEL_COMPILE, TIT_Packages(), null); } return null; }
Example 10
Source File: RefactoringActionsProvider.java From netbeans with Apache License 2.0 | 5 votes |
public static FileObject getTarget(Lookup look) { ExplorerContext drop = look.lookup(ExplorerContext.class); if (drop==null) { return null; } Node n = drop.getTargetNode(); if (n==null) { return null; } DataObject dob = n.getCookie(DataObject.class); if (dob!=null) { return dob.getPrimaryFile(); } return null; }
Example 11
Source File: MobileCompositeProvider.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { jwsProps = new ProjectExtensionProperties(context.lookup(Project.class), keyList); MobileCustomizerPanel panel = new MobileCustomizerPanel(jwsProps); category.setStoreListener(new SavePropsListener(jwsProps, context.lookup(Project.class))); category.setOkButtonListener(panel); return panel; }
Example 12
Source File: SunDescriptorDataObject.java From netbeans with Apache License 2.0 | 5 votes |
@MultiViewElement.Registration( mimeType={ DDType.SUN_MIME_TYPE_PREFIX + DDType.WEB_MIME_TYPE_SUFFIX, DDType.SUN_MIME_TYPE_PREFIX + DDType.EJB_MIME_TYPE_SUFFIX, DDType.SUN_MIME_TYPE_PREFIX + DDType.APP_CLI_MIME_TYPE_SUFFIX, DDType.GLASSFISH_MIME_TYPE_PREFIX + DDType.APP_CLI_MIME_TYPE_SUFFIX }, iconBase="org/netbeans/modules/j2ee/sun/ddloaders/resources/DDDataIcon.gif", persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED, preferredID="multiview_xml_gf_shared_jms", displayName="#CTL_JmsTabCaption", position=10 ) public static MultiViewElement createJmsMultiViewElement(Lookup lookup) { return new JmsMultiViewElement(lookup.lookup(SunDescriptorDataObject.class)); }
Example 13
Source File: ProjectConvertors.java From netbeans with Apache License 2.0 | 5 votes |
@Override public <T> T lookup(Class<T> clazz) { if (supports(clazz)) { final Lookup delegate = findDelegate(); if (delegate != null) { return delegate.lookup(clazz); } } return null; }
Example 14
Source File: SunDescriptorDataObject.java From netbeans with Apache License 2.0 | 5 votes |
@MultiViewElement.Registration( mimeType={ DDType.IPLANET_MIME_TYPE_PREFIX + DDType.WEB_MIME_TYPE_SUFFIX, DDType.SUN_MIME_TYPE_PREFIX + DDType.WEB_MIME_TYPE_SUFFIX }, iconBase="org/netbeans/modules/j2ee/sun/ddloaders/resources/DDDataIcon.gif", persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED, preferredID="multiview_xml_gf_web_servlet", displayName="#CTL_ServletsTabCaption", position=2 ) public static MultiViewElement createServletsMultiViewElement(Lookup lookup) { return new ServletMultiViewElement(lookup.lookup(SunDescriptorDataObject.class)); }
Example 15
Source File: SQLCompletionProvider.java From netbeans with Apache License 2.0 | 5 votes |
private static DatabaseConnection findDBConn(JTextComponent component) { Lookup context = findContext(component); if (context == null) { return null; } SQLExecution sqlExecution = context.lookup(SQLExecution.class); if (sqlExecution == null) { return null; } return sqlExecution.getDatabaseConnection(); }
Example 16
Source File: ProjectSearchingUtils.java From netbeans with Apache License 2.0 | 5 votes |
@Override public org.netbeans.api.search.provider.SearchInfo getSearchInfoForLookup( Lookup lookup) { SearchInfo si = lookup.lookup(SearchInfo.class); if (si != null) { return wrap(si); } return null; }
Example 17
Source File: ActionInvocationTest.java From netbeans with Apache License 2.0 | 4 votes |
public DummyUI(Lookup lookup, Kind kind) { Node node = lookup.lookup(Node.class); this.l = Lookups.singleton(node.getLookup().lookup(FileObject.class)); this.kind = kind; }
Example 18
Source File: JavaRefactoringsFactory.java From netbeans with Apache License 2.0 | 4 votes |
@Override public RefactoringPlugin createInstance(AbstractRefactoring refactoring) { Lookup look = refactoring.getRefactoringSource(); FileObject file = look.lookup(FileObject.class); NonRecursiveFolder folder = look.lookup(NonRecursiveFolder.class); TreePathHandle handle = look.lookup(TreePathHandle.class); DocTreePathHandle docHandle = look.lookup(DocTreePathHandle.class); if (refactoring instanceof WhereUsedQuery) { if (handle!=null) { return new JavaWhereUsedQueryPlugin((WhereUsedQuery) refactoring); } } else if (refactoring instanceof RenameRefactoring) { if (handle!=null || docHandle!=null || ((file!=null) && RefactoringUtils.isJavaFile(file))) { //rename java file, class, method etc.. return new RenameRefactoringPlugin((RenameRefactoring)refactoring); } else if (file!=null && JavaRefactoringUtils.isOnSourceClasspath(file) && file.isFolder()) { //rename folder return new MoveFileRefactoringPlugin((RenameRefactoring)refactoring); } else if (folder!=null && JavaRefactoringUtils.isOnSourceClasspath(folder.getFolder())) { //rename package return new MoveFileRefactoringPlugin((RenameRefactoring)refactoring); } } else if (refactoring instanceof SafeDeleteRefactoring) { //TODO: should be implemented better if (checkSafeDelete(refactoring.getRefactoringSource())) { return new SafeDeleteRefactoringPlugin((SafeDeleteRefactoring)refactoring); } } else if (refactoring instanceof MoveRefactoring) { if (checkMove(refactoring.getRefactoringSource())) { return new MoveFileRefactoringPlugin((MoveRefactoring) refactoring); } else if (checkMoveMembers(refactoring.getContext())) { return new MoveMembersRefactoringPlugin((MoveRefactoring) refactoring); } } else if (refactoring instanceof SingleCopyRefactoring) { if (checkCopy(refactoring.getRefactoringSource())) { return new CopyClassRefactoringPlugin((SingleCopyRefactoring) refactoring); } } else if (refactoring instanceof CopyRefactoring) { if (checkCopy(refactoring.getRefactoringSource())) { return new CopyClassesRefactoringPlugin((CopyRefactoring) refactoring); } } else if (handle!=null) { if (refactoring instanceof ExtractInterfaceRefactoring) { return new ExtractInterfaceRefactoringPlugin((ExtractInterfaceRefactoring) refactoring); } else if (refactoring instanceof ExtractSuperclassRefactoring) { return new ExtractSuperclassRefactoringPlugin((ExtractSuperclassRefactoring) refactoring); } else if (refactoring instanceof IntroduceLocalExtensionRefactoring) { return new IntroduceLocalExtensionPlugin((IntroduceLocalExtensionRefactoring) refactoring); } else if (refactoring instanceof PullUpRefactoring) { return new PullUpRefactoringPlugin((PullUpRefactoring)refactoring); } else if (refactoring instanceof PushDownRefactoring) { return new PushDownRefactoringPlugin((PushDownRefactoring) refactoring); } else if (refactoring instanceof UseSuperTypeRefactoring) { return new UseSuperTypeRefactoringPlugin((UseSuperTypeRefactoring) refactoring); } else if (refactoring instanceof InnerToOuterRefactoring) { return new InnerToOuterRefactoringPlugin((InnerToOuterRefactoring) refactoring); } else if (refactoring instanceof ChangeParametersRefactoring) { return new ChangeParametersPlugin((ChangeParametersRefactoring) refactoring); } else if (refactoring instanceof IntroduceParameterRefactoring) { return new IntroduceParameterPlugin((IntroduceParameterRefactoring) refactoring); } else if (refactoring instanceof EncapsulateFieldRefactoring) { return new EncapsulateFieldRefactoringPlugin((EncapsulateFieldRefactoring) refactoring); } else if (refactoring instanceof EncapsulateFieldsRefactoring) { return new EncapsulateFieldsPlugin((EncapsulateFieldsRefactoring) refactoring); } else if (refactoring instanceof InlineRefactoring) { return new InlineRefactoringPlugin((InlineRefactoring) refactoring); } else if (refactoring instanceof ReplaceConstructorWithFactoryRefactoring) { return new ReplaceConstructorWithFactoryPlugin((ReplaceConstructorWithFactoryRefactoring) refactoring); } else if (refactoring instanceof InvertBooleanRefactoring) { return new InvertBooleanRefactoringPlugin((InvertBooleanRefactoring) refactoring); } else if (refactoring instanceof ReplaceConstructorWithBuilderRefactoring) { return new ReplaceConstructorWithBuilderPlugin((ReplaceConstructorWithBuilderRefactoring) refactoring); } } return null; }
Example 19
Source File: JavaEEServerModuleFactory.java From netbeans with Apache License 2.0 | 4 votes |
@Override public Object createModule(Lookup instanceLookup) { // When creating JavaEE support, also ensure this instance is added to j2eeserver InstanceProperties ip = null; final GlassfishModule commonModule = instanceLookup.lookup(GlassfishModule.class); if(commonModule != null) { Map<String, String> props = commonModule.getInstanceProperties(); String url = props.get(InstanceProperties.URL_ATTR); ip = InstanceProperties.getInstanceProperties(url); if (ip == null) { String username = props.get(InstanceProperties.USERNAME_ATTR); // Password shall not be read from keyring during initialization String password = null; String displayName = props.get(InstanceProperties.DISPLAY_NAME_ATTR); try { ip = InstanceProperties.createInstancePropertiesNonPersistent( url, username, password, displayName, props); } catch (InstanceCreationException ex) { // the initialization delay of the ServerRegistry may have triggered a ignorable // exception ip = InstanceProperties.getInstanceProperties(url); if (null == ip) { Logger.getLogger("glassfish-javaee").log(Level.WARNING, null, ex); // NOI18N } } if(ip == null) { Logger.getLogger("glassfish-javaee").log(Level.INFO, "Unable to create/locate J2EE InstanceProperties for {0}", url); } } final String glassfishRoot = commonModule.getInstanceProperties().get( GlassfishModule.GLASSFISH_FOLDER_ATTR); final String installRoot = commonModule.getInstanceProperties().get( GlassfishModule.INSTALL_FOLDER_ATTR); RP.post(new Runnable() { @Override public void run() { ensureEclipseLinkSupport(glassfishRoot); ensureCometSupport(glassfishRoot); ensureGlassFishApiSupport(commonModule.getInstance()); // lookup the javadb register service here and use it. RegisteredDerbyServer db = Lookup.getDefault().lookup(RegisteredDerbyServer.class); if (null != db && null != installRoot) { File ir = new File(installRoot); File f = new File(ir,"javadb"); if (f.exists() && f.isDirectory() && f.canRead()) { db.initialize(f.getAbsolutePath()); } } } }); } else { Logger.getLogger("glassfish-javaee").log(Level.WARNING, "commonModule is NULL"); } return (ip != null) ? new JavaEEServerModule(instanceLookup, ip) : null; }
Example 20
Source File: CheckstyleCustomizerPanel.java From netbeans with Apache License 2.0 | 4 votes |
@Override public JComponent createComponent(ProjectCustomizer.Category cat, Lookup look) { ModelHandle2 handle = look.lookup(ModelHandle2.class); return new CheckstylePanel(handle, cat); }