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


Java Action.actionPerformed方法代码示例

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


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

示例1: handleRename

import javax.swing.Action; //导入方法依赖的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

示例2: invokeDefaultAction

import javax.swing.Action; //导入方法依赖的package包/类
private void invokeDefaultAction (final TopComponent tc) {
    performed = false;
    try {
        Node[] nodes = tc.getActivatedNodes ();
        assertNotNull ("View has the active nodes.", nodes);
        Node n = nodes.length > 0 ? nodes[0] : null;
        assertNotNull ("View has a active node.", n);
        
        final Action action = n.getPreferredAction ();
        action.actionPerformed (new ActionEvent (n, ActionEvent.ACTION_PERFORMED, ""));
        
        // wait to invoke action is propagated
        Thread.sleep (300);
    } catch (Exception x) {
        fail (x.getMessage ());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DefaultActionTest.java

示例3: testContextAction

import javax.swing.Action; //导入方法依赖的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

示例4: actionPerformed

import javax.swing.Action; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt) {
    TextRegionManager manager = textRegionManager(evt);
    if (manager != null) {
        switch (actionType) {
            case TAB:
                manager.tabAction();
                break;
            case SHIFT_TAB:
                manager.shiftTabAction();
                break;
            case ENTER:
                if (!manager.enterAction()) {
                    Action original = (Action)getValue(ORIGINAL_ACTION_PROPERTY);
                    if (original != null)
                        original.actionPerformed(evt);
                }
                break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:TextRegionManager.java

示例5: testMemoryLeak

import javax.swing.Action; //导入方法依赖的package包/类
public void testMemoryLeak() throws Exception {
    final AtomicInteger count = new AtomicInteger();
    Action singleton = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            count.incrementAndGet();
        }
    };
    Object heavy = new Object();
    AlwaysEnabledAction always = AlwaysEnabledAction.create(
        Collections.singletonMap("delegate", singleton)
    );
    Action clone = always.createContextAwareInstance(Lookups.singleton(heavy));
    clone.actionPerformed(null);
    assertEquals(1, count.get());
    Reference<?> r = new WeakReference<Object>(heavy);
    clone = null;
    heavy = null;
    assertGC("should not leak context", r, Collections.singleton(singleton));        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AlwaysEnabledActionTest.java

示例6: testOwnContextAction

import javax.swing.Action; //导入方法依赖的package包/类
public void testOwnContextAction() throws Exception {
    MultiContext.cnt = 0;
    
    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testOwnContext.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is action", obj instanceof Action);
    assertFalse("It is not context aware action: " + obj, obj instanceof ContextAwareAction);
    Action a = (Action)obj;

    InstanceContent ic = contextI;
    ic.add(10);

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

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

示例7: processKeyBinding

import javax.swing.Action; //导入方法依赖的package包/类
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    boolean ret = super.processKeyBinding(ks, e, condition, pressed);

    // XXX #250546 Reason of overriding: to process global shortcut.
    if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) {

        Keymap km = Lookup.getDefault().lookup(Keymap.class);
        Action action = (km != null) ? km.getAction(ks) : null;

        if (action == null) {
            return false;
        }

        if (action instanceof CallbackSystemAction) {
            CallbackSystemAction csAction = (CallbackSystemAction) action;
            if (tabbedPane != null) {
                Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey());
                if (a != null) {
                    a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)));
                    return true;
                }
            }
        }
        return false;
    } else {
        return ret;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CommitPanel.java

示例8: actionPerformed

import javax.swing.Action; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    if (!openCustomEditor(e)) {
        Action a = getActionMap().get(delegateActionBind);
        if (a != null && a.isEnabled()) {
            a.actionPerformed(e);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:OutlineView.java

示例9: testActionWorksOnMultipleSaveCookies

import javax.swing.Action; //导入方法依赖的package包/类
public void testActionWorksOnMultipleSaveCookies() {
    cnt = 0;
    SaveCookie cookie1 = new SaveCookieTestImpl();
    SaveCookie cookie2 = new SaveCookieTestImpl();
    Lookup lkp = Lookups.fixed(cookie1, cookie2);
    SaveAction sa = SaveAction.get(SaveAction.class);
    Action clone = sa.createContextAwareInstance(lkp);
    clone.actionPerformed(new ActionEvent(this, 0, ""));
    assertEquals("Save was called multiple times", 2, cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SaveActionTest.java

示例10: testExecutionOfActionsThatDoesNotDefineAsynchronousIsSynchronousNoWarningIsPrinted

import javax.swing.Action; //导入方法依赖的package包/类
public void testExecutionOfActionsThatDoesNotDefineAsynchronousIsSynchronousNoWarningIsPrinted() throws Exception {
    Action action = (Action)FileUtil.getConfigFile("actions/async/none.instance").getAttribute("instanceCreate");
    
    synchronized (AsynchronousTest.class) {
        action.actionPerformed(new ActionEvent(this, 0, ""));
        assertTrue("The synchronous action is finished immediatelly", AC.finished);
    }
    
    if (err.length() > 0) {
        fail("There should be no warning about missing asynchronous: " + err);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AsynchronousTest.java

示例11: actionPerformed

import javax.swing.Action; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent evt, final JTextComponent target) {
    BaseKit kit = (target == null) ? BaseKit.getKit(BaseKit.class) : Utilities.getKit(target);
    if (kit != null) {
        Action a = kit.getActionByName(delegateId);
        if ((a instanceof BaseAction) && a != this) {
            ((BaseAction)a).actionPerformed(evt, target);
            return;
        } else {
            a.actionPerformed(evt);
            return;
        }
    }
    Toolkit.getDefaultToolkit().beep();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ActionFactory.java

示例12: delegateScrollingKey

import javax.swing.Action; //导入方法依赖的package包/类
private void delegateScrollingKey(KeyEvent ev) {
    final Pair<String,JComponent> p = listActionFor(ev);
    if (p == null) {
        return;
    }
    final String action = p.first();
    final JComponent target = p.second();

    // Wrap around
    if ( "selectNextRow".equals(action) &&
        matchesList.getSelectedIndex() == matchesList.getModel().getSize() -1 ) {
        matchesList.setSelectedIndex(0);
        matchesList.ensureIndexIsVisible(0);
        return;
    }
    else if ( "selectPreviousRow".equals(action) &&
              matchesList.getSelectedIndex() == 0 ) {
        int last = matchesList.getModel().getSize() - 1;
        matchesList.setSelectedIndex(last);
        matchesList.ensureIndexIsVisible(last);
        return;
    }

    // Plain delegation
    final Action a = target.getActionMap().get(action);
    if (a != null) {
        a.actionPerformed(new ActionEvent(target, 0, action));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:GoToPanelImpl.java

示例13: stopExecution

import javax.swing.Action; //导入方法依赖的package包/类
private void stopExecution(ActionEvent e) {
    Action a = pane.getActionMap().get(StopExecutionAction.NAME);
    a.actionPerformed(e);
    /*
    if (session != null) {
        BaseProgressUtils.runOffEventDispatchThread(session::stopExecutingCode, 
                Bundle.LBL_AttemptingStop(), null, false, 100, 2000);
    }
            */
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ConsoleEditor.java

示例14: runCustomActionIfAvailable

import javax.swing.Action; //导入方法依赖的package包/类
boolean runCustomActionIfAvailable(ActionEvent e) {
    if (instance != null) {
        Action custom = instance.getPersistence().getNewJobAction();
        if (custom != null) {
            custom.actionPerformed(e);
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CreateJob.java

示例15: testDisplayNameDiffer

import javax.swing.Action; //导入方法依赖的package包/类
public void testDisplayNameDiffer() throws Exception {
    Action a = readAction("testDisplayNameDiffer.instance");
    assertNull(MyAction.last);
    assertNotNull("Action created", a);
    a.actionPerformed(new ActionEvent(this, 0, ""));
    // Check LOG for warning
    assertEquals("MyNamedAction", a.getValue(Action.NAME)); // Queries the delegate
    assertEquals("MyNamedAction", MyAction.last.getValue(Action.NAME));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AlwaysEnabledActionTest.java


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