예제 #1
0
  public void realizeParent(CompoundCommand tgtCmd) {
    // logger.info("realizeParent: " + this);
    // logger.info(this.getClass().getName() + " .realizeParent() - parent: " + parent
    //        + " / findEditPart(parent): " + findEditPart(parent));

    if (getModel() instanceof DerivedArtifact) return;

    final Artifact parentArt =
        getArtifact().getArt().queryParentArtifact(getBrowseModel().getRepo());
    if (parentArt == null) return;

    final ReloController rc = getRootController();

    ArtifactEditPart parentEP = (ArtifactEditPart) findEditPart(parentArt);
    if (parentEP != null) {
      parentEP.assertParenthood(tgtCmd);
      return;
    }

    if (!rc.artCreatable(parentArt)) return; // check if browse model will allow

    // parentEP = null and it is creatable

    tgtCmd.add(new CreateParentCommand(this, "create parent and assert parenthood", parentArt, rc));
    return;
  }
예제 #2
0
  /**
   * Ensures that all elements on a valid path (given by rel) are shown Note: src.rel.tgt &&
   * src!=tgt has to be true
   *
   * @param rel - join defining valid paths
   */
  public void showPathElements(JoinedRelType rel) {
    Artifact curArt = getArtifact().getArt();

    if (!isActive()) {
      log("not active");
      return;
    }

    logBeg("showPathElements");

    ReloController rc = getRootController();
    for (ArtifactEditPart visEP : rc.getVisibleNonDerivedArtifactEditParts()) {
      Artifact visArt = visEP.getArtifact().getArt();
      if (curArt.equals(visArt)) continue;
      // ObjectPair examiningPair = new ObjectPair(this, visEP);

      for (List<Artifact> resultSetVar : rel.getPaths(getRepo(), curArt, visArt)) {
        for (Artifact resultArt : resultSetVar) {
          rc.createOrFindArtifactEditPart(resultArt);
        }
      }

      // flip order of pair (everything else is identical
      for (List<Artifact> resultSetVar : rel.getPaths(getRepo(), visArt, curArt)) {
        for (Artifact resultArt : resultSetVar) {
          rc.createOrFindArtifactEditPart(resultArt);
        }
      }
    }
    logEnd();
  }
예제 #3
0
  // TODO: clean the threading/scheduling functionality here (may need UNDO support)
  private void autoBrowse(List<ArtifactEditPart> selEP, IProgressMonitor monitor) {
    for (ArtifactEditPart endEP : selEP) {
      for (ArtifactEditPart startEP : selEP) {
        // check start and end so that we call auto-browse only once
        if (endEP == startEP) break;

        autoBrowse(startEP.getArtifact().getArt(), endEP.getArtifact().getArt(), 5, monitor);
      }
    }
  }
예제 #4
0
  /** Asserts parenthood for this AEP */
  public void assertParenthood(CompoundCommand tgtCmd) {
    final ArtifactEditPart thisAEP = this;
    Artifact thisArt = thisAEP.getArtifact().getArt();
    ReloController rc = getRootController();

    // logger.info("assertParenthood: " + thisAEP);

    for (Artifact child : thisArt.queryChildrenArtifacts(thisAEP.getRepo())) {
      final ArtifactEditPart childEP = rc.findArtifactEditPart(child);
      if (childEP == null) continue;

      final ArtifactEditPart oldParentEP = (ArtifactEditPart) childEP.getParent();

      Command reparentCmd = new ReparentCommand(childEP, thisAEP, oldParentEP);

      if (oldParentEP instanceof ReloController) {
        // was at the top level before
        tgtCmd.add(reparentCmd);
        continue;
      }

      ArtifactEditPart oldParentAEP = (ArtifactEditPart) oldParentEP;

      // want to do: if (oldParentAEP == thisAEP) continue;
      //      need to do this otherwise we will have infinite loops
      // we also need to take into account derived code units as well

      // @tag post-rearch-verify
      if (oldParentAEP
          .getArtifact()
          .getNonDerivedBaseArtifact()
          .equals(thisAEP.getArtifact().getNonDerivedBaseArtifact())) {
        continue;
      }

      tgtCmd.add(reparentCmd);
    }
  }
예제 #5
0
 public void addModelAndChild(ArtifactEditPart child) {
   addChild(child);
   appendModelChild(child.getArtifact());
 }