public static XSDConstrainingFacet addOrSetFacetValue( XSDSimpleTypeDefinition type, String facetName, FacetValue fv) { XSDConstrainingFacet workFacet = fv.facet; // do we need to add? if (fv.facet == null || fv.facet.getContainer() != type) { // need to add to this type: boolean inclusiveness = false; if (fv.value instanceof InclusiveInteger) { inclusiveness = ((InclusiveInteger) fv.value).isInclusive; } // endif // remove any facets with opposite inclusiveness: if (facetName == FAKE_FACET_MAXIMUM || facetName == FAKE_FACET_MINIMUM) { // go ahead and remove: removeFacet(type, facetName); } // endif -- using fake facets? workFacet = createFacet(facetName, inclusiveness); try { ModelerCore.getModelEditor().addValue(type, workFacet, type.getFacetContents()); } catch (ModelerCoreException err) { ModelerXsdUiConstants.Util.log(err); } // endtry } // endif // set main value: if (!FormUtil.safeEquals(fv.value, getMainFacetValue(workFacet))) { // only set if changed: workFacet = setMainFacetValue(type, workFacet, fv.value); // in case this is a bounds facet and we swapped them out: fv.facet = workFacet; } // endif // set description: String existingDesc = ModelObjectUtilities.getDescription(workFacet); if (fv.description != null) { // new not null: if (!fv.description.equals(existingDesc)) { // description changed to a nonnull value: ModelObjectUtilities.setDescription(workFacet, fv.description, type); } // endif -- different } else if (existingDesc != null && existingDesc.length() > 0) { // new null, old not null: ModelObjectUtilities.setDescription(workFacet, " ", type); // $NON-NLS-1$ } // endif // Lastly, set fixed if applicable: setFixed(workFacet, fv.isFixedLocal); return workFacet; }