/** generate the notation for the stereotype and stuff it into the text Fig */
 protected void updateStereotypeText() {
   if (getOwner() == null) {
     return;
   }
   Object modelElement = getOwner();
   stereotypeFig.setOwner(modelElement);
   ((FigStereotypesCompartment) stereotypeFig).populate();
 }
Exemplo n.º 2
0
  /** Test getModelTarget(). */
  public void testGetModelTarget() {
    Object owner = Model.getCoreFactory().buildClass();
    Fig fig = new FigRect(0, 0, 12, 12);
    fig.setOwner(owner);
    Object test = new Object();

    List<Object> list1 = new ArrayList<Object>();
    List<Object> list2 = new ArrayList<Object>();
    list2.add(test);
    List<Object> list3 = new ArrayList<Object>();
    list3.add(fig);
    list3.add(test);

    TargetListener listener = new TestTargetListener();
    TargetManager.getInstance().addTargetListener(listener);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTarget(null);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTarget(test);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTarget(fig);
    assertEquals(owner, TargetManager.getInstance().getModelTarget());
    assertEquals(owner, targetSetModelTarget);

    targetRemovedCalled = false;
    TargetManager.getInstance().removeTarget(owner);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertTrue(targetRemovedCalled);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTarget(test);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    TargetManager.getInstance().setTarget(null);
    targetAddedModelTarget = null;
    TargetManager.getInstance().addTarget(test);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetAddedModelTarget);

    TargetManager.getInstance().setTarget(null);
    targetAddedModelTarget = null;
    TargetManager.getInstance().addTarget(fig);
    assertEquals(owner, TargetManager.getInstance().getModelTarget());
    assertEquals(owner, targetAddedModelTarget);

    targetAddedModelTarget = null;
    TargetManager.getInstance().addTarget(test);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetAddedModelTarget);

    targetRemovedCalled = false;
    TargetManager.getInstance().removeTarget(null);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertTrue(!targetRemovedCalled);

    targetRemovedModelTarget = null;
    TargetManager.getInstance().removeTarget(test);
    assertEquals(owner, TargetManager.getInstance().getModelTarget());
    assertEquals(owner, targetRemovedModelTarget);

    TargetManager.getInstance().addTarget(test);
    targetRemovedModelTarget = null;
    TargetManager.getInstance().removeTarget(fig);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetRemovedModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTargets(list1);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTargets(list2);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTargets(list3);
    assertEquals(owner, TargetManager.getInstance().getModelTarget());
    assertEquals(owner, targetSetModelTarget);

    targetSetModelTarget = null;
    TargetManager.getInstance().setTargets(list2);
    assertEquals(null, TargetManager.getInstance().getModelTarget());
    assertEquals(null, targetSetModelTarget);

    TargetManager.getInstance().removeTargetListener(listener);
  }
Exemplo n.º 3
0
  /** Test getFigTarget(). */
  public void testGetFigTarget() {
    final Object owner = new Object();
    final Fig fig = new FigRect(0, 0, 12, 12);
    fig.setOwner(owner);
    Object test = new Object();
    ArgoDiagram diag =
        new ArgoDiagramImpl() {
          public Fig getContainingFig(Object obj) {
            if (obj == owner) return fig;
            return null;
          }

          public void encloserChanged(FigNode enclosed, FigNode oldEncloser, FigNode newEncloser) {}
        };
    Project p = ProjectManager.getManager().getCurrentProject();
    p.addDiagram(diag);
    TargetManager.getInstance().setTarget(diag);
    List<Object> list1 = new ArrayList<Object>();
    List<Object> list2 = new ArrayList<Object>();
    list2.add(test);
    List<Object> list3 = new ArrayList<Object>();
    list3.add(owner);
    list3.add(test);

    TargetListener listener = new TestTargetListener();
    TargetManager.getInstance().addTargetListener(listener);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTarget(null);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTarget(test);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTarget(owner);
    assertEquals(fig, TargetManager.getInstance().getFigTarget());
    assertEquals(fig, targetSetFigTarget);

    targetRemovedCalled = false;
    TargetManager.getInstance().removeTarget(fig);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertTrue(targetRemovedCalled);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTarget(test);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    TargetManager.getInstance().setTarget(null);
    targetAddedFigTarget = null;
    TargetManager.getInstance().addTarget(test);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetAddedFigTarget);

    TargetManager.getInstance().setTarget(null);
    targetAddedFigTarget = null;
    TargetManager.getInstance().addTarget(owner);
    assertEquals(fig, TargetManager.getInstance().getFigTarget());
    assertEquals(fig, targetAddedFigTarget);

    targetRemovedCalled = false;
    TargetManager.getInstance().removeTarget(null);
    assertEquals(fig, TargetManager.getInstance().getFigTarget());
    assertTrue(!targetRemovedCalled);

    targetRemovedFigTarget = null;
    TargetManager.getInstance().removeTarget(test);
    assertEquals(fig, TargetManager.getInstance().getFigTarget());

    TargetManager.getInstance().addTarget(test);
    targetRemovedFigTarget = null;
    TargetManager.getInstance().removeTarget(owner);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetRemovedFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTargets(list1);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTargets(list2);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTargets(list3);
    assertEquals(fig, TargetManager.getInstance().getFigTarget());
    assertEquals(fig, targetSetFigTarget);

    targetSetFigTarget = null;
    TargetManager.getInstance().setTargets(list2);
    assertEquals(null, TargetManager.getInstance().getFigTarget());
    assertEquals(null, targetSetFigTarget);

    TargetManager.getInstance().removeTargetListener(listener);
  }