Search in sources :

Example 1 with SyncInfoCompareInput

use of org.eclipse.team.ui.synchronize.SyncInfoCompareInput 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 "";
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) ITypedElement(org.eclipse.compare.ITypedElement) ICompareInput(org.eclipse.compare.structuremergeviewer.ICompareInput) IEditorPart(org.eclipse.ui.IEditorPart) IResourceProvider(org.eclipse.compare.IResourceProvider) CompareEditorInput(org.eclipse.compare.CompareEditorInput) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IFileEditorInput(org.eclipse.ui.IFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) SyncInfoCompareInput(org.eclipse.team.ui.synchronize.SyncInfoCompareInput) IEditorInput(org.eclipse.ui.IEditorInput) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Aggregations

CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 IResourceProvider (org.eclipse.compare.IResourceProvider)1 ITypedElement (org.eclipse.compare.ITypedElement)1 ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)1 IFile (org.eclipse.core.resources.IFile)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 SyncInfoCompareInput (org.eclipse.team.ui.synchronize.SyncInfoCompareInput)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IFileEditorInput (org.eclipse.ui.IFileEditorInput)1 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1 MultiPageEditorPart (org.eclipse.ui.part.MultiPageEditorPart)1