Java 类javax.swing.text.TextAction 实例源码

项目:incubator-netbeans    文件:Utilities.java   
/**
 * Fetches the text component that currently has focus. It delegates to 
 * TextAction.getFocusedComponent().
 * @return the component
 */
public static JTextComponent getFocusedComponent() {
    /** Fake action for getting the focused component */
    class FocusedComponentAction extends TextAction {

        FocusedComponentAction() {
            super("focused-component"); // NOI18N
        }

        /** adding this method because of protected final getFocusedComponent */
        JTextComponent getFocusedComponent2() {
            return getFocusedComponent();
        }

        public @Override void actionPerformed(ActionEvent evt){}
    }

    if (focusedComponentAction == null) {
        focusedComponentAction = new FocusedComponentAction();
    }

    return ((FocusedComponentAction)focusedComponentAction).getFocusedComponent2();
}
项目:incubator-netbeans    文件:LanguagesEditorKit.java   
protected @Override Action[] createActions() {
    Action[] myActions = new Action[] {
        new BraceCompletionInsertAction (),
        new BraceCompletionDeleteAction (),
        //new IndentAction (),
        new InstantRenameAction(),
        new LanguagesGenerateFoldPopupAction (),
        new org.netbeans.modules.languages.features.ToggleCommentAction(),
        new org.netbeans.modules.languages.features.CodeCommentAction(),
        new org.netbeans.modules.languages.features.CodeUncommentAction()
    };
    return TextAction.augmentList (
        super.createActions (), 
        myActions
    );
}
项目:goworks    文件:GrammarEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    StandardCommenter commenter = new StandardCommenter(LINE_COMMENT_FORMAT, BLOCK_COMMENT_FORMAT);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedCommentAction commentAction = new ExtendedCommentAction(commenter);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedUncommentAction uncommentAction = new ExtendedUncommentAction(commenter);

    Action[] actions = {
        new ToggleLegacyModeAction(),
        new GrammarGoToDeclarationAction(),
    };

    actions = TextAction.augmentList(superActions, actions);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CommentAction) {
            actions[i] = commentAction;
        } else if (actions[i] instanceof UncommentAction) {
            actions[i] = uncommentAction;
        }
    }

    return actions;
}
项目:goworks    文件:StringTemplateEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Commenter commenter = new StandardCommenter(LINE_COMMENT_FORMAT, OUTER_BLOCK_COMMENT_FORMAT, INNER_BLOCK_COMMENT_FORMAT);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedCommentAction commentAction = new ExtendedCommentAction(commenter);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedUncommentAction uncommentAction = new ExtendedUncommentAction(commenter);

    Action[] extraActions = {
    };

    Action[] actions = TextAction.augmentList(superActions, extraActions);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CommentAction) {
            actions[i] = commentAction;
        } else if (actions[i] instanceof UncommentAction) {
            actions[i] = uncommentAction;
        }
    }

    return actions;
}
项目:goworks    文件:GoEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    StandardCommenter commenter = new StandardCommenter(LINE_COMMENT_FORMAT, BLOCK_COMMENT_FORMAT);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedCommentAction commentAction = new ExtendedCommentAction(commenter);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedUncommentAction uncommentAction = new ExtendedUncommentAction(commenter);

    Action[] actions = {
        new GoGoToDeclarationAction(),
    };

    actions = TextAction.augmentList(superActions, actions);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CommentAction) {
            actions[i] = commentAction;
        } else if (actions[i] instanceof UncommentAction) {
            actions[i] = uncommentAction;
        }
    }

    return actions;
}
项目:antlrworks2    文件:GrammarEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    StandardCommenter commenter = new StandardCommenter(LINE_COMMENT_FORMAT, BLOCK_COMMENT_FORMAT);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedCommentAction commentAction = new ExtendedCommentAction(commenter);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedUncommentAction uncommentAction = new ExtendedUncommentAction(commenter);

    Action[] actions = {
        new ToggleLegacyModeAction(),
        new GrammarGoToDeclarationAction(),
    };

    actions = TextAction.augmentList(superActions, actions);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CommentAction) {
            actions[i] = commentAction;
        } else if (actions[i] instanceof UncommentAction) {
            actions[i] = uncommentAction;
        }
    }

    return actions;
}
项目:antlrworks2    文件:StringTemplateEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Commenter commenter = new StandardCommenter(LINE_COMMENT_FORMAT, OUTER_BLOCK_COMMENT_FORMAT, INNER_BLOCK_COMMENT_FORMAT);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedCommentAction commentAction = new ExtendedCommentAction(commenter);
    @SuppressWarnings("LocalVariableHidesMemberVariable")
    ExtendedUncommentAction uncommentAction = new ExtendedUncommentAction(commenter);

    Action[] extraActions = {
    };

    Action[] actions = TextAction.augmentList(superActions, extraActions);
    for (int i = 0; i < actions.length; i++) {
        if (actions[i] instanceof CommentAction) {
            actions[i] = commentAction;
        } else if (actions[i] instanceof UncommentAction) {
            actions[i] = uncommentAction;
        }
    }

    return actions;
}
项目:incubator-netbeans    文件:BaseCaretTest.java   
@Override
protected Action[] getDeclaredActions() {
    Action swa = new TextAction("") {
        @Override
        public void actionPerformed(ActionEvent evt) {
            selectWordCalled = true;
        }
    };
    swa.putValue(Action.NAME, BaseKit.selectWordAction);

    Action[] actions = new Action[] {
        swa
    };
    return TextAction.augmentList(super.createActions(), actions);
}
项目:incubator-netbeans    文件:ExtKit.java   
protected @Override Action[] createActions() {
        ArrayList<Action> actions = new ArrayList<Action>();

        actions.add(new ExtDefaultKeyTypedAction());
// XXX: remove
//        if (!ExtCaret.NO_HIGHLIGHT_BRACE_LAYER) {
//            actions.add(new MatchBraceAction(matchBraceAction, false));
//            actions.add(new MatchBraceAction(selectionMatchBraceAction, true));
//        }
        actions.add(new CommentAction()); // to make ctrl-shift-T in Netbeans55 profile work
        actions.add(new UncommentAction()); // to make ctrl-shift-D in Netbeans55 profile work

        return TextAction.augmentList(super.createActions(), actions.toArray(new Action[actions.size()]));
    }
项目:incubator-netbeans    文件:CslEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();
    Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType);
    ArrayList<Action> actions = new ArrayList<Action>(30);

    actions.add(new GsfDefaultKeyTypedAction());
    actions.add(new GsfInsertBreakAction());
    actions.add(new GsfDeleteCharAction(deletePrevCharAction, false));

    // The php needs to handle special cases of toggle comment. There has to be 
    // registered ToggleBlockCommentAction in PHP that handles these special cases,
    // but the current way, how the actions are registered, doesn't allow to overwrite the action
    // registered here.
    // See issue #204616. This hack can be removed, when issue #204616 will be done.
    if (!mimeType.equals("text/x-php5")) {
        actions.add(new ToggleBlockCommentAction());
    }
    actions.add(new GenerateFoldPopupAction());
    actions.add(new InstantRenameAction());
    actions.add(CslActions.createGoToDeclarationAction());
    actions.add(new GenericGenerateGoToPopupAction());
    actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectNextElementAction, true));
    actions.add(new SelectCodeElementAction(SelectCodeElementAction.selectPreviousElementAction, false));

    if (language == null) {
        LOG.log(Level.WARNING, "Language missing for MIME type {0}", mimeType);
    } else if (language.hasOccurrencesFinder()) {
        actions.add(new GoToMarkOccurrencesAction(false));
        actions.add(new GoToMarkOccurrencesAction(true));
    }

    return TextAction.augmentList(superActions,
        actions.toArray(new Action[actions.size()]));
}
项目:incubator-netbeans    文件:ActionsSearchProvider.java   
private static ActionEvent createActionEvent (Action action) {
    Object evSource = null;
    int evId = ActionEvent.ACTION_PERFORMED;

    // text (editor) actions
    if (action instanceof TextAction) {
        EditorCookie ec = Utilities.actionsGlobalContext().lookup(EditorCookie.class);
        if (ec == null) {
            return null;
        }

        JEditorPane[] editorPanes = ec.getOpenedPanes();
        if (editorPanes == null || editorPanes.length <= 0) {
            return null;
        }
        evSource = editorPanes[0];
    }

    if (evSource == null) {
        evSource = TopComponent.getRegistry().getActivated();
    }
    if (evSource == null) {
        evSource = WindowManager.getDefault().getMainWindow();
    }


    return new ActionEvent(evSource, evId, null);
}
项目:incubator-netbeans    文件:KeymapViewModelTest.java   
private static String getName (Object action) {
    if (action instanceof TextAction)
        return (String) ((TextAction) action).getValue (Action.SHORT_DESCRIPTION);
    if (action instanceof Action)
        return (String) ((Action) action).getValue (Action.NAME);
    return action.toString ();
}
项目:incubator-netbeans    文件:PropertiesKit.java   
@Override
protected Action[] createActions() {
    Action[]  actions = new Action[] {
        new ToggleCommentAction("#"), //NOI18N
    };
    return TextAction.augmentList(super.createActions(), actions);
}
项目:incubator-netbeans    文件:XMLKit.java   
/**
 * Provide XML related actions.
 */
protected @Override Action[] createActions() {
    Action[] actions = new Action[] {
        new XMLCommentAction(),
        new XMLUncommentAction(),
        new ToggleBlockCommentAction(new XmlCommentHandler()),
        new TestAction(),
    };
    return TextAction.augmentList(super.createActions(), actions);
}
项目:incubator-netbeans    文件:HtmlKit.java   
@Override
protected Action[] createActions() {
    Action[] HtmlActions = new Action[]{
        CslActions.createSelectCodeElementAction(true),
        CslActions.createSelectCodeElementAction(false),
        CslActions.createInstantRenameAction(),
        CslActions.createToggleBlockCommentAction(),
        new ExtKit.CommentAction(""), //NOI18N
        new ExtKit.UncommentAction(""), //NOI18N
        CslActions.createGoToMarkOccurrencesAction(false),
        CslActions.createGoToMarkOccurrencesAction(true),
        CslActions.createGoToDeclarationAction()
    };
    return TextAction.augmentList(super.createActions(), HtmlActions);
}
项目:incubator-netbeans    文件:JavaKit.java   
protected Action[] createActions() {
    Action[] javaActions = new Action[] {
                               new JavaDefaultKeyTypedAction(),
                               new PrefixMakerAction(makeGetterAction, "get", getSetIsPrefixes), // NOI18N
                               new PrefixMakerAction(makeSetterAction, "set", getSetIsPrefixes), // NOI18N
                               new PrefixMakerAction(makeIsAction, "is", getSetIsPrefixes), // NOI18N
                               new AbbrevDebugLineAction(),
                           };
    return TextAction.augmentList(super.createActions(), javaActions);
}
项目:incubator-netbeans    文件:NbEditorKit.java   
protected @Override Action[] createActions() {
        Action[] nbEditorActions = new Action[] {
                                       nbUndoActionDef,
                                       nbRedoActionDef,
                                       new GenerateFoldPopupAction(),
                                       new NavigationHistoryBackAction(),
                                       new NavigationHistoryForwardAction(),
//                                       new ToggleToolbarAction(),
//                                       new NbToggleLineNumbersAction(),
                                       new NbGenerateGoToPopupAction(),
                                   };
        return TextAction.augmentList(super.createActions(), nbEditorActions);
    }
项目:goworks    文件:ParserDebuggerEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Action[] actions = {
    };

    actions = TextAction.augmentList(superActions, actions);
    return actions;
}
项目:goworks    文件:LexerDebuggerEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Action[] actions = {
    };

    actions = TextAction.augmentList(superActions, actions);
    return actions;
}
项目:cn1    文件:JFormattedTextFieldTest.java   
public void testGetActions() {
    Action[] actions = tf.getActions();
    Action[] defaultActions = new DefaultEditorKit().getActions();
    assertEquals(defaultActions.length + 2, actions.length);
    Action cancellAction = null;
    Action commitAction = null;
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        String name = (String) action.getValue(Action.NAME);
        if ("notify-field-accept".equals(name)) {
            commitAction = action;
            continue;
        } else if ("reset-field-edit".equals(name)) {
            cancellAction = action;
            continue;
        } else {
            boolean fromDefaultAction = false;
            for (int j = 0; j < defaultActions.length; j++) {
                if (defaultActions[j].equals(action)) {
                    fromDefaultAction = true;
                    break;
                }
            }
            assertTrue(fromDefaultAction);
        }
    }
    assertTrue(cancellAction instanceof TextAction);
    assertTrue(commitAction instanceof TextAction);
    //TODO check commit & cancel actions
}
项目:freeVM    文件:JFormattedTextFieldTest.java   
public void testGetActions() {
    Action[] actions = tf.getActions();
    Action[] defaultActions = new DefaultEditorKit().getActions();
    assertEquals(defaultActions.length + 2, actions.length);
    Action cancellAction = null;
    Action commitAction = null;
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        String name = (String) action.getValue(Action.NAME);
        if ("notify-field-accept".equals(name)) {
            commitAction = action;
            continue;
        } else if ("reset-field-edit".equals(name)) {
            cancellAction = action;
            continue;
        } else {
            boolean fromDefaultAction = false;
            for (int j = 0; j < defaultActions.length; j++) {
                if (defaultActions[j].equals(action)) {
                    fromDefaultAction = true;
                    break;
                }
            }
            assertTrue(fromDefaultAction);
        }
    }
    assertTrue(cancellAction instanceof TextAction);
    assertTrue(commitAction instanceof TextAction);
    //TODO check commit & cancel actions
}
项目:freeVM    文件:JFormattedTextFieldTest.java   
public void testGetActions() {
    Action[] actions = tf.getActions();
    Action[] defaultActions = new DefaultEditorKit().getActions();
    assertEquals(defaultActions.length + 2, actions.length);
    Action cancellAction = null;
    Action commitAction = null;
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        String name = (String) action.getValue(Action.NAME);
        if ("notify-field-accept".equals(name)) {
            commitAction = action;
            continue;
        } else if ("reset-field-edit".equals(name)) {
            cancellAction = action;
            continue;
        } else {
            boolean fromDefaultAction = false;
            for (int j = 0; j < defaultActions.length; j++) {
                if (defaultActions[j].equals(action)) {
                    fromDefaultAction = true;
                    break;
                }
            }
            assertTrue(fromDefaultAction);
        }
    }
    assertTrue(cancellAction instanceof TextAction);
    assertTrue(commitAction instanceof TextAction);
    //TODO check commit & cancel actions
}
项目:antlrworks2    文件:ParserDebuggerEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Action[] actions = {
    };

    actions = TextAction.augmentList(superActions, actions);
    return actions;
}
项目:antlrworks2    文件:LexerDebuggerEditorKit.java   
@Override
protected Action[] createActions() {
    Action[] superActions = super.createActions();

    Action[] actions = {
    };

    actions = TextAction.augmentList(superActions, actions);
    return actions;
}
项目:incubator-netbeans    文件:HTMLKit.java   
protected Action[] createActions() {
    Action[] HTMLActions = new Action[] {
                               new HTMLShiftBreakAction()
                           };
    return TextAction.augmentList(super.createActions(), HTMLActions);
}
项目:j2se_for_android    文件:JTextField.java   
public Action[] getActions() {
    return TextAction.augmentList(super.getActions(), defaultActions);
}
项目:First-Fruits    文件:OfferingReportDialog.java   
private void initComponents()
{
    setLayout(new BorderLayout());

    final List<Image> icons = new ArrayList<Image>();
    icons.add(new ImageIcon(OfferingReportDialog.class.getResource("/icons/offering16.png")).getImage());
    setIconImages(icons);
    setModalityType(ModalityType.MODELESS);
    setTitle("Offering Report");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    offeringPanel = new OfferingPanel();
    add(offeringPanel, BorderLayout.CENTER);

    final JPanel buttonPanel = new JPanel();

    printButton = new JButton(new TextAction("Print"){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            printReport();
        }
    });
    buttonPanel.add(printButton);

    saveButton = new JButton(new TextAction("Save"){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                chooseOutputFile();
                if (outputFile != null) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    saveReport();
                    setCursor(Cursor.getDefaultCursor());
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(OfferingReportDialog.this, "Error occurred while running report: " + e.getMessage(), "Run Report Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    saveButton.setDefaultCapable(true);

    buttonPanel.add(saveButton);

    final JButton closeButton = new JButton(new TextAction("Close"){
        @Override
        public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
            dispose();
        }
    });
    buttonPanel.add(closeButton);
    add(buttonPanel, BorderLayout.SOUTH);
    setResizable(false);
    invalidate();
    pack();
}
项目:powertext    文件:RSyntaxTextAreaEditorKit.java   
/**
 * Fetches the set of commands that can be used
 * on a text component that is using a model and
 * view produced by this kit.
 *
 * @return the command list
 */
@Override
public Action[] getActions() {
    return TextAction.augmentList(super.getActions(),
                        RSyntaxTextAreaEditorKit.defaultActions);
}
项目:j2se_for_android    文件:JFormattedTextField.java   
/**
 * Fetches the command list for the editor. This is the list of commands
 * supported by the plugged-in UI augmented by the collection of commands
 * that the editor itself supports. These are useful for binding to events,
 * such as in a keymap.
 * 
 * @return the command list
 */
public Action[] getActions() {
    return TextAction.augmentList(super.getActions(), defaultActions);
}
项目:javify    文件:HTMLEditorKit.java   
/**
 * Gets the action list. This list is supported by the superclass
 * augmented by the collection of actions defined locally for style
 * operations.
 *
 * @return an array of all the actions
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), defaultActions);
}
项目:javify    文件:JTextField.java   
/**
 * Returns the set of Actions that are commands for the editor.
 * This is the actions supported by this editor plus the actions
 * of the UI (returned by JTextComponent.getActions()).
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), actions);
}
项目:jvm-stm    文件:HTMLEditorKit.java   
/**
 * Gets the action list. This list is supported by the superclass
 * augmented by the collection of actions defined locally for style
 * operations.
 * 
 * @return an array of all the actions
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), defaultActions);
}
项目:jvm-stm    文件:JTextField.java   
/**
 * Returns the set of Actions that are commands for the editor.
 * This is the actions supported by this editor plus the actions
 * of the UI (returned by JTextComponent.getActions()).
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), actions);
}
项目:seaglass    文件:MacEditorKit.java   
/**
 * Create this action with the appropriate identifier.
 *
 * @param name           DOCUMENT ME!
 * @param verticalAction DOCUMENT ME!
 * @param beginEndAction DOCUMENT ME!
 */
VerticalAction(String name, TextAction verticalAction, TextAction beginEndAction) {
    super(name);
    this.verticalAction = verticalAction;
    this.beginEndAction = beginEndAction;
}
项目:jdk7-jdk    文件:Notepad.java   
/**
 * Fetch the list of actions supported by this
 * editor.  It is implemented to return the list
 * of actions supported by the embedded JTextComponent
 * augmented with the actions defined locally.
 */
public Action[] getActions() {
    return TextAction.augmentList(editor.getActions(), defaultActions);
}
项目:openjdk-source-code-learn    文件:Notepad.java   
/**
 * Fetch the list of actions supported by this
 * editor.  It is implemented to return the list
 * of actions supported by the embedded JTextComponent
 * augmented with the actions defined locally.
 */
public Action[] getActions() {
    return TextAction.augmentList(editor.getActions(), defaultActions);
}
项目:JamVM-PH    文件:HTMLEditorKit.java   
/**
 * Gets the action list. This list is supported by the superclass
 * augmented by the collection of actions defined locally for style
 * operations.
 * 
 * @return an array of all the actions
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), defaultActions);
}
项目:JamVM-PH    文件:JTextField.java   
/**
 * Returns the set of Actions that are commands for the editor.
 * This is the actions supported by this editor plus the actions
 * of the UI (returned by JTextComponent.getActions()).
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), actions);
}
项目:jif    文件:JifEditorKit.java   
/**
 * Fetches the command list for the editor. This is the list of commands
 * supported by the superclass augmented by the collection of commands
 * defined locally for Jif text editor operations.
 * 
 * @return the command list
 */
@Override
public Action[] getActions() {
    return TextAction.augmentList(super.getActions(), JifActions);
}
项目:classpath    文件:HTMLEditorKit.java   
/**
 * Gets the action list. This list is supported by the superclass
 * augmented by the collection of actions defined locally for style
 * operations.
 *
 * @return an array of all the actions
 */
public Action[] getActions()
{
  return TextAction.augmentList(super.getActions(), defaultActions);
}