Search in sources :

Example 1 with ICompareInput

use of org.eclipse.compare.structuremergeviewer.ICompareInput in project linuxtools by eclipse.

the class ReportComparisonView method setInput.

@Override
public void setInput(Object input) {
    if (input instanceof ICompareInput) {
        fInput = (ICompareInput) input;
        if (fInput.getAncestor() != null || (fInput.getKind() & Differencer.DIRECTION_MASK) != 0) {
            setStyledText(Messages.CompUnsupported);
        } else {
            // get corresponding files
            IPath oldDatum;
            IPath newDatum;
            IProject proj = null;
            if (fInput.getLeft() instanceof ResourceNode) {
                ResourceNode left = (ResourceNode) fInput.getLeft();
                IResource oldData = left.getResource();
                oldDatum = oldData.getLocation();
                proj = oldData.getProject();
            } else {
                IEncodedStreamContentAccessor lStream = (IEncodedStreamContentAccessor) fInput.getLeft();
                oldDatum = generateTempFile(lStream);
            }
            if (fInput.getRight() instanceof ResourceNode) {
                ResourceNode right = (ResourceNode) fInput.getRight();
                IResource newData = right.getResource();
                newDatum = newData.getLocation();
                proj = newData.getProject();
            } else {
                IEncodedStreamContentAccessor rStream = (IEncodedStreamContentAccessor) fInput.getRight();
                newDatum = generateTempFile(rStream);
            }
            String title = MessageFormat.format(Messages.ContentDescription_0, oldDatum.toFile().getName(), newDatum.toFile().getName());
            // create comparison data and run comparison.
            ReportComparisonData diffData;
            if (reverse) {
                diffData = new ReportComparisonData(title, oldDatum, newDatum, proj);
            } else {
                diffData = new ReportComparisonData(title, newDatum, oldDatum, proj);
            }
            diffData.parse();
            setStyledText(diffData.getPerfData());
        }
    }
    fComposite.layout();
}
Also used : ReportComparisonData(org.eclipse.linuxtools.internal.perf.ReportComparisonData) IPath(org.eclipse.core.runtime.IPath) ICompareInput(org.eclipse.compare.structuremergeviewer.ICompareInput) IEncodedStreamContentAccessor(org.eclipse.compare.IEncodedStreamContentAccessor) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) ResourceNode(org.eclipse.compare.ResourceNode)

Example 2 with ICompareInput

use of org.eclipse.compare.structuremergeviewer.ICompareInput in project linuxtools by eclipse.

the class StatComparisonView method setInput.

@Override
public void setInput(Object input) {
    if (input instanceof ICompareInput) {
        fInput = (ICompareInput) input;
        if (fInput.getAncestor() != null || (fInput.getKind() & Differencer.DIRECTION_MASK) != 0) {
            setStyledText(Messages.CompUnsupported);
        } else {
            // get corresponding files
            IPath oldDatum;
            IPath newDatum;
            if (fInput.getLeft() instanceof ResourceNode) {
                ResourceNode left = (ResourceNode) fInput.getLeft();
                oldDatum = left.getResource().getLocation();
            } else {
                IEncodedStreamContentAccessor lStream = (IEncodedStreamContentAccessor) fInput.getLeft();
                oldDatum = generateTempFile(lStream);
            }
            if (fInput.getRight() instanceof ResourceNode) {
                ResourceNode right = (ResourceNode) fInput.getRight();
                newDatum = right.getResource().getLocation();
            } else {
                IEncodedStreamContentAccessor rStream = (IEncodedStreamContentAccessor) fInput.getRight();
                newDatum = generateTempFile(rStream);
            }
            String title = MessageFormat.format(Messages.ContentDescription_0, oldDatum.toFile().getName(), newDatum.toFile().getName());
            // create comparison data and run comparison.
            StatComparisonData diffData;
            if (reverse) {
                diffData = new StatComparisonData(title, newDatum, oldDatum);
            } else {
                diffData = new StatComparisonData(title, oldDatum, newDatum);
            }
            diffData.runComparison();
            updateData(diffData);
        }
    }
    fComposite.layout();
}
Also used : IPath(org.eclipse.core.runtime.IPath) StatComparisonData(org.eclipse.linuxtools.internal.perf.StatComparisonData) ICompareInput(org.eclipse.compare.structuremergeviewer.ICompareInput) IEncodedStreamContentAccessor(org.eclipse.compare.IEncodedStreamContentAccessor) ResourceNode(org.eclipse.compare.ResourceNode)

Example 3 with ICompareInput

use of org.eclipse.compare.structuremergeviewer.ICompareInput 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

ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)3 IEncodedStreamContentAccessor (org.eclipse.compare.IEncodedStreamContentAccessor)2 ResourceNode (org.eclipse.compare.ResourceNode)2 IPath (org.eclipse.core.runtime.IPath)2 CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 IResourceProvider (org.eclipse.compare.IResourceProvider)1 ITypedElement (org.eclipse.compare.ITypedElement)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 ReportComparisonData (org.eclipse.linuxtools.internal.perf.ReportComparisonData)1 StatComparisonData (org.eclipse.linuxtools.internal.perf.StatComparisonData)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