Search in sources :

Example 41 with IAction

use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method updateInsertModeAction.

private void updateInsertModeAction() {
    // drop out in this case.
    if (getSite() == null)
        return;
    IAction action = getAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE);
    if (action != null) {
        action.setEnabled(!fIsOverwriting);
        action.setChecked(fInsertMode == SMART_INSERT);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction)

Example 42 with IAction

use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method handlePreferenceStoreChanged.

/**
 * Handles a property change event describing a change of the editor's
 * preference store and updates the preference related editor properties.
 * <p>
 * Subclasses may extend.
 * </p>
 *
 * @param event the property change event
 */
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    if (fSourceViewer == null)
        return;
    String property = event.getProperty();
    if (getFontPropertyPreferenceKey().equals(property))
        // There is a separate handler for font preference changes
        return;
    if (PREFERENCE_COLOR_FOREGROUND.equals(property) || PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_BACKGROUND.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
        initializeViewerColors(fSourceViewer);
    } else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) {
        initializeFindScopeColor(fSourceViewer);
    } else if (PREFERENCE_USE_CUSTOM_CARETS.equals(property)) {
        updateCaret();
    } else if (PREFERENCE_WIDE_CARET.equals(property)) {
        updateCaret();
    }
    if (affectsTextPresentation(event))
        fSourceViewer.invalidateTextPresentation();
    if (PREFERENCE_HYPERLINKS_ENABLED.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension6) {
            IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
            int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
            ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
            textViewer6.setHyperlinkDetectors(detectors, stateMask);
        }
        return;
    }
    if (PREFERENCE_HYPERLINK_KEY_MODIFIER.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension6) {
            ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
            IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
            int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
            textViewer6.setHyperlinkDetectors(detectors, stateMask);
        }
        return;
    }
    if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
        String[] difference = StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
        IColumnSupport support = getAdapter(IColumnSupport.class);
        for (int i = 0; i < difference.length; i++) {
            RulerColumnDescriptor desc = RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
            if (desc != null && support.isColumnSupported(desc)) {
                boolean newState = !support.isColumnVisible(desc);
                support.setColumnVisible(desc, newState);
            }
        }
        return;
    }
    if (PREFERENCE_SHOW_WHITESPACE_CHARACTERS.equals(property) || PREFERENCE_SHOW_LEADING_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_TABS.equals(property) || PREFERENCE_SHOW_ENCLOSED_TABS.equals(property) || PREFERENCE_SHOW_TRAILING_TABS.equals(property) || PREFERENCE_SHOW_CARRIAGE_RETURN.equals(property) || PREFERENCE_SHOW_LINE_FEED.equals(property) || PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE.equals(property)) {
        IAction action = getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
        if (action instanceof IUpdate)
            ((IUpdate) action).update();
        return;
    }
    if (PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED.equals(property)) {
        IPreferenceStore store = getPreferenceStore();
        if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED))
            installTextDragAndDrop(getSourceViewer());
        else
            uninstallTextDragAndDrop(getSourceViewer());
        return;
    }
    if (PREFERENCE_HOVER_ENRICH_MODE.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension8) {
            IPreferenceStore store = getPreferenceStore();
            if (store != null) {
                ((ITextViewerExtension8) fSourceViewer).setHoverEnrichMode(convertEnrichModePreference(store.getInt(PREFERENCE_HOVER_ENRICH_MODE)));
            }
        }
        return;
    }
}
Also used : IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) IAction(org.eclipse.jface.action.IAction) ITextViewerExtension6(org.eclipse.jface.text.ITextViewerExtension6) Point(org.eclipse.swt.graphics.Point) RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) ITextViewerExtension8(org.eclipse.jface.text.ITextViewerExtension8) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 43 with IAction

use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method doSetInput.

/**
 * Called directly from <code>setInput</code> and from within a workspace
 * runnable from <code>init</code>, this method does the actual setting
 * of the editor input. Closes the editor if <code>input</code> is
 * <code>null</code>. Disconnects from any previous editor input and its
 * document provider and connects to the new one.
 * <p>
 * Subclasses may extend.
 * </p>
 *
 * @param input the input to be set
 * @exception CoreException if input cannot be connected to the document
 *            provider
 */
protected void doSetInput(IEditorInput input) throws CoreException {
    ISaveablesLifecycleListener listener = getSite().getService(ISaveablesLifecycleListener.class);
    if (listener == null)
        fSavable = null;
    if (input == null) {
        close(isSaveOnCloseNeeded());
        if (fSavable != null) {
            listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_CLOSE, getSaveables(), false));
            fSavable.disconnectEditor();
            fSavable = null;
        }
    } else {
        boolean mustSendLifeCycleEvent = false;
        if (fSavable != null) {
            listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_CLOSE, getSaveables(), false));
            fSavable.disconnectEditor();
            fSavable = null;
            mustSendLifeCycleEvent = true;
        }
        IEditorInput oldInput = getEditorInput();
        if (oldInput != null)
            getDocumentProvider().disconnect(oldInput);
        super.setInput(input);
        updateDocumentProvider(input);
        IDocumentProvider provider = getDocumentProvider();
        if (provider == null) {
            IStatus s = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.Editor_error_no_provider, null);
            throw new CoreException(s);
        }
        provider.connect(input);
        initializeTitle(input);
        if (fSourceViewer != null) {
            initializeSourceViewer(input);
            // Reset the undo context for the undo and redo action handlers
            IAction undoAction = getAction(ITextEditorActionConstants.UNDO);
            IAction redoAction = getAction(ITextEditorActionConstants.REDO);
            boolean areOperationActionHandlersInstalled = undoAction instanceof OperationHistoryActionHandler && redoAction instanceof OperationHistoryActionHandler;
            IUndoContext undoContext = getUndoContext();
            if (undoContext != null && areOperationActionHandlersInstalled) {
                ((OperationHistoryActionHandler) undoAction).setContext(undoContext);
                ((OperationHistoryActionHandler) redoAction).setContext(undoContext);
            } else {
                createUndoRedoActions();
            }
        }
        if (fIsOverwriting)
            toggleOverwriteMode();
        setInsertMode(getLegalInsertModes().get(0));
        updateCaret();
        updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
        if (fSelectionListener != null)
            fSelectionListener.setDocument(getDocumentProvider().getDocument(input));
        IVerticalRuler ruler = getVerticalRuler();
        if (ruler instanceof CompositeRuler)
            updateContributedRulerColumns((CompositeRuler) ruler);
        // Send savable life-cycle if needed.
        if (mustSendLifeCycleEvent && listener != null)
            listener.handleLifecycleEvent(new SaveablesLifecycleEvent(this, SaveablesLifecycleEvent.POST_OPEN, getSaveables(), false));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) OperationHistoryActionHandler(org.eclipse.ui.operations.OperationHistoryActionHandler) IStatus(org.eclipse.core.runtime.IStatus) IAction(org.eclipse.jface.action.IAction) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) ISaveablesLifecycleListener(org.eclipse.ui.ISaveablesLifecycleListener) IUndoContext(org.eclipse.core.commands.operations.IUndoContext) CoreException(org.eclipse.core.runtime.CoreException) IEditorInput(org.eclipse.ui.IEditorInput) SaveablesLifecycleEvent(org.eclipse.ui.SaveablesLifecycleEvent)

Example 44 with IAction

use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method createNavigationActions.

/**
 * Creates action entries for all SWT StyledText actions as defined in
 * <code>org.eclipse.swt.custom.ST</code>. Overwrites and
 * extends the list of these actions afterwards.
 * <p>
 * Subclasses may extend.
 * </p>
 * @since 2.0
 */
protected void createNavigationActions() {
    IAction action;
    StyledText textWidget = fSourceViewer.getTextWidget();
    for (int i = 0; i < ACTION_MAP.length; i++) {
        IdMapEntry entry = ACTION_MAP[i];
        action = new TextNavigationAction(textWidget, entry.getAction());
        action.setActionDefinitionId(entry.getActionId());
        setAction(entry.getActionId(), action);
    }
    // $NON-NLS-1$
    action = new ToggleOverwriteModeAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleOverwriteMode.");
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE);
    setAction(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, action);
    textWidget.setKeyBinding(SWT.INSERT, SWT.NULL);
    action = new ScrollLinesAction(-1);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_UP);
    setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_UP, action);
    action = new ScrollLinesAction(1);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN);
    setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN, action);
    action = new LineEndAction(textWidget, false);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_END);
    setAction(ITextEditorActionDefinitionIds.LINE_END, action);
    action = new LineStartAction(textWidget, false);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_START);
    setAction(ITextEditorActionDefinitionIds.LINE_START, action);
    action = new LineEndAction(textWidget, true);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_END);
    setAction(ITextEditorActionDefinitionIds.SELECT_LINE_END, action);
    action = new LineStartAction(textWidget, true);
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_START);
    setAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, action);
    // to accommodate https://bugs.eclipse.org/bugs/show_bug.cgi?id=51516
    // nullify handling of DELETE key by StyledText
    textWidget.setKeyBinding(SWT.DEL, SWT.NULL);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) Point(org.eclipse.swt.graphics.Point)

Example 45 with IAction

use of org.eclipse.jface.action.IAction in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method createAccessibilityActions.

/**
 * Creates this editor's accessibility actions.
 * @since 2.0
 */
private void createAccessibilityActions() {
    IAction action = new ShowRulerContextMenuAction();
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU);
    setAction(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU, action);
}
Also used : IAction(org.eclipse.jface.action.IAction)

Aggregations

IAction (org.eclipse.jface.action.IAction)406 Action (org.eclipse.jface.action.Action)153 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)54 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 ArrayList (java.util.ArrayList)38 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)37 IMenuManager (org.eclipse.jface.action.IMenuManager)37 IContributionItem (org.eclipse.jface.action.IContributionItem)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)27 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)19 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 IToolBarManager (org.eclipse.jface.action.IToolBarManager)17 Iterator (java.util.Iterator)15 Point (org.eclipse.swt.graphics.Point)15 IEditorPart (org.eclipse.ui.IEditorPart)15 List (java.util.List)14