use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject 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);
}
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitChangeSetModelProvider method getMappings.
@Override
public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
if (context instanceof GitSubscriberResourceMappingContext) {
GitSubscriberResourceMappingContext gitContext = (GitSubscriberResourceMappingContext) context;
GitSynchronizeDataSet gsds = gitContext.getSyncData();
GitSynchronizeData data = gsds.getData(resource.getProject());
if (data != null) {
GitModelObject object = null;
try {
object = GitModelObject.createRoot(data);
} catch (IOException e) {
Activator.logError(e.getMessage(), e);
}
if (object != null) {
ResourceMapping rm = AdapterUtils.adapt(object, ResourceMapping.class);
return new ResourceMapping[] { rm };
}
}
}
return super.getMappings(resource, context, monitor);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitContainerMapping method createTraversalForContainer.
private Set<ResourceTraversal> createTraversalForContainer(GitModelObject child, GitSynchronizeDataSet dataSet) {
GitModelObject[] containerChildren = child.getChildren();
Set<ResourceTraversal> result = new LinkedHashSet<>();
for (GitModelObject aChild : containerChildren) {
if (aChild.isContainer())
result.addAll(createTraversalForContainer(aChild, dataSet));
else {
ResourceTraversal traversal = createTraversalForFile(aChild, dataSet);
if (traversal != null)
result.add(traversal);
}
}
return result;
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitTreeMapping method getTraversals.
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
GitModelObject[] objects = tree.getChildren();
ResourceTraversal[] result = new ResourceTraversal[objects.length];
for (int i = 0; i < objects.length; i++) {
if (objects[i] instanceof GitModelTree)
result[i] = new GitTreeTraversal((GitModelTree) objects[i]);
else {
IResource[] resources = getResources((GitModelBlob) objects[i]);
result[i] = new ResourceTraversal(resources, IResource.DEPTH_ZERO, IResource.ALLOW_MISSING_LOCAL);
}
}
return result;
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitTreeTraversal method getResourcesImpl.
private static IResource[] getResourcesImpl(GitModelObject[] children) {
List<IResource> result = new ArrayList<>(children.length);
for (GitModelObject object : children) {
IPath location = object.getLocation();
IResource resource;
if (object.isContainer())
resource = ROOT.getContainerForLocation(location);
else
resource = ROOT.getFileForLocation(location);
if (resource != null)
result.add(resource);
}
return result.toArray(new IResource[result.size()]);
}
Aggregations