예제 #1
0
  public static FacetValue getEnterpriseFacetValue(final XSDSimpleTypeDefinition startingType) {
    FacetValue fv = new FacetValue();

    final XSDSimpleTypeDefinition definingEnterpriseType = getDefiningEnterpriseType(startingType);
    fv.type = startingType;
    EnterpriseDatatypeInfo edi =
        ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(definingEnterpriseType);
    fv.value = edi.getRuntimeType();

    if (startingType == definingEnterpriseType) {
      // this "facet" set in the specified type, so it is not default.
      // check parent for real default:
      final XSDSimpleTypeDefinition dftDefiner =
          getDefiningEnterpriseType(definingEnterpriseType.getBaseTypeDefinition());
      EnterpriseDatatypeInfo ediDft =
          ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(dftDefiner);
      fv.defaultValue = ediDft.getRuntimeType();
      // set a fake facet to allow inherited checks to work:
      fv.facet =
          new XSDConstrainingFacetImpl() {
            @Override
            public String getFacetName() {
              return "This is not a real facet!"; //$NON-NLS-1$
            }

            @Override
            public XSDConcreteComponent getContainer() {
              return dftDefiner;
            }
          }; // endanon
    } else {
      // facet set by a parent, so it is default:
      fv.defaultValue = fv.value;
      // set a fake facet to allow inherited checks to work:
      fv.facet =
          new XSDConstrainingFacetImpl() {
            @Override
            public String getFacetName() {
              return "This is not a real facet!"; //$NON-NLS-1$
            }

            @Override
            public XSDConcreteComponent getContainer() {
              return definingEnterpriseType;
            }
          }; // endanon
    } // endif

    Boolean rtFixed = edi.getRuntimeTypeFixed();
    if (rtFixed != null) {
      fv.isFixedLocal = rtFixed.booleanValue();
    } // endif -- fixed null

    return fv;
  }
 /** @see DatatypeFinder#findDatatype(org.eclipse.emf.common.util.URI) */
 @Override
 public EObject findDatatype(final URI uri) throws CoreException {
   final DatatypeManager dtMgr =
       ModelerCore.getWorkspaceDatatypeManager(); // only care about built-ins!
   if (uri == null) {
     return dtMgr.getAnySimpleType();
   }
   final EObject datatype = dtMgr.findDatatype(uri.toString());
   return datatype;
 }
 /** @see DatatypeFinder#findDatatype(java.lang.String) */
 @Override
 public EObject findDatatype(final String name) throws CoreException {
   final DatatypeManager dtMgr =
       ModelerCore.getWorkspaceDatatypeManager(); // only care about built-ins!
   if (name == null) {
     return dtMgr.getAnySimpleType();
   }
   final EObject datatype = dtMgr.getBuiltInDatatype(name);
   return datatype;
 }
예제 #4
0
  private static XSDSimpleTypeDefinition getDefiningEnterpriseType(
      XSDSimpleTypeDefinition simpleType) {
    XSDSimpleTypeDefinition root = simpleType.getRootTypeDefinition();
    XSDSimpleTypeDefinition rv = root; // if nothing else is found, root will be right.

    while (simpleType != root) {
      if (ModelerCore.getWorkspaceDatatypeManager().isEnterpriseDatatype(simpleType)) {
        rv = simpleType;
        break;
      } // endif

      // try the parent:
      simpleType = simpleType.getBaseTypeDefinition();
    } // endwhile

    return rv;
  }
예제 #5
0
 public static void setEnterpriseFacetValue(XSDSimpleTypeDefinition type, FacetValue newValue) {
   if (newValue.value != null) {
     // set new enterprise info:
     EnterpriseDatatypeInfo edi =
         ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(type);
     if (edi == null) {
       edi = new EnterpriseDatatypeInfo();
     } // endif
     edi.setRuntimeTypeFixed(new Boolean(newValue.isFixedLocal));
     edi.setRuntimeType((String) newValue.value);
     ModelEditorImpl.fillWithDefaultValues(edi, type);
     ModelerCore.getModelEditor().setEnterpriseDatatypePropertyValue(type, edi);
   } else {
     // need to unset:
     ModelerCore.getModelEditor().unsetEnterpriseDatatypePropertyValue(type);
   } // endif
 }
예제 #6
0
  public static boolean needsNumeric(XSDSimpleTypeDefinition simpleType) {
    // check main first:
    if (ModelerCore.getWorkspaceDatatypeManager().isNumeric(simpleType)) return true;

    // above only checks against decimal:
    XSDSimpleTypeDefinition base = simpleType.getBaseTypeDefinition();

    if (base != null) {
      String basename = base.getName();
      for (int i = 0; i < NUMERIC_TYPES.length; i++) {
        String numericTypeName = NUMERIC_TYPES[i];
        if (numericTypeName.equalsIgnoreCase(basename)) {
          return true;
        } // endif
      } // endfor
    } // endif

    return false;
  }