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


Java InstanceContent.set方法代码示例

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


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

示例1: testActionsUpdatedWhenActionMapChanges

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

示例2: testCreateCompositeChildren

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
/**
 * Test of createCompositeChildren method, of class org.netbeans.spi.project.ui.support.NodeFactorySupport.
 */
public void testCreateCompositeChildren() throws InterruptedException, InvocationTargetException {
    InstanceContent ic = new InstanceContent();
    final Children dels = new TestDelegates(new AbstractLookup(ic));
    final Node node1 = new AbstractNode(Children.LEAF);
    final Node node2 = new AbstractNode(Children.LEAF);
    final Node node3 = new AbstractNode(Children.LEAF);
    final Node node4 = new AbstractNode(Children.LEAF);
    node1.setName("node1");
    node2.setName("node2");
    node3.setName("node3");
    node4.setName("node4");
    NodeFactory fact1 = new TestNodeFactory(node1);
    NodeFactory fact2 = new TestNodeFactory(node2);
    NodeFactory fact3 = new TestNodeFactory(node3);
    NodeFactory fact4 = new TestNodeFactory(node4);
    List<NodeFactory> col = new ArrayList<NodeFactory>();
    col.add(fact1);
    col.add(fact2);
    ic.set(col, null);

    assertEquals(Arrays.asList(node1, node2), Arrays.asList(dels.getNodes(true)));
    
    col.add(0, fact4);
    col.add(fact3);
    col.remove(fact2);
    ic.set(col, null);
    //#115995, caused by fix for #115128
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            Node[] nds = dels.getNodes();
            assertEquals(nds[0], node4);
            assertEquals(nds[1], node1);
            assertEquals(nds[2], node3);
        }
    });
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:NodeFactorySupportTest.java

示例3: NodeDataLookup

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
/**
 * This private constructor is used by the public constructor
 * so that the InstanceContent can be captured.
 * 
 * @param content the InstanceContent to construct the object with
 */
private NodeDataLookup(InstanceContent content, Lookup lookup) {
    super(content);
    this.content = content;

    if (lookup != null) {
        Collection<? extends Object> objects = lookup.lookupAll(Object.class);
        for (Object obj : objects) {
            dataInstances.add(obj);
        }
        
        content.set(dataInstances, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:NodeDataLookup.java

示例4: testSurviveFocusChangeBehavior

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
public void testSurviveFocusChangeBehavior() throws Exception {
    class MyAction extends AbstractAction {
        public int cntEnabled;
        public int cntPerformed;
        
        @Override
        public boolean isEnabled() {
            cntEnabled++;
            return true;
        }
        
        @Override
        public void actionPerformed(ActionEvent ev) {
            cntPerformed++;
        }
    }
    MyAction myAction = new MyAction();
    
    ActionMap disable = new ActionMap();
    ActionMap enable = new ActionMap();
    
    InstanceContent ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);
    
    ContextAwareAction temp = (ContextAwareAction) Actions.forID("Windows", "my.survival.action");
    Action a = temp.createContextAwareInstance(al);
    
    enable.put(SURVIVE_KEY, myAction);
    
    ic.add(enable);
    assertTrue("MyAction is enabled", a.isEnabled());
    ic.set(Collections.singletonList(disable), null);
    assertTrue("Remains enabled on other component", a.isEnabled());
    ic.remove(disable);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ActionProcessorTest.java

示例5: testContextInstancesAreIndependent

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
public void testContextInstancesAreIndependent() throws Exception {
    System.out.println("testContextInstancesAreIndependent");
    A a = new A();
    assertNull(Utilities.actionsGlobalContext().lookup(String.class)); //sanity check
    InstanceContent ic = new InstanceContent();
    Lookup l = new AbstractLookup(ic);
    Action a3 = a.createContextAwareInstance(l);
    assertFalse(a3.isEnabled());
    PCL pcl = new PCL();
    a3.addPropertyChangeListener(pcl);
    setContent("fuddle");
    a.assertNotPerformed();
    assertTrue(a.isEnabled());
    assertFalse(a3.isEnabled());
    synchronized (a3) {
        //should time out if test is going to pass
        a3.wait(TIMEOUT);
    }
    synchronized (pcl) {
        pcl.wait(TIMEOUT);
    }
    pcl.assertNotFired();
    ic.set(Collections.singleton("boo"), null);
    synchronized (a3) {
        a3.wait(TIMEOUT);
    }
    synchronized (pcl) {
        pcl.wait(TIMEOUT);
    }
    pcl.assertEnabledChangedTo(true);
    clearContent();
    assertTrue(a3.isEnabled());
    assertFalse(a.isEnabled());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ContextActionTest.java

示例6: add

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
static void add(String mimePath, Object... instances) {
    InstanceContent content = new InstanceContent();
    content.set(Arrays.asList(instances), null);
    Lookup lkp = new AbstractLookup(content);
    mime2Lookup.put(MimePath.get(mimePath), lkp);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:JavaViewHierarchyRandomTest.java

示例7: MyLookup

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
private MyLookup(MimePath mimePath, String profile, InstanceContent ic) {
    super(ic);

    this.mimePath = mimePath;
    
    if (profile == null) {
        // Use the selected current profile
        String currentProfile = EditorSettings.getDefault().getCurrentFontColorProfile();
        this.fcsProfile = FontColorSettingsImpl.get(mimePath).getInternalFontColorProfile(currentProfile);
        this.specialFcsProfile = false;
    } else {
        // This is the special test profile derived from the mime path.
        // It will never change.
        this.fcsProfile = profile;
        this.specialFcsProfile = true;
    }
    
    this.ic = ic;
    
    // Start listening
    EditorSettings es = EditorSettings.getDefault();
    es.addPropertyChangeListener(WeakListeners.propertyChange(this, es));
    
    this.kbsi = KeyBindingSettingsImpl.get(mimePath);
    this.kbsi.addPropertyChangeListener(WeakListeners.propertyChange(this, this.kbsi));

    // in fact this could probably be turned into 'assert preferences == null;'
    if (preferences == null) {
        preferences = PreferencesImpl.get(mimePath);
        preferences.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, preferences));
    }

    fontColorSettings = new CompositeFCS(mimePath, fcsProfile, preferences);
    keyBindingSettings = this.kbsi.createInstanceForLookup();

    ic.set(Arrays.asList(new Object [] {
        fontColorSettings,
        keyBindingSettings,
        preferences
    }), null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:SettingsProvider.java

示例8: testComponentChangeActionMapIsPropagatedToGlobalLookup

import org.openide.util.lookup.InstanceContent; //导入方法依赖的package包/类
public void testComponentChangeActionMapIsPropagatedToGlobalLookup() throws Exception {
    assertEquals("test1", 0, cnt);

    
    InstanceContent ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);
    tc = new TopComponent (al);

    assertEquals("test2", 0, cnt);
    
    
    ActionMap myMap = new ActionMap();
    myMap.put (KEY, sampleAction);
    assertEquals("test3", 0, cnt);

    tc.requestActive();
    
    assertEquals("test4", 1, cnt);
    
    result = lookup.lookup (new Lookup.Template<ActionMap> (ActionMap.class));
    result.addLookupListener (this);
    result.allItems();
    
    assertEquals("test5", 1, cnt);
    
    ic.set(Collections.singleton(new ActionMap()), null);
    
    assertEquals("One change in ActiomMap delivered", 2, cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:GlobalContextImplTest.java


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