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


Java AbstractLookup类代码示例

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


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

示例1: testLkpChanges

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testLkpChanges() {
    final CompilerOptionsQueryImpl impl1 = new CompilerOptionsQueryImpl();
    final CompilerOptionsQueryImpl impl2 = new CompilerOptionsQueryImpl();
    impl1.addRoot(root1).addArgs("a1", "a2");   //NOI18N
    impl2.addRoot(root1).addArgs("b1", "b2");   //NOI18N

    final InstanceContent ic = new InstanceContent();
    final Lookup baseLkp = new AbstractLookup(ic);
    final CompilerOptionsQueryImplementation merged =
            LookupMergerSupport.createCompilerOptionsQueryMerger()
            .merge(baseLkp);
    assertNull(merged.getOptions(root1));
    ic.add(impl1);
    final CompilerOptionsQueryImplementation.Result res = merged.getOptions(root1);
    assertEquals(
            Arrays.asList("a1","a2"), //NOI18N
            res.getArguments());
    ic.add(impl2);
    assertEquals(
            Arrays.asList("a1","a2","b1","b2"), //NOI18N
            res.getArguments());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CompilerOptionsQueryMergerTest.java

示例2: FilterNode

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        @Override
        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);
    
    setShortDescription("Double-click to open filter");
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:26,代码来源:FilterNode.java

示例3: testLookupInitializedForCloneable

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testLookupInitializedForCloneable() {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(10);

    CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
    assertEquals("10 now", Integer.valueOf(10), cmv.getLookup().lookup(Integer.class));
    
    assertNotNull("MultiViewComponent created", cmv);
    TopComponent mvc = cmv.cloneTopComponent();
    
    assertNotNull("MultiViewComponent cloned", mvc);
    MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
    assertNotNull("Handler found", handler);
    
    assertEquals("10 now", Integer.valueOf(10), mvc.getLookup().lookup(Integer.class));
    ic.remove(10);
    ic.add(1);
    assertEquals("1 now", Integer.valueOf(1), mvc.getLookup().lookup(Integer.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MultiViewProcessorTest.java

示例4: testContextAction

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testContextAction() throws Exception {
    Context.cnt = 0;
    
    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testInjectContext.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is context aware action", obj instanceof ContextAwareAction);
    ContextAwareAction a = (ContextAwareAction)obj;

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = a.createContextAwareInstance(lkp);
    ic.add(10);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(10);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ContextActionInjectTest.java

示例5: testActionsUpdatedWhenActionMapChanges

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testActionsUpdatedWhenActionMapChanges() throws Exception {
    ContextAwareAction a = Actions.callback("ahoj", null, true, "Ahoj!", "no/icon.png", true);
    final InstanceContent ic = new InstanceContent();
    Lookup lkp = new AbstractLookup(ic);

    ActionMap a1 = new ActionMap();
    ActionMap a2 = new ActionMap();
    a2.put("ahoj", new Enabled());

    ic.add(a1);
    Action clone = a.createContextAwareInstance(lkp);
    class L implements PropertyChangeListener {
        int cnt;
        public void propertyChange(PropertyChangeEvent evt) {
            cnt++;
        }
    }
    L listener = new L();
    clone.addPropertyChangeListener(listener);
    assertFalse("Not enabled", isEnabled(clone));

    ic.set(Collections.singleton(a2), null);

    assertTrue("Enabled now", isEnabled(clone));
    assertEquals("one change", 1, listener.cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:GlobalManagerTest.java

示例6: testRenameAction

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testRenameAction() throws InterruptedException, InvocationTargetException, IOException {
    DataObject testdo = DataObject.find(f);
    final Node node = testdo.getNodeDelegate();
    
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(node);
    final Action rename = RefactoringActionsFactory.renameAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (rename.isEnabled()) {
                rename.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((RenameRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("Rename dialog was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ActionInvocationTest.java

示例7: testMoveAction

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testMoveAction() throws InterruptedException, InvocationTargetException, DataObjectNotFoundException, IOException {
    DataObject testdo = DataObject.find(f);
    final Node node = testdo.getNodeDelegate();

    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(node);
    final Action move = RefactoringActionsFactory.moveAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (move.isEnabled()) {
                move.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((MoveRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("MoveClass was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ActionInvocationTest.java

示例8: testChangeOfDefaultLookupAppliedToRPTask

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public void testChangeOfDefaultLookupAppliedToRPTask() throws Exception {
    Lookup prev = Lookup.getDefault();
    final Lookup my = new AbstractLookup(new InstanceContent());
    final Thread myThread = Thread.currentThread();
    final RequestProcessor.Task[] task = { null };
    final boolean[] ok = { false };
    
    Lookups.executeWith(my, new Runnable() {
        @Override
        public void run() {
            assertSame("Default lookup has been changed", my, Lookup.getDefault());

            if (task[0] == null) {
                assertSame("We are being executed in the same thread", myThread, Thread.currentThread());
                // once again in the RP
                task[0] = RequestProcessor.getDefault().post(this, 500);
            } else {
                ok[0] = true;
            }
        }
    });
    assertNotNull("In my lookup code executed OK", task[0]);
    assertEquals("Current lookup back to normal", prev, Lookup.getDefault());
    task[0].waitFinished();
    assertTrue("Even RP task had the right lookup", ok[0]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:RequestProcessorLookupGetDefaultTest.java

示例9: setUp

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    MockServices.setServices(DD.class);


    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());

    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ExternalChangeOfModifiedContentTest.java

示例10: setUp

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
@Override
protected void setUp () throws Exception {
    MockServices.setServices(DD.class);
    
    
    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());
    
    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ExternalDeleteOfModifiedContentTest.java

示例11: MVMapElement

import org.openide.util.lookup.AbstractLookup; //导入依赖的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

示例12: FilterNode

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        @Override
        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);

    setShortDescription("Double-click to open filter");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:FilterNode.java

示例13: handleRename

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
@Override
public void handleRename(Node node, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(node);
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    Lookup l = new AbstractLookup(ic);
    DataObject dob = node.getCookie(DataObject.class);
    Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
    if (Boolean.TRUE.equals(a.getValue("applicable"))) {//NOI18N
        a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
    } else {
        try {
            dob.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RenameHandlerImpl.java

示例14: GraphNode

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
private GraphNode(InputGraph graph, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.graph = graph;
    this.setDisplayName(graph.getName());
    content.add(graph);

    final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);

    if (viewer != null) {
        // Action for opening the graph
        content.add(new GraphOpenCookie(viewer, graph));
    }

    // Action for removing a graph
    content.add(new GraphRemoveCookie(graph));

    // Action for diffing to the current graph
    content.add(new DiffGraphCookie(graph));

    // Action for cloning to the current graph
    content.add(new GraphCloneCookie(viewer, graph));
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:23,代码来源:GraphNode.java

示例15: getWebPageMimeType

import org.openide.util.lookup.AbstractLookup; //导入依赖的package包/类
public static String getWebPageMimeType(SyntaxAnalyzerResult result) {
    InstanceContent ic = new InstanceContent();
    ic.add(result);
    WebPageMetadata wpmeta = WebPageMetadata.getMetadata(new AbstractLookup(ic));

    if (wpmeta != null) {
        //get an artificial mimetype for the web page, this doesn't have to be equal
        //to the fileObjects mimetype.
        String mimeType = (String) wpmeta.value(WebPageMetadata.MIMETYPE);
        if (mimeType != null) {
            return mimeType;
        }
    }

    FileObject fo = result.getSource().getSourceFileObject();
    if(fo != null) {
        return fo.getMIMEType();
    } else {
        //no fileobject?
        return result.getSource().getSnapshot().getMimeType();
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:Utils.java


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