当前位置: 首页>>代码示例>>Java>>正文


Java Lookup.lookup方法代码示例

本文整理汇总了Java中org.openide.util.Lookup.lookup方法的典型用法代码示例。如果您正苦于以下问题:Java Lookup.lookup方法的具体用法?Java Lookup.lookup怎么用?Java Lookup.lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.util.Lookup的用法示例。


在下文中一共展示了Lookup.lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCategory

import org.openide.util.Lookup; //导入方法依赖的package包/类
public ProjectCustomizer.Category createCategory(Lookup context) {
    Project p = context.lookup(Project.class);
    if (p == null) {
        return null;
    }
    if (WhiteListLookupProvider.getUserSelectableWhiteLists().isEmpty()) {
        return null;
    }
    if (!WhiteListLookupProvider.isWhiteListPanelEnabled(p) && !alwaysShowWhiteListPanel) {
        return null;
    }
    return ProjectCustomizer.Category.create(
            CATEGORY_WHITELIST,
            NbBundle.getMessage(WhiteListCategoryPanel.class, "LBL_CategoryWhitelist"), //NOI18N
            null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:WhiteListCategoryPanel.java

示例2: createContextAwareInstance

import org.openide.util.Lookup; //导入方法依赖的package包/类
@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);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ViewAction.java

示例3: createConfigForDefaultAction

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
    public final RunConfig createConfigForDefaultAction(String actionName, Project project, Lookup lookup) {
        FileObject[] fos = extractFileObjectsfromLookup(lookup);
        @SuppressWarnings("unchecked")
        Map<String, String> replaceMap = lookup.lookup(Map.class);
        if (replaceMap == null) { //#159698
            replaceMap = new HashMap<String, String>();
            Logger.getLogger(AbstractMavenActionsProvider.class.getName()).log(Level.FINE, "Missing replace tokens map when executing maven build. Could lead to problems with execution. See issue #159698 for details.", new Exception()); //NOI18N
        }
        FileObject fo = null;
        if (fos.length > 0) {
            fo = fos[0];
        }
//        if (group != null && MavenSourcesImpl.NAME_TESTSOURCE.equals(group.getName()) &&
//                ActionProvider.COMMAND_RUN_SINGLE.equals(actionName)) {
//            //TODO how to allow running main() in tests?
//            actionName = ActionProvider.COMMAND_TEST_SINGLE;
//        }
//        if (group != null && MavenSourcesImpl.NAME_TESTSOURCE.equals(group.getName()) &&
//                ActionProvider.COMMAND_DEBUG_SINGLE.equals(actionName)) {
//            //TODO how to allow running main() in tests?
//            actionName = ActionProvider.COMMAND_DEBUG_TEST_SINGLE;
//        }
        return mapGoalsToAction(project, actionName, replaceMap, fo, lookup);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AbstractMavenActionsProvider.java

示例4: prepareTemplates

import org.openide.util.Lookup; //导入方法依赖的package包/类
public static List<TemplateItem> prepareTemplates(@NullAllowed Project project, @NonNull Lookup lookup) {
    // check the action context for recommmended/privileged templates..
    PrivilegedTemplates privs = lookup.lookup(PrivilegedTemplates.class);
    final List<TemplateItem> items = new ArrayList<TemplateItem>();
    for (DataObject template : OpenProjectList.getDefault().getTemplatesLRU(project, privs)) {
        Node delegate = template.getNodeDelegate();
        items.add(new TemplateItem(template, delegate.getDisplayName(), ImageUtilities.image2Icon(delegate.getIcon(BeanInfo.ICON_COLOR_16x16))));
    }
    return items;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:OpenProjectList.java

示例5: createXmlMultiViewElement

import org.openide.util.Lookup; //导入方法依赖的package包/类
@MultiViewElement.Registration(
    mimeType=HibernateCfgDataLoader.REQUIRED_MIME,
    iconBase=ICON,
    persistenceType=TopComponent.PERSISTENCE_ONLY_OPENED,
    preferredID=SOURCE_VIEW_ID,
    displayName="#CTL_SourceTabCaption",
    position=2550
)
@NbBundle.Messages("CTL_SourceTabCaption=Source")
public static XmlMultiViewElement createXmlMultiViewElement(Lookup lookup) {
    return new XmlMultiViewElement(lookup.lookup(XmlMultiViewDataObject.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:HibernateCfgDataObject.java

示例6: create

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public List<? extends CodeGenerator> create(Lookup context) {
    ArrayList<CodeGenerator> toRet = new ArrayList<CodeGenerator>();
    POMModel model = context.lookup(POMModel.class);
    JTextComponent component = context.lookup(JTextComponent.class);
    if (model != null) {
        toRet.add(new PluginGenerator(model, component));
    }
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:PluginGenerator.java

示例7: saveDocuments

import org.openide.util.Lookup; //导入方法依赖的package包/类
private void saveDocuments(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveDocuments
    // Add your handling code here:
    Node[] selNodes = explorer.getSelectedNodes();
    if (selNodes.length == 0) {
        return;
    }
    for (int i = 0; i < selNodes.length; i++) {
        TopComponent tc = ((TopComponentNode) selNodes[i]).getTopComponent();
        Lookup l = tc.getLookup();
        SaveCookie sc = (SaveCookie) l.lookup(SaveCookie.class);
        if (sc != null) {
            try {
                sc.save();
            } catch (IOException exc) {
                Logger.getAnonymousLogger().log(Level.WARNING,
                "[WinSys.DocumentsDlg.saveDocuments]" // NOI18N
                + " Warning: Cannot save content of TopComponent: [" // NOI18N
                + WindowManagerImpl.getInstance().getTopComponentDisplayName(tc) + "]" // NOI18N
                + " [" + tc.getClass().getName() + "]", exc); // NOI18N
            }
            //Refresh name of node because TopComponent name is probably changed too
            //('*' is removed)
            ((TopComponentNode) selNodes[i]).refresh();
        }
    }
    jButtonSave.setEnabled(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:DocumentsDlg.java

示例8: configure

import org.openide.util.Lookup; //导入方法依赖的package包/类
public void configure(Lookup configuration) {
    // Handle Profile Class action from editor
    SourceClassInfo classInfo = configuration.lookup(SourceClassInfo.class);
    if (classInfo != null) selectClassForProfiling(classInfo);
    
    // Handle Profile Class action from snapshot
    ClientUtils.SourceCodeSelection sel = configuration.lookup(ClientUtils.SourceCodeSelection.class);
    if (sel != null && Wildcards.ALLWILDCARD.equals(sel.getMethodName())) selectForProfiling(sel);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:ObjectsFeature.java

示例9: canRefactorSingle

import org.openide.util.Lookup; //导入方法依赖的package包/类
/**
 * utility method to perform enable/disable logic for refactoring actions
 * @param lookup
 * @param notOnlyFile action is disabled when the selection is on File
 * @param onlyFromEditor action is enabled only in editor
 * @return 
 */
public static boolean canRefactorSingle(Lookup lookup, boolean notOnlyFile, boolean onlyFromEditor) {
    Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
    if(nodes.size() != 1) {
        return false;
    }
    Node node = nodes.iterator().next();
    TreePathHandle tph = node.getLookup().lookup(TreePathHandle.class);
    if (tph != null) {
        if(JavaRefactoringUtils.isRefactorable(tph.getFileObject())) {
            return !onlyFromEditor || RefactoringUtils.isFromEditor(lookup.lookup(EditorCookie.class));
        } else {
            return false;
        }
    }
    DataObject dObj = node.getLookup().lookup(DataObject.class);
    if(null == dObj) {
        return false;
    }
    FileObject fileObj = dObj.getPrimaryFile();
    if(null == fileObj || !JavaRefactoringUtils.isRefactorable(fileObj)) {
        return false;
    }

    EditorCookie ec = lookup.lookup(EditorCookie.class);
    if (RefactoringUtils.isFromEditor(ec)) {
        return true;
    }
    return !notOnlyFile;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ContextAnalyzer.java

示例10: propertyChange

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
        public void propertyChange(PropertyChangeEvent evt) {
            if(TopComponent.Registry.PROP_TC_OPENED.equals(evt.getPropertyName())) {
                Object obj = evt.getNewValue();
                if(obj instanceof TopComponent) {
                    final TopComponent openedTC = (TopComponent) obj;
                    Lookup lookup = openedTC.getLookup();
                    DataObject openedDataObject = lookup.lookup(DataObject.class);
                    dataObjectFoundInLookup = openedDataObject != null;
//                    if(openedDataObject != null) {
//                        dataObjectOnTCOpen = data == openedDataObject;
//                    } 
//                    else {
//                        Result<DataObject> r = lookup.lookupResult(DataObject.class);
//                        r.addLookupListener(new LookupListener() {
//                            @Override
//                            public void resultChanged(LookupEvent ev) {
//                                Lookup lookup = openedTC.getLookup();
//                                DataObject openedDataObject = lookup.lookup(DataObject.class);
//                                dataObjectAfterTCOpen = data == openedDataObject;
//                            }
//                        });
//                    }
                    this.tc = openedTC;
                }
                opened = true;
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NoMVCLookupTest.java

示例11: getParser

import org.openide.util.Lookup; //导入方法依赖的package包/类
public Parser getParser () {
    synchronized (TaskProcessor.INTERNAL_LOCK) {
        if (parserInitialized) {
            return parser;
        }
    }
    Parser _parser = null;
    Lookup lookup = MimeLookup.getLookup (mimeType);
    ParserFactory parserFactory = lookup.lookup (ParserFactory.class);
    if (parserFactory != null) {
        final Snapshot _snapshot = getSnapshot ();
        final Collection<Snapshot> _tmp = Collections.singleton (_snapshot);
        _parser = parserFactory.createParser (_tmp);
        if (_parser == null) {
            LOG.log(
                Level.INFO,
                "Parser factory: {0} returned null parser for {1}", //NOI18N
                new Object[]{
                    parserFactory,
                    _snapshot
                });
        }
    }

    synchronized (TaskProcessor.INTERNAL_LOCK) {
        if (!parserInitialized) {                                                                                
            parser = _parser;
            if (parser != null) {
                parser.addChangeListener(WeakListeners.change(
                    SourceAccessor.getINSTANCE().getParserEventForward(source),
                    parser));
            }
            parserInitialized = true;
        }
        return parser;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:SourceCache.java

示例12: canReorderCategories

import org.openide.util.Lookup; //导入方法依赖的package包/类
/**
 * @param paletteRoot Lookup of palette's root node.
 * @return True if it is possible to reorder categories by drag and drop operations.
 */
public boolean canReorderCategories( Lookup paletteRoot ) {
    Node rootNode = (Node)paletteRoot.lookup( Node.class );
    if( null != rootNode ) {
        return null != rootNode.getCookie( Index.class );
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DragAndDropHandler.java

示例13: findStandardSettings

import org.openide.util.Lookup; //导入方法依赖的package包/类
private static Standard findStandardSettings(Lookup where) {
    ProjectSettings settings = where.lookup(ProjectSettings.class);
    
    return settings instanceof Standard ? (Standard) settings : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:ProjectCustomizer.java

示例14: getLocationPrefix

import org.openide.util.Lookup; //导入方法依赖的package包/类
/**
 * Returns the file:line prefix for the tooltip
 */
private CharSequence getLocationPrefix() {
    if (locationPrefix == null) {
        final StringBuilder sb = new StringBuilder();
        sb.append(Bundle.property_set_at_prefix());
        Model model = getModel();
        Lookup lookup = model.getLookup();
        FileObject file = lookup.lookup(FileObject.class);
        if (file == null) {
            sb.append(Bundle.property_no_file());
        } else {
            sb.append(file.getNameExt());
        }
        Snapshot snap = lookup.lookup(Snapshot.class);
        final Document doc = lookup.lookup(Document.class);
        if (snap != null && doc != null) {
            PropertyDeclaration decl = getDeclaration();
            int ast_from = decl.getStartOffset();
            if (ast_from != -1) {
                //source element, not virtual which is not persisted yet
                final int doc_from = snap.getOriginalOffset(ast_from);
                if (doc_from != -1) {
                    doc.render(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                int lineOffset = 1 + Utilities.getLineOffset((BaseDocument) doc, doc_from);
                                sb.append(':');
                                sb.append(lineOffset);
                            } catch (BadLocationException ex) {
                                //no-op
                            }
                        }
                    });
                }
            }
        }
        locationPrefix = sb.toString();
    }

    return locationPrefix;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:RuleEditorNode.java

示例15: redirect

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
protected CloneableEditorSupport redirect(Lookup ces) {
    return ces.lookup(CloneableEditorSupport.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:XMLCESTest.java


注:本文中的org.openide.util.Lookup.lookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。