Search in sources :

Example 51 with IAction

use of org.eclipse.jface.action.IAction in project sling by apache.

the class ServersActionModeFiddlerActionDelegate method init.

@Override
public void init(IViewPart view) {
    this.view = view;
    actionBars = view.getViewSite().getActionBars();
    initToolbarContributedActions();
    for (ActionContributionItem actionContributionItem : prependedToolbarActions) {
        // TODO - this looks wrong
        IAction action = (IAction) actionContributionItem;
        final ActionContributionItem contribution = new ActionContributionItem(action);
        actionBars.getToolBarManager().add(contribution);
    }
}
Also used : ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction)

Example 52 with IAction

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

the class TextEditorActionContributor method doSetActiveEditor.

/**
 * Internally sets the active editor to the actions provided by this contributor.
 * Cannot be overridden by subclasses.
 *
 * @param part the editor
 */
private void doSetActiveEditor(final IEditorPart part) {
    ITextEditor textEditor = null;
    if (part instanceof ITextEditor)
        textEditor = (ITextEditor) part;
    /**
     * The global actions to be connected with editor actions
     */
    IActionBars actionBars = getActionBars();
    actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
    actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
    IAction action = getAction(textEditor, ITextEditorActionConstants.NEXT);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, action);
    action = getAction(textEditor, ITextEditorActionConstants.PREVIOUS);
    actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, action);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
    action = getAction(textEditor, ITextEditorActionConstants.REFRESH);
    actionBars.setGlobalActionHandler(ITextEditorActionConstants.REFRESH, action);
    fChangeEncodingAction.setAction(getAction(textEditor, ITextEditorActionConstants.CHANGE_ENCODING));
    IAction quickAssistAction = getAction(textEditor, ITextEditorActionConstants.QUICK_ASSIST);
    fQuickAssistAction.setAction(quickAssistAction);
    if (textEditor == null)
        return;
    // Update Quick Assist menu entry - for now don't show disabled entry
    IMenuManager menuMgr = textEditor.getEditorSite().getActionBars().getMenuManager();
    IMenuManager editMenu = menuMgr.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null) {
        boolean isEnabled = quickAssistAction != null && quickAssistAction.isEnabled();
        fQuickAssistMenuEntry.setVisible(isEnabled);
        editMenu.update(true);
    }
    fRetargetShowInformationAction.setAction(getAction(textEditor, ITextEditorActionConstants.SHOW_INFORMATION));
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IAction(org.eclipse.jface.action.IAction) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 53 with IAction

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

the class GotoLineTest method goToLine.

private void goToLine(int line, int expectedResult) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    try {
        IEditorPart part = IDE.openEditor(page, fFile);
        if (part instanceof ITextEditor) {
            ITextEditor editor = (ITextEditor) part;
            IAction action = editor.getAction(ITextEditorActionConstants.GOTO_LINE);
            Accessor accessor = new Accessor(action, GotoLineAction.class);
            accessor.invoke("gotoLine", new Class[] { int.class }, new Integer[] { Integer.valueOf(line) });
            Control control = part.getAdapter(Control.class);
            if (control instanceof StyledText) {
                int caretLine = -1;
                StyledText styledText = (StyledText) control;
                int caret = styledText.getCaretOffset();
                try {
                    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
                    caretLine = document.getLineOfOffset(caret);
                } catch (BadLocationException e1) {
                    fail();
                }
                assertEquals(expectedResult, caretLine);
            } else
                fail();
        } else
            fail();
    } catch (PartInitException e) {
        fail();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) Control(org.eclipse.swt.widgets.Control) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) Accessor(org.eclipse.text.tests.Accessor) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 54 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 55 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)

Aggregations

IAction (org.eclipse.jface.action.IAction)387 Action (org.eclipse.jface.action.Action)147 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)79 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)57 Separator (org.eclipse.jface.action.Separator)55 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)50 MenuManager (org.eclipse.jface.action.MenuManager)39 IMenuManager (org.eclipse.jface.action.IMenuManager)37 ArrayList (java.util.ArrayList)36 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)35 IContributionItem (org.eclipse.jface.action.IContributionItem)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)26 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)22 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)18 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)16 IToolBarManager (org.eclipse.jface.action.IToolBarManager)16 IEditorPart (org.eclipse.ui.IEditorPart)15 Point (org.eclipse.swt.graphics.Point)14 Iterator (java.util.Iterator)13 Menu (org.eclipse.swt.widgets.Menu)13