Esempio n. 1
0
  /**
   * @see
   *     org.argouml.cognitive.ToDoListListener#toDoItemsChanged(org.argouml.cognitive.ToDoListEvent)
   */
  public void toDoItemsChanged(ToDoListEvent tde) {
    LOG.debug("toDoItemsChanged");
    Vector items = tde.getToDoItems();
    int nItems = items.size();
    Object[] path = new Object[2];
    path[0] = Designer.theDesigner().getToDoList();

    Vector goals = Designer.theDesigner().getGoals();
    Enumeration elems = goals.elements();
    while (elems.hasMoreElements()) {
      Goal g = (Goal) elems.nextElement();
      path[1] = g;
      int nMatchingItems = 0;
      for (int i = 0; i < nItems; i++) {
        ToDoItem item = (ToDoItem) items.elementAt(i);
        if (!item.supports(g)) continue;
        nMatchingItems++;
      }
      if (nMatchingItems == 0) continue;
      int[] childIndices = new int[nMatchingItems];
      Object[] children = new Object[nMatchingItems];
      nMatchingItems = 0;
      for (int i = 0; i < nItems; i++) {
        ToDoItem item = (ToDoItem) items.elementAt(i);
        if (!item.supports(g)) continue;
        childIndices[nMatchingItems] = getIndexOfChild(g, item);
        children[nMatchingItems] = item;
        nMatchingItems++;
      }
      fireTreeNodesChanged(this, path, childIndices, children);
    }
  }
Esempio n. 2
0
  /*
   * @see org.argouml.cognitive.ToDoListListener#toDoItemsAdded(org.argouml.cognitive.ToDoListEvent)
   */
  public void toDoItemsAdded(ToDoListEvent tde) {
    LOG.debug("toDoItemAdded");
    Object[] path = new Object[2];
    path[0] = Designer.theDesigner().getToDoList();

    for (Goal g : Designer.theDesigner().getGoalList()) {
      path[1] = g;
      int nMatchingItems = 0;
      for (ToDoItem item : tde.getToDoItemList()) {
        if (!item.supports(g)) {
          continue;
        }
        nMatchingItems++;
      }
      if (nMatchingItems == 0) {
        continue;
      }
      int[] childIndices = new int[nMatchingItems];
      Object[] children = new Object[nMatchingItems];
      nMatchingItems = 0;
      // TODO: This shouldn't require two passes through the list - tfm
      for (ToDoItem item : tde.getToDoItemList()) {
        if (!item.supports(g)) {
          continue;
        }
        childIndices[nMatchingItems] = getIndexOfChild(g, item);
        children[nMatchingItems] = item;
        nMatchingItems++;
      }
      fireTreeNodesInserted(this, path, childIndices, children);
    }
  }
Esempio n. 3
0
  /*
   * @see org.argouml.cognitive.ToDoListListener#toDoItemsChanged(org.argouml.cognitive.ToDoListEvent)
   */
  public void toDoItemsChanged(ToDoListEvent tde) {
    LOG.debug("toDoItemsChanged");
    Object[] path = new Object[2];
    path[0] = Designer.theDesigner().getToDoList();

    for (Goal g : Designer.theDesigner().getGoalList()) {
      path[1] = g;
      int nMatchingItems = 0;
      for (ToDoItem item : tde.getToDoItemList()) {
        if (!item.supports(g)) {
          continue;
        }
        nMatchingItems++;
      }
      if (nMatchingItems == 0) continue;
      int[] childIndices = new int[nMatchingItems];
      Object[] children = new Object[nMatchingItems];
      nMatchingItems = 0;
      for (ToDoItem item : tde.getToDoItemList()) {
        if (!item.supports(g)) {
          continue;
        }
        childIndices[nMatchingItems] = getIndexOfChild(g, item);
        children[nMatchingItems] = item;
        nMatchingItems++;
      }
      fireTreeNodesChanged(this, path, childIndices, children);
    }
  }
Esempio n. 4
0
 /** @see java.lang.Runnable#run() */
 public void run() {
   Designer dsgr = Designer.theDesigner();
   org.argouml.uml.cognitive.critics.Init.init();
   org.argouml.uml.cognitive.checklist.Init.init();
   Project p = ProjectManager.getManager().getCurrentProject();
   // set the icon for this poster
   dsgr.setClarifier(ResourceLoaderWrapper.lookupIconResource("PostItD0"));
   dsgr.setDesignerName(Configuration.getString(Argo.KEY_USER_FULLNAME));
   Configuration.addListener(Argo.KEY_USER_FULLNAME, dsgr); // MVW
   dsgr.spawnCritiquer(p);
   dsgr.setChildGenerator(new ChildGenUML());
   java.util.Enumeration models = (p.getUserDefinedModels()).elements();
   while (models.hasMoreElements()) {
     Object o = models.nextElement();
     Model.getPump().addModelEventListener(dsgr, o);
   }
   LOG.info("spawned critiquing thread");
   dsgr.getDecisionModel().startConsidering(UMLDecision.CLASS_SELECTION);
   dsgr.getDecisionModel().startConsidering(UMLDecision.BEHAVIOR);
   dsgr.getDecisionModel().startConsidering(UMLDecision.NAMING);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STORAGE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.INHERITANCE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.CONTAINMENT);
   dsgr.getDecisionModel().startConsidering(UMLDecision.PLANNED_EXTENSIONS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STATE_MACHINES);
   dsgr.getDecisionModel().startConsidering(UMLDecision.PATTERNS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.RELATIONSHIPS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.INSTANCIATION);
   dsgr.getDecisionModel().startConsidering(UMLDecision.MODULARITY);
   dsgr.getDecisionModel().startConsidering(UMLDecision.EXPECTED_USAGE);
   dsgr.getDecisionModel().startConsidering(UMLDecision.METHODS);
   dsgr.getDecisionModel().startConsidering(UMLDecision.CODE_GEN);
   dsgr.getDecisionModel().startConsidering(UMLDecision.STEREOTYPES);
   Designer.setUserWorking(true);
 }
 private void doAdd() {
   Designer designer = Designer.theDesigner();
   String headline = headLineTextField.getText();
   int priority = ToDoItem.HIGH_PRIORITY;
   switch (priorityComboBox.getSelectedIndex()) {
     case 0:
       priority = ToDoItem.HIGH_PRIORITY;
       break;
     case 1:
       priority = ToDoItem.MED_PRIORITY;
       break;
     case 2:
       priority = ToDoItem.LOW_PRIORITY;
       break;
   }
   String desc = descriptionTextArea.getText();
   String moreInfoURL = moreinfoTextField.getText();
   ListSet newOffenders = new ListSet();
   for (int i = 0; i < offenderList.getModel().getSize(); i++) {
     newOffenders.add(offenderList.getModel().getElementAt(i));
   }
   ToDoItem item = new UMLToDoItem(designer, headline, priority, desc, moreInfoURL, newOffenders);
   designer.getToDoList().addElement(item); // ? inform()
   Designer.firePropertyChange(Designer.MODEL_TODOITEM_ADDED, null, item);
 }
Esempio n. 6
0
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent ae) {
    if (OsUtil.isWin32()) {
      ToDoItem target = (ToDoItem) getRememberedTarget();
      Poster p = target.getPoster();
      String to = p.getExpertEmail();
      String subject = target.getHeadline().trim();
      /* The replaceAll function is only supported in Java 1.4 and up.
       * Once we stop supporting Java 1.3,
       * we can reintroduce this clean solution!
       * subject = subject.replaceAll("\\s", "%20");
       */
      int i;
      while ((i = subject.indexOf(" ")) >= 0) {
        StringBuffer s = new StringBuffer(subject);
        subject = s.replace(i, i + 1, "%20").toString();
      }

      Designer dsgr = Designer.theDesigner();
      try {
        // MVW: This works under MSWindows only, I guess.
        Runtime.getRuntime()
            .exec("cmd /c start mailto:" + to + "?subject=" + subject + "&body=" + dsgr);
      } catch (Exception ex) {
        /*ignore for now*/
      }
    } else {
      EmailExpertDialog dialog = new EmailExpertDialog();
      dialog.setTarget(getRememberedTarget());
      dialog.setVisible(true);
    }
  }
Esempio n. 7
0
  /*
   * @see org.argouml.cognitive.ToDoListListener#toDoItemsRemoved(org.argouml.cognitive.ToDoListEvent)
   */
  public void toDoItemsRemoved(ToDoListEvent tde) {
    LOG.debug("toDoItemAdded");
    Object[] path = new Object[2];
    path[0] = Designer.theDesigner().getToDoList();

    for (Goal g : Designer.theDesigner().getGoalList()) {
      LOG.debug("toDoItemRemoved updating decision node!");
      boolean anyInGoal = false;
      for (ToDoItem item : tde.getToDoItemList()) {
        if (item.supports(g)) anyInGoal = true;
      }
      if (!anyInGoal) continue;
      path[1] = g;
      // fireTreeNodesChanged(this, path, childIndices, children);
      fireTreeStructureChanged(path);
    }
  }
  /** @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent) */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // TODO: Remove this line after 0.20.
    // This is a hack that removes the ordering menu according to issue 3645
    popUpActions.remove(0);

    // popupAddOffset should be equal to the number of items added here:
    popUpActions.addElement(new JSeparator());
    popupAddOffset = 1;
    if (removeFromDiagram) {
      popUpActions.addElement(ProjectBrowser.getInstance().getRemoveFromDiagramAction());
      popupAddOffset++;
    }
    popUpActions.addElement(new ActionDeleteModelElements());
    popupAddOffset++;

    /* Check if multiple items are selected: */
    boolean ms = TargetManager.getInstance().getTargets().size() > 1;
    if (!ms) {
      // #if defined(COGNITIVE)
      // @#$LPS-COGNITIVE:GranularityType:Statement
      // @#$LPS-COGNITIVE:Localization:NestedStatement
      ToDoList list = Designer.theDesigner().getToDoList();
      Vector items = (Vector) list.elementsForOffender(getOwner()).clone();
      if (items != null && items.size() > 0) {
        ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
        ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
        if (itemUnderMouse != null) {
          critiques.add(new ActionGoToCritique(itemUnderMouse));
          critiques.addSeparator();
        }
        int size = items.size();
        for (int i = 0; i < size; i++) {
          ToDoItem item = (ToDoItem) items.elementAt(i);
          if (item == itemUnderMouse) continue;
          critiques.add(new ActionGoToCritique(item));
        }
        popUpActions.insertElementAt(new JSeparator(), 0);
        popUpActions.insertElementAt(critiques, 0);
      }
    }
    // #endif

    // Add stereotypes submenu
    Action[] stereoActions = getApplyStereotypeActions();
    if (stereoActions != null) {
      popUpActions.insertElementAt(new JSeparator(), 0);
      ArgoJMenu stereotypes = new ArgoJMenu("menu.popup.apply-stereotypes");
      for (int i = 0; i < stereoActions.length; ++i) {
        stereotypes.addCheckItem(stereoActions[i]);
      }
      popUpActions.insertElementAt(stereotypes, 0);
    }
    return popUpActions;
  }
Esempio n. 9
0
  /**
   * Internal method.
   *
   * @param e the element
   */
  protected void handleTodoItemEnd(XMLElement e) {
    ToDoItem item;
    Designer dsgr;

    /* This is expected to be safe, don't add a try block here */

    dsgr = Designer.theDesigner();
    item = new ToDoItem(dsgr, headline, priority, description, moreinfourl, new ListSet());
    dsgr.getToDoList().addElement(item);
    // cat.debug("Added ToDoItem: " + _headline);
  }
  /** @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */
  public void actionPerformed(ActionEvent ae) {
    super.actionPerformed(ae);

    // stop/start creating more critics
    Designer d = Designer.theDesigner();
    boolean b = d.getAutoCritique();
    d.setAutoCritique(!b);

    // stop/start cleaning up invalid TodoItems.
    ToDoList.getInstance().setPaused(!ToDoList.getInstance().isPaused());
  }
Esempio n. 11
0
  /**
   * Internal method.
   *
   * @param e the element
   */
  protected void handleIssueEnd(XMLElement e) {
    Designer dsgr;
    ResolvedCritic item;

    if (critic == null) {
      return;
    }

    item = new ResolvedCritic(critic, offenders);
    dsgr = Designer.theDesigner();
    dsgr.getToDoList().addResolvedCritic(item);
  }
Esempio n. 12
0
  /**
   * @see
   *     org.argouml.cognitive.ToDoListListener#toDoItemsRemoved(org.argouml.cognitive.ToDoListEvent)
   */
  public void toDoItemsRemoved(ToDoListEvent tde) {
    LOG.debug("toDoItemAdded");
    Vector items = tde.getToDoItems();
    int nItems = items.size();
    Object[] path = new Object[2];
    path[0] = Designer.theDesigner().getToDoList();

    Vector goals = Designer.theDesigner().getGoals();
    Enumeration elems = goals.elements();
    while (elems.hasMoreElements()) {
      Goal g = (Goal) elems.nextElement();
      LOG.debug("toDoItemRemoved updating decision node!");
      boolean anyInGoal = false;
      for (int i = 0; i < nItems; i++) {
        ToDoItem item = (ToDoItem) items.elementAt(i);
        if (item.supports(g)) anyInGoal = true;
      }
      if (!anyInGoal) continue;
      path[1] = g;
      // fireTreeNodesChanged(this, path, childIndices, children);
      fireTreeStructureChanged(path);
    }
  }
 /**
  * The user clicked on the clarifier.
  *
  * @param x the x of the point clicked
  * @param y the y of the point clicked
  * @return the todo item clicked
  */
 public ToDoItem hitClarifier(int x, int y) {
   int iconPos = 25, xOff = -4, yOff = -4;
   Point p = new Point();
   ToDoList list = Designer.theDesigner().getToDoList();
   Vector items = list.elementsForOffender(getOwner());
   int size = items.size();
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     stuffPointAlongPerimeter(iconPos, p);
     int width = icon.getIconWidth();
     int height = icon.getIconHeight();
     if (y >= p.y + yOff && y <= p.y + height + yOff && x >= p.x + xOff && x <= p.x + width + xOff)
       return item;
     iconPos += width;
   }
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     if (icon instanceof Clarifier) {
       ((Clarifier) icon).setFig(this);
       ((Clarifier) icon).setToDoItem(item);
       if (((Clarifier) icon).hit(x, y)) return item;
     }
   }
   items = list.elementsForOffender(this);
   size = items.size();
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     stuffPointAlongPerimeter(iconPos, p);
     int width = icon.getIconWidth();
     int height = icon.getIconHeight();
     if (y >= p.y + yOff && y <= p.y + height + yOff && x >= p.x + xOff && x <= p.x + width + xOff)
       return item;
     iconPos += width;
   }
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     if (icon instanceof Clarifier) {
       ((Clarifier) icon).setFig(this);
       ((Clarifier) icon).setToDoItem(item);
       if (((Clarifier) icon).hit(x, y)) return item;
     }
   }
   return null;
 }
 /*
  * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
  */
 public int getChildCount(Object parent) {
   if (parent instanceof ToDoList) {
     return getGoalList().size();
   }
   if (parent instanceof Goal) {
     Goal g = (Goal) parent;
     int count = 0;
     List<ToDoItem> itemList = Designer.theDesigner().getToDoList().getToDoItemList();
     synchronized (itemList) {
       for (ToDoItem item : itemList) {
         if (item.getPoster().supports(g)) {
           count++;
         }
       }
     }
     return count;
   }
   return 0;
 }
 /*
  * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
  */
 public Object getChild(Object parent, int index) {
   if (parent instanceof ToDoList) {
     return getGoalList().get(index);
   }
   if (parent instanceof Goal) {
     Goal g = (Goal) parent;
     List<ToDoItem> itemList = Designer.theDesigner().getToDoList().getToDoItemList();
     synchronized (itemList) {
       for (ToDoItem item : itemList) {
         if (item.getPoster().supports(g)) {
           if (index == 0) {
             return item;
           }
           index--;
         }
       }
     }
   }
   throw new IndexOutOfBoundsException("getChild shouldnt get here " + "GoListToGoalsToItems");
 }
 /*
  * @see javax.swing.tree.TreeModel#getIndexOfChild(
  * java.lang.Object, java.lang.Object)
  */
 public int getIndexOfChild(Object parent, Object child) {
   if (parent instanceof ToDoList) {
     return getGoalList().indexOf(child);
   }
   if (parent instanceof Goal) {
     // instead of making a new list, decrement index, return when
     // found and index == 0
     List<ToDoItem> candidates = new ArrayList<ToDoItem>();
     Goal g = (Goal) parent;
     List<ToDoItem> itemList = Designer.theDesigner().getToDoList().getToDoItemList();
     synchronized (itemList) {
       for (ToDoItem item : itemList) {
         if (item.getPoster().supports(g)) {
           candidates.add(item);
         }
       }
     }
     return candidates.indexOf(child);
   }
   return -1;
 }
 /** @param g the <code>Graphics</code> object */
 protected void paintClarifiers(Graphics g) {
   // #if defined(COGNITIVE)
   // @#$LPS-COGNITIVE:GranularityType:MethodBody
   // @#$LPS-COGNITIVE:Localization:EntireMethod
   int iconPos = 25, gap = 1, xOff = -4, yOff = -4;
   Point p = new Point();
   ToDoList list = Designer.theDesigner().getToDoList();
   Vector items = list.elementsForOffender(getOwner());
   int size = items.size();
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     if (icon instanceof Clarifier) {
       ((Clarifier) icon).setFig(this);
       ((Clarifier) icon).setToDoItem(item);
     }
     if (icon != null) {
       stuffPointAlongPerimeter(iconPos, p);
       icon.paintIcon(null, g, p.x + xOff, p.y + yOff);
       iconPos += icon.getIconWidth() + gap;
     }
   }
   items = list.elementsForOffender(this);
   size = items.size();
   for (int i = 0; i < size; i++) {
     ToDoItem item = (ToDoItem) items.elementAt(i);
     Icon icon = item.getClarifier();
     if (icon instanceof Clarifier) {
       ((Clarifier) icon).setFig(this);
       ((Clarifier) icon).setToDoItem(item);
     }
     if (icon != null) {
       stuffPointAlongPerimeter(iconPos, p);
       icon.paintIcon(null, g, p.x + xOff, p.y + yOff);
       iconPos += icon.getIconWidth() + gap;
     }
   }
   // #endif
 }
 /** The constructor. */
 public ActionAutoCritique() {
   super(Translator.localize("action.toggle-auto-critique"), null);
   // Set the tooltip string:
   putValue(Action.SHORT_DESCRIPTION, Translator.localize("action.toggle-auto-critique"));
   putValue("SELECTED", Boolean.valueOf(Designer.theDesigner().getAutoCritique()));
 }
 /** @return the goals */
 public List<Goal> getGoalList() {
   return Designer.theDesigner().getGoalModel().getGoalList();
 }