當前位置: 首頁>>代碼示例>>Java>>正文


Java ProxyLookup類代碼示例

本文整理匯總了Java中org.openide.util.lookup.ProxyLookup的典型用法代碼示例。如果您正苦於以下問題:Java ProxyLookup類的具體用法?Java ProxyLookup怎麽用?Java ProxyLookup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ProxyLookup類屬於org.openide.util.lookup包,在下文中一共展示了ProxyLookup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PackageRootNode

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
private PackageRootNode( SourceGroup group, Children ch) {
    super(ch, new ProxyLookup(createLookup(group), Lookups.singleton(
            SearchInfoDefinitionFactory.createSearchInfoBySubnodes(ch))));
    this.group = group;
    file = group.getRootFolder();
    files = Collections.singleton(file);
    try {
        FileSystem fs = file.getFileSystem();
        fileSystemListener = FileUtil.weakFileStatusListener(this, fs);
        fs.addFileStatusListener(fileSystemListener);
    } catch (FileStateInvalidException e) {            
        Exceptions.printStackTrace(Exceptions.attachMessage(e,"Can not get " + file + " filesystem, ignoring...")); //NOI18N
    }
    setName( group.getName() );
    setDisplayName( group.getDisplayName() );        
    // setIconBase("org/netbeans/modules/java/j2seproject/ui/resources/packageRoot");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:PackageRootNode.java

示例2: setUp

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@Override
public void setUp() throws Exception {
    super.setUp();
   
    clearWorkDir();
    
    DerbyDatabasesTest.SampleDatabaseLocator sdl = new DerbyDatabasesTest.SampleDatabaseLocator();
    sampleDBLookup = new ProxyLookup(Lookup.getDefault(), Lookups.singleton(sdl));
    
    Lookups.executeWith(sampleDBLookup, new Runnable() {
        @Override
        public void run() {
            // Force initialization of JDBCDrivers
            JDBCDriverManager jdm = JDBCDriverManager.getDefault();
            JDBCDriver[] registeredDrivers = jdm.getDrivers();
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:TestBase.java

示例3: showCustomizer

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@Messages({
    "PROGRESS_loading_data=Loading project information",
    "# {0} - project display name", "LBL_CustomizerTitle=Project Properties - {0}"
})
public void showCustomizer(String preselectedCategory, final String preselectedSubCategory) {
    if (dialog != null) {
        dialog.setVisible(true);
    } else {
        final String category = (preselectedCategory != null) ? preselectedCategory : lastSelectedCategory;
        final AtomicReference<Lookup> context = new AtomicReference<Lookup>();
        ProgressUtils.runOffEventDispatchThread(new Runnable() {
            @Override public void run() {
                context.set(new ProxyLookup(prepareData(), Lookups.fixed(new SubCategoryProvider(category, preselectedSubCategory))));
            }
        }, PROGRESS_loading_data(), /* currently unused */new AtomicBoolean(), false);
        if (context.get() == null) { // canceled
            return;
        }
        OptionListener listener = new OptionListener();
        dialog = ProjectCustomizer.createCustomizerDialog(layerPath, context.get(), category, listener, null);
        dialog.addWindowListener(listener);
        dialog.setTitle(LBL_CustomizerTitle(ProjectUtils.getInformation(getProject()).getDisplayName()));
        dialog.setVisible(true);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:BasicCustomizer.java

示例4: node

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
public Node node(final SourceGroup key) {
    try {
        Node nodeDelegate = DataObject.find(key.getRootFolder()).getNodeDelegate();
        return new FilterNode(nodeDelegate,
                null, new ProxyLookup(nodeDelegate.getLookup(), Lookups.singleton(new PathFinder(key)))) {
            @Override
            public String getName() {
                return key.getName();
            }
            @Override
            public String getDisplayName() {
                return key.getDisplayName();
            }
        };
    } catch (DataObjectNotFoundException ex) {
        throw new AssertionError(ex);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:TestDataDirsNodeFactory.java

示例5: LayerDataObject

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
public LayerDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    final Lookup baseLookup = cookies.getLookup();
    lkp = new ProxyLookup(baseLookup) {
        final AtomicBoolean checked = new AtomicBoolean();
        protected @Override void beforeLookup(Template<?> template) {
            if (template.getType() == LayerHandle.class && checked.compareAndSet(false, true)) {
                FileObject xml = getPrimaryFile();
                Project p = FileOwnerQuery.getOwner(xml);
                if (p != null) {
                    setLookups(baseLookup, Lookups.singleton(new LayerHandle(p, xml)));
                }
            }
        }
    };
    registerEditor("text/x-netbeans-layer+xml", true);
    cookies.add(new ValidateXMLSupport(DataObjectAdapters.inputSource(this)));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:LayerDataObject.java

示例6: PaletteItemNode

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
PaletteItemNode(DataNode original, 
                String name, 
                String bundleName, 
                String displayNameKey, 
                String className, 
                String tooltipKey, 
                String icon16URL, 
                String icon32URL, 
                InstanceContent content) 
{
    super(original, Children.LEAF, new ProxyLookup(( new Lookup[] {new AbstractLookup(content), original.getLookup()})));
    
    content.add( this );
    this.name = name;
    this.bundleName = bundleName; 
    this.displayNameKey = displayNameKey;
    this.className = className;
    this.tooltipKey = tooltipKey;
    this.icon16URL = icon16URL;
    this.icon32URL = icon32URL;
    
    this.originalDO = original.getLookup().lookup(DataObject.class);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:PaletteItemNode.java

示例7: runTaskWithinContext

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            SettingsModel model = SettingsModelFactory.getDefault().getModel(ms);
            if (model != null) {
                Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                task.run(newContext);
                return;
            }
        }
    }
    task.run(context);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:SettingsContextProvider.java

示例8: runTaskWithinContext

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            if (ms.isEditable()) {
                POMModel model = POMModelFactory.getDefault().getModel(ms);
                if (model != null) {
                    Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                    task.run(newContext);
                    return;
                }
            }
        }
    }
    task.run(context);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:ContextProvider.java

示例9: runTaskWithinContext

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
public void runTaskWithinContext(final Lookup context, final Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        try {
            JavaSource js = JavaSource.forDocument(component.getDocument());
            if (js != null) {
                final int caretOffset = component.getCaretPosition();
                js.runUserActionTask(new org.netbeans.api.java.source.Task<CompilationController>() {
                    public void run(CompilationController controller) throws Exception {
                        controller.toPhase(JavaSource.Phase.PARSED);
                        TreePath path = controller.getTreeUtilities().pathFor(caretOffset);
                        Lookup newContext = new ProxyLookup(context, Lookups.fixed(controller, path));
                        task.run(newContext);
                    }
                }, true);
                return;
            }
        } catch (IOException ioe) {
        }
    }
    task.run(context);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:ContextProvider.java

示例10: initDocumentFactories

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
private Lookup.Result<DocumentServiceFactory<?>> initDocumentFactories(Class<?> c) {
    List<Lookup> lkps = new ArrayList<Lookup>(5);
    do {
        String cn = c.getCanonicalName();
        if (cn != null) {
            lkps.add(Lookups.forPath("Editors/Documents/" + cn)); // NOI18N
        }
        c = c.getSuperclass();
    } while (c != null && c != java.lang.Object.class);
    Lookup[] arr = lkps.toArray(new Lookup[lkps.size()]);
    @SuppressWarnings("rawtypes")
    Lookup.Result lookupResult = new ProxyLookup(arr).lookupResult(DocumentServiceFactory.class);
    @SuppressWarnings("unchecked")
    Lookup.Result<DocumentServiceFactory<?>> res = (Lookup.Result<DocumentServiceFactory<?>>) lookupResult;
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DocumentServices.java

示例11: getLookup

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@Override
public Lookup getLookup() {
    List<Lookup> lookups = new ArrayList<Lookup>();
    for (OptionsPanelController controller : getControllers()) {
        Lookup lookup = controller.getLookup();
        if (lookup != null && lookup != Lookup.EMPTY) {
            lookups.add(lookup);
        }
        if (lookup == null) {
            LOGGER.log(Level.WARNING, "{0}.getLookup() should never return null. Please, see Bug #194736.", controller.getClass().getName()); // NOI18N
            throw new NullPointerException(controller.getClass().getName() + ".getLookup() should never return null. Please, see Bug #194736."); // NOI18N
        }
    }
    if (lookups.isEmpty()) {
        return Lookup.EMPTY;
    } else {
        return new ProxyLookup(lookups.toArray(new Lookup[lookups.size()]));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TabbedController.java

示例12: initComponentPopupMenu

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
/**
 * Initializes popup-menu of the web-browser component.
 *
 * @param browserComponent component whose popup-menu should be initialized.
 */
private void initComponentPopupMenu(JComponent browserComponent) {
    if (PageInspector.getDefault() != null) {
        // Web-page inspection support is available in the IDE
        // => add a menu item that triggers page inspection.
        String inspectPage = NbBundle.getMessage(WebBrowserImpl.class, "WebBrowserImpl.inspectPage"); // NOI18N
        JPopupMenu menu = new JPopupMenu();
        menu.add(new AbstractAction(inspectPage) {
            @Override
            public void actionPerformed(ActionEvent e) {
                PageInspector inspector = PageInspector.getDefault();
                if (inspector == null) {
                    Logger logger = Logger.getLogger(WebBrowserImpl.class.getName());
                    logger.log(Level.INFO, "No PageInspector found: ignoring the request for page inspection!"); // NOI18N
                } else {
                    inspector.inspectPage(new ProxyLookup(getLookup(), projectContext));
                }
            }
        });
        browserComponent.setComponentPopupMenu(menu);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:WebBrowserImpl.java

示例13: getImpls

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:CacheFolderProvider.java

示例14: MVMapElement

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
MVMapElement(TLDataObject dataObject) {
    // Hack
    if (Beans.isDesignTime()) {
        Beans.setDesignTime(false);
    }
    this.dataObject = dataObject;

    glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(), dataObject.getDatabase());

    slider = new TLSlider(dataObject.getDatabase());

    elementPanel = new JPanel(new BorderLayout());
    elementPanel.add(glPanel, BorderLayout.CENTER);
    elementPanel.add(slider, BorderLayout.PAGE_END);

    ActionMap map = new ActionMap();
    map.put("save", SystemAction.get(SaveAction.class));
    elementPanel.setActionMap(map);

    lookupContent = new InstanceContent();
    lookup = new ProxyLookup(dataObject.getLookup(), new AbstractLookup(lookupContent));
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:23,代碼來源:MVMapElement.java

示例15: MatDefDataObject

import org.openide.util.lookup.ProxyLookup; //導入依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public MatDefDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    registerEditor("text/jme-materialdefinition", true);
    contentLookup = new AbstractLookup(lookupContents);
    lookupContents.add(this);
    lookup = new ProxyLookup(getCookieSet().getLookup(), contentLookup);
    findAssetManager();
    final MatDefMetaData metaData = new MatDefMetaData(this);
    lookupContents.add(metaData);
    pf.addFileChangeListener(new FileChangeAdapter() {
        @Override
        public void fileChanged(FileEvent fe) {
            super.fileChanged(fe);
            metaData.save();
            if (file.isDirty()) {
                file.setLoaded(false);
                file.setDirty(false);
            }
        }
    });

}
 
開發者ID:jMonkeyEngine,項目名稱:sdk,代碼行數:24,代碼來源:MatDefDataObject.java


注:本文中的org.openide.util.lookup.ProxyLookup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。