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;
}
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;
}
});
}
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);
}
}
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);
}
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);
}
Aggregations