Search in sources :

Example 1 with ModelSynchronizeParticipant

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);
    }
}
Also used : IResourceState(org.eclipse.egit.ui.internal.resources.IResourceState) IContributionItem(org.eclipse.jface.action.IContributionItem) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModelSynchronizeParticipant(org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant) IResource(org.eclipse.core.resources.IResource) GitModelObject(org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 IResourceState (org.eclipse.egit.ui.internal.resources.IResourceState)1 GitModelObject (org.eclipse.egit.ui.internal.synchronize.model.GitModelObject)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 ModelSynchronizeParticipant (org.eclipse.team.ui.synchronize.ModelSynchronizeParticipant)1