當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。