Ejemplo n.º 1
0
 private boolean isMissingDIElement(BaseElement be) {
   // ignore DataStores - there are bound to be references
   // to these, which *should* be rendered
   if (be instanceof DataStore) return false;
   BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(be);
   if (bpmnDiagram != null) return false;
   // couldn't find a BPMNDiagram entry for this BaseElement
   // check its container to see if it has a BPMNDiagram
   FlowElementsContainer container = this.getRootElementContainer(be);
   bpmnDiagram = DIUtils.findBPMNDiagram(container);
   if (bpmnDiagram != null) {
     // is the BaseElement defined as a BPMNShape or BPMNEdge in its
     // container's BPMNDiagram?
     if (bpmnDiagram.getPlane().getPlaneElement().contains(be)) return false;
   }
   boolean missing = (elements.get(be) == null && diagnostics.get(be) == null);
   if (missing)
     GraphicsUtil.dump(
         "Missing DI element for: "
             + be.eClass().getName()
             + " '"
             + ExtendedPropertiesProvider.getTextValue(be)
             + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   return missing;
 }
Ejemplo n.º 2
0
  private BPMNDiagram createDIDiagram(BaseElement bpmnElement) {

    BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(bpmnElement, true);

    // if this container does not have a BPMNDiagram, create one
    if (bpmnElement instanceof Process) {
      if (bpmnDiagram == null) {
        // unless this Process is referenced by a Pool
        for (Collaboration c :
            ModelUtil.getAllObjectsOfType(bpmnElement.eResource(), Collaboration.class)) {
          for (Participant p : c.getParticipants()) {
            if (!ModelUtil.isParticipantBand(p)) {
              if (p.getProcessRef() == bpmnElement) {
                bpmnDiagram = DIUtils.findBPMNDiagram(p, true);
                break;
              }
            }
          }
          if (bpmnDiagram != null) break;
        }
      } else {
        // Always create a new BPMNDiagram if this Process is being referenced by a Participant Band
        //				for (Collaboration c : ModelUtil.getAllObjectsOfType(bpmnElement.eResource(),
        // Collaboration.class)) {
        //					for (Participant p : c.getParticipants()) {
        //						if (ModelUtil.isParticipantBand(p)) {
        //							if (p.getProcessRef() == bpmnElement) {
        //								bpmnDiagram = null;
        //								break;
        //							}
        //						}
        //					}
        //					if (bpmnDiagram==null)
        //						break;
        //				}
      }
    }

    if (bpmnDiagram == null) {
      FlowElementsContainer container = getRootElementContainer(bpmnElement);
      if (container == null) {
        diagnostics.add(IStatus.ERROR, bpmnElement, Messages.DIGenerator_No_Diagram);
        return this.bpmnDiagram;
      }
      BPMNPlane plane = BpmnDiFactory.eINSTANCE.createBPMNPlane();
      plane.setBpmnElement(container);

      bpmnDiagram = BpmnDiFactory.eINSTANCE.createBPMNDiagram();
      bpmnDiagram.setName(ExtendedPropertiesProvider.getTextValue(container));
      bpmnDiagram.setPlane(plane);

      definitions.getDiagrams().add(bpmnDiagram);
    }

    return bpmnDiagram;
  }
 protected String getText(EObject o) {
   String text = ""; // $NON-NLS-1$
   if (o != null) {
     text = labelProvider.getText(o);
     if (text == null) {
       text = ExtendedPropertiesProvider.getTextValue(o);
       if (text == null || text.isEmpty()) {
         EStructuralFeature f = o.eClass().getEStructuralFeature("id"); // $NON-NLS-1$
         if (f != null) text = o.eGet(f).toString();
       }
     }
   }
   return text;
 }
Ejemplo n.º 4
0
 @Override
 public String getText(Object element) {
   EObject object = getBusinessObject(element);
   if (object != null) {
     String text = ExtendedPropertiesProvider.getTextValue(object);
     // check if this is a CustomTask
     CustomTaskDescriptor ctd = getCustomTaskDescriptor(object);
     if (ctd != null) {
       // it is! build the property tab title from the CustomTask name
       // and the object's name (which could be the same)
       String name = ctd.getName();
       if (!text.equals(name)) return name + ": " + text; // $NON-NLS-1$
     }
     return text;
   }
   //		PictogramElement pe =
   // BusinessObjectUtil.getPictogramElementForSelection((ISelection)element);
   //		if (pe!=null && pe.getGraphicsAlgorithm()!=null) {
   //			return ModelUtil.getLabel( pe.getGraphicsAlgorithm() );
   //		}
   return super.getText(element);
 }
  @Override
  protected void bindReference(Composite parent, EObject object, EReference reference) {
    if ("calledElementRef".equals(reference.getName())) { // $NON-NLS-1$
      if (isModelObjectEnabled(object.eClass(), reference)) {
        if (parent == null) parent = getAttributesParent();

        String displayName = ExtendedPropertiesProvider.getLabel(object, reference);
        ObjectEditor editor =
            new TextAndButtonObjectEditor(this, object, reference) {

              @Override
              protected void buttonClicked(int buttonId) {
                final IInputValidator validator =
                    new IInputValidator() {

                      @Override
                      public String isValid(String newText) {
                        if (newText == null || newText.isEmpty())
                          return Messages.JbpmCallActivityDetailComposite_Error_Empty;
                        if (!JbpmModelUtil.isProcessId(newText))
                          return Messages.JbpmCallActivityDetailComposite_Error_Invalid;
                        return null;
                      }
                    };

                String initialValue = ExtendedPropertiesProvider.getTextValue(object, feature);
                InputDialog dialog =
                    new InputDialog(
                        getShell(),
                        Messages.JbpmCallActivityDetailComposite_Title,
                        Messages.JbpmCallActivityDetailComposite_Message,
                        initialValue,
                        validator);
                if (dialog.open() == Window.OK) {
                  setValue(dialog.getValue());
                }
              }

              @Override
              public boolean setValue(final Object result) {
                if (result != object.eGet(feature)) {
                  TransactionalEditingDomain domain = getDiagramEditor().getEditingDomain();
                  domain
                      .getCommandStack()
                      .execute(
                          new RecordingCommand(domain) {
                            @Override
                            protected void doExecute() {
                              String id = result.toString();
                              CallableElement ce = null;
                              Definitions defs = ModelUtil.getDefinitions(object);
                              for (RootElement re : defs.getRootElements()) {
                                if (re instanceof ExternalProcess) {
                                  if (id.equals(re.getId())) {
                                    ce = (ExternalProcess) re;
                                    break;
                                  }
                                }
                              }
                              if (ce == null) {
                                ce = DroolsFactory.eINSTANCE.createExternalProcess();
                                ce.setName(id);
                                ce.setId(id);
                                defs.getRootElements().add(ce);
                              }

                              object.eSet(feature, ce);
                            }
                          });
                  //							if (getDiagramEditor().getDiagnostics()!=null) {
                  //
                  //	ErrorUtils.showErrorMessage(getDiagramEditor().getDiagnostics().getMessage());
                  //							}
                  //							else {
                  //								ErrorUtils.showErrorMessage(null);
                  //								updateText();
                  //								return true;
                  //							}
                  updateText();
                  return true;
                }
                return false;
              }
            };
        editor.createControl(parent, displayName);
      }
    } else super.bindReference(parent, object, reference);
  }