public void reset() {
    for (String name : robotDialogMap.keySet()) {
      RobotDialog dialog = robotDialogMap.get(name);

      if (!dialog.isVisible()) {
        robotDialogMap.remove(name);
        dialog.detach();
        dialog.dispose();
      }
    }
  }
  public RobotDialog getRobotDialog(RobotButton robotButton, String name, boolean create) {
    RobotDialog robotDialog = robotDialogMap.get(name);

    if (create && robotDialog == null) {
      if (robotDialogMap.size() > MAX_PRE_ATTACHED) {
        reset();
      }
      robotDialog = Container.createComponent(RobotDialog.class);
      robotDialog.setup(robotButton);
      robotDialog.pack();
      WindowUtil.place(robotDialog);
      robotDialogMap.put(name, robotDialog);
    }
    return robotDialog;
  }
  public void trim(List<IRobotSnapshot> robots) {

    // new ArrayList in order to prevent ConcurrentModificationException
    for (String name : new ArrayList<String>(robotDialogMap.keySet())) {
      boolean found = false;

      for (IRobotSnapshot robot : robots) {
        if (robot.getName().equals(name)) {
          found = true;
          break;
        }
      }
      if (!found) {
        RobotDialog dialog = robotDialogMap.get(name);

        robotDialogMap.remove(name);
        dialog.dispose();
        dialog.detach();
      }
    }
  }
  public void purge(List<IRobotSnapshot> robots) {

    // new ArrayList in order to prevent ConcurrentModificationException
    for (String name : new ArrayList<String>(robotDialogMap.keySet())) {
      boolean found = false;
      boolean dead = false;
      for (IRobotSnapshot robot : robots) {
        if (robot.getName().equals(name)) {
          found = true;
          if (robot.getState().isDead()) {
            dead = true;
          }
          break;
        }
      }
      if (!found || dead) {
        RobotDialog dialog = robotDialogMap.get(name);
        System.out.println("purging " + name);
        robotDialogMap.remove(name);
        dialog.dispose();
        dialog.detach();
      }
    }
  }