コード例 #1
0
  @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);
  }
コード例 #2
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
 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$
   }
 }
コード例 #3
0
ファイル: SpellBooksTab.java プロジェクト: timoc/pcgen-svn
 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();
 }
コード例 #4
0
ファイル: EquipmentModels.java プロジェクト: dlabat/pcgen-svn
 @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();
   }
 }
コード例 #5
0
ファイル: Utility.java プロジェクト: timoc/pcgen-svn
  /**
   * @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);
    }
  }
コード例 #6
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
 @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;
 }
コード例 #7
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
 @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();
 }
コード例 #8
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
 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$
   }
 }
コード例 #9
0
ファイル: PCGTrackerPlugin.java プロジェクト: cpmeister/pcgen
 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));
 }
コード例 #10
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;
    }
  }
コード例 #11
0
ファイル: PCGTrackerPlugin.java プロジェクト: cpmeister/pcgen
  /** 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);
  }
コード例 #12
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;
  }
コード例 #13
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);
  }
コード例 #14
0
ファイル: SkillTreeViewModel.java プロジェクト: oiml/pcgen
 @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;
   }
 }
コード例 #15
0
ファイル: PreMult.java プロジェクト: cpmeister/pcgen
  /* (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());
  }
コード例 #16
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;
  }
コード例 #17
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
 @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;
 }
コード例 #18
0
ファイル: NoteInfoPane.java プロジェクト: timoc/pcgen-svn
 /**
  * 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();
 }
コード例 #19
0
ファイル: CompanionInfoTab.java プロジェクト: kne1p/pcgen
    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);
    }
コード例 #20
0
ファイル: SpellBooksTab.java プロジェクト: timoc/pcgen-svn
  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);
  }
コード例 #21
0
ファイル: DisplayLocationToken.java プロジェクト: kne1p/pcgen
 @Override
 protected ParseResult parseNonEmptyToken(LoadContext context, AbilityCategory ac, String value) {
   /*
    * TODO This i18n is a bit challenging - in that it can create
    * incompatible datasets between those that are i18n enabled and those
    * that are not. Not sure whether in_Feat should be equivalent to Feat
    * (logic can argue either way). Need some consideration if data sets
    * should be i18n aware (AbilityCategory is currently the only object
    * that is, and I'm not sure we want the data to be i18n aware) - TP
    *
    * See also DiaplayNameToken and PluralToken (and how they are processed
    * in AbilityCategory)
    */
   String loc;
   if (value.startsWith("in_")) {
     loc = LanguageBundle.getString(value);
   } else {
     loc = value;
   }
   ac.setDisplayLocation(DisplayLocation.getConstant(loc));
   return ParseResult.SUCCESS;
 }
コード例 #22
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;
    }
  }
コード例 #23
0
ファイル: NoteInfoPane.java プロジェクト: timoc/pcgen-svn
  private void initComponents() {
    setLayout(new BorderLayout());

    Box hbox = Box.createHorizontalBox();
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(new JLabel(LanguageBundle.getString("in_descNoteName"))); // $NON-NLS-1$
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(nameField);
    nameField.setText(name);
    hbox.add(Box.createRigidArea(new Dimension(5, 0)));
    hbox.add(removeButton);
    hbox.add(Box.createHorizontalGlue());

    noteField.setLineWrap(true);
    noteField.setWrapStyleWord(true);

    add(hbox, BorderLayout.NORTH);
    JScrollPane pane =
        new JScrollPane(
            noteField,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(pane, BorderLayout.CENTER);
  }
コード例 #24
0
 public SpellsInfoTab() {
   addTab(LanguageBundle.getString("in_InfoKnown"), knownTab); // $NON-NLS-1$
   addTab(LanguageBundle.getString("in_InfoPrepared"), preparedTab); // $NON-NLS-1$
   addTab(LanguageBundle.getString("in_InfoSpellbooks"), booksTab); // $NON-NLS-1$
 }
コード例 #25
0
 /**
  * Print error message with a stack trace if PCGen is debugging.
  *
  * @param s String error message
  * @param thr Throwable stack frame
  */
 public static void errorPrintLocalised(final String s, final Throwable thr) {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   PrintStream ps = new PrintStream(baos);
   thr.printStackTrace(ps);
   errorPrint(LanguageBundle.getString(s) + "\n" + baos.toString());
 }
コード例 #26
0
ファイル: NetworkView.java プロジェクト: timoc/pcgen-svn
  /**
   * This method is called from within the constructor to initialize the form. WARNING: Do NOT
   * modify this code. The content of this method is always regenerated by the Form Editor.
   */
  private void initComponents() { // GEN-BEGIN:initComponents
    buttonGroup1 = new javax.swing.ButtonGroup();
    toolbar = new javax.swing.JToolBar();
    rbServer = new javax.swing.JRadioButton();
    rbClient = new javax.swing.JRadioButton();
    clientPanel = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    serverAddress = new javax.swing.JTextField(15); // 255.255.255.255 = 15 chars
    connectButton = new javax.swing.JButton();
    connectionPanel = new javax.swing.JPanel();
    noteTitle = new javax.swing.JLabel();
    noteText = new javax.swing.JLabel();
    logPane = new javax.swing.JTabbedPane();
    messagePanel = new javax.swing.JPanel();
    messageBox = new javax.swing.JTextField();
    messageButton = new javax.swing.JButton();
    connectedUsersPanel = new javax.swing.JPanel();
    userList = new javax.swing.JList();
    jLabel1 = new javax.swing.JLabel();

    setLayout(new java.awt.BorderLayout());

    rbServer.setText(LanguageBundle.getString("in_plugin_network_server")); // $NON-NLS-1$
    buttonGroup1.add(rbServer);
    toolbar.add(rbServer);

    rbClient.setText(LanguageBundle.getString("in_plugin_network_client")); // $NON-NLS-1$
    buttonGroup1.add(rbClient);
    toolbar.add(rbClient);
    toolbar.addSeparator();

    clientPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 3));

    jLabel2.setText(LanguageBundle.getString("in_plugin_network_serverAddr")); // $NON-NLS-1$
    toolbar.add(jLabel2);

    serverAddress.setText(DEFAULT_IP);
    clientPanel.add(serverAddress);

    connectButton.setText(LanguageBundle.getString("in_plugin_network_connect")); // $NON-NLS-1$
    connectButton.setMargin(new java.awt.Insets(0, 10, 0, 10));
    clientPanel.add(connectButton);

    toolbar.add(clientPanel);

    toolbar.addSeparator();

    connectionPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 6));

    connectionPanel.add(noteTitle);

    connectionPanel.add(noteText);

    toolbar.add(connectionPanel);

    add(toolbar, java.awt.BorderLayout.NORTH);

    add(logPane, java.awt.BorderLayout.CENTER);

    messagePanel.setLayout(new java.awt.BorderLayout());

    messagePanel.add(messageBox, java.awt.BorderLayout.CENTER);

    messageButton.setText(LanguageBundle.getString("in_plugin_network_sendMsg")); // $NON-NLS-1$
    messagePanel.add(messageButton, java.awt.BorderLayout.EAST);

    add(messagePanel, java.awt.BorderLayout.SOUTH);

    connectedUsersPanel.setLayout(new java.awt.BorderLayout());

    connectedUsersPanel.setBorder(new javax.swing.border.EtchedBorder());
    userList.setBorder(new javax.swing.border.EtchedBorder());
    userList.setModel(
        new javax.swing.AbstractListModel() {
          String[] strings = {"Broadcast"};

          public int getSize() {
            return strings.length;
          }

          public Object getElementAt(int i) {
            return strings[i];
          }
        });
    userList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    connectedUsersPanel.add(userList, java.awt.BorderLayout.CENTER);

    jLabel1.setText(LanguageBundle.getString("in_plugin_network_spaced")); // $NON-NLS-1$
    connectedUsersPanel.add(jLabel1, java.awt.BorderLayout.NORTH);

    add(connectedUsersPanel, java.awt.BorderLayout.EAST);
  } // GEN-END:initComponents
コード例 #27
0
ファイル: NetworkView.java プロジェクト: timoc/pcgen-svn
 public void showClientPanel() {
   jLabel2.setText(LanguageBundle.getString("in_plugin_network_serverAddr")); // $NON-NLS-1$
   clientPanel.setVisible(true);
 }
コード例 #28
0
ファイル: NetworkView.java プロジェクト: timoc/pcgen-svn
 public void setLocalAddressText(String address) {
   jLabel2.setText(
       LanguageBundle.getString("in_plugin_network_localAddr") + address); // $NON-NLS-1$
 }
コード例 #29
0
ファイル: TabsPanel.java プロジェクト: aroni125/pcgen-svn
/**
 * The Class <code>TabsPanel</code> is responsible for displaying tabs display related preferences
 * and allowing the preferences to be edited by the user.
 *
 * <p>Last Editor: $Author$ Last Edited: $Date$
 *
 * @author James Dempsey <*****@*****.**>
 * @version $Revision$
 */
@SuppressWarnings("serial")
public class TabsPanel extends PCGenPrefsPanel {
  private static String in_tabs = LanguageBundle.getString("in_Prefs_tabs");

  private static String in_charTabPlacement = LanguageBundle.getString("in_Prefs_charTabPlacement");
  private static String in_charTabLabel = LanguageBundle.getString("in_Prefs_charTabLabel");
  private static String in_expertGUI = LanguageBundle.getString("in_Prefs_expertGUI");
  private static String in_mainTabPlacement = LanguageBundle.getString("in_Prefs_mainTabPlacement");
  private static String in_tabLabelPlain = LanguageBundle.getString("in_Prefs_tabLabelPlain");
  private static String in_tabLabelEpic = LanguageBundle.getString("in_Prefs_tabLabelEpic");
  private static String in_tabLabelRace = LanguageBundle.getString("in_Prefs_tabLabelRace");
  private static String in_tabLabelNetHack = LanguageBundle.getString("in_Prefs_tabLabelNetHack");
  private static String in_tabLabelFull = LanguageBundle.getString("in_Prefs_tabLabelFull");
  private static String in_tabPosTop = LanguageBundle.getString("in_Prefs_tabPosTop");
  private static String in_tabPosBottom = LanguageBundle.getString("in_Prefs_tabPosBottom");
  private static String in_tabPosLeft = LanguageBundle.getString("in_Prefs_tabPosLeft");
  private static String in_tabPosRight = LanguageBundle.getString("in_Prefs_tabPosRight");
  private static String in_tabAbilities = LanguageBundle.getString("in_Prefs_tabAbilities");

  private JCheckBox displayAbilitiesAsTab = new JCheckBox();
  private JCheckBox expertGUICheckBox = new JCheckBox();
  private JComboBoxEx charTabPlacementCombo;
  private JComboBoxEx mainTabPlacementCombo;
  private JComboBoxEx tabLabelsCombo;

  /** Instantiates a new Tabs panel. */
  public TabsPanel() {
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    JLabel label;
    Border etched = null;
    TitledBorder title1 = BorderFactory.createTitledBorder(etched, in_tabs);

    title1.setTitleJustification(TitledBorder.LEFT);
    this.setBorder(title1);
    gridbag = new GridBagLayout();
    this.setLayout(gridbag);
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(2, 2, 2, 2);

    Utility.buildConstraints(c, 0, 0, 2, 1, 0, 0);
    label = new JLabel(in_mainTabPlacement + ": ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, 0, 1, 1, 0, 0);
    mainTabPlacementCombo =
        new JComboBoxEx(
            new String[] {in_tabPosTop, in_tabPosBottom, in_tabPosLeft, in_tabPosRight});
    gridbag.setConstraints(mainTabPlacementCombo, c);
    this.add(mainTabPlacementCombo);

    Utility.buildConstraints(c, 0, 1, 2, 1, 0, 0);
    label = new JLabel(in_charTabPlacement + ": ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, 1, 1, 1, 0, 0);
    charTabPlacementCombo =
        new JComboBoxEx(
            new String[] {in_tabPosTop, in_tabPosBottom, in_tabPosLeft, in_tabPosRight});
    gridbag.setConstraints(charTabPlacementCombo, c);
    this.add(charTabPlacementCombo);

    Utility.buildConstraints(c, 0, 2, 2, 1, 0, 0);
    label = new JLabel(in_charTabLabel + ": ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, 2, 1, 1, 0, 0);
    tabLabelsCombo =
        new JComboBoxEx(
            new String[] {
              in_tabLabelPlain,
              in_tabLabelEpic,
              in_tabLabelRace,
              in_tabLabelNetHack,
              in_tabLabelFull
            });
    gridbag.setConstraints(tabLabelsCombo, c);
    this.add(tabLabelsCombo);

    Utility.buildConstraints(c, 0, 3, 2, 1, 0, 0);
    label = new JLabel(in_tabAbilities + ": ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, 3, 1, 1, 0, 0);
    gridbag.setConstraints(displayAbilitiesAsTab, c);
    this.add(displayAbilitiesAsTab);

    Utility.buildConstraints(c, 0, 4, 2, 1, 0, 0);
    label = new JLabel(in_expertGUI + ": ");
    gridbag.setConstraints(label, c);
    this.add(label);
    Utility.buildConstraints(c, 2, 4, 1, 1, 0, 0);
    gridbag.setConstraints(expertGUICheckBox, c);
    this.add(expertGUICheckBox);

    expertGUICheckBox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent evt) {
            SettingsHandler.setExpertGUI(expertGUICheckBox.isSelected());
          }
        });

    Utility.buildConstraints(c, 5, 20, 1, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    label = new JLabel(" ");
    gridbag.setConstraints(label, c);
    this.add(label);
  }

  /* (non-Javadoc)
   * @see pcgen.gui2.prefs.PCGenPrefsPanel#getTitle()
   */
  @Override
  public String getTitle() {
    return in_tabs;
  }

  /* (non-Javadoc)
   * @see pcgen.gui2.prefs.PreferencesPanel#applyPreferences()
   */
  @Override
  public void setOptionsBasedOnControls() {
    switch (mainTabPlacementCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setTabPlacement(SwingConstants.TOP);

        break;

      case 1:
        SettingsHandler.setTabPlacement(SwingConstants.BOTTOM);

        break;

      case 2:
        SettingsHandler.setTabPlacement(SwingConstants.LEFT);

        break;

      case 3:
        SettingsHandler.setTabPlacement(SwingConstants.RIGHT);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (mainTabPlacementCombo) the index "
                + mainTabPlacementCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    switch (charTabPlacementCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setChaTabPlacement(SwingConstants.TOP);

        break;

      case 1:
        SettingsHandler.setChaTabPlacement(SwingConstants.BOTTOM);

        break;

      case 2:
        SettingsHandler.setChaTabPlacement(SwingConstants.LEFT);

        break;

      case 3:
        SettingsHandler.setChaTabPlacement(SwingConstants.RIGHT);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (charTabPlacementCombo) the index "
                + charTabPlacementCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    switch (tabLabelsCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME);

        break;

      case 1:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_CLASS);

        break;

      case 2:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE);

        break;

      case 3:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE_CLASS);

        break;

      case 4:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_FULL);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (tabLabelsCombo) the index "
                + tabLabelsCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    SettingsHandler.setAbilitiesShownAsATab(displayAbilitiesAsTab.isSelected());
    SettingsHandler.setExpertGUI(expertGUICheckBox.isSelected());
  }

  /* (non-Javadoc)
   * @see pcgen.gui2.prefs.PreferencesPanel#initPreferences()
   */
  @Override
  public void applyOptionValuesToControls() {
    switch (SettingsHandler.getTabPlacement()) {
      case SwingConstants.TOP:
        mainTabPlacementCombo.setSelectedIndex(0);

        break;

      case SwingConstants.BOTTOM:
        mainTabPlacementCombo.setSelectedIndex(1);

        break;

      case SwingConstants.LEFT:
        mainTabPlacementCombo.setSelectedIndex(2);

        break;

      case SwingConstants.RIGHT:
        mainTabPlacementCombo.setSelectedIndex(3);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (tab placement) the tab option "
                + SettingsHandler.getTabPlacement()
                + " is unsupported.");

        break;
    }

    switch (SettingsHandler.getChaTabPlacement()) {
      case SwingConstants.TOP:
        charTabPlacementCombo.setSelectedIndex(0);

        break;

      case SwingConstants.BOTTOM:
        charTabPlacementCombo.setSelectedIndex(1);

        break;

      case SwingConstants.LEFT:
        charTabPlacementCombo.setSelectedIndex(2);

        break;

      case SwingConstants.RIGHT:
        charTabPlacementCombo.setSelectedIndex(3);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (cha tab placement) the tab option "
                + SettingsHandler.getChaTabPlacement()
                + " is unsupported.");

        break;
    }

    switch (SettingsHandler.getNameDisplayStyle()) {
      case Constants.DISPLAY_STYLE_NAME:
        tabLabelsCombo.setSelectedIndex(0);

        break;

      case Constants.DISPLAY_STYLE_NAME_CLASS:
        tabLabelsCombo.setSelectedIndex(1);

        break;

      case Constants.DISPLAY_STYLE_NAME_RACE:
        tabLabelsCombo.setSelectedIndex(2);

        break;

      case Constants.DISPLAY_STYLE_NAME_RACE_CLASS:
        tabLabelsCombo.setSelectedIndex(3);

        break;

      case Constants.DISPLAY_STYLE_NAME_FULL:
        tabLabelsCombo.setSelectedIndex(4);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (name display style) the tab option "
                + SettingsHandler.getNameDisplayStyle()
                + " is unsupported.");

        break;
    }

    displayAbilitiesAsTab.setSelected(SettingsHandler.isAbilitiesShownAsATab());
    expertGUICheckBox.setSelected(SettingsHandler.isExpertGUI());
  }
}
コード例 #30
0
 /** Resource bundles */
 static {
   LanguageBundle.getString("in_available");
   in_ok = LanguageBundle.getString("in_ok");
   in_cancel = LanguageBundle.getString("in_cancel");
 }