Ejemplo n.º 1
0
  /**
   * Listens to the map file chooser and sets a map file
   *
   * <p>Actionhandler that listens to the map file chooser. It creates a filter for MAP files in the
   * file dialog and makes sure only MAP files are accepted and set.
   *
   * @param actionEvent is the event.
   */
  public void actionPerformed(final ActionEvent actionEvent) {
    /** Create a file chooser, opening at the last path location saved in the configuration panel */
    JFileChooser fc = view.getConfigurationPanel().getFileChooser();

    /** Create a file name extension filter to filter on MAP files */
    int returnVal = fc.showOpenDialog(view);
    File file = fc.getSelectedFile();
    String mapExtension = ".map";

    /** Makes sure only files with the right extension are accepted */
    if (returnVal == JFileChooser.APPROVE_OPTION) {
      if (file.getName().endsWith(mapExtension)) {
        view.getConfigurationPanel().setMapFile(file.getPath());
      } else {
        ScenarioEditor.getOptionPrompt().showMessageDialog(view, "This is not a valid file.");
      }
    }
  }
  /**
   * Listens to the add communicator bot button. Executes action that needs to happen when the
   * "Communicator Bot" button is pressed. Gives default name of "Communicator Bot &lt;n&gt;" where
   * &lt;n&gt; is the n'th bot created.
   *
   * @param ae The action event.
   */
  public void actionPerformed(final ActionEvent ae) {
    BotConfig newBotConfig = new BotConfig();
    newBotConfig.setColorBlindHandicap(true);
    newBotConfig.setGripperHandicap(true);
    newBotConfig.setFileName(BotConfig.DEFAULT_GOAL_FILENAME);
    newBotConfig.setReferenceName(BotConfig.DEFAULT_GOAL_FILENAME_REFERENCE);

    botCount = model.getBots().size() + 1;
    newBotConfig.setBotName("Communicator Bot " + botCount);

    model.addBot(newBotConfig);
    view.getEntityPanel().getBotTableModel().update();
  }