/** refreshDiagram void */
  private void refreshDiagram() {

    Object obj = getSelectedObjects().get(0);
    RootEditPart root = null;

    if (!(obj instanceof EditPart)) {
      return;
    }

    root = ((EditPart) obj).getRoot();
    root.refresh();

    List<EditPart> editparts = root.getChildren();
    for (EditPart editpart : editparts) {
      editpart.refresh();

      List<EditPart> nodeEditParts = editpart.getChildren();
      for (EditPart nodeEditPart : nodeEditParts) {
        if (nodeEditPart instanceof GraphicalEditPart) {

          List<EditPart> sConnectionList =
              ((GraphicalEditPart) nodeEditPart).getSourceConnections();
          List<EditPart> tConnectionList =
              ((GraphicalEditPart) nodeEditPart).getTargetConnections();

          for (EditPart sConnectionEditPart : sConnectionList) {
            sConnectionEditPart.refresh();
          }
          for (EditPart tConnectionEditPart : tConnectionList) {
            tConnectionEditPart.refresh();
          }

          if (nodeEditPart.getModel() instanceof LifeLineNode) {
            List<EditPart> childrenEditPart = nodeEditPart.getChildren();
            for (EditPart child : childrenEditPart) {
              List<EditPart> csConnectionList = ((GraphicalEditPart) child).getSourceConnections();
              List<EditPart> ctConnectionList = ((GraphicalEditPart) child).getTargetConnections();

              for (EditPart sConnectionEditPart : csConnectionList) {
                sConnectionEditPart.refresh();
              }
              for (EditPart tConnectionEditPart : ctConnectionList) {
                tConnectionEditPart.refresh();
              }
            }
          }
        }
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void refreshChildren() {
    super.refreshChildren();

    for (Object child : this.getChildren()) {
      EditPart part = (EditPart) child;
      part.refresh();
    }
  }
Пример #3
0
  protected void contentChange(Map info) {
    Object action = info.get(GraphicsViewModelEventProcessor.CONTENT_EVENTTYPE);
    if (action instanceof Integer) {
      int intValue = ((Integer) action).intValue();
      if (intValue == ViewsContentEvent.ADD
          || intValue == ViewsContentEvent.SHIFT
          || intValue == ViewsContentEvent.REMOVE) {
        if (((ReportItemHandle) getModel()).getViews().size() > 0) {
          final Object tempModel = getModel();
          final DeferredGraphicalViewer viewer = (DeferredGraphicalViewer) getViewer();
          markDirty(true);
          EditPart part = getParent();
          ((ReportElementEditPart) getParent()).removeChild(this);
          part.refresh();
          removeGuideFeedBack();
          Display.getCurrent()
              .asyncExec(
                  new Runnable() {

                    public void run() {
                      Object part = viewer.getEditPartRegistry().get(tempModel);
                      if (part != null) {
                        viewer.setSelection(new StructuredSelection(part));
                      }
                    }
                  });
          return;
        } else {
          ((ReportElementEditPart) getParent()).contentChange(info);
          return;
        }
      }
    }
    List old = new ArrayList(getChildren());
    super.contentChange(info);
    List newChildren = getChildren();
    for (int i = 0; i < old.size(); i++) {
      if (newChildren.contains(old.get(i))) {
        ((AbstractCellEditPart) old.get(i)).updateExistPart();
      }
    }
  }
Пример #4
0
 @Override
 public void execute() {
   // configure the request
   EditPart source = request.getSourceEditPart();
   EditPart target = request.getTargetEditPart();
   PointList list = feedback.getPoints();
   DiagramEditPart diagramEditPart = null;
   if (source.getParent() instanceof DiagramEditPart) {
     diagramEditPart = (DiagramEditPart) source.getParent();
   } else if (source instanceof DiagramEditPart) {
     diagramEditPart = (DiagramEditPart) source;
   } else {
     if (source.getParent().getParent() instanceof DiagramEditPart) {
       diagramEditPart = (DiagramEditPart) source.getParent().getParent();
     }
   }
   if (diagramEditPart == null) {
     return;
   }
   if (!(source instanceof DiagramEditPart || target instanceof DiagramEditPart)) {
     // one must be whitespace, we make it the target
     request.setTargetEditPart(diagramEditPart);
     // additionally we must cut the drawn connection
     // in half to share room with the element that will
     // be auto-created
     PointList newList = new PointList();
     newList.addPoint(list.getFirstPoint());
     if (list.size() == 4) {
       // rectilinear routing will have a three points
       newList.addPoint(list.getPoint(1));
     }
     newList.addPoint(list.getMidpoint());
     feedback.setPoints(newList);
   }
   // create the active tool's element first
   CreateConnectionCommand command = new CreateConnectionCommand(request, feedback);
   command.execute();
   Connector_c newConnector = command.result;
   if (newConnector == null) {
     return;
   }
   // we need to now refresh the diagram to get the new edit part
   source.refresh();
   source.getParent().refresh();
   GraphicalEditPart newPart =
       (GraphicalEditPart) source.getViewer().getEditPartRegistry().get(newConnector);
   // transfer the feedback connection points to the newly created
   // edit part
   ((Connection) newPart.getFigure()).setPoints(feedback.getPoints().getCopy());
   // now adjust the request for the new element to be created for each
   // terminal specification that requires auto-creation
   createElementForTerminalSpec(
       autoStartSpec,
       ((NonRootModelElement) diagramEditPart.getModel()).getModelRoot(),
       list,
       newPart,
       target,
       diagramEditPart);
   createElementForTerminalSpec(
       autoEndSpec,
       ((NonRootModelElement) diagramEditPart.getModel()).getModelRoot(),
       list,
       newPart,
       target,
       diagramEditPart);
 }