Java 类org.openide.util.lookup.ProxyLookup 实例源码

项目:incubator-netbeans    文件:PackageRootNode.java   
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");
}
项目:incubator-netbeans    文件:TestBase.java   
@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();
        }
    });
}
项目:incubator-netbeans    文件:BasicCustomizer.java   
@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);
    }
}
项目:incubator-netbeans    文件:TestDataDirsNodeFactory.java   
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);
    }
}
项目:incubator-netbeans    文件:LayerDataObject.java   
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)));
}
项目:incubator-netbeans    文件:PaletteItemNode.java   
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);
}
项目:incubator-netbeans    文件:SettingsContextProvider.java   
@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);
}
项目:incubator-netbeans    文件:ContextProvider.java   
@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);
}
项目:incubator-netbeans    文件:ContextProvider.java   
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);
}
项目:incubator-netbeans    文件:DocumentServices.java   
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;
}
项目:incubator-netbeans    文件:TabbedController.java   
@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()]));
    }
}
项目:incubator-netbeans    文件:WebBrowserImpl.java   
/**
 * 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);
    }
}
项目:incubator-netbeans    文件:CacheFolderProvider.java   
@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();
}
项目:Pogamut3    文件:MVMapElement.java   
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));
}
项目:sdk    文件:MatDefDataObject.java   
@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);
            }
        }
    });

}
项目:BART    文件:EGTaskDataObjectDataObject.java   
@Override
protected Node createNodeDelegate() {
    return new DataNode(this, 
                        Children.create(new RootNodeFactory(this), true),
                        new ProxyLookup(getLookup(),abstractLookup))   {

        @Override
        public String getHtmlDisplayName() {
                    StringBuilder sb = new StringBuilder();
                    sb.append(R.HTML_R_Node);
                    sb.append(EGTaskDataObjectDataObject.this.getPrimaryFile().getName());
                    sb.append(R.HTML_CL_R_Node);
                    return sb.toString();
        }           
    };
}
项目:batmass    文件:FileDescriptorNode.java   
/**
 * Using this constructor you can share InstanceContent of the lookup, used
 * by this Node, with InstanceContent of DataObject lookup.
 * @param dobj
 * @param ic this node's lookup will be a merge of the original
 * {@link DataNode} lookup and this instance content.
 */
private FileDescriptorNode(FileDescriptorDataObject dobj, List<FileNodeInfo> nodeInfos,
        FileTypeResolver fileTypeResolver, Project project, InstanceContent ic) {
    super(dobj, Children.LEAF, new ProxyLookup(dobj.getLookup(), new AbstractLookup(ic)));
    this.fileTypeResolver = fileTypeResolver;
    this.project = new WeakReference<>(project);
    this.nodeInfos = nodeInfos;
    this.ic = ic;
    FileDescriptor desc = dobj.getDescriptor();
    if (desc != null) {
        ic.add(desc);
    }

    // this doesn't work, because the icons come from other modules and their paths are not resolved properly
    //this.setIconBaseWithExtension(fileTypeResolver.getIconPath());

    childFactory = new FileDescriptorNodeChildFactory();
    this.setChildren(Children.create(childFactory, false));
}
项目:ireport-fork    文件:ParameterNode.java   
public ParameterNode(JasperDesign jd, JRDesignParameter parameter, Lookup doLkp)
{
    super (Children.LEAF, new ProxyLookup(doLkp, Lookups.fixed(jd, parameter)));
    this.jd = jd;
    this.parameter = parameter;
    setDisplayName ( parameter.getName());
    super.setName( parameter.getName() );
    if (parameter.isSystemDefined())
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/parameter-16.png");
    }
    else
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/parameter-16.png");
    }

    parameter.getEventSupport().addPropertyChangeListener(this);
}
项目:ireport-fork    文件:VariableNode.java   
public VariableNode(JasperDesign jd, JRDesignVariable variable, Lookup doLkp)
{
    super (Children.LEAF, new ProxyLookup(doLkp, Lookups.fixed(jd, variable)));
    this.jd = jd;
    this.variable = variable;
    setDisplayName ( variable.getName());
    super.setName( variable.getName() );
    if (variable.isSystemDefined())
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/variable-16.png");
    }
    else
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/variable-16.png");
    }

    variable.getEventSupport().addPropertyChangeListener(this);
}
项目:ireport-fork    文件:NullBandNode.java   
public NullBandNode(JasperDesign jd, NullBand band,Lookup doLkp)
{
    super (Children.LEAF, new ProxyLookup( doLkp, Lookups.fixed(jd, band)));
    this.jd = jd;
    this.band = band;
    setDisplayName ( ModelUtils.nameOf(band.getOrigin()));

    if (band.getOrigin().getBandTypeValue() == BandTypeEnum.GROUP_FOOTER)
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/groupfooter-16.png");
    }
    else if (band.getOrigin().getBandTypeValue() == BandTypeEnum.GROUP_HEADER)
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/groupheader-16.png");
    }
    else
    {
        setIconBaseWithExtension("com/jaspersoft/ireport/designer/resources/band-16.png");
    }
}
项目:goworks    文件:PackageRootNode.java   
private PackageRootNode(Project project, SourceGroup group, Children children) {
    super(children, new ProxyLookup(createLookup(group),
        Lookups.fixed(project, SearchInfoDefinitionFactory.createSearchInfoBySubnodes(children))));
    this._group = group;
    this._file = group.getRootFolder();
    this._files = Collections.singleton(_file);
    try {
        FileSystem fs = _file.getFileSystem();
        this._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());
}
项目:netbeans-dlang-plugin    文件:DlangProject.java   
public ProjectNode(Node node, DlangProject project)
                    throws DataObjectNotFoundException {
//                super(node,
//                        new FilterNode.Children(node),
//                        new ProxyLookup(
//                                new Lookup[]{
//                                    Lookups.singleton(project),
//                                    node.getLookup()
//                                }));
                super(node,
                        NodeFactorySupport.createCompositeChildren(
                                project,
                                "Projects/org-dlang-project/Nodes"),
                        // new FilterNode.Children(node),
                        new ProxyLookup(
                                new Lookup[]{
                                    Lookups.singleton(project),
                                    node.getLookup()
                                }));
                this.project = project;
            }
项目:studio    文件:TopComponent.java   
/** Gets lookup which represents context of this component. By default
 * the lookup delegates to result of <code>getActivatedNodes</code>
 * method and result of this component <code>ActionMap</code> delegate.
 *
 * @return a lookup with designates context of this component
 * @see org.openide.util.ContextAwareAction
 * @see org.openide.util.Utilities#actionsToPopup(Action[], Lookup)
 * @since 3.29
 */
public Lookup getLookup() {
    synchronized (defaultLookupLock) {
        Object l = defaultLookupRef.get ();
        if (l instanceof Lookup) {
            return (Lookup)l;
        }

        Lookup lookup = new ProxyLookup(new Lookup[] {
            new DefaultTopComponentLookup (this), // Lookup of activated nodes.
            Lookups.singleton(new DelegateActionMap(this)) // Action map lookup.
        });

        defaultLookupRef = new java.lang.ref.WeakReference (lookup);
        return lookup;
    }
}
项目:gort-public    文件:GortLogicalView.java   
public GortProjectNode(Node node, Children children, GortProject project) 
        throws DataObjectNotFoundException {


    // uses the old implementation of the nodes
    super(node,
            /*
            // another option to create the children for the project
            NodeFactorySupport.createCompositeChildren(
                project, 
                "Projects/org-cmuchimps-gort-modules-gortproject/Nodes"),
                */
            children, // old implementation of the child nodes
            //The projects system wants the project in the Node's lookup.
            //NewAction and friends want the original Node's lookup.
            //Make a merge of both:
            new ProxyLookup(
                Lookups.singleton(project),
                node.getLookup())
            );

    this.project = project;
}
项目:designer    文件:mDNSExplorerTopComponent.java   
public mDNSExplorerTopComponent() {
    initComponents();
    setName(Bundle.CTL_mDNSExplorerTopComponent());
    setToolTipText(Bundle.HINT_mDNSExplorerTopComponent());

    setLayout(new BorderLayout());
    add(new BeanTreeView(), BorderLayout.CENTER);

    try {
        this.manager.setRootContext(new MDnsRootNode());
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }

    ActionMap map = getActionMap();

    associateLookup(new ProxyLookup(
            ExplorerUtils.createLookup(this.manager, map),
            Lookups.singleton(this))); // To allow access to expandNode()
}
项目:JRLib    文件:CalculationFolderNode.java   
private CalculationFolderNode(DataFolder folder, NamedCalculationProvider doProvider, boolean isRoot, InstanceContent ic) {
    super(folder.getNodeDelegate(),
          Children.create(new CFChildren(folder, doProvider), true),
          new ProxyLookup(folder.getLookup(), new AbstractLookup(ic))
    );

    this.folder = folder;
    ic.add(doProvider);
    ic.add(ClipboardUtil.createPasteable(this));

    this.isRoot = isRoot;
    if(!isRoot) {
        ic.add(new FolderDeletable(folder));
        ic.add(ClipboardUtil.createCopiable(folder));
        ic.add(ClipboardUtil.createCutable(folder));
        ic.add(new RenameableFolder());
    }
}
项目:JRLib    文件:DataSourceNode.java   
private DataSourceNode(DataSourceDataObject obj, InstanceContent ic) {
    super(obj, Children.LEAF, 
          new ProxyLookup(obj.getLookup(), new AbstractLookup(ic))
    );

    this.ic = ic;
    ic.add(ClipboardUtil.createCopiable(obj));
    ic.add(ClipboardUtil.createCutable(obj));
    ic.add(new DSRenameable());

    super.setDisplayName(obj.getName());
    if(getLookup().lookup(DataSource.class).getDataType() == DataType.TRIANGLE) {
        super.setIconBaseWithExtension(IMG_TRIANGLE);
    } else {
        super.setIconBaseWithExtension(IMG_VECTOR);
    }
}
项目:JRLib    文件:DataFolderNode.java   
private DataFolderNode(DataFolder folder, NamedDataSourceProvider doProvider, boolean isRoot, InstanceContent ic) {
    super(folder.getNodeDelegate(), 
          Children.create(new DFChildren(folder, doProvider), true),
          new ProxyLookup(folder.getLookup(), new AbstractLookup(ic))
    );
    this.folder = getLookup().lookup(DataFolder.class);
    ic.add(doProvider);
    ic.add(ClipboardUtil.createPasteable(this));

    this.isRoot = isRoot;
    if(!isRoot) {
        ic.add(new FolderDeletable(folder));
        ic.add(ClipboardUtil.createCopiable(folder));
        ic.add(ClipboardUtil.createCutable(folder));
        ic.add(new RenameableFolder());
    }
}
项目:JRLib    文件:DataSourceDataObject.java   
public DataSourceDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(fo, loader);
    registerEditor(MIME_TYPE, IS_MULTIVIEW);
    calculatePath();

    Properties props = DataSourceUtil.loadProperties(fo);
    auditId = DataSourceUtil.getLong(props, PROP_AUDIT_ID, -1);
    provider = DataSourceUtil.createProvider(this, props);
    dataType = DataSourceUtil.getDataType(fo, props);

    for(FileObject entry : provider.getSecondryFiles())
        super.registerEntry(entry);

    ic.add(new DataSourceAuditable());
    ic.add(new DataSourceImpl());
    ic.add(new DataSourceDeletable());
    ic.add(new DataSourceNamedContent());
    lkp = new ProxyLookup(super.getCookieSet().getLookup(), new AbstractLookup(ic));
}
项目:incubator-netbeans    文件:TreeRootNode.java   
private TreeRootNode (Node originalNode, DataFolder folder, SourceGroup g, boolean reduced) {
    super(originalNode, reduced ? Children.create(new ReducedChildren(folder, new GroupDataFilter(g), g), true) : new PackageFilterChildren(originalNode),
        new ProxyLookup(
            originalNode.getLookup(),
            Lookups.singleton(new PathFinder(g, reduced))
            // no need for explicit search info
        ));
    this.g = g;
    g.addPropertyChangeListener(WeakListeners.propertyChange(this, g));
}
项目:incubator-netbeans    文件:PackageViewChildren.java   
public PackageNode( FileObject root, DataFolder dataFolder, boolean empty ) {    
    super( dataFolder.getNodeDelegate(), 
           empty ? Children.LEAF : dataFolder.createNodeChildren( NO_FOLDERS_FILTER ),
           new ProxyLookup(
                Lookups.singleton(new NoFoldersContainer (dataFolder)),
                dataFolder.getNodeDelegate().getLookup(),
                Lookups.singleton(SearchInfoDefinitionFactory.createFlatSearchInfo(
                                          dataFolder.getPrimaryFile()))));
    this.root = root;
    this.dataFolder = dataFolder;
    this.isDefaultPackage = root.equals( dataFolder.getPrimaryFile() );
    this.accRes = new AtomicReference<>();
}
项目:incubator-netbeans    文件:MockMimeLookup.java   
/** You can call it, but it's probably not what you want. */
public @Override Lookup getLookup(MimePath mimePath) {
    synchronized (MAP) {
        List<String> paths = Collections.singletonList(mimePath.getPath());

        try {
            Method m = MimePath.class.getDeclaredMethod("getInheritedPaths", String.class, String.class); //NOI18N
            m.setAccessible(true);
            @SuppressWarnings("unchecked")
            List<String> ret = (List<String>) m.invoke(mimePath, null, null);
            paths = ret;
        } catch (Exception e) {
            throw new IllegalStateException("Can't call org.netbeans.api.editor.mimelookup.MimePath.getInheritedPaths method.", e); //NOI18N
        }

        List<Lookup> lookups = new ArrayList<Lookup>(paths.size());
        for(String path : paths) {
            MimePath mp = MimePath.parse(path);
            Lkp lookup = MAP.get(mp);
            if (lookup == null) {
                lookup = new Lkp();
                MAP.put(mp, lookup);
            }
            lookups.add(lookup);
        }

        return new ProxyLookup(lookups.toArray(new Lookup [lookups.size()]));
    }
}
项目:incubator-netbeans    文件:ActionUtilsTest.java   
private static Lookup context(Node[] sel) {
    Lookup[] delegates = new Lookup[sel.length + 1];
    for (int i = 0; i < sel.length; i++) {
        delegates[i] = sel[i].getLookup();
    }
    delegates[sel.length] = Lookups.fixed((Object[]) sel);
    return new ProxyLookup(delegates);
}
项目:incubator-netbeans    文件:UnitTestLibrariesNode.java   
LibraryDependencyNode(final TestModuleDependency dep,
        String testType,
        final NbModuleProject project, final Node original) {
    super(original, null, new ProxyLookup(new Lookup[] {
        original.getLookup(),
        Lookups.fixed(new Object[] { dep, project, testType })
    }));
    this.dep = dep;
    this.testType = testType;
    this.project = project;
}
项目:incubator-netbeans    文件:LibrariesNode.java   
LibraryDependencyNode(final ModuleDependency dep,
        final NbModuleProject project, final Node original) {
    super(original, null, new ProxyLookup(original.getLookup(), Lookups.fixed(dep, project)));
    this.dep = dep;
    this.project = project;
    setShortDescription(LibrariesNode.createHtmlDescription(dep));
}
项目:incubator-netbeans    文件:DefaultEMLookup.java   
/** Extracts activated nodes from a top component and
 * returns their lookups.
 */
public void updateLookups(Node[] arr) {
    if (arr == null) {
        arr = new Node[0];
    }

    Lookup[] lookups = new Lookup[arr.length];

    Map<Lookup, Lookup.Result> copy;

    synchronized (this) {
        if (attachedTo == null) {
            copy = Collections.<Lookup, Lookup.Result>emptyMap();
        } else {
            copy = new HashMap<Lookup, Lookup.Result>(attachedTo);
        }
    }

    for (int i = 0; i < arr.length; i++) {
        lookups[i] = arr[i].getLookup();

        if (copy != null) {
            // node arr[i] remains there, so do not remove it
            copy.remove(arr[i]);
        }
    }

    for (Iterator<Lookup.Result> it = copy.values().iterator(); it.hasNext();) {
        Lookup.Result res = it.next();
        res.removeLookupListener(listener);
    }

    synchronized (this) {
        attachedTo = null;
    }

    setLookups(new Lookup[] { new NoNodeLookup(new ProxyLookup(lookups), arr), Lookups.fixed((Object[])arr), actionMap, });
}
项目:incubator-netbeans    文件:RootNode.java   
private RootNode( Node originalRoot, InstanceContent content, Lookup lkp ) {
    super( originalRoot, 
            new Children( originalRoot, lkp ),
            new ProxyLookup( new Lookup[] { lkp, new AbstractLookup( content ), originalRoot.getLookup() } ) );
    DataFolder df = (DataFolder)getOriginal().getCookie( DataFolder.class );
    if( null != df ) {
        content.add( new DataFolder.Index( df, this ) );
    }
    content.add( this );
    setDisplayName(Utils.getBundleString("CTL_Component_palette")); // NOI18N
}
项目:incubator-netbeans    文件:CategoryNode.java   
private CategoryNode( Node originalNode, InstanceContent content, Lookup lkp ) {
    super( originalNode, 
           new Children( originalNode, lkp ),
           new ProxyLookup( new Lookup[] { lkp, new AbstractLookup(content), originalNode.getLookup() } ) );

    DataFolder folder = (DataFolder)originalNode.getCookie( DataFolder.class );
    if( null != folder ) {
        content.add( new DataFolder.Index( folder, this ) );
        FileObject fob = folder.getPrimaryFile();
        Object catName = fob.getAttribute( CAT_NAME );
        if (catName instanceof String)
            setDisplayName((String)catName);
    }
    content.add( this );
}
项目:incubator-netbeans    文件:CodeAnalysis.java   
public static void open(WarningDescription wd) {
    Node[] n = TopComponent.getRegistry().getActivatedNodes();
    final Lookup context = n.length > 0 ? n[0].getLookup():Lookup.EMPTY;
    RunAnalysis.showDialogAndRunAnalysis(
            new ProxyLookup(Utilities.actionsGlobalContext(), 
                    context), DialogState.from(wd));
}
项目:incubator-netbeans    文件:PlatformNode.java   
private PlatformNode(PlatformProvider pp, ClassPathSupport cs) {
    super (new PlatformContentChildren (cs), new ProxyLookup(new Lookup[]{
        Lookups.fixed(new PlatformEditable(pp), new JavadocProvider(pp),  new PathFinder()),
                new PlatformFolderLookup(new InstanceContent(), pp)
        }));
    this.pp = pp;
    this.pp.addChangeListener(this);
    setIconBaseWithExtension(PLATFORM_ICON);
}