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


Java Action类代码示例

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


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

示例1: getActions

import javax.swing.Action; //导入依赖的package包/类
@NbBundle.Messages({
    "CTL_Action.ViewCurrent.name=View Current"
})
Action[] getActions () {
    List<Action> actions = new ArrayList<Action>();
    boolean viewEnabled = getFile() != null && getChangedPath().getAction() != HgLogMessage.HgDelStatus;
    if (getFile() != null) {
        actions.add(new AbstractAction(NbBundle.getMessage(RepositoryRevision.class, "CTL_SummaryView_RollbackTo", getLogInfoHeader().getLog().getRevisionNumber())) { // NOI18N
            @Override
            public void actionPerformed(ActionEvent e) {
                revertModifications();
            }                
        });
    }
    if (viewEnabled) {
        actions.add(new AbstractAction(NbBundle.getMessage(RepositoryRevision.class, "CTL_SummaryView_View")) { //NOI18N
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:RepositoryRevision.java

示例2: getValue

import javax.swing.Action; //导入依赖的package包/类
@Override
public final Object getValue(String key) {
    Action dAction = delegateAction;
    // Delegate whole getValue() if delegateAction already exists
    if (dAction != null && dAction != UNITIALIZED_ACTION) {
        Object value = dAction.getValue(key);
        if (value == null) {
            value = getValueLocal(key);
            if (value != null) {
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("Transfer wrapper action property: key=" + key + ", value=" + value + '\n'); // NOI18N
                }
                dAction.putValue(key, value);
            }
        }
        return value;
    }

    return getValueLocal(key);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractEditorAction.java

示例3: testHistoryEntryEditable

import javax.swing.Action; //导入依赖的package包/类
public void testHistoryEntryEditable() throws IOException {
    MessageEditProviderImpl provider = new MessageEditProviderImpl();
    provider.message = null;
    VCSHistoryProvider.HistoryEntry h = 
            new VCSHistoryProvider.HistoryEntry(
                new File[] {new File("")}, 
                new Date(System.currentTimeMillis()), 
                "msg", 
                "user", 
                "username", 
                "12345", 
                "1234567890", 
                new Action[0], 
                null,
                provider);
    assertTrue(h.canEdit());
    h.setMessage("msg2");
    assertEquals("msg2", provider.message);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:VCSHistoryTest.java

示例4: selectNextColumnAction

import javax.swing.Action; //导入依赖的package包/类
private Action selectNextColumnAction() {
    return new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            ProfilerColumnModel cModel = table._getColumnModel();
            if (table.getRowCount() == 0 || cModel.getVisibleColumnCount() == 0) return;
            
            int column = table.getSelectedColumn();
            if (column == -1) {
                table.selectColumn(cModel.getFirstVisibleColumn(), false);
                table.selectRow(0, true);
            } else {
                int nextColumn = cModel.getNextVisibleColumn(column);
                if (nextColumn > column) table.selectColumn(nextColumn, true);
            }
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProfilerTableActions.java

示例5: getProvider

import javax.swing.Action; //导入依赖的package包/类
public static ShelveChangesActionProvider getProvider () {
    if (ACTION_PROVIDER == null) {
        ACTION_PROVIDER = new ShelveChangesActionProvider() {
            @Override
            public Action getAction () {
                Action a = SystemAction.get(SaveStashAction.class);
                Utils.setAcceleratorBindings("Actions/Git", a); //NOI18N
                return a;
            }

            @Override
            public JComponent[] getUnshelveActions (VCSContext ctx, boolean popup) {
                JComponent[] cont = UnshelveMenu.getInstance().getMenu(ctx, popup);
                if (cont == null) {
                    cont = super.getUnshelveActions(ctx, popup);
                }
                return cont;
            }
            
        };
    }
    return ACTION_PROVIDER;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ShelveChangesAction.java

示例6: testGetLookup

import javax.swing.Action; //导入依赖的package包/类
public void testGetLookup() throws Exception {
    final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
    final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
    MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
    TopComponent tc = callFactory(descs, desc2);
    
    tc.open();
    Object result = tc.getLookup().lookup(MVElem.class);
    assertNotNull(result);
    assertEquals(result, elem2);
    MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
    
    hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
    result = tc.getLookup().lookup(MVElem.class);
    assertNotNull(result);
    assertEquals(result, elem1);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractMultiViewTopComponentTestCase.java

示例7: getActions

import javax.swing.Action; //导入依赖的package包/类
public Action[] getActions(NodeActionsProvider original, Object node) throws UnknownTypeException {
    Action [] actions = original.getActions (node);
    if (node instanceof ObjectVariable) {
        int index;
        for (index = 0; index < actions.length; index++) {
            if (actions[index] == null)
                break;
        }
        Action[] newActions = new Action[actions.length + 1];
        System.arraycopy(actions, 0, newActions, 0, index);
        newActions[index] = MARK_OBJECT_ACTION;
        if (index < actions.length) {
            System.arraycopy(actions, index, newActions, index + 1, actions.length - index);
        }
        actions = newActions;
    }
    return actions;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:LabelVarsFilter.java

示例8: getCustomEditorAction

import javax.swing.Action; //导入依赖的package包/类
Action getCustomEditorAction() {
    if (customEditorAction == null) {
        PropertyModel mdl = null;

        if (modelRef != null) {
            mdl = modelRef.get();
        }

        customEditorAction = new CustomEditorAction(new Invoker(), mdl);

        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_DOWN_MASK, false), "invokeCustomEditor"
        ); //NOI18N

        //XXX this could be done lazily
        getActionMap().put("invokeCustomEditor", customEditorAction); //NOI18N

        //            System.err.println("Installed custom editor action");
    }

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

示例9: testListenerGCedAfterActionGCed

import javax.swing.Action; //导入依赖的package包/类
@RandomlyFails
public void testListenerGCedAfterActionGCed () throws Exception {
    InstanceContent ic = new InstanceContent();
    lkp = new AbstractLookup(ic);
    Lookup.Result<Integer> lookupResult = lkp.lookupResult(Integer.class);

    Action action = ((ContextAwareAction) Actions.forID("cat", "survive")).createContextAwareInstance(lkp);
    Action fallbackAction = ((GeneralAction.DelegateAction) action).fallback;
    WeakReference<Action> fallbackActionRef = new WeakReference<Action>(fallbackAction);
    WeakReference<Action> clone = new WeakReference<Action>(action);
    cm = ContextManager.findManager(lkp, true);
    WeakReference lsetRef = new WeakReference<Object>(cm.findLSet(Integer.class));

    // both delegate and delegating actions are GCed before WeakListenerSupport is triggered in ActiveRefQueue:
    // fallbackAction.removePropertyChangeListener(delegating.weakL);
    fallbackAction = null;
    action = null;
    assertGC("Action should be GCed", clone);

    assertGC("Fallback action should be GCed", fallbackActionRef);
    assertGC("Action LSet Should be GCed", lsetRef);
    lookupResult.allInstances();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ContextManagerTest.java

示例10: initializeRegistry

import javax.swing.Action; //导入依赖的package包/类
protected void initializeRegistry() {
    DefaultLanguageConfig defaultLanguage = getPreferredLanguage();
    if (defaultLanguage == null) {
        fail("If you don't implement getPreferredLanguage(), you must override initializeRegistry!");
        return;
    }
    if (!LanguageRegistry.getInstance().isSupported(getPreferredMimeType())) {
        List<Action> actions = Collections.emptyList();
        org.netbeans.modules.csl.core.Language dl = new org.netbeans.modules.csl.core.Language(
                "unknown", getPreferredMimeType(), actions,
                defaultLanguage, getCodeCompleter(),
                getRenameHandler(), defaultLanguage.getDeclarationFinder(),
                defaultLanguage.getFormatter(), getKeystrokeHandler(),
                getIndexerFactory(), getStructureScanner(), null,
                defaultLanguage.isUsingCustomEditorKit());
        List<org.netbeans.modules.csl.core.Language> languages = new ArrayList<org.netbeans.modules.csl.core.Language>();
        languages.add(dl);
        CslCorePackageAccessor.get().languageRegistryAddLanguages(languages);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CslTestBase.java

示例11: getDelegateAction

import javax.swing.Action; //导入依赖的package包/类
Action getDelegateAction() {
    Action result = null;
    synchronized (this) {
        result = delegateAction;
        if (result == null || !result.isEnabled()) {
            if (attached()) {
                result = updateDelegateAction();
            } else {
                result = findEnabledAction();
            }
        }
    }
    if (result == null) {
        result = actions[0];
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MergeAction.java

示例12: buildPopup

import javax.swing.Action; //导入依赖的package包/类
@Override
public JPopupMenu buildPopup(int row) {
  final JPopupMenu m = new JPopupMenu();
  final Action playAction = new Player.LaunchAction(ModuleManagerWindow.this, file);
  playAction.setEnabled(!Info.isModuleTooNew(metadata.getVassalVersion()));
  m.add(playAction);
  final Action editAction = new Editor.ListLaunchAction(ModuleManagerWindow.this, file);
  editAction.setEnabled(!Info.isModuleTooNew(metadata.getVassalVersion()));
  m.add(editAction);
  m.add(new AbstractAction(Resources.getString("General.remove")) {
    private static final long serialVersionUID = 1L;

    public void actionPerformed(ActionEvent e) {
      removeModule(file);
      cleanupTileCache();
    }
  });

  m.addSeparator();
  m.add(addFolderAction);
  m.addSeparator();
  m.add(newExtensionAction);
  m.add(addExtensionAction);
  return m;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:ModuleManagerWindow.java

示例13: setSelectedItem

import javax.swing.Action; //导入依赖的package包/类
@Override
public void setSelectedItem(final Object anItem) {
    if (anItem != null) {
        if (anItem.equals(SEPARATOR)) return;
        if (anItem instanceof Action) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    ((Action)anItem).actionPerformed(new ActionEvent(this, 0, "grow")); //NOI18N
                }
            });
            
        } else {
            selected = (T)anItem;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RuntimeComboBox.java

示例14: 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

示例15: testHideWhenDisabled

import javax.swing.Action; //导入依赖的package包/类
public void testHideWhenDisabled() throws Exception {
    class NoOpAction extends AbstractAction {
        NoOpAction(String n) {
            super(n);
        }
        public @Override void actionPerformed(ActionEvent e) {}
    }
    Action a = new NoOpAction("a1");
    assertEquals(Collections.singletonList("a1"), popupMenu(a));
    a = new NoOpAction("a2");
    a.setEnabled(false);
    assertEquals(Collections.singletonList("a2[disabled]"), popupMenu(a));
    a = new NoOpAction("a3");
    a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
    assertEquals(Collections.singletonList("a3"), popupMenu(a));
    a = new NoOpAction("a4");
    a.putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
    a.setEnabled(false);
    assertEquals(Collections.emptyList(), popupMenu(a));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultAWTBridgeTest.java


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