Skip to content

Commit

Permalink
[1998] Contribute IdHandler for DRepresentations and add the possibility
Browse files Browse the repository at this point in the history
to return a DRepresentation from an IScop based on
its uid

Bug: 1998

Conflicts:
	common/plugins/org.polarsys.capella.common.platform.sirius.customization/src/org/polarsys/capella/common/platform/sirius/customisation/id/handler/drepresentation/DRepresentationIdHandler.java

Change-Id: I8807738381b6707ca83265a080c8bbb00c7f1f8c
Signed-off-by: Tu Ton <minhtutonthat@gmail.com>
  • Loading branch information
minhtutonthat committed Apr 18, 2018
1 parent b91652f commit 485de93
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -1,7 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Expand Up @@ -10,9 +10,14 @@
*******************************************************************************/
package org.polarsys.capella.common.platform.sirius.customisation.id.handler.drepresentation;

import java.util.Optional;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.sirius.business.api.session.resource.AirdResource;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.polarsys.capella.shared.id.handler.AbstractIdHandler;
import org.polarsys.capella.shared.id.handler.IScope;

public class DRepresentationIdHandler extends AbstractIdHandler {

Expand All @@ -27,5 +32,20 @@ public String getId(EObject object) {
}
return null;
}

@Override
public EObject getEObject(String id, IScope scope) {
for (Resource resource : scope.getResources()) {
if (resource instanceof AirdResource) {
Optional<DRepresentation> foundDRepresentation = resource.getContents().stream()
.filter(DRepresentation.class::isInstance).map(DRepresentation.class::cast)
.filter(dRepresentation -> id.equals(dRepresentation.getUid())).findFirst();

if (foundDRepresentation.isPresent())
return foundDRepresentation.get();
}
}

return super.getEObject(id, scope);
}
}

0 comments on commit 485de93

Please sign in to comment.