• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ConstraintStatus类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.eclipse.emf.validation.model.ConstraintStatus的典型用法代码示例。如果您正苦于以下问题:Java ConstraintStatus类的具体用法?Java ConstraintStatus怎么用?Java ConstraintStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ConstraintStatus类属于org.eclipse.emf.validation.model包,在下文中一共展示了ConstraintStatus类的35个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createBatchFailureStatus

点赞 3

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Create a constraint failure status with a message appropriate for a batch validation
 * 
 * @param ctx the IValidationContext used for the validation
 * @param attribute the EAttribute whose value failed the constraint
 * @param value the value that failed the constraint
 * @param minValue the minimum allowed value or null
 * @param maxValue the maximum allowed value or null
 * @return IStatus a constraint failure status
 */
private IStatus createBatchFailureStatus(IValidationContext ctx, EObject target, EAttribute attribute, Object value, Object minValue, Object maxValue) {
	String attrName = EMFUtils.getDisplayName(target, attribute);
	String targetName = EMFUtils.getDisplayName(target);
	Collection<EObject> locus = EMFUtils.getConstraintStatusLocus(target, attribute);
	if (minValue == null && maxValue != null) {
		return ConstraintStatus.createStatus(ctx, locus, 
				"The {0} of {1} ({2}) is not less than or equal to the maximum of {3}.",
				new Object[] {attrName, targetName, value, maxValue});
	} else if (minValue != null && maxValue == null) {
		return ConstraintStatus.createStatus(ctx, locus, 
				"The {0} of {1} ({2}) is not greater than or equal to the minimum of {3}.",
				new Object[] {attrName, targetName, value, minValue});
	} else {
		return ConstraintStatus.createStatus(ctx, locus, 
				"The {0} of {1} ({2}) is not between {3} and {4} inclusive.",
				new Object[] {attrName, targetName, value, minValue, maxValue});
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:29,
代码来源:AttributeValueLimitConstraint.java

示例2: createLiveFailureStatus

点赞 3

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Create a constraint failure status with a message appropriate for a live validation
 * 
 * @param ctx the IValidationContext used for the validation
 * @param attribute the EAttribute whose value failed the constraint
 * @param value the value that failed the constraint
 * @param minValue the minimum allowed value or null
 * @param maxValue the maximum allowed value or null
 * @return IStatus a constraint failure status
 */
private IStatus createLiveFailureStatus(IValidationContext ctx, EAttribute attribute, Object value, Object minValue, Object maxValue) {
	if (minValue == null && maxValue != null) {
		return ConstraintStatus.createStatus(ctx, null, 
				"The value must be less than or equal to {0}.",
				new Object[] {maxValue});
	} else if (minValue != null && maxValue == null) {
		return ConstraintStatus.createStatus(ctx, null, 
				"The value must be greater than or equal to {0}.",
				new Object[] {minValue});
	} else {
		return ConstraintStatus.createStatus(ctx, null, 
				"The value must be between {0} and {1} inclusive.",
				new Object[] {minValue, maxValue});
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:26,
代码来源:AttributeValueLimitConstraint.java

示例3: addFailureToOtherDecorations

点赞 3

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private static List<ValidationControlDecoration> addFailureToOtherDecorations(ConstraintStatus failure, EObject target, EStructuralFeature feature, List<ValidationControlDecoration> decorations) {
	Set<EObject> failureLocus = failure.getResultLocus();
	for (EObject locusComponent : failureLocus) {
		if (locusComponent instanceof ObjectFeature) {
			ObjectFeature objectFeature = (ObjectFeature) locusComponent;
			EObject otherTarget = objectFeature.getObject();
			EStructuralFeature otherFeature = objectFeature.getFeature();
			if (otherTarget != target || otherFeature != feature) {
				List<Control> controls = getControls(otherTarget, otherFeature);
				if (controls != null)
					for (Control control : controls) {
						ValidationControlDecoration decoration = getDecoration(control, true);
						decoration.addValidationFailure(failure);
						if (decorations == null) {
							decorations = new ArrayList<ValidationControlDecoration>();
							decorations.add(decoration);
						} else if (!decorations.contains(decoration)) {
							decorations.add(decoration);
						}
					}
			}
		}
	}
	return decorations;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:26,
代码来源:EMFDetailUtils.java

示例4: validate

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
@Override
public IStatus validate(IValidationContext ctx) {
	EObject obj = ctx.getTarget();
	if (obj instanceof ComponentType) {
		ComponentType type = (ComponentType) obj;
		Optional<ConstraintStatus> optError = this.checkConnectors(ctx, type);
		if (optError.isPresent()) {
			return optError.get();
		}
	}
	return ctx.createSuccessStatus();
}
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:13,
代码来源:NoMultipleIncomingConnectorsPerPort.java

示例5: checkConnectors

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkConnectors(IValidationContext ctx, ComponentType type) {
	this.log("checkConnectors", type);
	Optional<ConstraintStatus> error = Optional.empty();
	Set<Port> portsWithMultipleIncomingConnectors = getMultipleIncomingPorts(type);
	if (!portsWithMultipleIncomingConnectors.isEmpty()) {
		error = Optional.of(ConstraintStatus.createStatus(
												ctx, 
												portsWithMultipleIncomingConnectors,
												format("The ports {0} have multiple incoming connectors."), 
												new Object[] { portsWithMultipleIncomingConnectors }));
	}
	return error;
}
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:14,
代码来源:NoMultipleIncomingConnectorsPerPort.java

示例6: validate

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
@Override
public IStatus validate(IValidationContext ctx) {
	EObject obj = ctx.getTarget();
	if (obj instanceof ComponentType) {
		ComponentType type = (ComponentType) obj;
		Optional<ConstraintStatus> optError = this.checkForUnconnectedPorts(ctx, type);
		if (optError.isPresent()) {
			return optError.get();
		}
	}
	return ctx.createSuccessStatus();
}
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:13,
代码来源:AllPortsConnected.java

示例7: checkForUnconnectedPorts

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkForUnconnectedPorts(IValidationContext ctx, ComponentType type) {
this.log("checkForUnconnectedPorts", type);
Optional<ConstraintStatus> error = Optional.empty();
Set<EObject> problemElements = new HashSet<>();
List<Port> unconnectedPorts = calcUnconnectedPorts(type);
if (!unconnectedPorts.isEmpty()) {
	problemElements.add(type);
	error = Optional.of(ConstraintStatus.createStatus(
               ctx,
               problemElements,
               format("The ports {0} are unconnected."),
               new Object[] {unconnectedPorts}));
}
      return error;
  }
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:16,
代码来源:AllPortsConnected.java

示例8: checkComponentTypeName

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkComponentTypeName(IValidationContext ctx, ComponentType type) {
Optional<ConstraintStatus> error = Optional.empty();
this.log("checkComponentTypeName", type);
Set<EObject> problemElements = new HashSet<>();
if (!firstLetterIsUppercase(type.getName())) {
	problemElements.add(type);
	error = Optional.of(ConstraintStatus.createStatus(
               ctx,
               problemElements,
               format("The name of {0} should start upper case."),
               new Object[] {type}));
}
      return error;
  }
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:15,
代码来源:AllNamesValid.java

示例9: checkPortName

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkPortName(IValidationContext ctx, Port port) {
Optional<ConstraintStatus> error = Optional.empty();
this.log("checkPortName", port);
Set<EObject> problemElements = new HashSet<>();
if (!firstLetterIsLowercase(port.getName())) {
	problemElements.add(port);
	error = Optional.of(ConstraintStatus.createStatus(
               ctx,
               problemElements,
               format("The name of {0} should start lower case."),
               new Object[] {port}));
}
      return error;
  }
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:15,
代码来源:AllNamesValid.java

示例10: checkSubcomponentName

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkSubcomponentName(IValidationContext ctx, Subcomponent sc) {
Optional<ConstraintStatus> error = Optional.empty();
this.log("checkSubcomponentName", sc);
Set<EObject> problemElements = new HashSet<>();
if (!firstLetterIsLowercase(sc.getName())) {
	problemElements.add(sc);
	error = Optional.of(ConstraintStatus.createStatus(
               ctx,
               problemElements,
               format("The name of {0} should start lower case."),
               new Object[] {sc}));
}
      return error;
  }
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:15,
代码来源:AllNamesValid.java

示例11: validate

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
@Override
public IStatus validate(IValidationContext ctx) {
	EObject obj = ctx.getTarget();
	if (obj instanceof Connector) {
		 Connector con = ( Connector) obj;
		 Optional<ConstraintStatus> optError = this.checkConnector(ctx, con);
			if (optError.isPresent()) {
				return optError.get();
			}
	}
	return ctx.createSuccessStatus();
}
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:13,
代码来源:ConnectedPortsAreTypeCompatible.java

示例12: checkConnector

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private Optional<ConstraintStatus> checkConnector(IValidationContext ctx, Connector con) {
Optional<ConstraintStatus> error = Optional.empty();
Set<Connector> errors = new HashSet<>();
Port source = ConnectorHelper.getSource(con);
Port target  = ConnectorHelper.getTarget(con);
if (!source.getType().equals(target.getType())) {
	errors.add(con);
	error = Optional.of(ConstraintStatus.createStatus(
               ctx,
               errors,
               format("The connector {0} connects incompatible ports."),
               new Object[] {con}));
}
      return error;
  }
 

开发者ID:awortmann,
项目名称:xmontiarc,
代码行数:16,
代码来源:ConnectedPortsAreTypeCompatible.java

示例13: combinedStatus

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public static IStatus combinedStatus(IValidationContext ctx, EObject target, List<IStatus> statusList) {
	if (statusList.size() == 1) {
		return statusList.get(0);
	} else {
		return ConstraintStatus.createMultiStatus(ctx, 
				"Multiple validation results for {0}", 
				new Object[] {targetName(target)}, 
				statusList);
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:11,
代码来源:JSConstraintUtils.java

示例14: validateFeatureConstraints

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Tests the value of a feature of a target object to determine whether the value violates any constraints
 * 
 * @param ctx the IValidationContext used for the validation
 * @param target the EObject to be validated
 * @param feature the EStructuralFeature whose value is to be validated
 * @param EAnnotation an EMF annotation with JavaScript constraints
 * @param value the Object value of the feature that is to be validated
 * @param failures an accumulator list of failure IStatus objects for any constraint violations
 */
private void validateFeatureConstraints(IValidationContext ctx, EObject target, EStructuralFeature feature,
		EAnnotation annotation, Object value, List<IStatus> failures) {
	for (Map.Entry<String,String> entry : annotation.getDetails()) {
		String constraintName = entry.getKey();
		String expression = entry.getValue();
		if (expression != null && expression.length() > 0) {
			Object result = evaluator.getValue(target, expression, true, value);
			if (result instanceof Boolean && !((Boolean)result).booleanValue()) {
				String message = EMFUtils.getAnnotation(feature, MESSAGE_SOURCE, constraintName);
				boolean batch = ctx.getEventType() == EMFEventType.NULL;
				String template = batch?"The {0} of {1} {2}":"The value {0}";
				int severityCode = IStatus.ERROR;
				if (message == null || message.length() < 1) {
					template = batch?"The {0} of {1} must satisfy {2}":"The value must satisfy {0}";
					message = expression;
				}
				Collection<EObject> locus = EMFUtils.getConstraintStatusLocus(target, feature);
				if (batch) {
					String featureName =  EMFUtils.getDisplayName(target, feature);
					failures.add(ConstraintStatus.createStatus(ctx, locus, severityCode, 1, template, featureName, targetName(target), message));
				} else {
					failures.add(ConstraintStatus.createStatus(ctx, locus, severityCode, 1, template, message));
				}
			}
		}
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:38,
代码来源:JSAnnotationConstraint.java

示例15: validateObjectConstraints

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Tests a target object to determine whether it violates any of the constraints associated with the object's
 * EMF class
 * 
 * @param ctx the IValidationContext used for the validation
 * @param target the EObject to be validated
 * @param eClass the target object's EClass
 * @param constraintNames a list of the names of the constraints to be tested
 * @param failures an accumulator list of failure IStatus objects for any constraint violations
 */
private void validateObjectConstraints(IValidationContext ctx, EObject target, EClass eClass, List<String> constraintNames, List<IStatus> failures) {
	for (String name : constraintNames) {
		String expression = lookupConstraintInfo(eClass, name, CONSTRAINT_SOURCE);
		if (expression != null && expression.length() > 0) {
			Object result = evaluator.getValue(target, expression, false, null);
			if (result instanceof Boolean && !((Boolean)result).booleanValue()) {
				String message = lookupConstraintInfo(eClass, name, MESSAGE_SOURCE);
				int severityCode = IStatus.ERROR;
				if (message == null || message.length() < 1) {
					message = "{0} must satisfy " + expression;
				} else {
					int commaPos = message.indexOf(',');
					if (commaPos > 0) {
						String severity = message.substring(0, commaPos);
						severityCode = getSeverityCode(severity);
						if (severityCode != IStatus.OK) {
							message = message.substring(commaPos + 1);
						} else {
							severityCode = IStatus.ERROR;
						}
					}
				}
				// Record the target EObject and involved structural features in the status object for use in error
				// decorations and explanations
				Collection<EObject> locus = EMFUtils.getConstraintStatusLocus(target, eClass, FormulaInfo.getVariableNames(expression));
				failures.add(ConstraintStatus.createStatus(ctx, locus, severityCode, 1, message, targetName(target)));
			}
		}
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:41,
代码来源:JSAnnotationConstraint.java

示例16: validateAffectedObjectConstraints

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * 
 * @param ctx the IValidationContext used for the validation
 * @param target the EObject to be validated
 * @param eClass the target object's EClass
 * @param feature the EStructuralFeature whose whose new value is being validated
 * @param failures an accumulator list of failure IStatus objects for any constraint violations
 */
private void validateAffectedObjectConstraints(IValidationContext ctx, EObject target, EClass eClass, EStructuralFeature feature, List<IStatus> failures) {
	for (String name : getAffectedConstraints(eClass, feature)) {
		String expression = EMFUtils.getAnnotation(eClass, CONSTRAINT_SOURCE, name);
		if (expression != null && expression.length() > 0) {
			Object result = evaluator.getValue(target, expression, false, null);
			if (result instanceof Boolean && !((Boolean)result).booleanValue()) {
				String message = EMFUtils.getAnnotation(eClass, MESSAGE_SOURCE, name);
				int severityCode = IStatus.ERROR;
				if (message == null || message.length() < 1) {
					message = "{0} must satisfy " + expression;
				} else {
					int commaPos = message.indexOf(',');
					if (commaPos > 0) {
						String severity = message.substring(0, commaPos);
						severityCode = getSeverityCode(severity);
						if (severityCode != IStatus.OK) {
							message = message.substring(commaPos + 1);
						} else {
							severityCode = IStatus.ERROR;
						}
					}
				}
				// Record the target EObject and involved structural features in the status object for use in error
				// decorations and explanations
				Collection<EObject> locus = EMFUtils.getConstraintStatusLocus(target, eClass, FormulaInfo.getVariableNames(expression));
				failures.add(ConstraintStatus.createStatus(ctx, locus, severityCode, 1, message, targetName(target)));
			}
		}
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:39,
代码来源:JSAnnotationConstraint.java

示例17: createWrongTypeFailureStatus

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private IStatus createWrongTypeFailureStatus(IValidationContext ctx, EObject target, EAttribute attribute, Object value) {
	if (ctx.getEventType() == EMFEventType.NULL) {
		String attrName = EMFUtils.getDisplayName(target, attribute);
		String targetName = EMFUtils.getDisplayName(target);
		Collection<EObject> locus = EMFUtils.getConstraintStatusLocus(target, attribute);
		return ConstraintStatus.createStatus(ctx, locus, 
				"The {0} of {1} ({2}) has a type inconsistent with the attribute limits.",
				new Object[] {attrName, targetName, value});
	} else {
		return ConstraintStatus.createStatus(ctx, null, 
				"The value has a type inconsistent with the attribute limits.",
				new Object[] {});
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:15,
代码来源:AttributeValueLimitConstraint.java

示例18: createBatchFailureStatus

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Create a constraint failure status with a message appropriate for a batch validation
 * 
 * @param ctx the IValidationContext used for the validation
 * @param attribute the EAttribute whose value failed the constraint
 * @param value the value that failed the constraint
 * @param charlen the maximum number of characters
 * @return IStatus a constraint failure status
 */
private IStatus createBatchFailureStatus(IValidationContext ctx, EObject target, EAttribute attribute, String value, int charlen) {
	String attrName = EMFUtils.getDisplayName(target, attribute);
	String targetName = EMFUtils.getDisplayName(target);
	if (value.length() > MAXIMUM_DISPLAY_LENGTH) {
		value = value.substring(0, MAXIMUM_DISPLAY_LENGTH) + "...";
	}
	return ConstraintStatus.createStatus(ctx, EMFUtils.getConstraintStatusLocus(target, attribute), 
			"The {0} of {1} ({2}) exceeds {3} characters.",
			new Object[] {attrName, targetName, value, charlen});
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:20,
代码来源:AttributeValueLengthConstraint.java

示例19: getStatusLeaves

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private static List<ConstraintStatus> getStatusLeaves(IStatus status, int severity) {
	List<ConstraintStatus> leaves = new ArrayList<ConstraintStatus>();
	if (status.isMultiStatus()) {
		for (IStatus child : status.getChildren()) {
			if (child.getSeverity() == severity) {
				leaves.addAll(getStatusLeaves(child, severity));
			}
		}
	} else {
		leaves.add((ConstraintStatus) status);
	}
	return leaves;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:14,
代码来源:EMFDetailUtils.java

示例20: hasEquivalentValidationFailure

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private static boolean hasEquivalentValidationFailure(List<ConstraintStatus> failures, ConstraintStatus failure) {
	for (ConstraintStatus status : failures) {
		if (equivalentValidationFailures(status, failure)) {
			return true;
		}
	}
	return false;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:9,
代码来源:EMFDetailUtils.java

示例21: removeFailureFromOtherDecorations

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private static List<ValidationControlDecoration> removeFailureFromOtherDecorations(ConstraintStatus failure, EObject target, EStructuralFeature feature, List<ValidationControlDecoration> decorations) {
	Set<EObject> failureLocus = failure.getResultLocus();
	for (EObject locusComponent : failureLocus) {
		if (locusComponent instanceof ObjectFeature) {
			ObjectFeature objectFeature = (ObjectFeature) locusComponent;
			EObject otherTarget = objectFeature.getObject();
			EStructuralFeature otherFeature = objectFeature.getFeature();
			if (otherTarget != target || otherFeature != feature) {
				List<Control> controls = getControls(otherTarget, otherFeature);
				if (controls != null)
					for (Control control : controls) {
						ValidationControlDecoration decoration = getDecoration(control, false);
						if (decoration == null) {
							continue;
						}
						decoration.removeValidationFailure(failure);
						if (decorations == null) {
							decorations = new ArrayList<ValidationControlDecoration>();
							decorations.add(decoration);
						} else if (!decorations.contains(decoration)) {
							decorations.add(decoration);
						}
					}
			}
		}
	}
	return decorations;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:29,
代码来源:EMFDetailUtils.java

示例22: addValidationFailure

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public void addValidationFailure(ConstraintStatus failure) {
	if (validationFailures == null) {
		validationFailures = new ArrayList<ConstraintStatus>();
		validationFailures.add(failure);
	} else if (!hasValidationFailure(failure)) {
		validationFailures.add(failure);
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:9,
代码来源:EMFDetailUtils.java

示例23: removeValidationFailure

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public void removeValidationFailure(ConstraintStatus failure) {
	if (validationFailures != null) {
		for (ListIterator<ConstraintStatus> iter = validationFailures.listIterator(); iter.hasNext();) {
			ConstraintStatus status = (ConstraintStatus) iter.next();
			if (failure.getMessage().equals(status.getMessage()) && equivalentFailureLoci(failure.getResultLocus(), status.getResultLocus())) {
				iter.remove();
				break;
			}
		}
	}
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:12,
代码来源:EMFDetailUtils.java

示例24: hasValidationFailure

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public boolean hasValidationFailure(ConstraintStatus failure) {
	if (validationFailures == null) {
		return false;
	}
	for (ConstraintStatus status : validationFailures) {
		if (equivalentValidationFailures(status, failure))
			return true;
	}
	return false;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:11,
代码来源:EMFDetailUtils.java

示例25: determineSeverity

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public int determineSeverity() {
	int highest = 0;
	if (validationFailures != null) {
		for (ConstraintStatus status : validationFailures) {
			int severity = status.getSeverity();
			if (severity > highest) {
				highest = severity;
			}
		}
	}
	return highest;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:13,
代码来源:EMFDetailUtils.java

示例26: determineDescription

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private String determineDescription() {
	StringBuilder builder = new StringBuilder();
	int i = 0;
	for (ConstraintStatus status : validationFailures) {
		if (i++ > 0) {
			builder.append('\n');
		}
		builder.append(status.getMessage());
	}
	return builder.toString();
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:12,
代码来源:EMFDetailUtils.java

示例27: validateInstanceInEditor

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * @generated NOT
 */
@Override
public IStatus validateInstanceInEditor(IValidationContext context) throws MMINTException {

	MMINTException.mustBeInstance(this);

	//TODO MMINT[MAVO] Extend this to the type level
	MAVOTruthValue validates = MAVOMIDConstraintChecker.checkMAVOModelConstraint(this, this.getConstraint());
	IStatus status;
	if (validates == MAVOTruthValue.TRUE) {
		status = context.createSuccessStatus();
	}
	else {
		ConstraintStatus failureStatus = (ConstraintStatus) context.createFailureStatus(
			"",
			this.getName(),
			this.getMetatype().getName());
		status = (validates == MAVOTruthValue.MAYBE) ? new ConstraintStatus(
			failureStatus.getConstraint(),
			this,
			IStatus.WARNING,
			200,
			"The MAVO constraint evaluated to Maybe",
			failureStatus.getResultLocus()) : failureStatus;
	}

	return status;
}
 

开发者ID:adisandro,
项目名称:MMINT,
代码行数:31,
代码来源:MAVOModelImpl.java

示例28: createFailureStatus

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
@Override
protected IStatus createFailureStatus(IValidationContext ctx, EObject target) {
    Collection<IStatus> failureStatus = ctx.getResultLocus().stream().filter(Extend.class::isInstance)
            .map(e -> super.createFailureStatus(ctx, e)).collect(Collectors.toSet());
    return ConstraintStatus.createMultiStatus(ctx, failureStatus);
}
 

开发者ID:Cooperate-Project,
项目名称:CooperateModelingEnvironment,
代码行数:7,
代码来源:UseCaseDiagramConditionAvailableForMultipleExtensions.java

示例29: createFailureStatus

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
@Override
protected IStatus createFailureStatus(IValidationContext ctx, EObject target) {
    Collection<IStatus> statuses = ctx.getResultLocus().stream().filter(ep -> ep != target)
            .map(ep -> super.createFailureStatus(ctx, ep)).collect(Collectors.toList());
    return ConstraintStatus.createMultiStatus(ctx, statuses);
}
 

开发者ID:Cooperate-Project,
项目名称:CooperateModelingEnvironment,
代码行数:7,
代码来源:UseCaseDiagramExtensionPointIsVisible.java

示例30: validate

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Validates an object in the given context to ensure that attribute values
 * conform to any minimum and/or maximum limit restrictions
 * 
 * @param ctx the IValidationContext used for the validation
 */
@Override
public IStatus validate(IValidationContext ctx) {
	EObject target = ctx.getTarget();
	EMFEventType eventType = ctx.getEventType();
	try {
		// In the case of batch mode.
		if (eventType == EMFEventType.NULL) {
			EClass eClass = target.eClass();
			List<IStatus> failureList = null;
			for (EAttribute attribute : eClass.getEAllAttributes()) {
				IStatus failure = validateAttributeLimit(ctx, target, attribute, target.eGet(attribute));
				if (failure != null) {
					if (failureList == null) {
						failureList = new ArrayList<IStatus>();
					}
					failureList.add(failure);
				}
			}
			if (failureList != null) {
				if (failureList.size() == 1) {
					return failureList.get(0);
				} else {
					return ConstraintStatus.createMultiStatus(ctx, 
							"Attribute limit violations for {0}", 
							new Object[] {target}, 
							failureList);
				}
			}
		} else {
			// In the case of live mode
			EStructuralFeature feature = ctx.getFeature();
			if (feature instanceof EAttribute) {
				IStatus status =  validateAttributeLimit(ctx, target, (EAttribute)feature, ctx.getFeatureNewValue());
				if (status != null) {
					return status;
				}
			}
		}
	} catch (Exception e) {
		LogUtil.error("Run time exception while checking the attribute value limit constraint", e);
	}
	return ctx.createSuccessStatus();
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:50,
代码来源:AttributeValueLimitConstraint.java

示例31: validate

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Validates an object in the given context to ensure that attribute value
 * strings do not exceed a maximum number of characters
 * 
 * @param ctx the IValidationContext used for the validation
 */
@Override
public IStatus validate(IValidationContext ctx) {
	EObject target = ctx.getTarget();
	EMFEventType eventType = ctx.getEventType();
	try {
		// In the case of batch mode.
		if (eventType == EMFEventType.NULL) {
			EClass eClass = target.eClass();
			List<IStatus> failureList = null;
			for (EAttribute attribute : eClass.getEAllAttributes()) {
				IStatus failure = validateLength(ctx, target, attribute, target.eGet(attribute));
				if (failure != null) {
					if (failureList == null) {
						failureList = new ArrayList<IStatus>();
					}
					failureList.add(failure);
				}
			}
			if (failureList != null) {
				if (failureList.size() == 1) {
					return failureList.get(0);
				} else {
					return ConstraintStatus.createMultiStatus(ctx, 
							"Attribute value string length violations for {0}", 
							new Object[] {target}, 
							failureList);
				}
			}
		} else {
			// In the case of live mode
			EStructuralFeature feature = ctx.getFeature();
			if (feature instanceof EAttribute) {
				IStatus status =  validateLength(ctx, target, (EAttribute)feature, ctx.getFeatureNewValue());
				if (status != null) {
					return status;
				}
			}
		}
	} catch (Exception e) {
		LogUtil.error("Run time exception while checking the attribute value length constraint", e);
	}
	return ctx.createSuccessStatus();
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:50,
代码来源:AttributeValueLengthConstraint.java

示例32: equivalentValidationFailures

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
private static boolean equivalentValidationFailures(ConstraintStatus failure1, ConstraintStatus failure2) {
	return (failure1.getMessage().equals(failure2.getMessage()) && equivalentFailureLoci(failure1.getResultLocus(), failure2.getResultLocus()));
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:4,
代码来源:EMFDetailUtils.java

示例33: getValidationFailures

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public List<ConstraintStatus> getValidationFailures() {
	if (validationFailures == null) {
		return Collections.emptyList();
	}
	return validationFailures;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:7,
代码来源:EMFDetailUtils.java

示例34: setValidationFailures

点赞 2

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
public void setValidationFailures(List<ConstraintStatus> validationFailures) {
	this.validationFailures = validationFailures;
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:4,
代码来源:EMFDetailUtils.java

示例35: createLiveFailureStatus

点赞 1

import org.eclipse.emf.validation.model.ConstraintStatus; //导入依赖的package包/类
/**
 * Create a constraint failure status with a message appropriate for a live validation
 * 
 * @param ctx the IValidationContext used for the validation
 * @param attribute the EAttribute whose value failed the constraint
 * @param value the value that failed the constraint
 * @param charlen the maximum number of characters
 * @return IStatus a constraint failure status
 */
private IStatus createLiveFailureStatus(IValidationContext ctx, EAttribute attribute, String value, int charlen) {
		return ConstraintStatus.createStatus(ctx, null, 
				"The value must be a maximum of {0} characters.",
				new Object[] {charlen});
}
 

开发者ID:nasa,
项目名称:OpenSPIFe,
代码行数:15,
代码来源:AttributeValueLengthConstraint.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)