public boolean removeModelElement(ModelElement e) {
    if (e instanceof Activity) {
      Activity a = (Activity) e;
      Collection links = ApesMediator.getInstance().getLinks(mFlowDiagram, getOwner());
      if (getOwner() != null && !contains(links, a)) {
        if (getOwner() != null && getOwner().containsFeature(a)) {
          getOwner().removeFeature(a);
        }
        a.setOwner(null);
      }
      return removeSubWork((Activity) e);
    }
    if (e instanceof FlowDiagram && mFlowDiagram == (FlowDiagram) e) {
      return removeFlowDiagram();
    }
    if (e instanceof ActivityDiagram && mActivityDiagram == (ActivityDiagram) e) {
      return removeActivityDiagram();
    }

    return false;
  }
  public boolean addModelElement(ModelElement e) {
    if (e instanceof Activity) {
      Activity a = (Activity) e;
      if (addSubWork(a)) {
        if (a.getOwner() == null && getOwner() != null) {
          if (getOwner() != null && !getOwner().containsFeature(a)) {
            getOwner().addFeature(a);
          }
          a.setOwner(getOwner());
        }
        return true;
      }
      return false;
    }
    if (e instanceof FlowDiagram) {
      return addFlowDiagram((FlowDiagram) e);
    }
    if (e instanceof ActivityDiagram) {
      return addActivityDiagram((ActivityDiagram) e);
    }

    return false;
  }