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);
}
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);
}
}
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;
}
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();
}
Aggregations