@Override
  public void widgetSelected(SelectionEvent e) {

    String formType = "/Model_Type/";
    String args = "?";
    int i = 1;

    if (modelType.getName() != null) args = args + "name=" + modelType.getName();
    if (modelType.getSupertype() != null)
      args = args + "&supertype=" + modelType.getSupertype().getName();

    if (modelType instanceof ModelRel) {
      formType = "/Relationship_Type/";

      ModelRel modelRelType = (ModelRel) modelType;

      if (!modelRelType.getModelEndpoints().isEmpty()) args = args + "&arguments=";

      for (ModelEndpoint modelEndpoint : modelRelType.getModelEndpoints()) {
        if (i != 1) args = args + ", ";
        args = args + modelEndpoint.getName() + ";" + modelEndpoint.getTarget().getName();
        i++;
      }
    }

    IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
    String url = WIKI_WWW + formType + modelType.getName() + args;
    try {
      IWebBrowser browser = support.createBrowser("MMINT Wiki");
      browser.openURL(new URL(url));
    } catch (Exception ex) {
      MMINTException.print(IStatus.ERROR, "Error opening wiki page " + url, ex);
    }
  }
Пример #2
0
  /** @generated NOT */
  public KleisliModel kleisliCreateType(KleisliModelEndpoint containerModelTypeEndpoint)
      throws MMINTException {

    // TODO MMINT[KLEISLI] should try to emulate normal api structure
    if (MultiModelConstraintChecker.isInstancesLevel(this)) {
      throw new MMINTException("Can't execute TYPES level operation on INSTANCES level element");
    }

    Model origModelType = containerModelTypeEndpoint.getTarget();
    String kModelTypeUri =
        getModelTypeExtendedUri(
            (KleisliModelRel) containerModelTypeEndpoint.eContainer(),
            origModelType,
            containerModelTypeEndpoint.getName());
    if (!MultiModelUtils.isFileOrDirectoryInState(kModelTypeUri)) {
      try {
        EPackage origRootModelTypeObj = origModelType.getEMFTypeRoot();
        String origModelTypeUri = origRootModelTypeObj.getNsURI();
        origRootModelTypeObj.setNsURI(
            origModelTypeUri + KleisliReasoningEngine.KLEISLI_MODELTYPE_URI_SUFFIX);
        MultiModelUtils.createModelFileInState(origRootModelTypeObj, kModelTypeUri);
        origRootModelTypeObj.setNsURI(
            origModelTypeUri); // restore original for packages coming from the registry
      } catch (Exception e) {
        throw new MMINTException("Error creating extended metamodel file");
      }
    }

    KleisliModel kModelType = KleisliFactory.eINSTANCE.createKleisliModel();
    kModelType.setUri(kModelTypeUri);
    kModelType.setName(origModelType.getName());
    kModelType.setLevel(MIDLevel.TYPES);
    kModelType.setSupertype(origModelType.getSupertype());
    kModelType.setDynamic(true);
    kModelType.setAbstract(origModelType.isAbstract());
    ExtendibleElementConstraint origConstraint = origModelType.getConstraint();
    if (origConstraint != null) {
      ExtendibleElementConstraint kConstraint =
          MIDFactory.eINSTANCE.createExtendibleElementConstraint();
      kConstraint.setLanguage(origConstraint.getLanguage());
      kConstraint.setImplementation(origConstraint.getImplementation());
      kModelType.setConstraint(kConstraint);
    }
    kModelType.setOrigin(ModelOrigin.CREATED);
    kModelType.setFileExtension(origModelType.getFileExtension());
    containerModelTypeEndpoint.setExtendedTarget(kModelType);

    return kModelType;
  }