Java Code Examples for org.openide.util.lookup.Lookups#proxy()
The following examples show how to use
org.openide.util.lookup.Lookups#proxy() .
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: ContextActionTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { lookup = Lookup.EMPTY; lookupProxy = Lookups.proxy(this); a1 = context(new SimpleCookieAction(), null, ContextSelection.EXACTLY_ONE, lookupProxy, Openable.class); a2 = context(new SimpleCookieAction(), this, ContextSelection.ANY, lookupProxy, Openable.class); any = context(new SimpleCookieAction(), null, ContextSelection.ANY, lookupProxy, Openable.class); each = context(new SimpleCookieAction(), null, ContextSelection.EACH, lookupProxy, Openable.class); all = context(new SimpleCookieAction(), null, ContextSelection.ALL, lookupProxy, Openable.class); n1 = new LookupWithOpenable(); n2 = new LookupWithOpenable(); n3 = new LookupWithOpenable(false); n4 = new LookupWithOpenable(n1.lookup(Openable.class)); // share the same cookie instance with n1 SimpleCookieAction.runOn.clear(); actionLookup.current = lookupProxy; MockLookup.setLookup(Lookups.metaInfServices(getClass().getClassLoader()), lookupProxy, Lookups.fixed(actionLookup)); }
Example 2
Source File: JavaEEServerModule.java From netbeans with Apache License 2.0 | 6 votes |
JavaEEServerModule(Lookup instanceLookup, InstanceProperties ip) { instanceProperties = ip; logSupport = new LogHyperLinkSupport.AppServerLogSupport("", "/"); // is this ok, can platform change ? ServerInstance inst = Deployment.getDefault().getServerInstance( instanceProperties.getProperty(InstanceProperties.URL_ATTR)); J2eePlatform platform = null; try { platform = inst.getJ2eePlatform(); } catch (InstanceRemovedException ex) { } lookup = platform != null ? new ProxyLookup(Lookups.fixed(platform, ip), Lookups.proxy(platform)) : Lookup.EMPTY; }
Example 3
Source File: JavaEEServerModule.java From netbeans with Apache License 2.0 | 6 votes |
JavaEEServerModule(Lookup instanceLookup, InstanceProperties ip) { instanceProperties = ip; logSupport = new LogHyperLinkSupport.AppServerLogSupport("", "/"); // is this ok, can platform change ? ServerInstance inst = Deployment.getDefault().getServerInstance( instanceProperties.getProperty(InstanceProperties.URL_ATTR)); J2eePlatform platform = null; try { platform = inst.getJ2eePlatform(); } catch (InstanceRemovedException ex) { } lookup = platform != null ? new ProxyLookup(Lookups.fixed(platform, ip), Lookups.proxy(platform)) : Lookup.EMPTY; }
Example 4
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 5
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 6
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 7
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 8
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 9
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 10
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 11
Source File: CacheFolderProvider.java From netbeans with Apache License 2.0 | 6 votes |
@NonNull private static Collection<? extends CacheFolderProvider> getImpls() { Lookup.Result<CacheFolderProvider> res = impls.get(); if (res == null) { final Lookup lkp = new ProxyLookup( // FIXME: the default Lookup instance changes between users; quick fix is to delegate // to a dynamic proxy lookup which always delegates to the current default Lookup instance. // Proper fix is to probably cache a weak(defaultLookup) -> Lookup.Result map - performance // of the lookup. Lookups.proxy(new Lookup.Provider() { @Override public Lookup getLookup() { return Lookup.getDefault(); } }), Lookups.singleton(DefaultCacheFolderProvider.getInstance())); res = lkp.lookupResult(CacheFolderProvider.class); if (!impls.compareAndSet(null, res)) { res = impls.get(); } } return res.allInstances(); }
Example 12
Source File: TestCatalogModel.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 13
Source File: FeatureProjectFactory.java From netbeans with Apache License 2.0 | 5 votes |
public FeatureNonProject( FileObject dir, FeatureInfo info, ProjectState state, List<FeatureInfo> additional ) { this.delegate = new FeatureDelegate(dir, this); this.info = info; this.additional = additional.toArray(new FeatureInfo[0]); this.lookup = Lookups.proxy(delegate); this.state = state; this.weakL = WeakListeners.change(this, FeatureManager.getInstance()); FeatureManager.getInstance().addChangeListener(weakL); }
Example 14
Source File: BridgingServerInstance.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Lookup getLookup() { // FIXME why is the platform written in such strange way ? J2eePlatform platform = Deployment.getDefault().getJ2eePlatform(instance.getUrl()); if (platform == null) { // can happen when J2EE is activated and J2SE is not !?@# return Lookups.singleton(instance.getInstanceProperties()); } else { return new ProxyLookup(Lookups.fixed(platform, instance.getInstanceProperties()), Lookups.proxy(platform)); } }
Example 15
Source File: NavigatorController.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of NavigatorController */ public NavigatorController(NavigatorDisplayer navigatorTC) { this.navigatorTC = navigatorTC; clientsLookup = new ClientsLookup(); panelLookup = Lookups.proxy(new PanelLookupWrapper()); panelLookupWithNodes = new PanelLookupWithNodes(); panelLookupListener = new PanelLookupListener(); navigatorTC.addPropertyChangeListener(this); //Add listener on custom topComponent - NavDisplayer navigatorTC doesnt have to be an instance of TopComponent if (navigatorTC != navigatorTC.getTopComponent()) { navigatorTC.getTopComponent().addPropertyChangeListener(this); } TopComponent.getRegistry().addPropertyChangeListener(this); installActions(); }
Example 16
Source File: KnockoutTC.java From netbeans with Apache License 2.0 | 2 votes |
/** * Updates the content of this lookup according to the given panel. * * @param panel new panel to display in {@code KnockoutTC}. */ void setPanel(KnockoutPanel panel) { Lookup lookup = Lookups.proxy(panel.createLookupProvider(getActionMap())); setLookups(lookup); }