示例#1
0
  private void clearConfigForSelectedCharacters() {
    int confirmation =
        JOptionPane.showConfirmDialog(
            panel,
            "WARNING:  this will erase the current configuration for all selected characters. \nAre you certain you wish to do this?",
            "Clear Selected Configurations?",
            JOptionPane.YES_NO_OPTION);

    if (confirmation == JOptionPane.YES_OPTION) {
      for (Object character : herolabsCharacterList.getSelectedValues()) {
        config.remove(((Character) character).getName());
      }
    }

    herolabsCharacterList.repaint();
  }
示例#2
0
  private void resetToDefaultsForSelectedCharacters() {
    int confirmation =
        JOptionPane.showConfirmDialog(
            panel,
            "NOTE:  this will attempt to replace any custom configuration for the selected characters with the Portfolio defaults. \nAre you certain you wish to do this?",
            "Reset to portfolio defaults?",
            JOptionPane.YES_NO_OPTION);

    if (confirmation == JOptionPane.YES_OPTION) {
      for (Object character : herolabsCharacterList.getSelectedValues()) {
        config.populateCharacterWithDefaults(((Character) character).getName(), true);
      }
    }

    herolabsCharacterList.repaint();
  }
示例#3
0
  private void exportCharacters() {
    Object[] selectedValues = herolabsCharacterList.getSelectedValues();
    HeroLabPathfinderDigester dig = new HeroLabPathfinderDigester();
    boolean success = true;
    ArrayList<Character> notExported = new ArrayList<Character>();

    for (Object object : selectedValues) {
      Character character = (Character) object;
      try {
        if (!dig.saveCharacter(config, character)) {
          notExported.add(character);
        }
      } catch (IOException io) {
        success = false;
        errorDialog(io.getMessage(), "Something bad happened:" + io.toString());

      } catch (SAXException saxe) {
        success = false;
        errorDialog(saxe.getMessage(), "Something bad happened:" + saxe.toString());
      } catch (Exception e) {
        success = false;
        errorDialog(e.getMessage(), "Something bad happened:" + e.toString());
      }
    }

    if (success) {
      String message =
          "Successfully exported "
              + (selectedValues.length - notExported.size())
              + " out of "
              + selectedValues.length
              + " Maptools token(s).";
      if (!notExported.isEmpty()) {
        message +=
            "  "
                + notExported.size()
                + " tokens were not exported as they are not fully configured.";
        // TODO: do something more useful with this collection
      }

      JOptionPane.showMessageDialog(panel, message);
    }
  }
示例#4
0
 private void exportSelectedCharacters() {
   if (herolabsCharacterList.getSelectedIndex() >= 0) {
     Character c =
         (Character)
             herolabsCharacterList
                 .getModel()
                 .getElementAt(herolabsCharacterList.getSelectedIndex());
     Config.ConfigEntry ce = config.get(c.getName());
     if (ce != null && ce.isOk()) {
       exportCharacters();
     } else {
       JOptionPane.showMessageDialog(
           panel,
           "The character you selected hasn't been configured yet.  Please configure "
               + "and try again.",
           "Export Warning",
           JOptionPane.WARNING_MESSAGE);
     }
   }
 }
示例#5
0
  private static void createAndShowGUI() {

    JFrame frame = null;
    try {
      TokenLabUI ui = new TokenLabUI();
      frame = new ExitFrame(ui.config);
      Dimension preferredSize = new Dimension(320, 500);
      frame.setPreferredSize(preferredSize);
      ui.setDefaults();
      frame.setContentPane(ui.panel);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      frame.pack();
      frame.setVisible(true);
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          frame,
          "Something bad happened! \n" + e.toString(),
          "Fatal error",
          JOptionPane.ERROR_MESSAGE);
    }
  }
示例#6
0
 private void errorDialog(String title, String error) {
   JOptionPane.showMessageDialog(panel, error, title, JOptionPane.ERROR_MESSAGE);
 }