예제 #1
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      // Get the renderer component from parent class

      JLabel label =
          (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

      // Get icon to use for the list item value
      Character character = (Character) value;
      Config.ConfigEntry ce = config.get(character.getName());
      Icon icon = null;

      if (ce == null) {
        icon = icons.get(NOTOK);
        label.setToolTipText(
            "Double-click to enter configuration information for this character, right-click for more options");
      } else {
        if (ce.isOk()) {
          icon = icons.get(OK);
          ui.exportAllButton.setEnabled(true);
        } else {
          icon = icons.get(NOTOK);
        }
      }
      // Set icon to display for value

      label.setIcon(icon);
      return label;
    }
예제 #2
0
  private Collection<Config.ConfigEntry> getSelectedCharacters() {
    final Collection<Config.ConfigEntry> entries = new ArrayList<Config.ConfigEntry>();

    Object[] selectedValues = herolabsCharacterList.getSelectedValues();
    for (Object object : selectedValues) {
      entries.add(config.getOrCreate(((Character) object).getName()));
    }

    return entries;
  }
예제 #3
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();
  }
예제 #4
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();
  }
예제 #5
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);
     }
   }
 }
예제 #6
0
 private void defaultNonOverriddenConfigurations() {
   ListModel model = herolabsCharacterList.getModel();
   for (int i = 0; i < model.getSize(); i++) {
     config.populateCharacterWithDefaults(((Character) model.getElementAt(i)).getName(), false);
   }
 }