use of org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant in project egit by eclipse.
the class GitActionContributor method fillContextMenu.
@Override
public void fillContextMenu(IMenuManager menu) {
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
if (selection.isEmpty())
return;
Object element = selection.getFirstElement();
IResource resource = ResourceUtil.getResource(element);
if (resource != null) {
// add standard git action for 'workspace' models
menu.appendToGroup(GIT_ACTIONS, createItem(COMMIT_ACTION));
IResourceState state = ResourceStateFactory.getInstance().get(resource);
if (state.hasUnstagedChanges()) {
menu.appendToGroup(GIT_ACTIONS, createItem(ADD_TO_INDEX));
}
if (state.isStaged()) {
menu.appendToGroup(GIT_ACTIONS, createItem(REMOVE_FROM_INDEX));
}
if (!state.isIgnored()) {
menu.appendToGroup(GIT_ACTIONS, createItem(IGNORE_ACTION));
}
menu.appendToGroup(GIT_ACTIONS, createItem(MERGE_TOOL_ACTION));
menu.appendToGroup(GIT_ACTIONS, createItem(CREATE_PATCH));
} else if (element instanceof GitModelObject && selection.size() == 1) {
createMenuForGitModelObject(menu, (GitModelObject) element);
}
IContributionItem fileGroup = findGroup(menu, ISynchronizePageConfiguration.FILE_GROUP);
if (fileGroup != null) {
ModelSynchronizeParticipant msp = ((ModelSynchronizeParticipant) getConfiguration().getParticipant());
if (msp.hasCompareInputFor(element))
menu.appendToGroup(fileGroup.getId(), openWorkingFileAction);
}
}
Aggregations