Search in sources :

Example 11 with IWorkbenchAction

use of org.eclipse.ui.actions.ActionFactory.IWorkbenchAction in project egit by eclipse.

the class CompareTreeView method createActions.

private void createActions() {
    IWorkbenchAction reuseCompareEditorAction = new CompareUtils.ReuseCompareEditorAction();
    actionsToDispose.add(reuseCompareEditorAction);
    getViewSite().getActionBars().getMenuManager().add(reuseCompareEditorAction);
    compareModeAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.TREE_COMPARE_COMPARE_MODE, UIText.CompareTreeView_CompareModeTooltip) {

        @Override
        public void apply(boolean value) {
        // nothing, just switch the preference
        }
    };
    compareModeAction.setImageDescriptor(UIIcons.ELCL16_COMPARE_VIEW);
    compareModeAction.setEnabled(true);
    actionsToDispose.add(compareModeAction);
    getViewSite().getActionBars().getToolBarManager().add(compareModeAction);
    showEqualsAction = new BooleanPrefAction((IPersistentPreferenceStore) Activator.getDefault().getPreferenceStore(), UIPreferences.TREE_COMPARE_SHOW_EQUALS, UIText.CompareTreeView_EqualFilesTooltip) {

        @Override
        public void apply(boolean value) {
            buildTrees(false);
        }
    };
    showEqualsAction.setImageDescriptor(UIIcons.ELCL16_FILTER);
    showEqualsAction.setEnabled(false);
    actionsToDispose.add(showEqualsAction);
    getViewSite().getActionBars().getToolBarManager().add(showEqualsAction);
    IAction expandAllAction = new Action(UIText.CompareTreeView_ExpandAllTooltip) {

        @Override
        public void run() {
            tree.expandAll();
        }
    };
    expandAllAction.setImageDescriptor(UIIcons.EXPAND_ALL);
    getViewSite().getActionBars().getToolBarManager().add(expandAllAction);
    IAction collapseAllAction = new Action(UIText.CompareTreeView_CollapseAllTooltip) {

        @Override
        public void run() {
            tree.collapseAll();
        }
    };
    collapseAllAction.setImageDescriptor(UIIcons.COLLAPSEALL);
    getViewSite().getActionBars().getToolBarManager().add(collapseAllAction);
}
Also used : IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) BooleanPrefAction(org.eclipse.egit.ui.internal.actions.BooleanPrefAction) IPersistentPreferenceStore(org.eclipse.jface.preference.IPersistentPreferenceStore)

Example 12 with IWorkbenchAction

use of org.eclipse.ui.actions.ActionFactory.IWorkbenchAction in project egit by eclipse.

the class CompareTreeView method buildTrees.

private void buildTrees(final boolean buildMaps) {
    final Object[] wsExpaneded = tree.getExpandedElements();
    final ISelection wsSel = tree.getSelection();
    tree.setInput(null);
    tree.setContentProvider(new PathNodeContentProvider());
    tree.setComparator(new PathNodeTreeComparator());
    tree.setLabelProvider(new PathNodeLabelProvider());
    tree.setFilters(new PathNodeFilter[] { new PathNodeFilter() });
    for (IWorkbenchAction action : actionsToDispose) action.setEnabled(false);
    showEquals = Activator.getDefault().getPreferenceStore().getBoolean(UIPreferences.TREE_COMPARE_SHOW_EQUALS);
    final Repository repo;
    if (input instanceof IResource[]) {
        repositoryMapping = RepositoryMapping.getMapping(((IResource[]) input)[0]);
        if (repositoryMapping == null || repositoryMapping.getRepository() == null)
            return;
        repo = repositoryMapping.getRepository();
    } else if (input instanceof Repository) {
        repo = (Repository) input;
    } else
        return;
    final RevCommit baseCommit;
    final RevCommit compareCommit;
    try (RevWalk rw = new RevWalk(repo)) {
        ObjectId commitId = repo.resolve(compareVersion);
        compareCommit = commitId != null ? rw.parseCommit(commitId) : null;
        if (baseVersion == null)
            baseCommit = null;
        else {
            commitId = repo.resolve(baseVersion);
            baseCommit = rw.parseCommit(commitId);
        }
    } catch (IOException e) {
        Activator.handleError(e.getMessage(), e, true);
        return;
    }
    showBusy(true);
    try {
        // this does the hard work...
        new ProgressMonitorDialog(getViewSite().getShell()).run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    if (buildMaps)
                        buildMaps(repo, baseCommit, compareCommit, monitor);
                    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            tree.setInput(input);
                            tree.setExpandedElements(wsExpaneded);
                            tree.setSelection(wsSel);
                            updateControls();
                        }
                    });
                } catch (IOException e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (InvocationTargetException e) {
        Activator.handleError(e.getTargetException().getMessage(), e.getTargetException(), true);
    } catch (InterruptedException e) {
        input = null;
    } finally {
        showBusy(false);
    }
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Repository(org.eclipse.jgit.lib.Repository) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ISelection(org.eclipse.jface.viewers.ISelection) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 13 with IWorkbenchAction

use of org.eclipse.ui.actions.ActionFactory.IWorkbenchAction in project egit by eclipse.

the class ActionUtils method createGlobalAction.

/**
 * Create an {@link IAction} taking the text, id, and action definition id
 * from the given {@link ActionFactory}.
 *
 * @param factory
 *            from which the new {@link IAction} shall be derived
 * @param action
 *            to execute
 * @param enabled
 *            to obtain the action's enablement
 * @return the new {@link IAction}
 */
public static IAction createGlobalAction(ActionFactory factory, final Runnable action, final BooleanSupplier enabled) {
    IWorkbenchAction template = factory.create(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
    IAction result = new Action(template.getText()) {

        @Override
        public void run() {
            action.run();
        }

        @Override
        public boolean isEnabled() {
            return enabled.getAsBoolean();
        }
    };
    result.setActionDefinitionId(factory.getCommandId());
    result.setId(factory.getId());
    template.dispose();
    return result;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)

Example 14 with IWorkbenchAction

use of org.eclipse.ui.actions.ActionFactory.IWorkbenchAction in project egit by eclipse.

the class GitHistoryPage method dispose.

@Override
public void dispose() {
    trace = GitTraceLocation.HISTORYVIEW.isActive();
    if (trace)
        GitTraceLocation.getTrace().traceEntry(GitTraceLocation.HISTORYVIEW.getLocation());
    if (focusTracker != null) {
        focusTracker.dispose();
        focusTracker = null;
    }
    detachSelectionTracker();
    Activator.getDefault().getPreferenceStore().removePropertyChangeListener(listener);
    if (myRefsChangedHandle != null) {
        myRefsChangedHandle.remove();
        myRefsChangedHandle = null;
    }
    resources.dispose();
    // dispose of the actions (the history framework doesn't do this for us)
    for (IWorkbenchAction action : actions.actionsToDispose) action.dispose();
    actions.actionsToDispose.clear();
    releaseGenerateHistoryJob();
    if (popupMgr != null) {
        for (final IContributionItem i : popupMgr.getItems()) if (i instanceof IWorkbenchAction)
            ((IWorkbenchAction) i).dispose();
        for (final IContributionItem i : getSite().getActionBars().getMenuManager().getItems()) if (i instanceof IWorkbenchAction)
            ((IWorkbenchAction) i).dispose();
    }
    renameTracker.reset(null);
    if (job != null) {
        job.cancel();
        job = null;
    }
    Job.getJobManager().cancel(JobFamilies.HISTORY_DIFF);
    super.dispose();
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)

Aggregations

IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)14 IAction (org.eclipse.jface.action.IAction)6 Action (org.eclipse.jface.action.Action)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 Separator (org.eclipse.jface.action.Separator)4 MdwMenuManager (com.centurylink.mdw.plugin.actions.MdwMenuManager)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 ActionGroup (org.eclipse.ui.actions.ActionGroup)3 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)2 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)2 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 BooleanPrefAction (org.eclipse.egit.ui.internal.actions.BooleanPrefAction)1 RedoRetargetAction (org.eclipse.gef.ui.actions.RedoRetargetAction)1 UndoRetargetAction (org.eclipse.gef.ui.actions.UndoRetargetAction)1 ZoomInRetargetAction (org.eclipse.gef.ui.actions.ZoomInRetargetAction)1