Search in sources :

Example 11 with CompareConfiguration

use of org.eclipse.compare.CompareConfiguration in project n4js by eclipse.

the class N4IDEXpectCompareEditorInput method createConfiguration.

@SuppressWarnings("javadoc")
protected static CompareConfiguration createConfiguration(IFile file) {
    CompareConfiguration configuration = new CompareConfiguration();
    configuration.setLeftEditable(true);
    configuration.setLeftLabel("Expected Test Result" + (file != null ? " - " + file.getName() : ""));
    configuration.setRightLabel("Actual Test Result");
    configuration.setAncestorLabel("File on Disk");
    configuration.setProperty(ICompareUIConstants.PROP_ANCESTOR_VISIBLE, Boolean.FALSE);
    return configuration;
}
Also used : CompareConfiguration(org.eclipse.compare.CompareConfiguration)

Example 12 with CompareConfiguration

use of org.eclipse.compare.CompareConfiguration in project liferay-ide by liferay.

the class AbstractCompareFileHandler method _openInCompare.

private void _openInCompare(final ITypedElement left, final ITypedElement right) {
    final CompareConfiguration configuration = new CompareConfiguration();
    configuration.setLeftLabel("Template");
    configuration.setRightLabel(((CompareItem) right).getFile().getAbsolutePath());
    CompareUI.openCompareEditor(new CompareEditorInput(configuration) {

        @Override
        protected Object prepareInput(final IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
            DiffNode diffNode = new DiffNode(left, right);
            return diffNode;
        }
    });
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CompareConfiguration(org.eclipse.compare.CompareConfiguration) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 13 with CompareConfiguration

use of org.eclipse.compare.CompareConfiguration in project liferay-ide by liferay.

the class LiferayUpgradeCompare method openCompareEditor.

public void openCompareEditor() {
    try {
        final ITypedElement left = new CompareItem(getSourceFile(), _fileName);
        final ITypedElement right = new CompareItem(getTargetFile(), _fileName + "_preview");
        final CompareConfiguration configuration = new CompareConfiguration();
        configuration.setLeftLabel("Original File");
        configuration.setRightLabel("Upgraded File");
        CompareEditorInput editorInput = new CompareEditorInput(configuration) {

            @Override
            protected Object prepareInput(final IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
                DiffNode diffNode = new DiffNode(left, right);
                return diffNode;
            }
        };
        StringBuilder titleBuilder = new StringBuilder("Compare ('");
        titleBuilder.append(_fileName);
        titleBuilder.append("'-'");
        titleBuilder.append(_fileName);
        titleBuilder.append("_preview");
        titleBuilder.append("')");
        editorInput.setTitle(titleBuilder.toString());
        CompareUI.openCompareEditor(editorInput);
    } catch (Exception e) {
        ProjectUI.logError(e);
    }
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CompareConfiguration(org.eclipse.compare.CompareConfiguration) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) ITypedElement(org.eclipse.compare.ITypedElement) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 14 with CompareConfiguration

use of org.eclipse.compare.CompareConfiguration in project liferay-ide by liferay.

the class CustomJspPage method compare.

public void compare(final String originalFilePath, final String changedFilePath, final String leftLabel, final String rightLabel) {
    CompareConfiguration config = new CompareConfiguration();
    config.setLeftEditable(false);
    config.setLeftLabel(leftLabel);
    config.setRightEditable(false);
    config.setRightLabel(rightLabel);
    CompareEditorInput editorInput = new CompareEditorInput(config) {

        @Override
        public void saveChanges(IProgressMonitor pm) throws CoreException {
            super.saveChanges(pm);
            _changedItem.writeFile();
        }

        @Override
        protected Object prepareInput(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
            return new DiffNode(_originalItem, _changedItem);
        }

        private CompareItem _changedItem = new CompareItem(changedFilePath);

        private CompareItem _originalItem = new CompareItem(originalFilePath);
    };
    editorInput.setTitle("Compare ('" + originalFilePath + "'-'" + changedFilePath + "')");
    CompareUI.openCompareEditor(editorInput);
}
Also used : CompareEditorInput(org.eclipse.compare.CompareEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CompareConfiguration(org.eclipse.compare.CompareConfiguration) DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode)

Example 15 with CompareConfiguration

use of org.eclipse.compare.CompareConfiguration in project tdq-studio-se by Talend.

the class ExampleLauncher method compare.

public static void compare() {
    // Load the two input models
    ResourceSet resourceSet1 = new ResourceSetImpl();
    ResourceSet resourceSet2 = new ResourceSetImpl();
    // String xmi1 = "path/to/first/model.xmi";
    // String xmi2 = "path/to/second/model.xmi";
    load(fileName1, resourceSet1);
    load(fileName2, resourceSet2);
    // Configure EMF Compare
    IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
    IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
    matchEngineFactory.setRanking(20);
    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory);
    EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    // Compare the two models
    IComparisonScope scope = new DefaultComparisonScope(resourceSet1, resourceSet2, null);
    Comparison compare = comparator.compare(scope);
    comparator.compare(scope);
    EList<Diff> differences = compare.getDifferences();
    ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(scope.getLeft(), scope.getRight(), null);
    AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration());
    CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope);
    // CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input);
    CompareUI.openCompareEditor(input);
}
Also used : MatchEngineFactoryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl) Diff(org.eclipse.emf.compare.Diff) CompareConfiguration(org.eclipse.compare.CompareConfiguration) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) Comparison(org.eclipse.emf.compare.Comparison) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ICompareEditingDomain(org.eclipse.emf.compare.domain.ICompareEditingDomain) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) ComparisonScopeEditorInput(org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput) CompareEditorInput(org.eclipse.compare.CompareEditorInput) EMFCompare(org.eclipse.emf.compare.EMFCompare) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher) IMatchEngine(org.eclipse.emf.compare.match.IMatchEngine)

Aggregations

CompareConfiguration (org.eclipse.compare.CompareConfiguration)19 DiffNode (org.eclipse.compare.structuremergeviewer.DiffNode)10 CompareEditorInput (org.eclipse.compare.CompareEditorInput)6 TextMergeViewer (org.eclipse.compare.contentmergeviewer.TextMergeViewer)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 TextCompareInput (com.cubrid.common.ui.compare.schema.control.TextCompareInput)2 QueryPlanComposite (com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite)2 IOException (java.io.IOException)2 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 QueryRecord (com.cubrid.common.ui.query.tuner.QueryRecord)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1