コード例 #1
0
  @Override
  public void refresh() {
    cancelActivityCombo.removeFocusListener(listener);
    messageCombo.removeFocusListener(listener);

    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = getBusinessObject(pe);
      if (bo == null) return;

      final Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
      if (model == null) {
        return;
      }

      boolean cancelActivity = ((BoundaryEvent) bo).isCancelActivity();
      if (cancelActivity == false) {
        cancelActivityCombo.select(1);
      } else {
        cancelActivityCombo.select(0);
      }

      String messageRef = null;
      if (bo instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bo;
        if (boundaryEvent.getEventDefinitions().get(0) != null) {
          MessageEventDefinition messageDefinition =
              (MessageEventDefinition) boundaryEvent.getEventDefinitions().get(0);
          if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
            messageRef = messageDefinition.getMessageRef();
          }
        }
      }

      String[] items = new String[model.getBpmnModel().getMessages().size() + 1];
      items[0] = "";
      int counter = 1;
      int selectedCounter = 0;
      for (Message message : model.getBpmnModel().getMessages()) {
        items[counter] = message.getId() + " / " + message.getName();
        if (message.getId().equals(messageRef)) {
          selectedCounter = counter;
        }
        counter++;
      }

      messageCombo.setItems(items);
      messageCombo.select(selectedCounter);
    }
    cancelActivityCombo.addFocusListener(listener);
    messageCombo.addFocusListener(listener);
  }
コード例 #2
0
  public static void writeSignalsAndMessages(BpmnModel model, XMLStreamWriter xtw)
      throws Exception {

    for (Process process : model.getProcesses()) {
      for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof Event) {
          Event event = (Event) flowElement;
          if (event.getEventDefinitions().size() > 0) {
            EventDefinition eventDefinition = event.getEventDefinitions().get(0);
            if (eventDefinition instanceof SignalEventDefinition) {
              SignalEventDefinition signalEvent = (SignalEventDefinition) eventDefinition;
              if (model.containsSignalId(signalEvent.getSignalRef()) == false) {
                Signal signal = new Signal(signalEvent.getSignalRef(), signalEvent.getSignalRef());
                model.addSignal(signal);
              }

            } else if (eventDefinition instanceof MessageEventDefinition) {
              MessageEventDefinition messageEvent = (MessageEventDefinition) eventDefinition;
              if (model.containsMessageId(messageEvent.getMessageRef()) == false) {
                Message message =
                    new Message(messageEvent.getMessageRef(), messageEvent.getMessageRef(), null);
                model.addMessage(message);
              }
            }
          }
        }
      }
    }

    for (Signal signal : model.getSignals()) {
      xtw.writeStartElement(ELEMENT_SIGNAL);
      xtw.writeAttribute(ATTRIBUTE_ID, signal.getId());
      xtw.writeAttribute(ATTRIBUTE_NAME, signal.getName());
      xtw.writeEndElement();
    }

    for (Message message : model.getMessages()) {
      xtw.writeStartElement(ELEMENT_MESSAGE);
      String messageId = message.getId();
      // remove the namespace from the message id if set
      if (messageId.startsWith(model.getTargetNamespace())) {
        messageId = messageId.replace(model.getTargetNamespace(), "");
        messageId = messageId.replaceFirst(":", "");
      } else {
        for (String prefix : model.getNamespaces().keySet()) {
          String namespace = model.getNamespace(prefix);
          if (messageId.startsWith(namespace)) {
            messageId = messageId.replace(model.getTargetNamespace(), "");
            messageId = prefix + messageId;
          }
        }
      }
      xtw.writeAttribute(ATTRIBUTE_ID, messageId);
      xtw.writeAttribute(ATTRIBUTE_NAME, message.getName());
      xtw.writeEndElement();
    }
  }
コード例 #3
0
ファイル: BpmnParse.java プロジェクト: justinsino83/Activiti
 public void createMessages() {
   for (Message messageElement : bpmnModel.getMessages()) {
     MessageDefinition messageDefinition = new MessageDefinition(messageElement.getId(), name);
     if (StringUtils.isNotEmpty(messageElement.getItemRef())) {
       if (!this.itemDefinitions.containsKey(messageElement.getItemRef())) {
         bpmnModel.addProblem(messageElement.getItemRef() + " does not exist", messageElement);
       } else {
         ItemDefinition itemDefinition = this.itemDefinitions.get(messageElement.getItemRef());
         messageDefinition.setItemDefinition(itemDefinition);
       }
     }
     this.messages.put(messageDefinition.getId(), messageDefinition);
   }
 }