use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitAdapterFactory method getAdapter.
@Override
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType.isAssignableFrom(IHistoryPageSource.class)) {
return GitHistoryPageSource.INSTANCE;
}
if (IWorkbenchAdapter.class == adapterType) {
// property page names for git repository tree nodes
if (adaptableObject instanceof RepositoryTreeNode) {
return getRepositoryTreeNodeWorkbenchAdapter((RepositoryTreeNode) adaptableObject);
}
if (gitModelWorkbenchAdapter == null) {
gitModelWorkbenchAdapter = new GitModelWorkbenchAdapter();
}
return gitModelWorkbenchAdapter;
}
if (adaptableObject instanceof IHistoryView && IShowInSource.class == adapterType) {
IHistoryView historyView = (IHistoryView) adaptableObject;
IHistoryPage historyPage = historyView.getHistoryPage();
if (historyPage instanceof GitHistoryPage) {
return historyPage;
}
}
if (adaptableObject instanceof IURIEditorInput && adapterType == Repository.class) {
return getRepository((IURIEditorInput) adaptableObject);
}
if (adaptableObject instanceof IURIEditorInput && adapterType == File.class) {
return getFile((IURIEditorInput) adaptableObject);
}
if (adaptableObject instanceof GitModelObject && adapterType == ResourceMapping.class) {
return GitObjectMapping.create((GitModelObject) adaptableObject);
}
if (adaptableObject instanceof GitModelObject && adapterType == IResource.class) {
GitModelObject obj = (GitModelObject) adaptableObject;
if (obj instanceof GitModelBlob) {
IResource res = ResourceUtil.getFileForLocation(obj.getLocation(), false);
if (res == null) {
// Deleted resource?
res = getWorkspaceResourceFromGitPath(obj.getLocation());
}
return res;
}
if (obj instanceof GitModelTree) {
IResource res = root.getContainerForLocation(obj.getLocation());
if (res == null) {
res = root.getFolder(obj.getLocation());
}
return res;
}
}
if (adapterType == Repository.class) {
ResourceMapping m = AdapterUtils.adapt(adaptableObject, ResourceMapping.class);
if (m != null) {
return SelectionUtils.getRepository(new StructuredSelection(m));
}
}
return null;
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitOpenInCompareAction method handleGitObjectComparison.
private void handleGitObjectComparison(GitModelBlob obj, boolean reuseEditor) {
ITypedElement left;
ITypedElement right;
if (obj instanceof GitModelWorkingFile) {
IPath location = obj.getLocation();
if (location == null) {
return;
}
IFile file = ResourceUtil.getFileForLocation(location, false);
if (file == null) {
Repository repository = null;
GitModelObject modelObject = obj;
while (modelObject != null) {
if (modelObject instanceof GitModelRepository) {
repository = ((GitModelRepository) modelObject).getRepository();
break;
}
modelObject = modelObject.getParent();
}
if (repository == null) {
return;
}
left = new LocalNonWorkspaceTypedElement(repository, location);
} else {
left = SaveableCompareEditorInput.createFileElement(file);
}
right = getCachedFileElement(obj);
} else if (obj instanceof GitModelCacheFile) {
left = getCachedFileElement(obj);
right = getHeadFileElement(obj);
if (right == null)
return;
} else {
oldAction.run();
return;
}
GitCompareFileRevisionEditorInput in = new GitCompareFileRevisionEditorInput(left, right, null);
IWorkbenchPage page = getWorkbenchPage(conf.getSite());
OpenInCompareAction.openCompareEditor(in, page, reuseEditor);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class OpenWorkingFileAction method run.
/*
* (non-Javadoc) Method declared on IAction.
*/
@Override
public void run() {
IStructuredSelection selection = getStructuredSelection();
IResource resource = getExistingResource(selection);
if (resource instanceof IFile)
openWorkspaceFile((IFile) resource);
else {
Object element = selection.getFirstElement();
if (element instanceof GitModelObject) {
IPath location = ((GitModelObject) element).getLocation();
if (location != null && location.toFile().exists())
openExternalFile(location.toFile());
}
}
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelObject in project egit by eclipse.
the class GitContainerMapping method getTraversals.
@Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
GitModelObject[] children = ((GitModelObjectContainer) getModelObject()).getChildren();
Set<ResourceTraversal> result = new LinkedHashSet<>();
final GitSynchronizeDataSet dataSet;
if (context instanceof GitSubscriberResourceMappingContext)
dataSet = ((GitSubscriberResourceMappingContext) context).getSyncData();
else
dataSet = null;
for (GitModelObject child : children) {
if (child.isContainer())
result.addAll(createTraversalForContainer(child, dataSet));
else
result.add(createTraversalForFile(child, dataSet));
}
return result.toArray(new ResourceTraversal[result.size()]);
}
Aggregations