Skip to content
Snippets Groups Projects
Commit 945ea863 authored by Alberto Debiasi's avatar Alberto Debiasi
Browse files

Update constrains on OpaqueExpr and OpaqueBehav, add header.

Change-Id: I8c0d0bf6b8a4ef0b353f9c94e9e22694315c8027
parent 44c1088e
No related branches found
No related tags found
No related merge requests found
Showing
with 220 additions and 110 deletions
......@@ -14,16 +14,16 @@ public class PreferenceProperties {
/** The diagram in view. */
public static String DIAGRAM_IN_VIEW="DiagramInView";
public static final String DIAGRAM_IN_VIEW="DiagramInView";
/** The palettes in view. */
public static String PALETTES_IN_VIEW="PaletteInView";
public static final String PALETTES_IN_VIEW="PaletteInView";
/** Supported Diagrams. */
public static String SUPPORTED_DIAGRAM="SupportedDiagram";
public static final String SUPPORTED_DIAGRAM="SupportedDiagram";
/** State Machines. */
public static String STATE_MACHINE="StateMachine";
public static final String STATE_MACHINE="StateMachine";
public static final String PORT_DIRECTIONS = "PortDirections";
......@@ -31,8 +31,8 @@ public class PreferenceProperties {
public static final String PROPERTY_TYPE = "PropertyType";
public static final String CLEANC = "CleanC";
public static final String OPAQUE_BEHAV = "OpaqueBehavior";
public static final String OCRA = "Ocra";
public static final String OPAQUE_EXPR = "OpaqueExpression";
}
......@@ -48,8 +48,8 @@ public class ConstraintPreferenceInitializer extends AbstractPreferenceInitializ
store.setDefault(PreferenceProperties.PORT_TYPES, true);
store.setDefault(PreferenceProperties.STATE_MACHINE, true);
store.setDefault(PreferenceProperties.PROPERTY_TYPE, true);
store.setDefault(PreferenceProperties.CLEANC, true);
store.setDefault(PreferenceProperties.OCRA, true);
store.setDefault(PreferenceProperties.OPAQUE_BEHAV, true);
store.setDefault(PreferenceProperties.OPAQUE_EXPR, true);
}
}
......@@ -19,6 +19,7 @@ import java.util.ArrayList;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.polarsys.chess.core.constraint.ConstraintList;
......@@ -80,8 +81,8 @@ public class ConstraintPreferencePage extends FieldEditorPreferencePage implemen
addField(PreferenceProperties.PORT_DIRECTIONS, "Flow ports on ends of connection must have compatible directions");
addField(PreferenceProperties.PORT_TYPES, "Flow ports on the ends of connection do not have compatible types");
addField(PreferenceProperties.PROPERTY_TYPE, "Properties must have valid types");
addField(PreferenceProperties.CLEANC, "Opaque Behaviors must be defined in the CleanC language");
addField(PreferenceProperties.OCRA, "Opaque Expresions must be defined in the OCRA language");
addField(PreferenceProperties.OPAQUE_BEHAV, "Opaque Behaviors must be defined using the proper language");
addField(PreferenceProperties.OPAQUE_EXPR, "Opaque Expressions must be defined using the proper language");
}
private void addField(String name, String text) {
......
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.validator.constraints;
import java.util.List;
......@@ -17,25 +27,6 @@ public class DiagramChecker extends AbstractModelConstraint {
@Override
public IStatus validate(IValidationContext ctx) {
//org.eclipse.papyrus.infra.gmfdiag.css.notation.CSSDiagramImpl
System.out.println("DiagramChecker: "+ctx.getTarget());;
for(String regName : EPackage.Registry.INSTANCE.keySet()){
//System.out.println("regName: "+regName);
}
if(ctx.getTarget() instanceof Port){
System.out.println("Port FOUND!!!");
}
if(ctx.getTarget() instanceof Diagram){
System.out.println("DIAGRAM FOUND!!!");
}
IStatus success = ctx.createSuccessStatus();
......
......@@ -40,8 +40,6 @@ public class FV_05 extends AbstractModelConstraint {
@Override
public IStatus validate(IValidationContext ctx) {
System.out.println("FV_05");
IStatus success = ctx.createSuccessStatus();
Port port = (Port) ctx.getTarget();
......
/*
-----------------------------------------------------------------------
-- CHESS Live/Batch Validator plugin --
-- --
-- Copyright (C) 2011-2012 --
-- University of Padova, ITALY --
-- --
-- Author: Nicholas Pacini --
-- --
-- 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-v20.html --
-----------------------------------------------------------------------
*/
package org.polarsys.chess.validator.constraints;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.IValidationContext;
import org.eclipse.uml2.uml.OpaqueBehavior;
import org.eclipse.uml2.uml.OpaqueExpression;
import org.eclipse.uml2.uml.Property;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
import org.polarsys.chess.core.constraint.PreferenceProperties;
public class OcraChecker extends AbstractModelConstraint {
private static String supportedLanguge = "OCRA";
/*
* (non-Javadoc)
*
* @see
* org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.
* emf.validation.IValidationContext)
*/
@Override
public IStatus validate(IValidationContext ctx) {
OpaqueExpression opaqueExpression = (OpaqueExpression) ctx.getTarget();
String thisElement = opaqueExpression.getName();
IStatus success = ctx.createSuccessStatus();
Boolean checkOpaqueExpression = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.OCRA);
if (checkOpaqueExpression) {
if(!opaqueExpression.getLanguages().contains(supportedLanguge)){
String errorMsg = "The expression is not defined with the language '"+supportedLanguge+"'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
}
}
return success;
}
}
/*
-----------------------------------------------------------------------
-- CHESS Live/Batch Validator plugin --
-- --
-- Copyright (C) 2011-2012 --
-- University of Padova, ITALY --
-- --
-- Author: Nicholas Pacini --
-- --
-- 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-v20.html --
-----------------------------------------------------------------------
*/
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.validator.constraints;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.IValidationContext;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.OpaqueBehavior;
import org.eclipse.uml2.uml.Property;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
import org.eclipse.uml2.uml.Transition;
import org.polarsys.chess.core.constraint.PreferenceProperties;
public class OpaqueBehavChecker extends AbstractModelConstraint {
public class CleanCChecker extends AbstractModelConstraint {
private static final String CLEAN_C_LANGUAGE = "CleanC";
private static String supportedLanguge = "CleanC";
/*
* (non-Javadoc)
*
......@@ -43,21 +37,45 @@ public class CleanCChecker extends AbstractModelConstraint {
String thisElement = opaqueBehavior.getName();
IStatus success = ctx.createSuccessStatus();
Boolean checkOpaqueBehavior = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.CLEANC);
.getBoolean(PreferenceProperties.OPAQUE_BEHAV);
if (checkOpaqueBehavior) {
if(!opaqueBehavior.getLanguages().contains(supportedLanguge)){
String errorMsg = "The behaviour is not defined with the language '"+supportedLanguge+"'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
if (belongsToTransitionEffect(opaqueBehavior)) {
if (!opaqueBehavior.getLanguages().contains(CLEAN_C_LANGUAGE)) {
String errorMsg = "The behaviour is not defined with the language '" + CLEAN_C_LANGUAGE + "'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
} else {
return success;
}
} if (belongsToClass(opaqueBehavior)) {
if (!opaqueBehavior.getLanguages().contains(CLEAN_C_LANGUAGE)) {
String errorMsg = "The behaviour is not defined with the language '" + CLEAN_C_LANGUAGE + "'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
} else {
return success;
}
}else {
String errorMsg = "The behaviour with this owner is not supported.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
}
}
return success;
}
private boolean belongsToClass(OpaqueBehavior expr) {
Element owner = expr.getOwner();
return (owner instanceof org.eclipse.uml2.uml.Class);
}
private boolean belongsToTransitionEffect(OpaqueBehavior expr) {
Element owner = expr.getOwner();
return (owner instanceof Transition);
}
}
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.validator.constraints;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.validation.AbstractModelConstraint;
import org.eclipse.emf.validation.IValidationContext;
import org.eclipse.uml2.uml.Constraint;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.OpaqueExpression;
import org.eclipse.uml2.uml.Transition;
import org.polarsys.chess.contracts.profile.chesscontract.util.EntityUtil;
import org.polarsys.chess.core.constraint.PreferenceProperties;
public class OpaqueExprChecker extends AbstractModelConstraint {
private static final String CLEAN_C_LANGUAGE = "CleanC";
private static final String OCRA_LANGUAGE = "OCRA";
/*
* (non-Javadoc)
*
* @see
* org.eclipse.emf.validation.AbstractModelConstraint#validate(org.eclipse.
* emf.validation.IValidationContext)
*/
@Override
public IStatus validate(IValidationContext ctx) {
OpaqueExpression opaqueExpression = (OpaqueExpression) ctx.getTarget();
String thisElement = opaqueExpression.getName();
IStatus success = ctx.createSuccessStatus();
Boolean checkOpaqueExpression = org.polarsys.chess.core.Activator.getDefault().getPreferenceStore()
.getBoolean(PreferenceProperties.OPAQUE_EXPR);
if (checkOpaqueExpression) {
if (belongsToTransitionGuard(opaqueExpression)) {
if (!opaqueExpression.getLanguages().contains(CLEAN_C_LANGUAGE)) {
String errorMsg = "The transition guard must be defined with the language '" + CLEAN_C_LANGUAGE
+ "'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
} else {
return success;
}
} else if (belongsToDelegationConstraints(opaqueExpression)) {
if (!opaqueExpression.getLanguages().contains(OCRA_LANGUAGE)) {
String errorMsg = "The delegation constraint must be defined with the language '" + OCRA_LANGUAGE
+ "'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
} else {
return success;
}
} else if (belongsToFormalProperty(opaqueExpression)) {
if (!opaqueExpression.getLanguages().contains(OCRA_LANGUAGE)) {
String errorMsg = "The formal property must be defined with the language '" + OCRA_LANGUAGE + "'.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
} else {
return success;
}
} else {
String errorMsg = "The expression with this owner is not supported.";
IStatus failure = ctx.createFailureStatus(thisElement, errorMsg);
return failure;
}
}
return success;
}
private boolean belongsToFormalProperty(OpaqueExpression expr) {
Element owner = expr.getOwner();
return EntityUtil.getInstance().isFormalProperty(owner);
}
private boolean belongsToDelegationConstraints(OpaqueExpression expr) {
Element owner = expr.getOwner();
return EntityUtil.getInstance().isDelegationConstraint(owner);
}
private boolean belongsToTransitionGuard(OpaqueExpression expr) {
Element owner = expr.getOwner();
return (owner instanceof Constraint) && (owner.getOwner() instanceof Transition);
}
}
/*
-----------------------------------------------------------------------
-- CHESS Live/Batch Validator plugin --
-- --
-- Copyright (C) 2011-2012 --
-- University of Padova, ITALY --
-- --
-- Author: Nicholas Pacini --
-- --
-- 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-v20.html --
-----------------------------------------------------------------------
*/
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.validator.constraints;
......
/*******************************************************************************
* Copyright (C) 2020 Fondazione Bruno Kessler.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Alberto Debiasi - initial API and implementation
******************************************************************************/
package org.polarsys.chess.validator.constraints;
import java.util.List;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment