use of org.eclipse.compare.IResourceProvider in project linuxtools by eclipse.
the class ChangeLogAction method getDocumentLocation.
protected String getDocumentLocation(IEditorPart currentEditor, boolean appendRoot) {
IFile loc = getDocumentIFile(currentEditor);
IEditorInput cc = null;
String WorkspaceRoot;
IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
if (currentEditor instanceof MultiPageEditorPart) {
Object ed = ((MultiPageEditorPart) currentEditor).getSelectedPage();
if (ed instanceof IEditorPart)
cc = ((IEditorPart) ed).getEditorInput();
if (cc instanceof FileEditorInput)
return (appendRoot) ? WorkspaceRoot + ((FileEditorInput) cc).getFile().getFullPath().toOSString() : ((FileEditorInput) cc).getFile().getFullPath().toOSString();
}
cc = currentEditor.getEditorInput();
if (cc == null)
return "";
if ((cc instanceof SyncInfoCompareInput) || (cc instanceof CompareEditorInput)) {
CompareEditorInput test = (CompareEditorInput) cc;
if (test.getCompareResult() == null) {
return "";
} else if (test.getCompareResult() instanceof ICompareInput) {
ITypedElement leftCompare = ((ICompareInput) test.getCompareResult()).getLeft();
if (leftCompare instanceof IResourceProvider) {
String localPath = ((IResourceProvider) leftCompare).getResource().getFullPath().toString();
if (appendRoot) {
return WorkspaceRoot + localPath;
}
return localPath;
}
} else {
if (appendRoot)
return WorkspaceRoot + test.getCompareResult().toString();
return test.getCompareResult().toString();
}
} else if (cc instanceof FileStoreEditorInput) {
return ((FileStoreEditorInput) cc).getName();
}
if (appendRoot) {
return WorkspaceRoot + loc.getFullPath().toOSString();
} else if (loc != null) {
return loc.getFullPath().toOSString();
} else {
return "";
}
}
use of org.eclipse.compare.IResourceProvider in project linuxtools by eclipse.
the class SpecStructureCreator method createStructureComparator.
@Override
protected IStructureComparator createStructureComparator(Object input, IDocument document, ISharedDocumentAdapter adapter, IProgressMonitor monitor) {
final boolean isEditable;
if (input instanceof IEditableContent) {
isEditable = ((IEditableContent) input).isEditable();
} else {
isEditable = false;
}
// get the resource being compared, but treat compare with history as
// null resource
IFile file = null;
if (input instanceof IResourceProvider) {
IResource res = ((IResourceProvider) input).getResource();
file = res.getAdapter(IFile.class);
}
DocumentRangeNode rootNode = new StructureRootNode(document, input, this, adapter) {
@Override
public boolean isEditable() {
return isEditable;
}
};
try {
monitor = beginWork(monitor);
// Section Root
SpecNode specfileSectionRoot = new SpecNode(rootNode, 0, SPECFILE_ROOT_NODE, document, 0, document.getLength());
parseSpecfile(specfileSectionRoot, document, file);
} finally {
if (monitor != null) {
monitor.done();
}
}
return rootNode;
}
Aggregations