コード例 #1
0
  public void reset() {
    for (String name : robotDialogMap.keySet()) {
      RobotDialog dialog = robotDialogMap.get(name);

      if (!dialog.isVisible()) {
        robotDialogMap.remove(name);
        dialog.detach();
        dialog.dispose();
      }
    }
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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();
      }
    }
  }
コード例 #4
0
  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();
      }
    }
  }