Example usage for org.eclipse.jface.action Action setImageDescriptor

List of usage examples for org.eclipse.jface.action Action setImageDescriptor

Introduction

In this page you can find the example usage for org.eclipse.jface.action Action setImageDescriptor.

Prototype

@Override
    public void setImageDescriptor(ImageDescriptor newImage) 

Source Link

Usage

From source file:org.eclipse.mylyn.internal.commons.ui.screenshots.SelectToolAction.java

License:Open Source License

private void addActionsToMenu() {
    for (ToolActionItem actionItem : items) {
        Action action = new Action() {
            @Override//w ww  .j  a va  2 s  . co m
            public void run() {
                selectAndRun(getText(), getImageDescriptor());
            }
        };
        action.setText(actionItem.label);
        if (actionItem.image != null) {
            action.setImageDescriptor(actionItem.image);
        }
        updateAction(action, actionItem.id);
        ActionContributionItem contributionItem = new ActionContributionItem(action);
        contributionItem.fill(dropDownMenu, -1);
    }
}

From source file:org.eclipse.mylyn.internal.github.ui.gist.GistAttachmentPart.java

License:Open Source License

/**
 * @see org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart#fillToolBar(org.eclipse.jface.action.ToolBarManager)
 *///from w  w  w.j a  v a  2  s .  c om
protected void fillToolBar(ToolBarManager toolBarManager) {
    Action attachFileAction = new Action() {
        @Override
        public void run() {
            EditorUtil.openNewAttachmentWizard(getTaskEditorPage(), Mode.DEFAULT, null);
        }
    };
    attachFileAction.setToolTipText(
            org.eclipse.mylyn.internal.tasks.ui.editors.Messages.TaskEditorAttachmentPart_Attach_);
    attachFileAction.setImageDescriptor(CommonImages.FILE_PLAIN_SMALL);
    toolBarManager.add(attachFileAction);
}

From source file:org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttachmentPart.java

License:Open Source License

@Override
protected void fillToolBar(ToolBarManager toolBarManager) {
    filterDeprecatedAttachmentsAction = new Action("", IAction.AS_CHECK_BOX) { //$NON-NLS-1$
        @Override//from   w  w  w .  java2s .  c o m
        public void run() {
            TasksUiPlugin.getDefault().getPreferenceStore().setValue(PREF_FILTER_DEPRECATED, isChecked());
            filterDeprecated(isChecked());
        }
    };
    filterDeprecatedAttachmentsAction.setImageDescriptor(TasksUiImages.FILTER_OBSOLETE_SMALL);
    filterDeprecatedAttachmentsAction.setToolTipText(Messages.TaskEditorAttachmentPart_Hide_Obsolete_Tooltip);
    if (nonDeprecatedCount > 0 && nonDeprecatedCount < attachmentAttributes.size()) {
        filterDeprecated(TasksUiPlugin.getDefault().getPreferenceStore().getBoolean(PREF_FILTER_DEPRECATED));
    } else {
        // do not allow filtering if it would cause the table to be empty or no change
        filterDeprecatedAttachmentsAction.setEnabled(false);
    }
    toolBarManager.add(filterDeprecatedAttachmentsAction);

    Action attachFileAction = new Action() {
        @Override
        public void run() {
            EditorUtil.openNewAttachmentWizard(getTaskEditorPage(), Mode.DEFAULT, null);
        }
    };
    attachFileAction.setToolTipText(Messages.TaskEditorAttachmentPart_Attach_);
    attachFileAction.setImageDescriptor(TasksUiImages.FILE_NEW_SMALL);
    toolBarManager.add(attachFileAction);

    Action attachScreenshotAction = new Action() {
        @Override
        public void run() {
            EditorUtil.openNewAttachmentWizard(getTaskEditorPage(), Mode.SCREENSHOT, null);
        }
    };
    attachScreenshotAction.setToolTipText(Messages.TaskEditorAttachmentPart_Attach__Screenshot);
    attachScreenshotAction.setImageDescriptor(TasksUiImages.IMAGE_CAPTURE_SMALL);
    toolBarManager.add(attachScreenshotAction);
}

From source file:org.eclipse.mylyn.internal.tasks.ui.MoveToCategoryMenuContributor.java

License:Open Source License

public MenuManager getSubMenuManager(final List<IRepositoryElement> selectedElements) {
    final MenuManager subMenuManager = new MenuManager(
            Messages.MoveToCategoryMenuContributor_Set_Category_Menu_Item);

    // Compute selected tasks
    List<AbstractTask> selectedTasks = new ArrayList<AbstractTask>(selectedElements.size());
    for (IRepositoryElement element : selectedElements) {
        if (element instanceof ITask) {
            selectedTasks.add((AbstractTask) element);
        }/*w  w w. ja v a2  s  .c  o  m*/
    }
    subMenuManager.setVisible(!selectedTasks.isEmpty());

    List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(
            TasksUiInternal.getTaskList().getCategories());
    Collections.sort(categories, new TaskContainerComparator());
    for (final AbstractTaskCategory category : categories) {
        if (!(category instanceof UnmatchedTaskContainer)) {
            String text = handleAcceleratorKeys(category.getSummary());
            Action action = new Action(text, IAction.AS_RADIO_BUTTON) {
                @Override
                public void run() {
                    moveToCategory(selectedElements, category);
                }
            };
            action.setImageDescriptor(TasksUiImages.CATEGORY);
            if (selectedTasks.size() == 1) {
                if (category.contains(selectedTasks.get(0).getHandleIdentifier())) {
                    action.setChecked(true);
                }
            }
            subMenuManager.add(action);
        }
    }
    // add New Category action at the end of the Move to Category Submenu
    // and move selected actions to this newly created category
    Action action = new NewCategoryAction() {
        @Override
        public void run() {
            TaskCategory category = createCategory();
            if (category != null) {
                moveToCategory(selectedElements, category);
            }
        }
    };
    subMenuManager.add(new Separator());
    subMenuManager.add(action);
    return subMenuManager;
}

From source file:org.eclipse.mylyn.internal.tasks.ui.ScheduleTaskMenuContributor.java

License:Open Source License

private Action createDateSelectionAction(final DateRange dateContainer, ImageDescriptor imageDescriptor) {
    Action action = new Action() {
        @Override/*from   w  w  w . j  av  a 2s . com*/
        public void run() {
            setScheduledDate(dateContainer);
        }
    };
    action.setText(dateContainer.toString());
    action.setImageDescriptor(imageDescriptor);
    action.setEnabled(canSchedule());

    DateRange scheduledDate = getScheduledForDate(singleTaskSelection);
    if (scheduledDate != null) {
        action.setChecked(dateContainer.equals(scheduledDate));
    }
    return action;
}

From source file:org.eclipse.mylyn.internal.tasks.ui.search.RepositorySearchResultView.java

License:Open Source License

@Override
protected void fillContextMenu(IMenuManager menuManager) {
    super.fillContextMenu(menuManager);

    // open actions
    menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction);

    // Add to Task List menu
    // HACK: this should be a contribution
    final MenuManager subMenuManager = new MenuManager(MessageFormat
            .format(Messages.RepositorySearchResultView_Add_to_X_Category, TaskListView.LABEL_VIEW));
    List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(
            TasksUiInternal.getTaskList().getCategories());
    Collections.sort(categories);
    for (final AbstractTaskCategory category : categories) {
        if (!(category instanceof UnmatchedTaskContainer)) {//.equals(TasksUiPlugin.getTaskList().getArchiveContainer())) {
            Action action = new Action() {
                @Override//from  w w  w  .j a v  a 2  s . c  om
                public void run() {
                    moveToCategory(category);
                }
            };
            String text = category.getSummary();
            action.setText(text);
            action.setImageDescriptor(TasksUiImages.CATEGORY);
            subMenuManager.add(action);
        }
    }
    menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, subMenuManager);

    // search actions

    menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, createQueryAction);
    menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refineSearchAction);
    menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, openSearchWithBrowserAction);

    menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortByDialogAction);
    addPresentationActions(menuManager);
}

From source file:org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin.java

License:Open Source License

private void addSystemTaskBarActions() {
    MenuManager taskBarMenuManager = TaskBarManager.getTaskBarMenuManager();
    if (taskBarMenuManager != null) {
        NewTaskAction newTaskAction = new NewTaskAction(Messages.TasksUiPlugin_New_Task, true);
        taskBarMenuManager.add(newTaskAction);

        Action activateTaskAction = new Action() {
            @Override//from   w w w  .j a va 2 s  .c om
            public void run() {
                ActivateTaskDialogAction activateTaskDialogAction = new ActivateTaskDialogAction();
                IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
                if (window == null && getWorkbench().getWorkbenchWindows().length > 0) {
                    window = getWorkbench().getWorkbenchWindows()[0];
                }
                activateTaskDialogAction.init(window);
                activateTaskDialogAction.run(null);
            }
        };
        activateTaskAction.setImageDescriptor(TasksUiImages.CONTEXT_ACTIVE_CENTERED);
        activateTaskAction.setText(Messages.TasksUiPlugin_Activate_Task);
        taskBarMenuManager.add(activateTaskAction);
        taskBarMenuManager.update(true);
    }
}

From source file:org.eclipse.mylyn.reviews.tasks.ui.internal.editors.ReviewSummaryTaskEditorPart.java

License:Open Source License

@Override
protected void fillToolBar(ToolBarManager manager) {
    Action toggleFiltering = new Action("Filter", SWT.TOGGLE) { //$NON-NLS-1$
        @Override//from ww w . ja  va 2 s.  co m
        public void run() {
            enableFiltering(!isFiltering());
        }
    };
    toggleFiltering.setImageDescriptor(Images.FILTER);
    toggleFiltering.setToolTipText("Toogle Filtering");
    toggleFiltering.setChecked(true);
    enableFiltering(true);
    manager.add(toggleFiltering);
    super.fillToolBar(manager);
}

From source file:org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage.java

License:Open Source License

/**
 * Override for customizing the tool bar.
 *//*from   w  w w . j a  v  a 2s.c om*/
@Override
public void fillToolBar(IToolBarManager toolBarManager) {
    final TaskRepository taskRepository = (model != null) ? getModel().getTaskRepository() : null;

    if (taskData == null) {
        synchronizeEditorAction = new SynchronizeEditorAction();
        synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
        toolBarManager.appendToGroup("repository", synchronizeEditorAction); //$NON-NLS-1$
    } else {
        if (taskData.isNew()) {
            DeleteTaskEditorAction deleteAction = new DeleteTaskEditorAction(getTask());
            deleteAction.setImageDescriptor(CommonImages.CLEAR);
            toolBarManager.appendToGroup("new", deleteAction); //$NON-NLS-1$
        } else if (taskRepository != null) {
            ClearOutgoingAction clearOutgoingAction = new ClearOutgoingAction(
                    Collections.singletonList((IRepositoryElement) task));
            (clearOutgoingAction).setTaskEditorPage(this);
            if (clearOutgoingAction.isEnabled()) {
                toolBarManager.appendToGroup("new", clearOutgoingAction); //$NON-NLS-1$
            }

            if (task.getSynchronizationState() != SynchronizationState.OUTGOING_NEW) {
                synchronizeEditorAction = new SynchronizeEditorAction();
                synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
                toolBarManager.appendToGroup("repository", synchronizeEditorAction); //$NON-NLS-1$
            }

            NewSubTaskAction newSubTaskAction = new NewSubTaskAction();
            newSubTaskAction.selectionChanged(newSubTaskAction, new StructuredSelection(task));
            if (newSubTaskAction.isEnabled()) {
                toolBarManager.appendToGroup("new", newSubTaskAction); //$NON-NLS-1$
            }

            AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin
                    .getConnectorUi(taskData.getConnectorKind());
            if (connectorUi != null) {
                final String historyUrl = connectorUi.getTaskHistoryUrl(taskRepository, task);
                if (historyUrl != null) {
                    final Action historyAction = new Action() {
                        @Override
                        public void run() {
                            TasksUiUtil.openUrl(historyUrl);
                        }
                    };

                    historyAction.setText(Messages.AbstractTaskEditorPage_History);
                    historyAction.setImageDescriptor(TasksUiImages.TASK_REPOSITORY_HISTORY);
                    historyAction.setToolTipText(Messages.AbstractTaskEditorPage_History);
                    if (getEditor().openWithBrowserAction != null) {
                        getEditor().openWithBrowserAction.setMenuCreator(new MenuCreator() {
                            @Override
                            protected void initialize(MenuManager menuManager) {
                                OpenWithBrowserAction openWithBrowserAction = new OpenWithBrowserAction();
                                openWithBrowserAction.selectionChanged(new StructuredSelection(task));
                                menuManager.add(openWithBrowserAction);
                                menuManager.add(new Separator());
                                menuManager.add(historyAction);
                            };
                        });
                    } else {
                        toolBarManager.prependToGroup("open", historyAction); //$NON-NLS-1$
                    }
                }
            }
        }
        if (needsSubmitButton()) {
            ToolBarButtonContribution submitButtonContribution = new ToolBarButtonContribution(
                    "org.eclipse.mylyn.tasks.toolbars.submit") { //$NON-NLS-1$
                @Override
                protected Control createButton(Composite composite) {
                    submitButton = new Button(composite, SWT.FLAT);
                    submitButton.setText(Messages.TaskEditorActionPart_Submit + " "); //$NON-NLS-1$
                    submitButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_SUBMIT));
                    submitButton.setBackground(null);
                    submitButton.addListener(SWT.Selection, new Listener() {
                        public void handleEvent(Event e) {
                            doSubmit();
                        }
                    });
                    return submitButton;
                }
            };
            submitButtonContribution.marginLeft = 10;
            toolBarManager.add(submitButtonContribution);
        }
        if (findSupport != null) {
            findSupport.addFindAction(toolBarManager);
        }
    }
}

From source file:org.eclipse.n4js.smith.ui.PerformanceView.java

License:Open Source License

private Action createAction(String label, int style, String tooltip, ImageDescriptor image,
        Consumer<Action> onRun) {
    final Action result = new Action(label, style) {
        @Override/*from ww  w . j  a  va2 s  .  c  o  m*/
        public void run() {
            onRun.accept(this);
        }
    };
    result.setText(label);
    result.setToolTipText(tooltip);
    result.setImageDescriptor(image);
    getViewSite().getActionBars().getToolBarManager().add(result);
    return result;
}