/**
   * 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 <n>" where
   * <n> 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();
  }
Esempio n. 2
0
  /** Checks wheter all goalfiles exist */
  public boolean allGoalFilesExist() {
    boolean allExist = true;
    BW4TClientConfig model = this.getModel();
    List<BotConfig> botList = model.getBots();
    for (int i = 0; i < botList.size() && allExist; i++) {
      allExist = allExist && AgentFileChecker.fileNameExists(botList.get(i).getFileName());
    }

    List<EPartnerConfig> epartnerList = model.getEpartners();
    for (int i = 0; i < epartnerList.size() && allExist; i++) {
      allExist = allExist && AgentFileChecker.fileNameExists(epartnerList.get(i).getFileName());
    }

    return allExist;
  }
Esempio n. 3
0
  /**
   * Exoirts as a mas project
   *
   * @param xmlFile
   */
  private void exportAsMASProject(File xmlFile) {
    try {
      String saveDirectory = xmlFile.getAbsolutePath();

      String extension = ".xml";
      if (!saveDirectory.endsWith(extension)) {
        saveDirectory += extension;
      }

      saveConfigAsXMLFile(saveDirectory);
      BW4TClientConfig configuration = BW4TClientConfig.fromXML(saveDirectory);

      /* Split the name into two around the ., and pass the name without the extension */
      ExportToMAS.export(xmlFile.getParent(), configuration, xmlFile.getName().split("\\.")[0]);
    } catch (JAXBException ex) {
      ScenarioEditor.handleException(ex, "Error: Saving to XML has failed.");
    } catch (FileNotFoundException ex) {
      ScenarioEditor.handleException(ex, "Error: No file has been found.");
    }
  }
Esempio n. 4
0
  @Before
  public void setUp() throws IOException, JAXBException {
    /* Delete the export directory and everything in it */
    FileUtils.deleteDirectory(new File(EXPORT_DIR));

    /* Mock the alert boxes in ScenarioEditor in the case of an error (unexpected) so Jenkins doesn't freeze */
    ScenarioEditor.setOptionPrompt(OptionPromptHelper.getYesOptionPrompt());

    configuration = BW4TClientConfig.fromXML(CONFIG_PATH);

    /*
     * Nasty hack time:
     * The exporter supports loading an existing GOAL file and copying it to the directory.
     * To test this is a challenge since paths aren't equal across computers.
     *
     * The solution is to copy the robot.goal file to the working directory, thus making it available for loading
     * during the test, and in the test breakdown to delete it.
     */
    FileUtils.copyFile(new File(AGENT_GOAL_FILE), new File(AGENT_GOAL_FILE_WORKING));

    // The actual export.
    ExportToMAS.export(EXPORT_DIR, configuration, CONFIG_NAME);
  }