Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-01-25 13:32:41 +0000
committercletavernie2012-01-25 13:32:41 +0000
commitfbae691e02f84b4f4294a9ec6032d344de0cda98 (patch)
tree9a5499c9769f5e5792b13403be42dd90ccac9f31 /plugins/views
parenta11bb5817723ef0a61813767db2f079c0be6cf6a (diff)
downloadorg.eclipse.papyrus-fbae691e02f84b4f4294a9ec6032d344de0cda98.tar.gz
org.eclipse.papyrus-fbae691e02f84b4f4294a9ec6032d344de0cda98.tar.xz
org.eclipse.papyrus-fbae691e02f84b4f4294a9ec6032d344de0cda98.zip
369659: [Property view] The CompoundConstraint crashes when a sub-constraint cannot be resolved
https://bugs.eclipse.org/bugs/show_bug.cgi?id=369659
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java89
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultViewConstraintEngine.java1
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTSection.java2
3 files changed, 2 insertions, 90 deletions
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java
deleted file mode 100644
index 731c78a5691..00000000000
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/ConstraintFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.views.properties.runtime;
-
-import org.eclipse.papyrus.infra.constraints.CompositeConstraint;
-import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
-import org.eclipse.papyrus.infra.constraints.SimpleConstraint;
-import org.eclipse.papyrus.infra.constraints.constraints.CompoundConstraint;
-import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
-import org.eclipse.papyrus.infra.tools.util.ClassLoaderHelper;
-import org.eclipse.papyrus.views.properties.Activator;
-
-/**
- * A Singleton class for creating {@link Constraint}s from a {@link ConstraintDescriptor}
- *
- * @author Camille Letavernier
- */
-public class ConstraintFactory {
-
- private ConstraintFactory() {
-
- }
-
- /**
- * @return the singleton instance
- */
- public static ConstraintFactory getInstance() {
- return instance;
- }
-
- /**
- * Creates a new Constraint from the given ConstraintDescriptor
- *
- * @param model
- * The ConstraintDescriptor describing the Constraint
- * @return
- * The new constraint instance
- */
- public Constraint createFromModel(ConstraintDescriptor model) {
- Constraint constraint = null;
- try {
- if(model instanceof CompositeConstraint) {
- CompoundConstraint cConstraint = new CompoundConstraint();
- cConstraint.setConstraintDescriptor(model);
- for(SimpleConstraint descriptor : ((CompositeConstraint)model).getConstraints()) {
- Constraint subConstraint = loadConstraint(descriptor);
- cConstraint.addConstraint(subConstraint);
- }
-
- constraint = cConstraint;
- } else {
- constraint = loadConstraint((SimpleConstraint)model);
- }
- } catch (Exception ex) {
- Activator.log.error(ex);
- }
- return constraint;
- }
-
- private Constraint loadConstraint(SimpleConstraint model) {
- String className = model.getConstraintType().getConstraintClass();
- Constraint constraint = null;
-
- if(model.getConstraintType().eIsProxy()) {
- Activator.log.error("The constraint URI cannot be resolved. Constraint : " + model.getName() + ". " + model.getConstraintType(), null);
- return null;
- }
-
- constraint = ClassLoaderHelper.newInstance(className, Constraint.class);
- if(constraint == null) {
- Activator.log.warn("Cannot load constraint " + model.getName()); //$NON-NLS-1$
- return null;
- }
- constraint.setConstraintDescriptor(model);
-
- return constraint;
- }
-
- private static ConstraintFactory instance = new ConstraintFactory();
-}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultViewConstraintEngine.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultViewConstraintEngine.java
index 004a0274ff9..372ebcf5f8a 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultViewConstraintEngine.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/runtime/DefaultViewConstraintEngine.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
+import org.eclipse.papyrus.infra.constraints.runtime.ConstraintFactory;
import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.View;
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTSection.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTSection.java
index 150530e0168..fbe3acc496c 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTSection.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/xwt/XWTSection.java
@@ -20,12 +20,12 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.constraints.ConstraintDescriptor;
import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
+import org.eclipse.papyrus.infra.constraints.runtime.ConstraintFactory;
import org.eclipse.papyrus.views.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.Section;
import org.eclipse.papyrus.views.properties.contexts.View;
import org.eclipse.papyrus.views.properties.modelelement.DataSource;
import org.eclipse.papyrus.views.properties.modelelement.DataSourceFactory;
-import org.eclipse.papyrus.views.properties.runtime.ConstraintFactory;
import org.eclipse.papyrus.views.properties.runtime.DisplayEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;

Back to the top