Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-01-21 12:13:29 -0500
committerChristian W. Damus2015-01-21 15:50:49 -0500
commit83de1b8003bf87fcfa260982f15975a117fc71b5 (patch)
tree11cd54d74f3ed70e054854f0e466be6f7c28ce6a /plugins
parentc42dda4199efe4f677ce20e510a3eb80f38605a2 (diff)
downloadorg.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.tar.gz
org.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.tar.xz
org.eclipse.papyrus-83de1b8003bf87fcfa260982f15975a117fc71b5.zip
436666: "Stereotype repair" pop-up for already upgraded model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436666 Detect orphaned (dangling) stereotype instances and suggest to delete them. Orphans are treated as a separate group from properly attached stereotype instances of the same schema (broken or not) because they cannot be repaired by profile application; they are not stereotype applications because they have no base elements. Also update some test models that are opened in editors to remove orphaned stereotype instances (which cause tests to hang on the repair dialog). Conflicts: extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/RepairStereotypes.java plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IStereotypeOrphanGroup.java28
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java205
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java39
3 files changed, 219 insertions, 53 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IStereotypeOrphanGroup.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IStereotypeOrphanGroup.java
new file mode 100644
index 00000000000..1287de538cf
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/IStereotypeOrphanGroup.java
@@ -0,0 +1,28 @@
+/*****************************************************************************
+ * Copyright (c) 2015 Christian W. Damus and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
+
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ * Protocol for a grouping of stereotype instances of some schema that are orphaned (no longer attached to any UML elements).
+ */
+public interface IStereotypeOrphanGroup {
+ /**
+ * Queries the schema of the orphaned stereotype instances.
+ *
+ * @return the profile schema
+ */
+ EPackage getSchema();
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java
index a1acffa90aa..1cc14a00c2c 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/stereotypes/ZombieStereotypesDescriptor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA, Christian W. Damus, and others.
+ * Copyright (c) 2014, 2015 CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,6 +10,7 @@
* Christian W. Damus (CEA) - Initial API and implementation
* Christian W. Damus - bug 399859
* Christian W. Damus - bug 451338
+ * Christian W. Damus - bug 436666
*
*/
package org.eclipse.papyrus.uml.modelrepair.internal.stereotypes;
@@ -22,6 +23,7 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.EList;
@@ -36,6 +38,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.papyrus.uml.modelrepair.internal.participants.StereotypesUtil;
import org.eclipse.papyrus.uml.tools.helper.IProfileApplicationDelegate;
@@ -81,11 +84,11 @@ public class ZombieStereotypesDescriptor {
private final Multimap<ProfileContext, EObject> zombies = ArrayListMultimap.create();
- private final Map<EPackage, IRepairAction> suggestedActions = Maps.newHashMap();
+ private final Map<IAdaptable, IRepairAction> suggestedActions = Maps.newHashMap();
private final Function<? super EPackage, Profile> dynamicProfileSupplier;
- private Map<EPackage, Map<IRepairAction.Kind, IRepairAction>> repairActions = Maps.newHashMap();
+ private Map<IAdaptable, Map<IRepairAction.Kind, IRepairAction>> repairActions = Maps.newHashMap();
private Map<EPackage, Profile> definitionToProfileMap = Maps.newHashMap();
@@ -123,7 +126,10 @@ public class ZombieStereotypesDescriptor {
public void analyze(EObject stereotypeApplication) {
EPackage schema = getEPackage(stereotypeApplication);
- if ((schema == null) || (!appliedProfileDefinitions.contains(schema) && couldBeProfileDefinition(schema, stereotypeApplication))) {
+ if ((schema == null)
+ || (!appliedProfileDefinitions.contains(schema) && couldBeProfileDefinition(schema, stereotypeApplication))
+ || (appliedProfileDefinitions.contains(schema) && (UMLUtil.getBaseElement(stereotypeApplication) == null))) {
+
// It's a zombie. Determine the profile-application context that covers this stereotype instance
ProfileContext context = getProfileContext(stereotypeApplication, schema);
@@ -131,11 +137,12 @@ public class ZombieStereotypesDescriptor {
zombies.put(context, stereotypeApplication);
if (newContext && (schema != null)) {
- if (!suggestedActions.containsKey(schema)) {
- suggestedActions.put(schema, computeSuggestedAction(schema));
+ IAdaptable schemaAdaptable = context.getSchemaAdaptable();
+ if (!suggestedActions.containsKey(schemaAdaptable)) {
+ suggestedActions.put(schemaAdaptable, computeSuggestedAction(schemaAdaptable));
} else {
// Already computed the actions previously, but we need to add this new package to the apply-profile action
- ApplyProfileAction applyProfile = (ApplyProfileAction) getRepairAction(schema, IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION);
+ ApplyProfileAction applyProfile = (ApplyProfileAction) getRepairAction(schemaAdaptable, IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION);
if (applyProfile != null) {
applyProfile.addPackage(context.getApplyingPackage());
}
@@ -164,40 +171,61 @@ public class ZombieStereotypesDescriptor {
return resource;
}
- public Collection<? extends EPackage> getZombiePackages() {
- return ImmutableSet.copyOf(Iterables.transform(zombies.keySet(), new Function<ProfileContext, EPackage>() {
+ /**
+ * Obtains a collection of zombie schemas detected by the stereotype repair analysis and for which {@link IRepairAction}s
+ * are available to remedy problems. Every resulting adaptable
+ * <ul>
+ * <li>adapts to {@link EPackage} to provide the EMF schema that is unresolved or otherwise broken</li>
+ * <li>may possibly adapt to {@link IStereotypeOrphanGroup} representing stereotype applications from a broken schema that are not repairable by profile migration and so are treated separately with a distinct set of available actions
+ * </ul>
+ *
+ * @return the zombie schemas that are detected
+ */
+ public Collection<? extends IAdaptable> getZombieSchemas() {
+ return ImmutableSet.copyOf(Iterables.transform(zombies.keySet(), new Function<ProfileContext, IAdaptable>() {
- public EPackage apply(ProfileContext input) {
- return input.getSchema();
+ public IAdaptable apply(ProfileContext input) {
+ return input.getSchemaAdaptable();
}
}));
}
- public int getZombieCount(EPackage schema) {
+ public int getZombieCount(IAdaptable schema) {
int result = 0;
- for (Map.Entry<ProfileContext, Collection<EObject>> next : zombies.asMap().entrySet()) {
- if (equal(next.getKey().getSchema(), schema, root)) {
- result = result + next.getValue().size();
- }
+
+ for (Map.Entry<ProfileContext, Collection<EObject>> next : Iterables.filter(zombies.asMap().entrySet(), matches(schema))) {
+ result = result + next.getValue().size();
}
return result;
}
- public Collection<? extends EObject> getZombies(EPackage schema) {
- ImmutableList.Builder<EObject> result = ImmutableList.builder();
+ private Predicate<Map.Entry<ProfileContext, ?>> matches(IAdaptable schema) {
+ IStereotypeOrphanGroup orphans = AdapterUtils.adapt(schema, IStereotypeOrphanGroup.class, null);
+ final boolean isOrphanGroup = orphans != null;
+ final EPackage targetSchema = isOrphanGroup ? orphans.getSchema() : AdapterUtils.adapt(schema, EPackage.class, null);
- for (Map.Entry<ProfileContext, Collection<EObject>> next : zombies.asMap().entrySet()) {
- if (equal(next.getKey().getSchema(), schema, root)) {
- result.addAll(next.getValue());
+ return new Predicate<Map.Entry<ProfileContext, ?>>() {
+ public boolean apply(Map.Entry<ProfileContext, ?> input) {
+ ProfileContext context = input.getKey();
+ return (context.isOrphanGroup() == isOrphanGroup) && equal(context.getSchema(), targetSchema, root);
}
+ };
+ }
+
+ public Collection<? extends EObject> getZombies(IAdaptable schema) {
+ ImmutableList.Builder<EObject> result = ImmutableList.builder();
+
+ for (Map.Entry<ProfileContext, Collection<EObject>> next : Iterables.filter(zombies.asMap().entrySet(), matches(schema))) {
+ result.addAll(next.getValue());
}
return result.build();
}
- public boolean repair(EPackage schema, IRepairAction repairAction, DiagnosticChain diagnostics, IProgressMonitor monitor) {
- return repairAction.repair(resource, schema, getZombies(schema), diagnostics, monitor);
+ public boolean repair(IAdaptable schema, IRepairAction repairAction, DiagnosticChain diagnostics, IProgressMonitor monitor) {
+ EPackage ePackage = AdapterUtils.adapt(schema, EPackage.class).get(); // Fails if not present
+ return !repairAction.isNull() && repairAction.repair(resource, ePackage, getZombies(schema), diagnostics, monitor);
}
protected EPackage getEPackage(EObject object) {
@@ -205,18 +233,27 @@ public class ZombieStereotypesDescriptor {
return (eclass == null) ? null : eclass.getEPackage();
}
- protected IRepairAction computeSuggestedAction(EPackage schema) {
+ protected IRepairAction computeSuggestedAction(IAdaptable schema) {
// Try options in our preferred order
IRepairAction result = getRepairAction(schema, IRepairAction.Kind.APPLY_LATEST_PROFILE_DEFINITION);
+
if (result.isNull()) {
- // This one is always available
- result = getRepairAction(schema, IRepairAction.Kind.NO_OP);
+ IStereotypeOrphanGroup orphanGroup = AdapterUtils.adapt(schema, IStereotypeOrphanGroup.class, null);
+ if (orphanGroup != null) {
+ // Prefer to just delete orphans
+ result = getRepairAction(schema, IRepairAction.Kind.DELETE);
+ }
+
+ if (result.isNull()) {
+ // This one is always available
+ result = getRepairAction(schema, IRepairAction.Kind.NO_OP);
+ }
}
return result;
}
- protected Map<IRepairAction.Kind, IRepairAction> computeFeasibleRepairActions(EPackage schema) {
+ protected Map<IRepairAction.Kind, IRepairAction> computeFeasibleRepairActions(IAdaptable schema) {
Map<IRepairAction.Kind, IRepairAction> result = Maps.newEnumMap(IRepairAction.Kind.class);
// Always available
@@ -224,15 +261,21 @@ public class ZombieStereotypesDescriptor {
result.put(DeleteAction.INSTANCE.kind(), DeleteAction.INSTANCE);
result.put(CreateMarkersAction.INSTANCE.kind(), CreateMarkersAction.INSTANCE);
- IRepairAction applyProfile;
- Collection<Package> packages = getContextPackages(schema);
- Profile profile = findProfile(schema);
- if (profile == null) {
- applyProfile = new ApplyProfileAction(resource, packages, curry(schema, dynamicProfileSupplier));
+ IStereotypeOrphanGroup orphanGroup = AdapterUtils.adapt(schema, IStereotypeOrphanGroup.class, null);
+ if (orphanGroup != null) {
+ // Easy case. Nothing more to add!
} else {
- applyProfile = new ApplyProfileAction(resource, packages, profile, labelProviderService);
+ EPackage ePackage = AdapterUtils.adapt(schema, EPackage.class, null);
+ IRepairAction applyProfile;
+ Collection<Package> packages = getContextPackages(ePackage);
+ Profile profile = findProfile(ePackage);
+ if (profile == null) {
+ applyProfile = new ApplyProfileAction(resource, packages, curry(ePackage, dynamicProfileSupplier));
+ } else {
+ applyProfile = new ApplyProfileAction(resource, packages, profile, labelProviderService);
+ }
+ result.put(applyProfile.kind(), applyProfile);
}
- result.put(applyProfile.kind(), applyProfile);
return result;
}
@@ -259,21 +302,34 @@ public class ZombieStereotypesDescriptor {
return Suppliers.compose(function, Suppliers.ofInstance(input));
}
- public IRepairAction getSuggestedRepairAction(EPackage schema) {
+ public IRepairAction getSuggestedRepairAction(IAdaptable schema) {
return suggestedActions.get(schema);
}
- public IRepairAction getRepairAction(EPackage schema, IRepairAction.Kind kind) {
+ /**
+ * Obtains a repair action of the specified {@code kind} for a broken {@code schema}, if it is available.
+ *
+ * @param schema
+ * a schema to repair
+ * @param kind
+ * the kind of repair action to obtain
+ * @return the requested {@code kind} of action, or {@link IRepairAction#NULL} if the requested {@code kind} is not available for this {@code schema}
+ */
+ public IRepairAction getRepairAction(IAdaptable schema, IRepairAction.Kind kind) {
Map<IRepairAction.Kind, IRepairAction> available = repairActions.get(schema);
if (available == null) {
available = computeFeasibleRepairActions(schema);
repairActions.put(schema, available);
}
- return available.get(kind);
+ IRepairAction result = available.get(kind);
+ if (result == null) {
+ result = IRepairAction.NULL;
+ }
+ return result;
}
- public List<IRepairAction> getAvailableRepairActions(EPackage schema) {
+ public List<IRepairAction> getAvailableRepairActions(IAdaptable schema) {
Map<IRepairAction.Kind, IRepairAction> actions = repairActions.get(schema);
return (actions == null) ? Collections.<IRepairAction> emptyList() : ImmutableList.copyOf(Iterables.filter(actions.values(), IRepairAction.NOT_NULL));
}
@@ -300,8 +356,8 @@ public class ZombieStereotypesDescriptor {
} else {
Element base = getBaseElement(stereotypeApplication);
if (base == null) {
- // Can't make any inference about package context
- result = new ProfileContext(root, schema);
+ // These are orphans
+ result = new ProfileContext(schema);
} else {
// Find the profile application
result = null;
@@ -453,7 +509,7 @@ public class ZombieStereotypesDescriptor {
// Nested types
//
- static class ProfileContext {
+ static class ProfileContext implements IAdaptable {
private final Package applyingPackage;
@@ -471,6 +527,18 @@ public class ZombieStereotypesDescriptor {
this(profileApplication.getApplyingPackage(), schema);
}
+ /**
+ * Creates a descriptor for a group of orphaned stereotype instances of the given {@code schema}.
+ * An orphan group is distinct from the stereotype instances of the same schema that are attached
+ * to base UML elements, because those can be properly managed by the UML2 API.
+ *
+ * @param schema
+ * the XML/Ecore schema of the orphaned stereotype instances
+ */
+ ProfileContext(EPackage schema) {
+ this(null, schema);
+ }
+
private void init() {
String schemaHash = (schema == null) ? null : schema.getNsURI();
hash = Objects.hashCode(applyingPackage, schemaHash);
@@ -484,6 +552,37 @@ public class ZombieStereotypesDescriptor {
return schema;
}
+ public IAdaptable getSchemaAdaptable() {
+ return isOrphanGroup() ? this : new EPackageAdapter(getSchema());
+ }
+
+ /**
+ * Queries whether I represent a group of orphaned stereotype instances.
+ * An orphan group is distinct from the stereotype instances of the same schema that are attached
+ * to base UML elements, because those can be properly managed by the UML2 API.
+ *
+ * @return whether I represent orphaned stereotype instances of some schema
+ */
+ public boolean isOrphanGroup() {
+ return getApplyingPackage() == null;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ Object result = null;
+
+ if (adapter == EPackage.class) {
+ result = getSchema();
+ } else if ((adapter == IStereotypeOrphanGroup.class) && isOrphanGroup()) {
+ result = new IStereotypeOrphanGroup() {
+ public EPackage getSchema() {
+ return ProfileContext.this.getSchema();
+ }
+ };
+ }
+
+ return result;
+ }
+
@Override
public boolean equals(Object obj) {
boolean result = false;
@@ -505,4 +604,28 @@ public class ZombieStereotypesDescriptor {
return hash;
}
}
+
+ private static final class EPackageAdapter implements IAdaptable {
+ private final EPackage ePackage;
+
+ EPackageAdapter(EPackage ePackage) {
+ super();
+
+ this.ePackage = ePackage;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return (adapter == EPackage.class) ? ePackage : null;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof EPackageAdapter) && (((EPackageAdapter) obj).ePackage == ePackage);
+ }
+
+ @Override
+ public int hashCode() {
+ return ePackage.hashCode();
+ }
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
index df95dbcb284..8d63b45aec1 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/ui/ZombieStereotypesDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2014 CEA, Christian W. Damus, and others.
+ * Copyright (c) 2013, 2015 CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Christian W. Damus - bug 451338
* Christian W. Damus - bug 451557
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - bug 454997
+ * Christian W. Damus - bug 436666
*
*/
package org.eclipse.papyrus.uml.modelrepair.ui;
@@ -25,6 +26,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -59,8 +61,10 @@ import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.jface.window.SameShellProvider;
import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.core.utils.TransactionHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
@@ -68,6 +72,7 @@ import org.eclipse.papyrus.infra.services.markerlistener.dialogs.DiagnosticDialo
import org.eclipse.papyrus.infra.tools.util.UIUtil;
import org.eclipse.papyrus.uml.modelrepair.Activator;
import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.IRepairAction;
+import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.IStereotypeOrphanGroup;
import org.eclipse.papyrus.uml.modelrepair.internal.stereotypes.ZombieStereotypesDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
@@ -217,7 +222,7 @@ public class ZombieStereotypesDialog extends TrayDialog {
missingSchemas = Lists.newArrayList();
for (ZombieStereotypesDescriptor next : zombieDescriptors) {
- for (EPackage schema : next.getZombiePackages()) {
+ for (IAdaptable schema : next.getZombieSchemas()) {
missingSchemas.add(new MissingSchema(schema, next));
}
}
@@ -434,8 +439,14 @@ public class ZombieStereotypesDialog extends TrayDialog {
}
void updateAffected(ViewerCell cell) {
- int count = ((MissingSchema) cell.getElement()).getAffectedCount();
- cell.setText(Integer.toString(count));
+ MissingSchema schema = (MissingSchema) cell.getElement();
+ int count = schema.getAffectedCount();
+
+ String text = Integer.toString(count);
+ if (schema.isOrphanGroup()) {
+ text = NLS.bind("{0} dangling stereotypes", text);
+ }
+ cell.setText(text);
}
void updateSchema(ViewerCell cell) {
@@ -453,16 +464,16 @@ public class ZombieStereotypesDialog extends TrayDialog {
private class MissingSchema {
- private final EPackage ePackage;
+ private final IAdaptable schema;
private final ZombieStereotypesDescriptor descriptor;
private IRepairAction selectedAction;
- MissingSchema(EPackage ePackage, ZombieStereotypesDescriptor descriptor) {
- this.ePackage = ePackage;
+ MissingSchema(IAdaptable schema, ZombieStereotypesDescriptor descriptor) {
+ this.schema = schema;
this.descriptor = descriptor;
- this.selectedAction = descriptor.getSuggestedRepairAction(ePackage);
+ this.selectedAction = descriptor.getSuggestedRepairAction(schema);
}
void initialiseRepairAction(Map<String, Profile> brokenNsProfileMap) {
@@ -477,15 +488,19 @@ public class ZombieStereotypesDialog extends TrayDialog {
}
int getAffectedCount() {
- return descriptor.getZombieCount(getSchema());
+ return descriptor.getZombieCount(schema);
}
EPackage getSchema() {
- return ePackage;
+ return AdapterUtils.adapt(schema, EPackage.class, null);
+ }
+
+ boolean isOrphanGroup() {
+ return AdapterUtils.adapt(schema, IStereotypeOrphanGroup.class).isPresent();
}
List<IRepairAction> getRepairActions() {
- return descriptor.getAvailableRepairActions(ePackage);
+ return descriptor.getAvailableRepairActions(schema);
}
IRepairAction getSelectedRepairAction() {
@@ -497,7 +512,7 @@ public class ZombieStereotypesDialog extends TrayDialog {
}
boolean apply(DiagnosticChain diagnostics, IProgressMonitor monitor) {
- return descriptor.repair(getSchema(), getSelectedRepairAction(), diagnostics, monitor);
+ return descriptor.repair(schema, getSelectedRepairAction(), diagnostics, monitor);
}
}

Back to the top