Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2012-07-31 11:29:13 -0400
committerptessier2012-07-31 11:29:13 -0400
commitde598d06b564755b2ea5ac88dc4e418f5d24e2f9 (patch)
tree7ca3b72983b51374e1a9dffa8d84cbde1e677c8c /plugins/infra
parentc5524f547d4a333e0ea804b7e3def60106afda4a (diff)
downloadorg.eclipse.papyrus-de598d06b564755b2ea5ac88dc4e418f5d24e2f9.tar.gz
org.eclipse.papyrus-de598d06b564755b2ea5ac88dc4e418f5d24e2f9.tar.xz
org.eclipse.papyrus-de598d06b564755b2ea5ac88dc4e418f5d24e2f9.zip
330349: [All diagrams]Applying a profile with a Property of an undefined Type corrupts the model and makes save action crash
https://bugs.eclipse.org/bugs/show_bug.cgi?id=330349
Diffstat (limited to 'plugins/infra')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java41
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java41
2 files changed, 60 insertions, 22 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
index 72e165ad098..a59ba45109e 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/SelectAndValidateModelCommand.java
@@ -23,13 +23,37 @@ import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.papyrus.infra.services.validation.ValidationTool;
import org.eclipse.ui.dialogs.PreferencesUtil;
-
+/**
+ * this command is used to open the list of constraint to compute on the root model
+ *
+ */
public class SelectAndValidateModelCommand extends AbstractValidateCommand {
+ /**
+ *
+ * Constructor.
+ *
+ * @param selectedElement
+ */
public SelectAndValidateModelCommand(EObject selectedElement) {
- super("Validate subtree", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
+ super("Validate subtree", TransactionUtil.getEditingDomain(selectedElement), getTopOwner(selectedElement));
+ }
+
+ /**
+ * get the root element
+ * @param selectedElement
+ * @return the root element
+ */
+ private static EObject getTopOwner(EObject selectedElement){
+ EObject selectedObject = selectedElement;
+ while(selectedObject.eContainer() != null) {
+ selectedObject = selectedObject.eContainer();
+ }
+ return selectedObject;
+
}
/**
@@ -48,16 +72,11 @@ public class SelectAndValidateModelCommand extends AbstractValidateCommand {
int result = dialog.open();
if(result == IDialogConstants.OK_ID) {
- EObject selectedObject = selectedElement;
- // replace selection by model instead of current selection
- while(selectedObject.eContainer() != null) {
- selectedObject = selectedObject.eContainer();
- }
- Resource resource = getResource();
- if ((resource != null) && (eclipseResourcesUtil != null)) {
- eclipseResourcesUtil.deleteMarkers(getResource());
+ if( selectedElement!=null){
+ ValidationTool vt = new ValidationTool(selectedElement);
+ vt.deleteSubMarkers();
+ runValidation(selectedElement);
}
- runValidation(selectedObject);
}
return null;
}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
index 2cc0815a246..2633298a6fe 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.validation/src/org/eclipse/papyrus/infra/services/validation/commands/ValidateModelCommand.java
@@ -18,33 +18,52 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.papyrus.infra.services.validation.ValidationTool;
-
+/**
+ * use to validate the model from a selected element in the model
+ *
+ */
public class ValidateModelCommand extends AbstractValidateCommand {
+ /**
+ *
+ * Constructor.
+ *
+ * @param selectedElement
+ */
public ValidateModelCommand(EObject selectedElement) {
- super("Validate model", TransactionUtil.getEditingDomain(selectedElement), selectedElement);
+ super("Validate model", TransactionUtil.getEditingDomain(selectedElement), getTopOwner(selectedElement));
}
+
/**
- * {@inheritDoc}
+ * get the root element
+ * @param selectedElement
+ * @return the root element
*/
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ private static EObject getTopOwner(EObject selectedElement){
EObject selectedObject = selectedElement;
- // replace selection by model instead of current selection
while(selectedObject.eContainer() != null) {
selectedObject = selectedObject.eContainer();
}
- Resource resource = getResource();
- if ((resource != null) && (eclipseResourcesUtil != null)) {
- eclipseResourcesUtil.deleteMarkers(getResource());
+ return selectedObject;
+
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // replace selection by model instead of current selection
+ if( selectedElement!=null){
+ ValidationTool vt = new ValidationTool(selectedElement);
+ vt.deleteSubMarkers();
+ runValidation(selectedElement);
}
- runValidation(selectedObject);
return null;
}

Back to the top