void createDefinitionsIfMissing() {
    EList<EObject> contents = resource.getContents();

    if (contents.isEmpty() || !(contents.get(0) instanceof DocumentRoot)) {
      TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource);

      if (domain != null) {
        final DocumentRoot docRoot = FACTORY.createDocumentRoot();
        final Definitions definitions = FACTORY.createDefinitions();
        //				definitions.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(definitions, resource);
        Collaboration collaboration = FACTORY.createCollaboration();
        //				collaboration.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(collaboration, resource);
        Participant participant = FACTORY.createParticipant();
        //				participant.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(participant, resource);
        participant.setName("Internal");
        collaboration.getParticipants().add(participant);
        definitions.getRootElements().add(collaboration);

        domain
            .getCommandStack()
            .execute(
                new RecordingCommand(domain) {
                  @Override
                  protected void doExecute() {
                    docRoot.setDefinitions(definitions);
                    resource.getContents().add(docRoot);
                  }
                });
        return;
      }
    }
  }
 public Lane createLane(Object target) {
   Lane lane = FACTORY.createLane();
   //		lane.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(lane, resource);
   FlowElementsContainer container = getFlowElementContainer(target);
   if (container.getLaneSets().isEmpty()) {
     LaneSet laneSet = FACTORY.createLaneSet();
     //			laneSet.setId(EcoreUtil.generateUUID());
     container.getLaneSets().add(laneSet);
   }
   container.getLaneSets().get(0).getLanes().add(lane);
   ModelUtil.setID(lane);
   return lane;
 }
  private Collaboration getOrCreateCollaboration() {
    final List<RootElement> rootElements = getDefinitions().getRootElements();

    for (RootElement element : rootElements) {
      if (element instanceof Collaboration) {
        return (Collaboration) element;
      }
    }
    TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource);
    final Collaboration collaboration = FACTORY.createCollaboration();
    //		collaboration.setId(EcoreUtil.generateUUID());
    ModelUtil.setID(collaboration, resource);
    if (domain != null) {
      domain
          .getCommandStack()
          .execute(
              new RecordingCommand(domain) {

                @Override
                protected void doExecute() {
                  addCollaborationToRootElements(rootElements, collaboration);
                }
              });
    }
    return collaboration;
  }
예제 #4
0
  private BPMNShape createDIShape(
      BPMNDiagram bpmnDiagram, BaseElement bpmnElement, float x, float y, boolean doImport) {

    BPMNPlane plane = bpmnDiagram.getPlane();
    BPMNShape bpmnShape = null;
    for (DiagramElement de : plane.getPlaneElement()) {
      if (de instanceof BPMNShape) {
        if (bpmnElement == ((BPMNShape) de).getBpmnElement()) {
          bpmnShape = (BPMNShape) de;
          break;
        }
      }
    }

    if (bpmnShape == null) {
      bpmnShape = BpmnDiFactory.eINSTANCE.createBPMNShape();
      bpmnShape.setBpmnElement(bpmnElement);
      Bounds bounds = DcFactory.eINSTANCE.createBounds();
      bounds.setX(x);
      bounds.setY(y);
      ShapeStyle ss = preferences.getShapeStyle(bpmnElement);
      bounds.setWidth(ss.getDefaultWidth());
      bounds.setHeight(ss.getDefaultHeight());
      bpmnShape.setBounds(bounds);
      plane.getPlaneElement().add(bpmnShape);
      preferences.applyBPMNDIDefaults(bpmnShape, null);

      ModelUtil.setID(bpmnShape);
      if (doImport) importer.importShape(bpmnShape);
    }

    return bpmnShape;
  }
 public void laneToTop(Lane lane) {
   LaneSet laneSet = FACTORY.createLaneSet();
   //		laneSet.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(laneSet, resource);
   laneSet.getLanes().add(lane);
   Process process = getOrCreateProcess(getInternalParticipant());
   process.getLaneSets().add(laneSet);
 }
 public Participant addParticipant() {
   Collaboration collaboration = getOrCreateCollaboration();
   Participant participant = FACTORY.createParticipant();
   //		participant.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(participant, resource);
   collaboration.getParticipants().add(participant);
   return participant;
 }
 public MessageFlow createMessageFlow(InteractionNode source, InteractionNode target) {
   MessageFlow messageFlow = FACTORY.createMessageFlow();
   //		messageFlow.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(messageFlow, resource);
   messageFlow.setSourceRef(source);
   messageFlow.setTargetRef(target);
   getOrCreateCollaboration().getMessageFlows().add(messageFlow);
   return messageFlow;
 }
 private InputOutputSpecification getOrCreateIOSpecification(Object target) {
   Process process = getOrCreateProcess(getParticipant(target));
   if (process.getIoSpecification() == null) {
     InputOutputSpecification ioSpec = FACTORY.createInputOutputSpecification();
     //			ioSpec.setId(EcoreUtil.generateUUID());
     ModelUtil.setID(ioSpec, resource);
     process.setIoSpecification(ioSpec);
   }
   return process.getIoSpecification();
 }
  public SequenceFlow createSequenceFlow(FlowNode source, FlowNode target) {
    SequenceFlow sequenceFlow = FACTORY.createSequenceFlow();
    //		sequenceFlow.setId(EcoreUtil.generateUUID());
    ModelUtil.setID(sequenceFlow, resource);

    addFlowElement(source, sequenceFlow);
    sequenceFlow.setSourceRef(source);
    sequenceFlow.setTargetRef(target);
    return sequenceFlow;
  }
 public Process getOrCreateProcess(Participant participant) {
   if (participant.getProcessRef() == null) {
     Process process = FACTORY.createProcess();
     //			process.setId(EcoreUtil.generateUUID());
     ModelUtil.setID(process, resource);
     process.setName("Process for " + participant.getName());
     getDefinitions().getRootElements().add(process);
     participant.setProcessRef(process);
   }
   return participant.getProcessRef();
 }
 private void addCollaborationToRootElements(
     final List<RootElement> rootElements, final Collaboration collaboration) {
   Participant participant = FACTORY.createParticipant();
   //		participant.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(participant, resource);
   participant.setName("Internal");
   for (RootElement element : rootElements) {
     if (element instanceof Process) {
       participant.setProcessRef((Process) element);
       break;
     }
   }
   collaboration.getParticipants().add(participant);
   rootElements.add(collaboration);
 }
  @Override
  protected EObject addListItem(EObject object, EStructuralFeature feature) {
    InputSet inputSet = throwEvent.getInputSet();
    if (inputSet == null) {
      inputSet = FACTORY.createInputSet();
      throwEvent.setInputSet(inputSet);
      ModelUtil.setID(inputSet);
    }
    // generate a unique parameter name
    String base = "inParam";
    int suffix = 1;
    String name = base + suffix;
    for (; ; ) {
      boolean found = false;
      for (DataInput p : inputSet.getDataInputRefs()) {
        if (name.equals(p.getName())) {
          found = true;
          break;
        }
      }
      if (!found) break;
      name = base + ++suffix;
    }

    DataInput param = (DataInput) super.addListItem(object, feature);
    // add the new parameter to the InputSet
    (param).setName(name);
    inputSet.getDataInputRefs().add(param);

    // create a DataInputAssociation
    DataInputAssociation inputAssociation = FACTORY.createDataInputAssociation();
    throwEvent.getDataInputAssociation().add(inputAssociation);
    inputAssociation.setTargetRef((DataInput) param);
    ModelUtil.setID(inputAssociation);
    return param;
  }
 public Association createAssociation(BaseElement source, BaseElement target) {
   BaseElement e = null;
   if (getParticipant(source) != null) {
     e = source;
   } else if (getParticipant(target) != null) {
     e = target;
   } else {
     e = getInternalParticipant();
   }
   Association association = FACTORY.createAssociation();
   addArtifact(e, association);
   //		association.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(association, resource);
   association.setSourceRef(source);
   association.setTargetRef(target);
   return association;
 }
  public Lane createLane(Lane targetLane) {
    Lane lane = FACTORY.createLane();
    //		lane.setId(EcoreUtil.generateUUID());
    ModelUtil.setID(lane, resource);

    if (targetLane.getChildLaneSet() == null) {
      targetLane.setChildLaneSet(ModelHandler.FACTORY.createLaneSet());
    }

    LaneSet targetLaneSet = targetLane.getChildLaneSet();
    targetLaneSet.getLanes().add(lane);

    lane.getFlowNodeRefs().addAll(targetLane.getFlowNodeRefs());
    targetLane.getFlowNodeRefs().clear();

    return lane;
  }
 @Override
 public Connection create(ICreateConnectionContext context) {
   try {
     A source = getSourceBo(context);
     B target = getTargetBo(context);
     ModelHandler mh = ModelHandler.getInstance(getDiagram());
     AddConnectionContext addContext =
         new AddConnectionContext(context.getSourceAnchor(), context.getTargetAnchor());
     BaseElement flow = createFlow(mh, source, target);
     //			flow.setId(EcoreUtil.generateUUID());
     addContext.setNewObject(flow);
     Connection connection = (Connection) getFeatureProvider().addIfPossible(addContext);
     ModelUtil.setID(flow);
     return connection;
   } catch (IOException e) {
     Activator.logError(e);
   }
   return null;
 }
예제 #16
0
  public static BPMNShape createDIShape(
      Shape shape,
      BaseElement elem,
      int x,
      int y,
      int w,
      int h,
      IFeatureProvider fp,
      Diagram diagram) {

    EList<EObject> businessObjects =
        Graphiti.getLinkService().getLinkForPictogramElement(diagram).getBusinessObjects();
    BPMNShape bpmnShape = null;

    for (EObject eObject : businessObjects) {
      if (eObject instanceof BPMNDiagram) {
        BPMNDiagram bpmnDiagram = (BPMNDiagram) eObject;

        bpmnShape = BpmnDiFactory.eINSTANCE.createBPMNShape();
        //				bpmnShape.setId(EcoreUtil.generateUUID());
        bpmnShape.setBpmnElement(elem);
        Bounds bounds = DcFactory.eINSTANCE.createBounds();
        bounds.setX(x);
        bounds.setY(y);
        bounds.setWidth(w);
        bounds.setHeight(h);
        bpmnShape.setBounds(bounds);

        List<DiagramElement> elements = bpmnDiagram.getPlane().getPlaneElement();
        elements.add(bpmnShape);
        ModelUtil.setID(shape);

        fp.link(shape, new Object[] {elem, bpmnShape});
        break;
      }
    }

    return bpmnShape;
  }
  private void modifyModelStructure(IMoveShapeContext context) {
    Lane movedLane = getMovedLane(context);
    Participant sourceParticipant =
        (Participant) getBusinessObjectForPictogramElement(context.getSourceContainer());
    Participant internalParticipant = null;

    try {
      ModelHandler handler = ModelHandler.getInstance(getDiagram());
      internalParticipant = handler.getInternalParticipant();
      handler.moveLane(movedLane, internalParticipant);
    } catch (IOException e) {
      Activator.logError(e);
    }

    LaneSet laneSet = null;
    for (LaneSet set : sourceParticipant.getProcessRef().getLaneSets()) {
      if (set.getLanes().contains(movedLane)) {
        laneSet = set;
        break;
      }
    }

    if (laneSet != null) {
      laneSet.getLanes().remove(movedLane);
      if (laneSet.getLanes().isEmpty()) {
        sourceParticipant.getProcessRef().getLaneSets().remove(laneSet);
      }

      Process process = internalParticipant.getProcessRef();
      if (process.getLaneSets().isEmpty()) {
        LaneSet createLaneSet = ModelHandler.FACTORY.createLaneSet();
        //				createLaneSet.setId(EcoreUtil.generateUUID());
        process.getLaneSets().add(createLaneSet);
        ModelUtil.setID(createLaneSet);
      }
      process.getLaneSets().get(0).getLanes().add(movedLane);
    }
  }
  public void updateTask() {
    /*
     * Here we need to examine the current list of DataInputAssociations on the
     * Task and, if there is already a DataInput named NotStartedReassign or
     * NotCompletedReassign, append a new expression. Otherwise create a new
     * DataInput and DataInputAssociation.
     *
     * The XML looks like this:
     *
     * <bpmn2:ioSpecification id="IOSpec_1">
     *   <bpmn2:dataInput id="DataInput_1" name="NotCompletedReassign"/>
     *   <bpmn2:dataInput id="DataInput_2" name="NotStartedReassign"/>
     * </bpmn2:ioSpecification>
     *
     * <bpmn2:dataInputAssociation id="DataInputAssociation_1">
     *   <bpmn2:targetRef>DataInput_1</bpmn2:targetRef>
     *   <bpmn2:assignment id="Assignment_1">
     *     <bpmn2:from xsi:type="bpmn2:tFormalExpression"><![CDATA[[users:user2|groups:group2]@[exp2]^[users:user1,user2,user3|groups:group1,group2,group3]@[exp4]]]></bpmn2:from>
     *     <bpmn2:to xsi:type="bpmn2:tFormalExpression">DataInput_1</bpmn2:to>
     *   </bpmn2:assignment>
     * </bpmn2:dataInputAssociation>
     *
     * <bpmn2:dataInputAssociation id="DataInputAssociation_2">
     *   <bpmn2:targetRef>DataInput_2</bpmn2:targetRef>
     *   <bpmn2:assignment id="Assignment_2">
     *     <bpmn2:from xsi:type="bpmn2:tFormalExpression"><![CDATA[[users:user1|groups:group1]@[exp1]^[users:user1,user2,user3|groups:group1,group2,group3]@[exp4]]]></bpmn2:from>
     *     <bpmn2:to xsi:type="bpmn2:tFormalExpression">DataInput_2</bpmn2:to>
     *   </bpmn2:assignment>
     * </bpmn2:dataInputAssociation>
     */
    Resource resource = task.eResource();
    InputOutputSpecification iospec = task.getIoSpecification();
    DataInputAssociation notStarted = null;
    DataInputAssociation notCompleted = null;
    DataInput input;
    Assignment assignment;
    FormalExpression expression;
    String body;
    for (DataInputAssociation dia : task.getDataInputAssociations()) {
      if (dia.getTargetRef() instanceof DataInput) {
        input = (DataInput) dia.getTargetRef();
        if (ReassignmentType.NOT_STARTED_REASSIGN.getLiteral().equals(input.getName())) {
          notStarted = dia;
        } else if (ReassignmentType.NOT_COMPLETED_REASSIGN.getLiteral().equals(input.getName())) {
          notCompleted = dia;
        }
      }
    }

    body = toString(ReassignmentType.NOT_STARTED_REASSIGN);
    if (body.isEmpty()) {
      if (notStarted != null) {
        // need to remove the NotCompletedReassign data input and association
        iospec.getDataInputs().remove(notStarted.getTargetRef());
        iospec.getInputSets().get(0).getDataInputRefs().remove(notStarted.getTargetRef());
        task.getDataInputAssociations().remove(notStarted);
      }
    } else {
      if (notStarted == null) {
        // create the NotStartedReassign data input and association
        input =
            (DataInput) Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getDataInput());
        input.setName(ReassignmentType.NOT_STARTED_REASSIGN.getLiteral());
        iospec.getDataInputs().add(input);
        iospec.getInputSets().get(0).getDataInputRefs().add(input);
        notStarted =
            (DataInputAssociation)
                Bpmn2ModelerFactory.create(
                    resource, Bpmn2Package.eINSTANCE.getDataInputAssociation());
        notStarted.setTargetRef(input);
        assignment =
            (Assignment)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getAssignment());
        expression =
            (FormalExpression)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getFormalExpression());
        // make sure this DataInput has an ID
        ModelUtil.setID(input);
        expression.setBody(input.getId());
        assignment.setTo(expression);
        notStarted.getAssignment().add(assignment);
        task.getDataInputAssociations().add(notStarted);

        ModelUtil.setID(notStarted);
        ModelUtil.setID(assignment);
        ModelUtil.setID(expression);
      }

      assignment = (Assignment) notStarted.getAssignment().get(0);
      expression = (FormalExpression) assignment.getFrom();
      if (expression == null) {
        expression =
            (FormalExpression)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getFormalExpression());
        assignment.setFrom(expression);
        ModelUtil.setID(expression);
      }
      expression.setBody(body);
    }

    body = toString(ReassignmentType.NOT_COMPLETED_REASSIGN);
    if (body.isEmpty()) {
      if (notCompleted != null) {
        // need to remove the NotCompletedReassign data input and association
        iospec.getDataInputs().remove(notCompleted.getTargetRef());
        iospec.getInputSets().get(0).getDataInputRefs().remove(notCompleted.getTargetRef());
        task.getDataInputAssociations().remove(notCompleted);
      }
    } else {
      if (notCompleted == null) {
        // create the NotStartedReassign data input and association
        input =
            (DataInput) Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getDataInput());
        input.setName(ReassignmentType.NOT_COMPLETED_REASSIGN.getLiteral());
        iospec.getDataInputs().add(input);
        iospec.getInputSets().get(0).getDataInputRefs().add(input);
        notCompleted =
            (DataInputAssociation)
                Bpmn2ModelerFactory.create(
                    resource, Bpmn2Package.eINSTANCE.getDataInputAssociation());
        notCompleted.setTargetRef(input);
        assignment =
            (Assignment)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getAssignment());
        expression =
            (FormalExpression)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getFormalExpression());
        // make sure this DataInput has an ID
        ModelUtil.setID(input);
        expression.setBody(input.getId());
        assignment.setTo(expression);
        notCompleted.getAssignment().add(assignment);
        task.getDataInputAssociations().add(notCompleted);

        ModelUtil.setID(notCompleted);
        ModelUtil.setID(assignment);
        ModelUtil.setID(expression);
      }

      assignment = (Assignment) notCompleted.getAssignment().get(0);
      expression = (FormalExpression) assignment.getFrom();
      if (expression == null) {
        expression =
            (FormalExpression)
                Bpmn2ModelerFactory.create(resource, Bpmn2Package.eINSTANCE.getFormalExpression());
        assignment.setFrom(expression);
        ModelUtil.setID(expression);
      }
      expression.setBody(body);
    }
  }
  @SuppressWarnings("unchecked")
  public void execute() {
    // if the object into which this value is being added has other adapters execute those first
    executeIfNeeded(object);

    // remove this adapter from the value - this adapter is a one-shot deal!
    value.eAdapters().remove(this);
    try {
      Object o = object.eGet(feature);
    } catch (Exception e1) {
      try {
        Object o = value.eGet(feature);
        // this is the inverse add of object into value
        o = value;
        value = object;
        object = (EObject) o;
      } catch (Exception e2) {
      }
    }
    // if there are any EObjects contained or referenced by this value, execute those adapters first
    executeChildren(value);

    // set the value in the object
    boolean valueChanged = false;
    final EList<EObject> list = feature.isMany() ? (EList<EObject>) object.eGet(feature) : null;
    if (list == null) valueChanged = object.eGet(feature) != value;
    else valueChanged = !list.contains(value);

    if (valueChanged) {
      TransactionalEditingDomain domain = getEditingDomain();
      if (domain == null) {
        if (list == null) object.eSet(feature, value);
        else list.add(value);
        // assign the value's ID if it has one:
        // because of changes made by cascading InsertionAdapters,
        // the object could now be contained in a resource and hence
        // the setID() will need to be executed on the command stack.
        domain = getEditingDomain();
        if (domain == null) {
          ModelUtil.setID(value);
        } else {
          domain
              .getCommandStack()
              .execute(
                  new RecordingCommand(domain) {
                    @Override
                    protected void doExecute() {
                      ModelUtil.setID(value);
                    }
                  });
        }
      } else {
        domain
            .getCommandStack()
            .execute(
                new RecordingCommand(domain) {
                  @Override
                  protected void doExecute() {
                    ExtendedPropertiesAdapter adapter =
                        (ExtendedPropertiesAdapter)
                            AdapterUtil.adapt(object, ExtendedPropertiesAdapter.class);
                    if (adapter != null) {
                      adapter.getFeatureDescriptor(feature).setValue(value);
                    } else {
                      if (list == null) object.eSet(feature, value);
                      else list.add(value);
                    }
                    // assign the value's ID if it has one
                    ModelUtil.setID(value);
                  }
                });
      }
    }
  }
    /* (non-Javadoc)
     * @see org.eclipse.graphiti.features.IFeature#execute(org.eclipse.graphiti.features.context.IContext)
     */
    @Override
    public void execute(IContext context) {
      // TODO: clean this mess up: use {@code getWorkItemEditor()) to check if the selected task
      // has a WID and if the WID defines a customEditor
      BPMN2Editor editor =
          (BPMN2Editor)
              getFeatureProvider()
                  .getDiagramTypeProvider()
                  .getDiagramBehavior()
                  .getDiagramContainer();
      PictogramElement pe = ((ICustomContext) context).getPictogramElements()[0];
      final Task task =
          (Task) Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pe);
      String taskName = ""; // $NON-NLS-1$
      List<EStructuralFeature> features = ModelDecorator.getAnyAttributes(task);
      for (EStructuralFeature f : features) {
        if ("taskName".equals(f.getName())) { // $NON-NLS-1$
          taskName = (String) task.eGet(f);
          break;
        }
      }

      IBpmn2RuntimeExtension rte = editor.getTargetRuntime().getRuntimeExtension();
      WorkItemDefinition workItemDefinition =
          ((JBPM5RuntimeExtension) rte).getWorkItemDefinition(taskName);

      WorkDefinitionImpl wd = new WorkDefinitionImpl();
      for (String name : workItemDefinition.getParameters().keySet()) {
        String type = workItemDefinition.getParameters().get(name);
        DataTypeFactory factory = DataTypeRegistry.getFactory(type);
        wd.addParameter(new ParameterDefinitionImpl(name, factory.createDataType()));
      }

      WorkImpl w = new WorkImpl();
      w.setName(taskName);
      w.setParameterDefinitions(wd.getParameters());
      for (DataInputAssociation dia : task.getDataInputAssociations()) {
        DataInput dataInput = (DataInput) dia.getTargetRef();
        if (dataInput != null) {
          String name = dataInput.getName();
          ItemDefinition itemDefinition = dataInput.getItemSubjectRef();
          if (itemDefinition != null) {
            Object structureRef = itemDefinition.getStructureRef();
            if (ModelUtil.isStringWrapper(structureRef)) {
              ParameterDefinition parameterDefinition = w.getParameterDefinition(name);
              try {
                Object value =
                    parameterDefinition
                        .getType()
                        .readValue(ModelUtil.getStringWrapperTextValue(structureRef));
                w.setParameter(name, value);
              } catch (Exception e) {
              }
            }
          }
        }
      }

      /*
      	 * Load the class defined in the WID's "eclipse:customEditor" field.
      	 * This means that the containing Project must be a JavaProject, and
      	 * the class must exist and must implement the WorkEditor interface.
      try {
      	Resource res = ExtendedPropertiesAdapter.getResource(task);
      	URI uri = res.getURI();
      	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(uri.segment(1));
      	JavaProjectClassLoader cl = new JavaProjectClassLoader(project);
      	Class c = cl.loadClass("org.bpmn2.java.Calculator");
      	Object o = c.newInstance();
      	String s = o.toString();
      	System.out.println(s);
      } catch (Exception e) {
      	// TODO Auto-generated catch block
      	e.printStackTrace();
      }
      	 */

      WorkEditor dialog = getWorkItemEditor(task);
      dialog.setWorkDefinition(wd);
      dialog.setWork(w);
      dialog.show();

      hasChanges = dialog.getWork() != w;
      if (hasChanges) {
        w = (WorkImpl) dialog.getWork();
        for (DataInputAssociation dia : task.getDataInputAssociations()) {
          DataInput dataInput = (DataInput) dia.getTargetRef();
          if (dataInput != null) {
            String name = dataInput.getName();
            ItemDefinition itemDefinition = dataInput.getItemSubjectRef();
            // this always comes back as a String from the SampleCustomEditor dialog
            String value = (String) w.getParameter(name);
            if (value != null && !value.isEmpty()) {
              EObject structureRef = ModelUtil.createStringWrapper(value);
              if (itemDefinition == null) {
                itemDefinition =
                    Bpmn2ModelerFactory.createObject(task.eResource(), ItemDefinition.class);
                ModelUtil.getDefinitions(task).getRootElements().add(itemDefinition);
                ModelUtil.setID(itemDefinition);
              }
              itemDefinition.setItemKind(ItemKind.INFORMATION);
              itemDefinition.setStructureRef(structureRef);
              dataInput.setItemSubjectRef(itemDefinition);
            } else if (itemDefinition != null) {
              // TODO: remove Item Definition if it is on longer referenced anywhere
              //							ModelUtil.getDefinitions(task).getRootElements().remove(itemDefinition);
              dataInput.setItemSubjectRef(null);
            }
          }
        }
      }
    }