Ejemplo n.º 1
0
  public List<Object> getChildren(TreeItem treeItem) {
    List<Object> result = new ArrayList<Object>();
    //
    Object dataObj = treeItem.getDataObject();
    if (isLeafDataObject(dataObj)) {
      return result;
    }

    if (dataObj instanceof TMapModel) { // tMapModel is the root
      result.addAll(getImportedModels(myTMapModel, myPtTreeFilter));
      result.add(NodeType.NON_IMPORTED_ARTIFACTS);
    } else if (dataObj == NodeType.NON_IMPORTED_ARTIFACTS) {
      result.addAll(getNonImportedModels(myTMapModel, myPtTreeFilter));
    } else if (dataObj instanceof WSDLModel) {
      Definitions defs = ((WSDLModel) dataObj).getDefinitions();
      Collection<PortType> pts = defs != null ? defs.getPortTypes() : null;
      if (pts != null) {
        for (PortType pt : pts) {
          result.add(pt);
        }
      }
    } else if (dataObj instanceof PortType) {
      Collection<Operation> ops = ((PortType) dataObj).getOperations();
      if (ops != null) {
        for (Operation op : ops) {
          result.add(op);
        }
      }
    }
    //
    return result;
  }
Ejemplo n.º 2
0
  /**
   * @param model - wsdlModel
   * @param pt - portType
   * @return true in case model contains pt or pt is null
   */
  private static boolean hasPortType(WSDLModel model, PortType portType) {
    assert model != null;
    if (portType == null) {
      return true;
    }

    Definitions defs = model.getDefinitions();
    if (defs == null) {
      return false;
    }

    Collection<PortType> pts = defs.getPortTypes();
    if (pts == null || pts.size() <= 0) {
      return false;
    }

    for (PortType pt : pts) {
      if (portType.equals(pt)) {
        return true;
      }
    }

    return false;
  }
Ejemplo n.º 3
0
  private void sync() {
    List<DefinitionsCustomization> ee =
        definitions.getExtensibilityElements(DefinitionsCustomization.class);
    if (ee.size() == 1) {
      DefinitionsCustomization dc = ee.get(0);
      EnableAsyncMapping eam = dc.getEnableAsyncMapping();
      if (eam != null) {
        setEnableAsyncMapping(eam.isEnabled());
      } else { // default is false
        setEnableAsyncMapping(false);
      }

      EnableWrapperStyle ews = dc.getEnableWrapperStyle();
      if (ews != null) {
        setEnableWrapperStyle(ews.isEnabled());
      } else { // default is true
        setEnableWrapperStyle(true);
      }
      EnableMIMEContent emc = dc.getEnableMIMEContent();
      if (emc != null) {
        setEnableMIMEContent(emc.isEnabled());
      } else { // default is false
        setEnableMIMEContent(false);
      }
      JavaPackage javaPackage = dc.getPackage();
      if (javaPackage != null) {
        setPackageName(javaPackage.getName());
      } else { // default is false
        setPackageName(null);
      }
    } else {
      // no definitions bindings, set to defaults
      setEnableAsyncMapping(false);
      setEnableWrapperStyle(true);
      setEnableMIMEContent(false);
      setPackageName(null);
    }
  }
Ejemplo n.º 4
0
  public void setValue(JComponent jComponent, Object object) {
    List<DefinitionsCustomization> ee =
        definitions.getExtensibilityElements(DefinitionsCustomization.class);
    CustomizationComponentFactory factory = CustomizationComponentFactory.getDefault();

    try {
      // process default package name
      if (jComponent == packageNameText || jComponent == defaultPackageCB) {
        if (getPackageName() == null) {
          if (ee.size() == 1) { // there is an extensibility element
            DefinitionsCustomization dc = ee.get(0);
            JavaPackage javaPackage = dc.getPackage();
            if (javaPackage != null) { // there is no EnableWrapperStyle, create one
              try {
                model.startTransaction();
                dc.removePackage(javaPackage);
                wsdlDirty = true;
              } finally {
                model.endTransaction();
              }
            }
          }
        } else {
          if (ee.size() == 1) { // there is an extensibility element
            DefinitionsCustomization dc = ee.get(0);
            JavaPackage javaPackage = dc.getPackage();
            if (javaPackage == null) { // there is no EnableWrapperStyle, create one
              try {
                model.startTransaction();
                javaPackage = factory.createJavaPackage(model);
                javaPackage.setName(packageNameText.getText());
                dc.setPackage(javaPackage);
                wsdlDirty = true;
              } finally {
                model.endTransaction();
              }
            } else { // there is an EnableWrapperStyle, reset it
              try {
                model.startTransaction();
                javaPackage.setName(packageNameText.getText());
                wsdlDirty = true;
              } finally {
                model.endTransaction();
              }
            }
          } else { // there is no extensibility element, add a new one and add a new
            // wrapper style element
            DefinitionsCustomization dc = factory.createDefinitionsCustomization(model);
            JavaPackage javaPackage = factory.createJavaPackage(model);
            try {
              model.startTransaction();
              javaPackage.setName(packageNameText.getText());
              dc.setPackage(javaPackage);
              definitions.addExtensibilityElement(dc);
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          }
        }
      }
      // process Wrapper Style
      else if (jComponent == enableWrapperStyleCB) {
        if (ee.size() == 1) { // there is an extensibility element
          DefinitionsCustomization dc = ee.get(0);
          EnableWrapperStyle ews = dc.getEnableWrapperStyle();
          if (ews == null) { // there is no EnableWrapperStyle, create one
            try {
              model.startTransaction();
              ews = factory.createEnableWrapperStyle(model);
              ews.setEnabled(this.getEnableWrapperStyle());
              dc.setEnableWrapperStyle(ews);
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          } else { // there is an EnableWrapperStyle, reset it
            try {
              model.startTransaction();
              ews.setEnabled(this.getEnableWrapperStyle());
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          }
        } else { // there is no extensibility element, add a new one and add a new
          // wrapper style element
          DefinitionsCustomization dc = factory.createDefinitionsCustomization(model);
          EnableWrapperStyle ews = factory.createEnableWrapperStyle(model);
          try {
            model.startTransaction();
            ews.setEnabled(this.getEnableWrapperStyle());
            dc.setEnableWrapperStyle(ews);
            definitions.addExtensibilityElement(dc);
            wsdlDirty = true;
          } finally {
            model.endTransaction();
          }
        }
      } else if (jComponent == enableAsyncMappingCB) { // process Async Mapping
        if (ee.size() == 1) { // there is an extensibility element
          DefinitionsCustomization dc = ee.get(0);
          EnableAsyncMapping eam = dc.getEnableAsyncMapping();
          if (eam == null) { // there is no EnableAsyncMapping, create one
            try {
              model.startTransaction();
              eam = factory.createEnableAsyncMapping(model);
              eam.setEnabled(this.getEnableAsyncMapping());
              dc.setEnableAsyncMapping(eam);
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          } else { // there is an EnableAsyncMapping, reset it
            try {
              model.startTransaction();
              eam.setEnabled(this.getEnableAsyncMapping());
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          }
        } else { // there is no extensibility element, add a new one and add a new
          // async mapping element
          DefinitionsCustomization dc = factory.createDefinitionsCustomization(model);
          EnableAsyncMapping eam = factory.createEnableAsyncMapping(model);
          try {
            model.startTransaction();
            eam.setEnabled(this.getEnableAsyncMapping());
            dc.setEnableAsyncMapping(eam);
            definitions.addExtensibilityElement(dc);
            wsdlDirty = true;
          } finally {
            model.endTransaction();
          }
        }
      } else if (jComponent == enableMIMEContentCB) { // process MIME content
        if (ee.size() == 1) { // there is an extensibility element
          DefinitionsCustomization dc = ee.get(0);
          EnableMIMEContent emc = dc.getEnableMIMEContent();
          if (emc == null) { // there is no EnableMIMEContent, create one
            try {
              model.startTransaction();
              emc = factory.createEnableMIMEContent(model);
              emc.setEnabled(this.getEnableMIMEContent());
              dc.setEnableMIMEContent(emc);
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          } else { // there is an EnableMIMEContent, reset it
            try {
              model.startTransaction();
              emc.setEnabled(this.getEnableMIMEContent());
              wsdlDirty = true;
            } finally {
              model.endTransaction();
            }
          }
        } else { // there is no extensibility element, add a new one and add a new
          // MIME content element
          DefinitionsCustomization dc = factory.createDefinitionsCustomization(model);
          EnableMIMEContent emc = factory.createEnableMIMEContent(model);
          try {
            model.startTransaction();
            emc.setEnabled(this.getEnableMIMEContent());
            dc.setEnableMIMEContent(emc);
            definitions.addExtensibilityElement(dc);

            wsdlDirty = true;
          } finally {
            model.endTransaction();
          }
        }
      }
    } catch (IllegalStateException ex) {
      Exceptions.attachSeverity(ex, Level.WARNING);
      Exceptions.printStackTrace(ex);
    }
  }