Skip to content

Fix OML model compare in Git staging view #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="io.opencaesar.rosetta.feature"
label="%featureName"
version="0.9.1"
version="0.9.2"
provider-name="%providerName">

<description url="http://www.example.com/description">
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>
<artifactId>io.opencaesar.rosetta.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.oml.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.rosetta.oml.ui;singleton:=true
Bundle-Version: 0.9.1
Bundle-Version: 0.9.2
Automatic-Module-Name: io.opencaesar.rosetta.oml.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.oml.ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>
<artifactId>io.opencaesar.rosetta.oml.ui</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@

import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.compare.ide.ui.logical.AbstractModelResolver;
import org.eclipse.emf.compare.ide.ui.logical.IStorageProviderAccessor;
import org.eclipse.emf.compare.ide.ui.logical.IStorageProviderAccessor.DiffSide;
import org.eclipse.emf.compare.ide.ui.logical.SynchronizationModel;
import org.eclipse.emf.compare.ide.utils.ResourceUtil;
import org.eclipse.emf.compare.ide.utils.StorageTraversal;

/**
Expand All @@ -36,33 +41,75 @@
public class OmlModelResolver extends AbstractModelResolver {

@Override
public SynchronizationModel resolveLocalModels(IResource left, IResource right, IResource origin,
IProgressMonitor monitor) throws InterruptedException {
return new SynchronizationModel(getTraversal(left), getTraversal(right), getTraversal(origin));
}

@Override
public SynchronizationModel resolveModels(IStorageProviderAccessor storageAccessor, IStorage left, IStorage right,
IStorage origin, IProgressMonitor monitor) throws InterruptedException {
return new SynchronizationModel(getTraversal(left), getTraversal(right), getTraversal(origin));
public boolean canResolve(IStorage sourceStorage) {
return true;
}


// Local

@Override
public StorageTraversal resolveLocalModel(IResource resource, IProgressMonitor monitor)
throws InterruptedException {
return getTraversal(resource);
return getLocalTraversal(resource);
}

@Override
public boolean canResolve(IStorage sourceStorage) {
return true;
public SynchronizationModel resolveLocalModels(IResource left, IResource right, IResource origin,
IProgressMonitor monitor) throws InterruptedException {
return new SynchronizationModel(getLocalTraversal(left), getLocalTraversal(right), getLocalTraversal(origin));
}

private static StorageTraversal getTraversal(Object resource) {
/**
* For local resources, include the given resource directly in the StorageTraversal.
*/
private static StorageTraversal getLocalTraversal(IResource resource) {
if (resource instanceof IStorage) {
return new StorageTraversal(Collections.singleton((IStorage)resource));
} else {
return new StorageTraversal(Collections.emptySet());
}
}

// Remote

@Override
public SynchronizationModel resolveModels(IStorageProviderAccessor storageAccessor, IStorage left, IStorage right,
IStorage origin, IProgressMonitor monitor) throws InterruptedException {
var subMonitor = SubMonitor.convert(monitor, 3);
return new SynchronizationModel(
getRemoteTraversal(storageAccessor, left, DiffSide.SOURCE, subMonitor.split(1)),
getRemoteTraversal(storageAccessor, right, DiffSide.REMOTE, subMonitor.split(1)),
getRemoteTraversal(storageAccessor, origin, DiffSide.ORIGIN, subMonitor.split(1))
);
}

/**
* For remote traversals, the IStorage given to us may be a wrapper for an underlying IStorage object that
* doesn't actually exist and is null; trying to load the contents of this IStorage results in an error.
*
* To prevent this, try to locate the storage object ourselves from the
* storageAccessor using the given storage object's name to ensure it exists.
*/
private static StorageTraversal getRemoteTraversal(IStorageProviderAccessor storageAccessor, IStorage givenStorage, DiffSide side, IProgressMonitor monitor) {
try {
if (givenStorage != null) {
var path = ResourceUtil.getAbsolutePath(givenStorage);
var file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
var storageProvider = storageAccessor.getStorageProvider(file, side);
if (storageProvider != null) {
var foundStorage = storageProvider.getStorage(monitor);
if (foundStorage != null) {
return new StorageTraversal(Collections.singleton(foundStorage));
}
}
}
} catch (CoreException e) {
// returns an empty traversal in the event of a CoreException
e.printStackTrace();
} finally {
monitor.done();
}
return new StorageTraversal(Collections.emptySet());
}

}
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.product/rosetta.product
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="Rosetta" uid="rosetta" id="io.opencaesar.rosetta.rcp.product" application="org.eclipse.ui.ide.workbench" version="0.9.1" useFeatures="true" includeLaunchers="true">
<product name="Rosetta" uid="rosetta" id="io.opencaesar.rosetta.rcp.product" application="org.eclipse.ui.ide.workbench" version="0.9.2" useFeatures="true" includeLaunchers="true">

<aboutInfo>
<image path="/io.opencaesar.rosetta.rcp/images/about.png"/>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.rcp.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="io.opencaesar.rosetta.rcp.feature"
label="%featureName"
version="0.9.1"
version="0.9.2"
provider-name="%providerName">

<description url="http://www.example.com/description">
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.rcp.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>
<artifactId>io.opencaesar.rosetta.rcp.feature</artifactId>
<packaging>eclipse-feature</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.rcp/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.rosetta.rcp;singleton:=true
Bundle-Version: 0.9.1
Bundle-Version: 0.9.2
Automatic-Module-Name: io.opencaesar.rosetta.rcp
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Localization: plugin
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.rcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>
<artifactId>io.opencaesar.rosetta.rcp</artifactId>
<packaging>eclipse-plugin</packaging>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>

<artifactId>io.opencaesar.rosetta.repository</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.rosetta.sirius.viewpoint;singleton:=true
Bundle-Version: 0.9.1
Bundle-Version: 0.9.2
Automatic-Module-Name: io.opencaesar.rosetta.sirius.viewpoint
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Activator: io.opencaesar.rosetta.sirius.viewpoint.Activator
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.sirius.viewpoint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>

<artifactId>io.opencaesar.rosetta.sirius.viewpoint</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.sirius/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: io.opencaesar.rosetta.sirius;singleton:=true
Bundle-Version: 0.9.1
Bundle-Version: 0.9.2
Bundle-Localization: plugin
Automatic-Module-Name: io.opencaesar.rosetta.sirius
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
2 changes: 1 addition & 1 deletion io.opencaesar.rosetta.target/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
</parent>

</project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.opencaesar.rosetta</groupId>
<artifactId>io.opencaesar.rosetta.parent</artifactId>
<version>0.9.1</version>
<version>0.9.2</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.1
0.9.2