Search in sources :

Example 36 with IAction

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

the class DefaultEncodingSupport method createStatusEncodingChangeControl.

/**
 * Creates the control which allows to change the encoding.
 * In case of encoding errors this control will be placed below
 * the status of the status editor.
 *
 * @param parent the parent control
 * @param status the status
 * @since 3.1
 */
public void createStatusEncodingChangeControl(Composite parent, final IStatus status) {
    final IAction action = fTextEditor.getAction(ITextEditorActionConstants.CHANGE_ENCODING);
    if (action instanceof TextEditorAction)
        ((TextEditorAction) action).update();
    if (action == null || !action.isEnabled())
        return;
    Shell shell = parent.getShell();
    Display display = shell.getDisplay();
    Color bgColor = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
    Button button = new Button(parent, SWT.PUSH | SWT.FLAT);
    button.setText(action.getText());
    button.addSelectionListener(new SelectionAdapter() {

        /*
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
			 */
        @Override
        public void widgetSelected(SelectionEvent e) {
            action.run();
        }
    });
    button.setFocus();
    Label filler = new Label(parent, SWT.NONE);
    filler.setLayoutData(new GridData(GridData.FILL_BOTH));
    filler.setBackground(bgColor);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IAction(org.eclipse.jface.action.IAction) Button(org.eclipse.swt.widgets.Button) Color(org.eclipse.swt.graphics.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) TextEditorAction(org.eclipse.ui.texteditor.TextEditorAction) Display(org.eclipse.swt.widgets.Display)

Example 37 with IAction

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

the class TextEditor method handlePreferenceStoreChanged.

@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        ISourceViewer viewer = getSourceViewer();
        if (!(viewer instanceof ISourceViewerExtension2))
            // cannot unconfigure - do nothing
            return;
        // XXX: this is pretty heavy-weight
        ((ISourceViewerExtension2) viewer).unconfigure();
        viewer.configure(getSourceViewerConfiguration());
        if (Boolean.FALSE.equals(event.getNewValue()))
            SpellingProblem.removeAll(getSourceViewer(), null);
        IAction quickAssistAction = getAction(ITextEditorActionConstants.QUICK_ASSIST);
        if (quickAssistAction instanceof IUpdate)
            ((IUpdate) quickAssistAction).update();
        return;
    }
    super.handlePreferenceStoreChanged(event);
}
Also used : IAction(org.eclipse.jface.action.IAction) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IUpdate(org.eclipse.ui.texteditor.IUpdate) ISourceViewerExtension2(org.eclipse.jface.text.source.ISourceViewerExtension2)

Example 38 with IAction

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

the class AbstractTextSearchViewPage method removeFilterActionsFromViewMenu.

private void removeFilterActionsFromViewMenu(IAction[] filterActions) {
    IActionBars bars = getSite().getActionBars();
    IMenuManager menu = bars.getMenuManager();
    if (filterActions != null) {
        for (IAction filterAction : filterActions) {
            menu.remove(filterAction.getId());
        }
    }
    menu.remove(MatchFilterSelectionAction.ACTION_ID);
}
Also used : IAction(org.eclipse.jface.action.IAction) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 39 with IAction

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

the class AbstractTextEditor method editorContextMenuAboutToShow.

/**
 * Sets up this editor's context menu before it is made visible.
 * <p>
 * Subclasses may extend to add other actions.</p>
 *
 * @param menu the menu
 */
protected void editorContextMenuAboutToShow(IMenuManager menu) {
    menu.add(new Separator(ITextEditorActionConstants.GROUP_UNDO));
    menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_SAVE));
    menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY));
    menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT));
    menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
    menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND));
    menu.add(new Separator(IWorkbenchActionConstants.GROUP_ADD));
    menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    if (isEditable()) {
        addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.UNDO);
        addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.REVERT_TO_SAVED);
        addAction(menu, ITextEditorActionConstants.GROUP_SAVE, ITextEditorActionConstants.SAVE);
        addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.CUT);
        addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
        addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.PASTE);
        IAction action = getAction(ITextEditorActionConstants.QUICK_ASSIST);
        if (action != null && action.isEnabled())
            addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.QUICK_ASSIST);
    } else {
        addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
    }
}
Also used : IAction(org.eclipse.jface.action.IAction) GroupMarker(org.eclipse.jface.action.GroupMarker) Separator(org.eclipse.jface.action.Separator)

Example 40 with IAction

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

the class AbstractTextEditor method getAction.

@Override
public IAction getAction(String actionID) {
    Assert.isNotNull(actionID);
    IAction action = fActions.get(actionID);
    if (action == null) {
        action = findContributedAction(actionID);
        if (action != null)
            setAction(actionID, action);
    }
    return 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