示例#1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   CompanionSupportFacade support = character.getCompanionSupport();
   if (REMOVE_COMMAND.equals(e.getActionCommand())) {
     CompanionFacade companion = (CompanionFacade) selectedElement;
     int ret =
         JOptionPane.showConfirmDialog(
             button,
             LanguageBundle.getFormattedString(
                 "in_companionConfirmRemovalMsg",
                 companion //$NON-NLS-1$
                     .getNameRef()
                     .getReference()),
             LanguageBundle.getString("in_companionConfirmRemoval"), // $NON-NLS-1$
             JOptionPane.YES_NO_OPTION);
     if (ret == JOptionPane.YES_OPTION) {
       support.removeCompanion(companion);
     }
   }
   if (CREATE_COMMAND.equals(e.getActionCommand())) {
     initDialog();
     String type = (String) selectedElement;
     companionDialog.setCharacter(character);
     companionDialog.setCompanionType(type);
     Utility.setDialogRelativeLocation(CompanionInfoTab.this, companionDialog);
     companionDialog.setVisible(true);
     CharacterFacade comp = companionDialog.getNewCompanion();
     if (comp != null) {
       selectCompanion(comp);
     }
   }
   cancelCellEditing();
 }
示例#2
0
 private void initMenus() {
   charToolsItem.setMnemonic(
       LanguageBundle.getMnemonic("in_mn_plugin_pcgtracker_name")); // $NON-NLS-1$
   charToolsItem.setText(LanguageBundle.getString("in_plugin_pcgtracker_name")); // $NON-NLS-1$
   charToolsItem.addActionListener(this::toolMenuItem);
   messageHandler.handleMessage(new AddMenuItemToGMGenToolsMenuMessage(this, charToolsItem));
 }
  @Override
  public void previewSpells() {
    boolean aBool = SettingsHandler.getPrintSpellsWithPC();
    SettingsHandler.setPrintSpellsWithPC(true);

    String templateFileName =
        PCGenSettings.getInstance().getProperty(PCGenSettings.SELECTED_SPELL_SHEET_PATH);
    if (StringUtils.isEmpty(templateFileName)) {
      delegate.showErrorMessage(
          Constants.APPLICATION_NAME, LanguageBundle.getString("in_spellNoSheet")); // $NON-NLS-1$
      return;
    }
    File templateFile = new File(templateFileName);

    File outputFile = BatchExporter.getTempOutputFilename(templateFile);

    boolean success;
    if (ExportUtilities.isPdfTemplate(templateFile)) {
      success = BatchExporter.exportCharacterToPDF(pcFacade, outputFile, templateFile);
    } else {
      success = BatchExporter.exportCharacterToNonPDF(pcFacade, outputFile, templateFile);
    }
    if (success) {
      try {
        Utility.viewInBrowser(outputFile);
      } catch (IOException e) {
        Logging.errorPrint("SpellSupportFacadeImpl.previewSpells failed", e);
        delegate.showErrorMessage(
            Constants.APPLICATION_NAME,
            LanguageBundle.getString("in_spellPreviewFail")); // $NON-NLS-1$
      }
    }
    SettingsHandler.setPrintSpellsWithPC(aBool);
  }
示例#4
0
  public void initialize() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(gridbag);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(2, 2, 2, 2);

    int col = 0;
    Utility.buildConstraints(c, col, 0, 1, 1, 100, 20);
    JLabel label =
        new JLabel(LanguageBundle.getFormattedString("in_SolverView_Perspective")); // $NON-NLS-1$
    gridbag.setConstraints(label, c);
    getContentPane().add(label);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(identifierChooser, c);
    getContentPane().add(identifierChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(scopeChooser, c);
    getContentPane().add(scopeChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(objectChooser, c);
    getContentPane().add(objectChooser);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    label =
        new JLabel(
            LanguageBundle.getFormattedString("in_SolverView_VarName") // $NON-NLS-1$
            );
    gridbag.setConstraints(label, c);
    getContentPane().add(label);

    Utility.buildConstraints(c, col++, 1, 1, 1, 0, 20);
    gridbag.setConstraints(varName, c);
    getContentPane().add(varName);

    tableModel = new SolverTableModel();
    viewTable = new JTable(tableModel);

    viewTable.getColumnModel().getColumn(0).setPreferredWidth(25);
    viewTable.getColumnModel().getColumn(1).setPreferredWidth(50);
    viewTable.getColumnModel().getColumn(2).setPreferredWidth(25);
    viewTable.getColumnModel().getColumn(3).setPreferredWidth(50);

    Utility.buildConstraints(c, 0, 2, col, 1, 0, 1000);
    JScrollPane pane = new JScrollPane(viewTable);
    viewTable.setFillsViewportHeight(true);
    pane.setPreferredSize(new Dimension(500, 300));
    gridbag.setConstraints(pane, c);
    getContentPane().add(pane);

    setTitle("Core Variable Debug View");
    getContentPane().setSize(500, 400);
    pack();
    Utility.centerFrame(this, true);
  }
示例#5
0
  /* (non-Javadoc)
   * @see pcgen.core.prereq.PrerequisiteTest#toHtmlString(pcgen.core.prereq.Prerequisite)
   */
  @Override
  public String toHtmlString(final Prerequisite prereq) {
    final PrerequisiteTestFactory factory = PrerequisiteTestFactory.getInstance();

    StringBuilder str = new StringBuilder(250);
    String delimiter = ""; // $NON-NLS-1$
    for (Prerequisite element : prereq.getPrerequisites()) {
      final PrerequisiteTest test = factory.getTest(element.getKind());
      if (test == null) {
        Logging.errorPrintLocalised(
            "PreMult.cannot_find_subformatter", element.getKind()); // $NON-NLS-1$
      } else {
        str.append(delimiter);
        if (test instanceof PreMult && !delimiter.equals("")) {
          str.append("##BR##");
        }
        str.append(test.toHtmlString(element));
        delimiter = LanguageBundle.getString("PreMult.html_delimiter"); // $NON-NLS-1$
      }
    }

    // Handle some special cases - all required, one required or none required
    int numRequired = -1;
    if (StringUtils.isNumeric(prereq.getOperand())) {
      numRequired = Integer.parseInt(prereq.getOperand());
    }
    if ((prereq.getOperator() == PrerequisiteOperator.GTEQ
            || prereq.getOperator() == PrerequisiteOperator.GT
            || prereq.getOperator() == PrerequisiteOperator.EQ)
        && numRequired == prereq.getPrerequisites().size()) {
      return LanguageBundle.getFormattedString(
          "PreMult.toHtmlAllOf", //$NON-NLS-1$
          str.toString());
    }
    if ((prereq.getOperator() == PrerequisiteOperator.GTEQ
            || prereq.getOperator() == PrerequisiteOperator.EQ)
        && numRequired == 1) {
      return LanguageBundle.getFormattedString(
          "PreMult.toHtmlEither", //$NON-NLS-1$
          str.toString());
    }
    if ((prereq.getOperator() == PrerequisiteOperator.LT && numRequired == 1)
        || ((prereq.getOperator() == PrerequisiteOperator.EQ
                || prereq.getOperator() == PrerequisiteOperator.LTEQ)
            && numRequired == 0)) {
      return LanguageBundle.getFormattedString(
          "PreMult.toHtmlNone", //$NON-NLS-1$
          str.toString());
    }

    return LanguageBundle.getFormattedString(
        "PreMult.toHtml", //$NON-NLS-1$
        prereq.getOperator().toDisplayString(),
        prereq.getOperand(),
        str.toString());
  }
示例#6
0
 private void configureButton() {
   CompanionFacade companion = getSelectedCompanion();
   setEnabled(companion != null);
   if (companion != null && isCompanionOpen(companion)) {
     // configure action for show
     this.putValue(Action.NAME, LanguageBundle.getString("in_companionSwitchTo")); // $NON-NLS-1$
   } else {
     // configure action for load
     this.putValue(Action.NAME, LanguageBundle.getString("in_companionLoadComp")); // $NON-NLS-1$
   }
 }
示例#7
0
 public SpellBooksTab() {
   super("SpellBooks");
   this.availableTable = new JTreeViewTable<SuperNode>();
   this.selectedTable = new JTreeViewTable<SuperNode>();
   this.addButton = new JButton();
   this.removeButton = new JButton();
   this.spellsPane = new InfoPane(LanguageBundle.getString("InfoSpells.spell.info"));
   this.classPane = new InfoPane(LanguageBundle.getString("InfoSpells.class.info"));
   this.defaultBookCombo = new JComboBox();
   initComponents();
 }
示例#8
0
 @Override
 public String toString() {
   switch (this) {
     case FULL:
       return LanguageBundle.getString("in_equipListFull"); // $NON-NLS-1$
     case UNEQUIPPED:
       return LanguageBundle.getString("in_equipListUnequipped"); // $NON-NLS-1$
     case EQUIPPED:
       return LanguageBundle.getString("in_equipListEquipped"); // $NON-NLS-1$
     default:
       throw new InternalError();
   }
 }
示例#9
0
  /**
   * @param obj
   * @param in_String
   */
  public static void setGuiTextInfo(Object obj, String in_String) {
    String text = LanguageBundle.getString(in_String);

    setTextAndMnemonic(obj, text);

    String tooltipKey = in_String + "_tip";
    String tooltip = LanguageBundle.getString(tooltipKey);

    if (tooltip.length() > 0
        && !tooltip.equals(tooltipKey + LanguageBundle.UNDEFINED)
        && obj instanceof JComponent) {
      setDescription((JComponent) obj, tooltip);
    }
  }
示例#10
0
 @Override
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   background.getTableCellRendererComponent(table, null, true, false, row, column);
   container.setBackground(background.getBackground());
   selectedElement = table.getValueAt(row, 0);
   if (selectedElement instanceof CompanionFacade) {
     button.setText(LanguageBundle.getString("in_companionRemove")); // $NON-NLS-1$
     button.setActionCommand(REMOVE_COMMAND);
   } else {
     button.setText(LanguageBundle.getString("in_companionCreateNew")); // $NON-NLS-1$
     button.setActionCommand(CREATE_COMMAND);
   }
   return container;
 }
示例#11
0
  /* (non-Javadoc)
   * @see pcgen.core.facade.SpellSupportFacade#removeSpellList(java.lang.String)
   */
  @Override
  public void removeSpellList(String spellList) {
    if (spellList.equalsIgnoreCase(Globals.getDefaultSpellBook())) {
      Logging.errorPrint(
          LanguageBundle.getString("InfoSpells.can.not.delete.default.spellbook")); // $NON-NLS-1$

      return;
    }

    if (pc.delSpellBook(spellList)) {
      pc.setDirty(true);
      for (Iterator<SpellNode> iterator = preparedSpellLists.iterator(); iterator.hasNext(); ) {
        SpellNode listNode = iterator.next();
        if (spellList.equals(listNode.getRootNode().getName())) {
          iterator.remove();
        }
      }

      for (Iterator<SpellNode> iterator = preparedSpellNodes.iterator(); iterator.hasNext(); ) {
        SpellNode spell = iterator.next();
        if (spellList.equals(spell.getRootNode().getName())) {
          iterator.remove();
        }
      }
    } else {
      Logging.errorPrint("delBookButton:failed "); // $NON-NLS-1$

      return;
    }
  }
示例#12
0
 public void setCompanionType(String type) {
   companionType = type;
   model.setCompanionType(type);
   selectButton.setText(
       LanguageBundle.getFormattedString("in_companionCreateType", type)); // $NON-NLS-1$
   newCompanion = null;
 }
示例#13
0
  /**
   * Request the metamagic feats to be applied to a spell from the user via a chooser.
   *
   * @param spellNode The spell to have metamagic applied
   * @return The list of metamagic feats to be applied.
   */
  private List<Ability> queryUserForMetamagic(SpellNode spellNode) {
    // get the list of metamagic feats for the PC
    List<InfoFacade> availableList = buildAvailableMetamagicFeatList(spellNode);
    if (availableList.isEmpty()) {
      return Collections.emptyList();
    }

    String label = dataSet.getGameMode().getAddWithMetamagicMessage();
    if (StringUtils.isEmpty(label)) {
      label = LanguageBundle.getString("InfoSpells.add.with.metamagic");
    }

    final ArrayList<Ability> selectedList = new ArrayList<>();
    GeneralChooserFacadeBase chooserFacade =
        new GeneralChooserFacadeBase(label, availableList, new ArrayList<>(), 99, infoFactory) {
          @Override
          public void commit() {
            for (InfoFacade item : getSelectedList()) {
              selectedList.add((Ability) item);
            }
          }
        };

    chooserFacade.setDefaultView(ChooserTreeViewType.NAME);
    boolean result = delegate.showGeneralChooser(chooserFacade);
    return result ? selectedList : null;
  }
示例#14
0
 /**
  * Print localised information message if PCGen is debugging.
  *
  * @param message String information message (usually variable)
  * @param param1 Object information message (usually value)
  * @param param2 Object information message (usually value)
  */
 public static void debugPrintLocalised(final String message, Object... params) {
   Logger l = getLogger();
   if (l.isLoggable(DEBUG)) {
     String msg = LanguageBundle.getFormattedString(message, params);
     l.log(DEBUG, msg);
   }
 }
示例#15
0
 /* (non-Javadoc)
  * @see pcgen.core.prereq.PrerequisiteTest#toHtmlString(pcgen.core.prereq.Prerequisite)
  */
 @Override
 public String toHtmlString(final Prerequisite prereq) {
   return LanguageBundle.getFormattedString(
       "PreDeityAlign.toHtml",
       prereq.getOperator().toDisplayString(),
       getPCAlignment(prereq.getOperand()).getKeyName()); // $NON-NLS-1$
 }
示例#16
0
  /* (non-Javadoc)
   * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
   */
  @Override
  public int passes(final Prerequisite prereq, final PlayerCharacter aPC, CDOMObject source)
      throws PrerequisiteException {
    final int number;
    try {
      number = Integer.parseInt(prereq.getOperand());
    } catch (NumberFormatException exceptn) {
      throw new PrerequisiteException(
          LanguageBundle.getFormattedString("PreFact.error", prereq.toString())); // $NON-NLS-1$
    }

    String location = prereq.getCategoryName();
    String[] locationElements = location.split("\\.");
    Iterable<Reducible> objModel =
        (Iterable<Reducible>) OutputDB.getIterable(aPC.getCharID(), locationElements);
    if (objModel == null) {
      throw new PrerequisiteException("Output System does not have model for: " + location);
    }

    String[] factinfo = prereq.getKey().split("=");
    FactKey<?> fk = FactKey.valueOf(factinfo[0]);
    Object targetVal = fk.getFormatManager().convertIndirect(factinfo[1]);

    int runningTotal = 0;
    for (Reducible r : objModel) {
      Indirect<?> cdoVal = r.getCDOMObject().get(fk);
      if (targetVal.equals(cdoVal)) {
        runningTotal++;
      }
    }

    runningTotal = prereq.getOperator().compare(runningTotal, number);
    return countedTotal(prereq, runningTotal);
  }
示例#17
0
  /** Handles the clicking of the <b>Add</b> button on the GUI. */
  public void handleOpen() {
    File defaultFile = new File(PCGenSettings.getPcgDir());
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(defaultFile);

    String[] pcgs = new String[] {FILENAME_PCG, FILENAME_PCP};
    SimpleFileFilter ff =
        new SimpleFileFilter(pcgs, LanguageBundle.getString("in_pcgen_file")); // $NON-NLS-1$
    chooser.addChoosableFileFilter(ff);
    chooser.setFileFilter(ff);
    chooser.setMultiSelectionEnabled(true);
    Component component = GMGenSystem.inst;
    Cursor originalCursor = component.getCursor();
    component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    int option = chooser.showOpenDialog(GMGenSystem.inst);

    if (option == JFileChooser.APPROVE_OPTION) {
      for (File selectedFile : chooser.getSelectedFiles()) {
        if (PCGFile.isPCGenCharacterOrPartyFile(selectedFile)) {
          messageHandler.handleMessage(
              new RequestOpenPlayerCharacterMessage(this, selectedFile, false));
        }
      }
    } else {
      /* this means the file is invalid */
    }

    GMGenSystem.inst.setCursor(originalCursor);
  }
示例#18
0
 void showCompanion(boolean switchTabs) {
   CompanionFacade companion = getSelectedCompanion();
   if (companion == null) {
     if (!switchTabs) {
       infoPane.setText(""); // $NON-NLS-1$
     }
     return;
   }
   if (isCompanionOpen(companion)) {
     CharacterFacade character = CharacterManager.getCharacterMatching(companion);
     if (character != null) {
       if (switchTabs) {
         frame.setSelectedCharacter(character);
         return;
       } else {
         sheetSupport.setCharacter(character);
         sheetSupport.refresh();
       }
     }
     // the companion was not found
     // TODO: show error, complain?
   } else if (switchTabs) {
     frame.loadCharacterFromFile(companion.getFileRef().getReference());
   } else {
     // Display a message telling the user to open the companion.
     infoPane.setText(
         LanguageBundle.getString("in_companionLoadCompanionMessage")); // $NON-NLS-1$
   }
 }
示例#19
0
  /**
   * Print a localized error message from the passed in key. If the application is in Debug mode
   * will also issue a beep.
   *
   * @param aKey A key for the localized string in the language bundle
   */
  public static void errorPrintLocalised(final String aKey) {
    if (isDebugMode()) {
      s_TOOLKIT.beep();
    }

    final String msg = LanguageBundle.getString(aKey);
    System.err.println(msg);
  }
示例#20
0
 @Override
 public Object getData(SkillFacade obj, int column) {
   if (selectionModel.isSelectionEmpty()) {
     switch (column) {
       case 0:
       case 1:
       case 4:
         return 0;
       case 2:
         return 0.0;
       case 3:
       case 5:
         return null;
       case 6:
         return obj.getSource();
       default:
         return null;
     }
   }
   int index = selectionModel.getMinSelectionIndex();
   CharacterLevelFacade level = levels.getElementAt(index);
   SkillBreakdown skillBreakdown = levels.getSkillBreakdown(level, obj);
   switch (column) {
     case 0:
       return skillBreakdown.total;
     case 1:
       return skillBreakdown.modifier;
     case 2:
       return skillBreakdown.ranks;
     case 3:
       return levels.getSkillCost(level, obj) == SkillCost.CLASS
           ? LanguageBundle.getString("in_yes")
           : //$NON-NLS-1$
           LanguageBundle.getString("in_no"); // $NON-NLS-1$
     case 4:
       return levels.getSkillCost(level, obj).getCost();
     case 5:
       return character.getInfoFactory().getDescription(obj);
     case 6:
       return obj.getSource();
     default:
       return null;
   }
 }
示例#21
0
  private void initComponents() {
    JLabel label = new JLabel(LanguageBundle.getString("in_character_sheet"));
    add(label);
    theCombo = new JComboBox();
    theCombo.addItemListener(this);
    add(theCombo);

    buildCombo();
    initialized = true;
  }
示例#22
0
 @Override
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   background.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);
   setBackground(background.getBackground());
   value = table.getValueAt(row, 0);
   if (value instanceof CompanionFacade) {
     button.setText(LanguageBundle.getString("in_companionRemove")); // $NON-NLS-1$
   } else {
     button.setText(LanguageBundle.getString("in_companionCreateNew")); // $NON-NLS-1$
   }
   value = table.getValueAt(row, 1);
   if (value instanceof Boolean) {
     button.setEnabled((Boolean) value);
   } else {
     button.setEnabled(true);
   }
   return this;
 }
示例#23
0
 /**
  * Create a new instance of NoteInfoPane
  *
  * @param note The note we are to manage.
  */
 public NoteInfoPane(NoteFacade note) {
   this.note = note;
   this.nameField = new JTextField(15);
   this.name = note.getName();
   this.noteField = new JTextArea(8, 20);
   this.title = new TabTitle(name);
   this.removeButton = new JButton(LanguageBundle.getString("in_descDelNote")); // $NON-NLS-1$
   nameField.setEditable(!note.isRequired());
   removeButton.setEnabled(!note.isRequired());
   initComponents();
 }
示例#24
0
  /**
   * Print a localized error message including parameter substitution. The method will issue a beep
   * if the application is running in Debug mode.
   *
   * <p>This method accepts a variable number of parameters and will replace <code>{argno}</code> in
   * the string with each passed paracter in turn.
   *
   * @param aKey A key for the localized string in the language bundle
   * @param varargs Variable number of parameters to substitute into the string
   */
  public static void errorPrintLocalised(final String aKey, Object... varargs) {
    if (isDebugMode()) {
      s_TOOLKIT.beep();
    }

    final String msg = LanguageBundle.getFormattedString(aKey, varargs);
    Logger l = getLogger();
    if (l.isLoggable(ERROR)) {
      l.log(ERROR, msg);
    }
  }
示例#25
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (availTable != null && (e.getActionCommand().equals("ADD") || e.getSource() == availTable)) {
      List<Object> data = availTable.getSelectedData();
      if (!data.isEmpty()) {
        for (Object object : data) {
          if (object instanceof InfoFacade) {
            chooser.addSelected((InfoFacade) object);
          }
        }
      }
      return;
    }
    if (availInput != null && (e.getActionCommand().equals("ADD") || e.getSource() == availInput)) {
      String data = availInput.getText();
      if (StringUtils.isNotBlank(data)) {
        chooser.addSelected(new InfoWrapper(data));
      }
      availInput.setText("");
      return;
    }

    if (e.getActionCommand().equals("REMOVE") || e.getSource() == list) {
      Object value = list.getSelectedValue();
      if (value != null && value instanceof InfoFacade) {
        chooser.removeSelected((InfoFacade) value);
        if (availInput != null) {
          availInput.setText(value.toString());
        }
      }
      return;
    }
    if (e.getActionCommand().equals("OK")) {
      if (chooser.isRequireCompleteSelection() && chooser.getRemainingSelections().get() > 0) {
        JOptionPane.showMessageDialog(
            this,
            LanguageBundle.getFormattedString(
                "in_chooserRequireComplete", //$NON-NLS-1$
                chooser.getRemainingSelections().get()),
            chooser.getName(),
            JOptionPane.INFORMATION_MESSAGE);
        return;
      } else {
        chooser.commit();
      }
    } else {
      chooser.rollback();
    }
    committed = e.getActionCommand().equals("OK");
    dispose();
  }
示例#26
0
  /* (non-Javadoc)
   * @see pcgen.core.facade.SpellSupportFacade#addSpellList(java.lang.String)
   */
  @Override
  public void addSpellList(String spellList) {
    if (StringUtils.isEmpty(spellList)) {
      return;
    }

    // Prevent spellbooks being given the same name as a class
    for (PCClass current :
        Globals.getContext().getReferenceContext().getConstructedCDOMObjects(PCClass.class)) {
      if ((spellList.equals(current.getKeyName()))) {
        JOptionPane.showMessageDialog(
            null,
            LanguageBundle.getString("in_spellbook_name_error"), // $NON-NLS-1$
            Constants.APPLICATION_NAME,
            JOptionPane.ERROR_MESSAGE);

        return;
      }
    }

    if (pc.addSpellBook(spellList)) {
      pc.setDirty(true);

      DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellList));
      preparedSpellLists.add(spellListNode);
      addDummyNodeIfSpellListEmpty(spellList);
    } else {
      JOptionPane.showMessageDialog(
          null,
          LanguageBundle.getFormattedString(
              "InfoPreparedSpells.add.list.fail", spellList), // $NON-NLS-1$
          Constants.APPLICATION_NAME,
          JOptionPane.ERROR_MESSAGE);

      return;
    }
  }
示例#27
0
    private void initComponents() {
      setTitle(LanguageBundle.getString("in_companionSelectRace")); // $NON-NLS-1$
      setLayout(new BorderLayout());
      Container container = getContentPane();
      {
        final ListSelectionModel selectionModel = raceTable.getSelectionModel();
        selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        selectionModel.addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                  selectButton.setEnabled(!selectionModel.isSelectionEmpty());
                }
              }
            });
      }
      SearchFilterPanel searchBar = new SearchFilterPanel();
      container.add(searchBar, BorderLayout.NORTH);
      raceTable.setDisplayableFilter(searchBar);
      raceTable.addActionListener(this);
      raceTable.setTreeViewModel(this);
      container.add(new JScrollPane(raceTable), BorderLayout.CENTER);
      JPanel buttonPane = new JPanel(new FlowLayout());
      selectButton.addActionListener(this);
      selectButton.setEnabled(false);
      selectButton.setActionCommand("SELECT");
      buttonPane.add(selectButton);

      JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
      cancelButton.addActionListener(this);
      cancelButton.setActionCommand("CANCEL");
      buttonPane.add(cancelButton);
      container.add(buttonPane, BorderLayout.SOUTH);

      Utility.installEscapeCloseOperation(this);
    }
示例#28
0
  private void initComponents() {
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    Box box = Box.createVerticalBox();
    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(250, 300));
    box.add(pane);
    box.add(Box.createVerticalStrut(5));
    {
      Box hbox = Box.createHorizontalBox();
      hbox.add(Box.createHorizontalStrut(5));
      hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
      hbox.add(Box.createHorizontalGlue());
      box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
      Box hbox = Box.createHorizontalBox();
      hbox.add(Box.createHorizontalStrut(5));
      hbox.add(defaultBookCombo);
      hbox.add(Box.createHorizontalGlue());
      hbox.add(Box.createHorizontalStrut(5));
      hbox.add(addButton);
      hbox.add(Box.createHorizontalStrut(5));
      box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setLeftComponent(box);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
      Box hbox = Box.createHorizontalBox();
      hbox.add(Box.createHorizontalStrut(5));
      hbox.add(removeButton);
      hbox.add(Box.createHorizontalGlue());
      box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
  }
示例#29
0
  /* (non-Javadoc)
   * @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
   */
  @Override
  public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source)
      throws PrerequisiteException {
    int runningTotal;
    try {
      final int targetHands = Integer.parseInt(prereq.getOperand());

      runningTotal = prereq.getOperator().compare(display.getHands(), targetHands);
    } catch (NumberFormatException nfe) {
      throw new PrerequisiteException(
          LanguageBundle.getFormattedString(
              "PreHands.error.badly_formed", prereq.getOperand())); // $NON-NLS-1$
    }
    return countedTotal(prereq, runningTotal);
  }
示例#30
0
  /* (non-Javadoc)
   * @see pcgen.core.prereq.PrerequisiteTest#toHtmlString(pcgen.core.prereq.Prerequisite)
   */
  @Override
  public String toHtmlString(final Prerequisite prereq) {
    // Simplify the output when requiring a single source
    if (prereq.getOperator() == PrerequisiteOperator.GTEQ && ("1".equals(prereq.getOperand()))) {
      return prereq.getKey();
    }

    final String foo =
        LanguageBundle.getFormattedString(
            "PreFact.toHtml", //$NON-NLS-1$
            new Object[] {
              prereq.getOperator().toDisplayString(), prereq.getOperand(), prereq.getKey()
            });
    return foo;
  }