/** * * @param collection * @param guiElementId * @return */ public static boolean hasDuplicateElementsWithId(Collection<EObject> collection, final QualifiedName guiElementId, IQualifiedNameProvider qualifiedNameProvider) { int count = 0; for (EObject obj : collection) { QualifiedName currentId = qualifiedNameProvider.apply(obj); if (guiElementId.equals(currentId)) { count++; if (count > 1) return true; } } return false; }
@Check(CheckType.NORMAL) public void checkGuiElementUnique(final GuiElement guiElement) { final QualifiedName guiElementId = qualifiedNameProvider.apply(guiElement); if (guiElementId != null) { EObject nsContainer = scopeProvider.getNsContainer(guiElement); List<EObject> nsElements = scopeProvider.getNsElements(nsContainer); if (ValidationCollectionUtil.hasDuplicateElementsWithId(nsElements, guiElementId, qualifiedNameProvider)) { error( "Duplicate page element detected " + guiElement.getClass().getSimpleName() + ": " + guiElementId + "'", null); } } }
@Check(CheckType.NORMAL) public void checkCompositeSimpleLayout(ReferencedXMAComposite composite) { boolean check = composite instanceof XmadslComposite || composite.getXmaComposite().isYnSimpleLayout(); if (!check) { error("Composite '" + qualifiedNameProvider.apply(composite) + "' has no SimpleLayout and can't be modelled", null); } }
@Check(CheckType.NORMAL) public void checkControl(XMAWidgetEventMapping widgetEventMapping) { if (!(widgetEventMapping.getControl() instanceof ISelectFunctionCaller) && !(widgetEventMapping.getControl() instanceof XMATree)) { error( "Type of widget '" + qualifiedNameProvider.apply(widgetEventMapping) + "' does not support event mapping!", PomPackage.eINSTANCE.getXMAWidgetEventMapping_Control()); } }
private boolean isFeatureValid(ComplexType parent, FieldFeature fieldFeature) { PresentableFeature f = fieldFeature.getFeature(); if (f.getAttribute() != null) { Attribute a = f.getAttribute(); if (parent.getAllPresentableFeaturesIncludingSuperType().contains(f) == false) { error("Attribute '" + qualifiedNameProvider.apply(a) + "' is not a member of '" + qualifiedNameProvider.apply(parent) + "'", PomPackage.eINSTANCE.getIField_Feature()); return false; } } Type type = getTypeOfPresentableFeature(f); if (type instanceof ComplexType) { if (fieldFeature.getSubFeature() != null) { return isFeatureValid((ComplexType) type, fieldFeature.getSubFeature()); } error("The feature " + type.getName() + " is complex and therefore must habe a subfeature specified", PomPackage.eINSTANCE.getIField_Feature()); return false; } return true; }
error("Widget '" + qualifiedNameProvider.apply(widgetEventMapping.getControl()) + "' does not support event '" + widgetEventMapping.getEvent().getName() + "'", PomPackage.eINSTANCE.getXMAWidgetEventMapping_Control());