public void onPageEntry() {
    Ooaofooa modelRoot =
        Selection.getModelRoot(
            (StructuredSelection)
                ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).getSelection());

    // cache for previous user selections
    StateMachineEvent_c v_Message =
        ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_Message;

    // cache for context
    AsynchronousMessage_c v_asyncMessage =
        ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_asyncMessage;
    ClassInstanceParticipant_c v_cip =
        ((CommunicationInstanceEventFormalizeOnMSG_AMWizard) getWizard()).v_cip;

    if (((v_asyncMessage != null))) {

      if (((v_cip != null))) {

        Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage);

        InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR930(v_cip);

        ModelClass_c v_mclass = ModelClass_c.getOneO_OBJOnR934(v_cip);

        if (((v_mclass != null))) {

          StateMachineEvent_c v_evt =
              StateMachineEvent_c.getOneSM_EVTOnR1009(
                  EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage));

          java.util.UUID v_existingId = Gd_c.Null_unique_id();

          if (((v_evt != null))) {

            v_existingId = v_evt.getSmevt_id();
          }

          StateMachine_c v_stateMachine =
              StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_mclass));

          StateMachine_c[] v_machines =
              StateMachine_c.getManySM_SMsOnR517(
                  InstanceStateMachine_c.getManySM_ISMsOnR518(
                      ModelClass_c.getManyO_OBJsOnR8001(
                          PackageableElement_c.getManyPE_PEsOnR8000(
                              Package_c.getManyEP_PKGsOnR1405(
                                  SystemModel_c.getManyS_SYSsOnR1405(
                                      Package_c.getManyEP_PKGsOnR8000(
                                          PackageableElement_c.getManyPE_PEsOnR8001(
                                              v_mclass))))))));

          if (((v_machines.length == 0))) {

            v_machines =
                StateMachine_c.getManySM_SMsOnR517(
                    InstanceStateMachine_c.getManySM_ISMsOnR518(
                        ModelClass_c.getManyO_OBJsOnR2(
                            Subsystem_c.getManyS_SSsOnR1(
                                Domain_c.getManyS_DOMsOnR1(
                                    Subsystem_c.getManyS_SSsOnR2(v_mclass))))));
          }

          if (((v_Message != null))) {}
        }
      }
    }
  }
  public boolean performFinish() {
    TransactionUtil.TransactionGroup transactionGroup = null;
    ModelRoot modelRoot = v_asyncMessage.getModelRoot();
    try {
      transactionGroup =
          TransactionUtil.startTransactionsOnSelectedModelRoots(
              "Instance Event Formalize"); //$NON-NLS-1$
      Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage);

      InteractionParticipant_c v_participant =
          InteractionParticipant_c.getOneSQ_POnR1007(v_message);

      Lifespan_c v_ls = Lifespan_c.getOneSQ_LSOnR930(v_participant);

      ClassInstanceParticipant_c v_cip =
          ClassInstanceParticipant_c.getOneSQ_CIPOnR930(
              InteractionParticipant_c.getOneSQ_POnR940(v_ls));

      ModelClass_c v_cipclass =
          (ModelClass_c)
              modelRoot.getInstanceList(ModelClass_c.class).getGlobal(null, Gd_c.Null_unique_id());

      if (((v_cip != null))) {

        v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip);

      } else {

        v_cip =
            ClassInstanceParticipant_c.getOneSQ_CIPOnR930(
                InteractionParticipant_c.getOneSQ_POnR1007(v_message));

        if (((v_cip != null))) {

          Communication_c v_communication =
              Communication_c.getOneCOMM_COMMOnR1126(
                  ParticipantInCommunication_c.getOneCOMM_PICOnR1126(
                      InteractionParticipant_c.getOneSQ_POnR930(v_cip)));

          if (((v_communication != null))) {

            v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip);
          }
        }
      }

      if (((v_cipclass != null))) {

        StateMachineEvent_c v_evt =
            StateMachineEvent_c.getOneSM_EVTOnR1009(
                EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage));

        java.util.UUID v_existingId = Gd_c.Null_unique_id();

        if (((v_evt != null))) {

          v_existingId = v_evt.getSmevt_id();
        }

        StateMachine_c v_stateMachine =
            StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_cipclass));

        StateMachine_c[] v_machines =
            StateMachine_c.getManySM_SMsOnR517(
                InstanceStateMachine_c.getManySM_ISMsOnR518(
                    ModelClass_c.getManyO_OBJsOnR8001(
                        PackageableElement_c.getManyPE_PEsOnR8000(
                            Package_c.getManyEP_PKGsOnR1405(
                                SystemModel_c.getManyS_SYSsOnR1405(
                                    Package_c.getManyEP_PKGsOnR8000(
                                        PackageableElement_c.getManyPE_PEsOnR8001(
                                            v_cipclass))))))));

        if (((v_machines.length == 0))) {

          v_machines =
              StateMachine_c.getManySM_SMsOnR517(
                  InstanceStateMachine_c.getManySM_ISMsOnR518(
                      ModelClass_c.getManyO_OBJsOnR2(
                          Subsystem_c.getManyS_SSsOnR1(
                              Domain_c.getManyS_DOMsOnR1(
                                  Subsystem_c.getManyS_SSsOnR2(v_cipclass))))));
        }

        if (((v_Message != null))) {

          if (v_asyncMessage != null) {
            v_asyncMessage.Formalizewithevent(v_Message.getSmevt_id());
          } else {
            Throwable t = new Throwable();
            t.fillInStackTrace();
            CorePlugin.logError("Attempted to call an operation on a null instance.", t);
          }
        }
      }

      // catch all exceptions and cancel the transaction
    } catch (Exception e) {
      if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e);
      CorePlugin.logError("Transaction: Instance Event Formalize failed", e); // $NON-NLS-1$
      // return true so that the wizard will
      // close
      return true;
    }
    if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup);
    if (m_viewer != null) {
      if (m_viewer instanceof StructuredViewer) {
        ((StructuredViewer) m_viewer).refresh(v_asyncMessage);
      } else {
        m_viewer.refresh();
      }
    }
    return true;
  }
Example #3
0
  /**
   * Loads (and returns) the instance of this class from the given file to which it previously had
   * been persisted.
   */
  private static Ooaofooa loadInstanceFromFile(IFile file) {
    // find the system-model that corresponds to the project
    // containing the given file
    final String projectName = file.getProject().getName();
    final SystemModel_c system =
        SystemModel_c.SystemModelInstances(
            Ooaofooa.getDefaultInstance(),
            new ClassQueryInterface_c() {
              public boolean evaluate(Object candidate) {
                SystemModel_c selected = (SystemModel_c) candidate;
                return selected.getName().equals(projectName);
              }
            })[0];

    // open an input-stream on the given file
    InputStream inStream = null;
    try {
      inStream = new FileInputStream(file.getLocation().toString());
    } catch (FileNotFoundException e) {
      CorePlugin.logError(
          "Internal error: failed to open " + file.getLocation().toString(), e); // $$NON-NLS-1$$
      return null;
    }

    // detm the instance's ID from the file's path
    final String id = createModelRootId(file.getProject(), file.getName(), false);

    // the enclosed could take a bit of time, so put up a busy indicator
    final InputStream finalInStream = inStream;
    BusyIndicator.showWhile(
        Display.getCurrent(),
        new Runnable() {
          public void run() {
            // load the instance from the stream and have it be associated
            // with the system-model found above
            String result =
                CorePlugin.getDefault()
                    .doLoad(system, id, finalInStream, new NullProgressMonitor(), false, false);
            if (!result.equals("")) {
              Ooaofooa modelRoot = getInstance(id, false);
              modelRoot.loadErrorMessage = result;
            }
          }
        });

    // close the input-stream from which the model was loaded
    try {
      inStream.close();
    } catch (IOException e) {
      CorePlugin.logError("Error closing stream after import", e);
    }

    // make sure the domain and file name are in sync
    Ooaofooa modelRoot = getInstance(id, false);
    if (modelRoot.loadedOk()) {
      Domain_c dom = Domain_c.DomainInstance(modelRoot);
      String fn = file.getName();
      String domName = fn.substring(0, fn.length() - MODELS_EXT.length() - 1);

      ModelRoot.disableChangeNotification();
      try {
        dom.setName(domName);
      } finally {
        ModelRoot.enableChangeNotification();
      }
    }

    // return the loaded instance
    return modelRoot;
  }