Java Examples for org.eclipse.ui.console.actions.TextViewerAction

The following java examples will help you to understand the usage of org.eclipse.ui.console.actions.TextViewerAction. These source code samples are taken from different open source projects.

Example 1
Project: eclipse.platform.debug-master  File: DefaultDetailPane.java View source code
/**
	 * Creates the actions to add to the context menu
	 */
private void createActions() {
    TextViewerAction textAction = new TextViewerAction(fSourceViewer, ISourceViewer.CONTENTASSIST_PROPOSALS);
    textAction.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    textAction.configureAction(DetailMessages.DefaultDetailPane_Co_ntent_Assist_3, IInternalDebugCoreConstants.EMPTY_STRING, IInternalDebugCoreConstants.EMPTY_STRING);
    textAction.setImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_ELCL_CONTENT_ASSIST));
    textAction.setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_CONTENT_ASSIST));
    textAction.setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_DLCL_CONTENT_ASSIST));
    PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDebugHelpContextIds.DETAIL_PANE_CONTENT_ASSIST_ACTION);
    ActionHandler actionHandler = new ActionHandler(textAction);
    IHandlerService handlerService = getViewSite().getService(IHandlerService.class);
    fContentAssistActivation = handlerService.activateHandler(textAction.getActionDefinitionId(), actionHandler);
    setAction(DETAIL_CONTENT_ASSIST_ACTION, textAction);
    textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.SELECT_ALL);
    textAction.configureAction(DetailMessages.DefaultDetailPane_Select__All_5, IInternalDebugCoreConstants.EMPTY_STRING, IInternalDebugCoreConstants.EMPTY_STRING);
    textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDebugHelpContextIds.DETAIL_PANE_SELECT_ALL_ACTION);
    setAction(DETAIL_SELECT_ALL_ACTION, textAction);
    textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.COPY);
    textAction.configureAction(DetailMessages.DefaultDetailPane__Copy_8, IInternalDebugCoreConstants.EMPTY_STRING, IInternalDebugCoreConstants.EMPTY_STRING);
    textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDebugHelpContextIds.DETAIL_PANE_COPY_ACTION);
    setAction(DETAIL_COPY_ACTION, textAction);
    textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.CUT);
    textAction.configureAction(DetailMessages.DefaultDetailPane_Cu_t_11, IInternalDebugCoreConstants.EMPTY_STRING, IInternalDebugCoreConstants.EMPTY_STRING);
    textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDebugHelpContextIds.DETAIL_PANE_CUT_ACTION);
    setAction(DETAIL_CUT_ACTION, textAction);
    textAction = new TextViewerAction(fSourceViewer, ITextOperationTarget.PASTE);
    textAction.configureAction(DetailMessages.DefaultDetailPane__Paste_14, IInternalDebugCoreConstants.EMPTY_STRING, IInternalDebugCoreConstants.EMPTY_STRING);
    textAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(textAction, IDebugHelpContextIds.DETAIL_PANE_PASTE_ACTION);
    setAction(ActionFactory.PASTE.getId(), textAction);
    setSelectionDependantAction(DETAIL_COPY_ACTION);
    setSelectionDependantAction(DETAIL_CUT_ACTION);
    setSelectionDependantAction(DETAIL_PASTE_ACTION);
    // TODO: Still using "old" resource access, find/replace won't work in popup dialogs
    //$NON-NLS-1$
    ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.debug.internal.ui.views.variables.VariablesViewResourceBundleMessages");
    //$NON-NLS-1$
    IAction action = new FindReplaceAction(bundle, "find_replace_action_", getWorkbenchPartSite().getShell(), new FindReplaceTargetWrapper(fSourceViewer.getFindReplaceTarget()));
    action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IDebugHelpContextIds.DETAIL_PANE_FIND_REPLACE_ACTION);
    setAction(DETAIL_FIND_REPLACE_TEXT_ACTION, action);
    updateSelectionDependentActions();
    action = new DetailPaneWordWrapAction(fSourceViewer);
    setAction(DETAIL_WORD_WRAP_ACTION, action);
    action = new DetailPaneMaxLengthAction(fSourceViewer.getControl().getShell());
    setAction(DETAIL_MAX_LENGTH_ACTION, action);
    action = new DetailPaneAssignValueAction(fSourceViewer, getViewSite());
    setAction(DETAIL_ASSIGN_VALUE_ACTION, action);
}
Example 2
Project: modellipse-master  File: PopupXtextEditorHelper.java View source code
private void initializeActions() {
    final List<IHandlerActivation> handlerActivations = Lists.newArrayListWithExpectedSize(3);
    final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
    final Expression expression = new ActiveShellExpression(sourceViewerHandle.getViewer().getControl().getShell());
    diagramShell.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            handlerService.deactivateHandlers(handlerActivations);
        }
    });
    TextViewerAction action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.UNDO);
    action.setText("UNDO");
    fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.REDO);
    action.setText("REDO");
    fGlobalActions.put(ITextEditorActionConstants.REDO, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.CUT);
    action.setText("CUT");
    fGlobalActions.put(ITextEditorActionConstants.CUT, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.COPY);
    action.setText("COPY");
    fGlobalActions.put(ITextEditorActionConstants.COPY, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.PASTE);
    action.setText("PASTE");
    fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ITextOperationTarget.SELECT_ALL);
    action.setText("SELECT_ALL");
    fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
    action = new TextViewerAction(sourceViewerHandle.getViewer(), ISourceViewer.CONTENTASSIST_PROPOSALS);
    action.setText("CONTENTASSIST_PROPOSALS");
    fGlobalActions.put(ITextEditorActionConstants.CONTENT_ASSIST, action);
    fSelectionActions.add(ITextEditorActionConstants.CUT);
    fSelectionActions.add(ITextEditorActionConstants.COPY);
    fSelectionActions.add(ITextEditorActionConstants.PASTE);
    sourceViewerHandle.getViewer().getTextWidget().addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            handlerService.deactivateHandlers(handlerActivations);
        }

        public void focusGained(FocusEvent e) {
            IAction action = fGlobalActions.get(ITextEditorActionConstants.REDO);
            handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO, new ActionHandler(action), expression));
            action = fGlobalActions.get(ITextEditorActionConstants.UNDO);
            handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO, new ActionHandler(action), expression));
            action = fGlobalActions.get(ITextEditorActionConstants.CONTENT_ASSIST);
            handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new ActionHandler(action), expression));
        }
    });
}
Example 3
Project: cdt-tests-runner-master  File: BuildConsolePage.java View source code
protected void createActions() {
    fClearOutputAction = new ClearOutputAction(getViewer());
    fScrollLockAction = new ScrollLockAction(getViewer());
    fScrollLockAction.setChecked(fIsLocked);
    fNextErrorAction = new NextErrorAction(this);
    fPreviousErrorAction = new PreviousErrorAction(this);
    fShowErrorAction = new ShowErrorAction(this);
    fSaveLogAction = new CopyBuildLogAction(this);
    getViewer().setAutoScroll(!fIsLocked);
    // In order for the clipboard actions to accessible via their shortcuts
    // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for
    // each action
    IActionBars actionBars = getSite().getActionBars();
    TextViewerAction action = new TextViewerAction(getViewer(), ITextOperationTarget.COPY);
    action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6, ConsoleMessages.BuildConsolePage_Copy_7, ConsoleMessages.BuildConsolePage_Copy_7);
    action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
    action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
    action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
    action.configureAction(ConsoleMessages.BuildConsolePage_Select__All_Ctrl_A_12, ConsoleMessages.BuildConsolePage_Select_All, ConsoleMessages.BuildConsolePage_Select_All);
    setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action);
    //XXX Still using "old" resource access
    ResourceBundle bundle = ResourceBundle.getBundle(ConsoleMessages.BUNDLE_NAME);
    setGlobalAction(actionBars, ActionFactory.FIND.getId(), new //$NON-NLS-1$
    FindReplaceAction(//$NON-NLS-1$
    bundle, //$NON-NLS-1$
    "find_replace_action_", getConsoleView()));
    action = new TextViewerGotoLineAction(getViewer());
    setGlobalAction(actionBars, ITextEditorActionConstants.GOTO_LINE, action);
    actionBars.updateActionBars();
    fSelectionActions.add(ActionFactory.COPY.getId());
    fSelectionActions.add(ActionFactory.FIND.getId());
}
Example 4
Project: cdt-master  File: BuildConsolePage.java View source code
protected void createActions() {
    fClearOutputAction = new ClearOutputAction(getViewer());
    fScrollLockAction = new ScrollLockAction(getViewer());
    fScrollLockAction.setChecked(fIsLocked);
    fWrapAction = new WrapLinesAction(getViewer());
    fNextErrorAction = new NextErrorAction(this);
    fPreviousErrorAction = new PreviousErrorAction(this);
    fShowErrorAction = new ShowErrorAction(this);
    fSaveLogAction = new CopyBuildLogAction(this);
    getViewer().setAutoScroll(!fIsLocked);
    // In order for the clipboard actions to accessible via their shortcuts
    // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for
    // each action
    IActionBars actionBars = getSite().getActionBars();
    TextViewerAction action = new TextViewerAction(getViewer(), ITextOperationTarget.COPY);
    action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6, ConsoleMessages.BuildConsolePage_Copy_7, ConsoleMessages.BuildConsolePage_Copy_7);
    action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
    action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
    setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
    action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
    action.configureAction(ConsoleMessages.BuildConsolePage_Select__All_Ctrl_A_12, ConsoleMessages.BuildConsolePage_Select_All, ConsoleMessages.BuildConsolePage_Select_All);
    setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action);
    //XXX Still using "old" resource access
    ResourceBundle bundle = ResourceBundle.getBundle(ConsoleMessages.BUNDLE_NAME);
    setGlobalAction(actionBars, ActionFactory.FIND.getId(), new //$NON-NLS-1$
    FindReplaceAction(//$NON-NLS-1$
    bundle, //$NON-NLS-1$
    "find_replace_action_", getConsoleView()));
    action = new TextViewerGotoLineAction(getViewer());
    setGlobalAction(actionBars, ITextEditorActionConstants.GOTO_LINE, action);
    actionBars.updateActionBars();
    fSelectionActions.add(ActionFactory.COPY.getId());
    fSelectionActions.add(ActionFactory.FIND.getId());
}