Commit 6b867a01 authored by Martti Käärik's avatar Martti Käärik
Browse files

Added ConstraintImplementation guards.

parent 8a202d01
Loading
Loading
Loading
Loading
+7 −1
Changes for plugins/org.etsi.mts.tdl.model/src/org/etsi/mts/tdl/Validator.java: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import org.eclipse.ocl.pivot.resource.CSResource;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.ocl.pivot.validation.ValidationRegistryAdapter;
import org.eclipse.ocl.xtext.completeocl.validation.CompleteOCLEObjectValidator;
import org.eclipse.ocl.xtext.oclinecore.validation.OCLinEcoreEObjectValidator;
//import org.eclipse.ocl.xtext.oclinecore.validation.OCLinEcoreEObjectValidator;
import org.eclipse.xtext.validation.CompositeEValidator;
import org.eclipse.xtext.validation.EValidatorRegistrar;
import org.etsi.mts.tdl.extendedconfigurations.ExtendedConfigurationsPackage;
@@ -41,6 +41,12 @@ import org.osgi.framework.BundleContext;
public class Validator {
	static CompleteOCLEObjectValidator validator;
	public static void reload() {
		if (!ConstraintImplementation.isInterpreted()) {
			// The registry holds the generated validators: replacing them with the interpreter would
			// switch implementations behind the user's back. Nothing here needs recovering either,
			// the compiled constraints do not depend on the interpreter's environment.
			return;
		}
		Validator.removeValidator(tdlPackage.eINSTANCE);
		Validator.removeValidator(StructuredObjectivesPackage.eINSTANCE);
		Validator.removeValidator(ExtendedConfigurationsPackage.eINSTANCE);
+7 −0
Changes for plugins/org.etsi.mts.tdl.rt.ui/src/org/etsi/mts/tdl/tools/rt/ui/ToggleHandler.java: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import org.eclipse.emf.ecore.EValidator;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.etsi.mts.tdl.ConstraintImplementation;
import org.etsi.mts.tdl.Validator;
import org.etsi.mts.tdl.tdlPackage;
import org.etsi.mts.tdl.structuredobjectives.StructuredObjectivesPackage;
@@ -46,6 +47,9 @@ public class ToggleHandler implements IStartup {
	}
    
    static void enablePlugin() {
        if (!ConstraintImplementation.isInterpreted()) {
            return; // the generated validators are registered; the toggle only concerns the interpreter
        }
		Bundle bundle = Platform.getBundle("org.etsi.mts.tdl.model");
		BundleContext context = bundle.getBundleContext();
		Validator.registerValidator("model/tdl-constraints.ocl", tdlPackage.eINSTANCE, context);
@@ -53,6 +57,9 @@ public class ToggleHandler implements IStartup {
    }
    
    static void disablePlugin() {
        if (!ConstraintImplementation.isInterpreted()) {
            return; // removing the registry entries would remove the generated validators, i.e. all constraint checking
        }
//		EValidator.Registry.INSTANCE.remove(tdlPackage.eINSTANCE);
		Validator.removeValidator(tdlPackage.eINSTANCE);
		Validator.removeValidator(StructuredObjectivesPackage.eINSTANCE);
+5 −1
Changes for plugins/org.etsi.mts.tdl.rt.ui/src/org/etsi/mts/tdl/tools/rt/ui/handlers/ReloadValidationHandler.java: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.ui.IWorkbenchWindow;
import org.etsi.mts.tdl.ConstraintImplementation;
import org.etsi.mts.tdl.Validator;
import org.etsi.mts.tdl.tdlPackage;
import org.osgi.framework.Bundle;
@@ -39,6 +40,9 @@ public class ReloadValidationHandler extends AbstractHandler {
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
		if (!ConstraintImplementation.isInterpreted()) {
			return null; // the generated validators are in the registry; there is no OCL document to reload
		}
		EValidator.Registry.INSTANCE.remove(tdlPackage.eINSTANCE);
		Bundle bundle = Platform.getBundle("org.etsi.mts.tdl.model");
		BundleContext context = bundle.getBundleContext();
@@ -52,7 +56,7 @@ public class ReloadValidationHandler extends AbstractHandler {

	@Override
	public boolean isEnabled() {
		return true;
		return ConstraintImplementation.isInterpreted();
	}

}