Exemplo n.º 1
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);
  }
Exemplo n.º 2
0
  public static PCGenDataConvert getConverter(CDOMObject pc) throws InterruptedException {
    PCGenDataConvert frame = new PCGenDataConvert();
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    List<ConvertSubPanel> panels = new ArrayList<ConvertSubPanel>();
    GameModeFileLoader gameModeFileLoader = new GameModeFileLoader();
    CampaignFileLoader campaignFileLoader = new CampaignFileLoader();
    panels.add(new StartupPanel(gameModeFileLoader, campaignFileLoader));

    final ConvertPanel installPanel = new ConvertPanel(panels);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent wEvent) {
            installPanel.checkExit();
          }
        });

    panels.add(new SourceSelectionPanel());
    panels.add(new GameModePanel(campaignFileLoader));
    panels.add(new CampaignPanel());

    panels.add(new WriteDirectoryPanel());

    panels.add(new SummaryPanel());

    panels.add(new RunConvertPanel(installPanel.getStatusField()));
    panels.add(new MessagePanel("PCGen Data Conversion Complete!", ProgressEvent.NOT_ALLOWED));

    frame.getContentPane().add(installPanel);
    frame.pack();
    Utility.centerFrame(frame, false);
    return frame;
  }
Exemplo n.º 3
0
  private void initComponents() {
    setTitle("Print Preview");
    sheetBox.setRenderer(
        new DefaultListCellRenderer() {

          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value != null) {
              setToolTipText(value.toString());
            }
            return this;
          }
        });
    sheetBox.setActionCommand(SHEET_COMMAND);
    sheetBox.addActionListener(this);
    pageBox.addItem("0 of 0");
    pageBox.setActionCommand(PAGE_COMMAND);
    pageBox.addActionListener(this);
    zoomBox.addItem(0.25);
    zoomBox.addItem(0.50);

    zoomBox.addItem(0.75);
    zoomBox.addItem(1.00);
    zoomBox.setSelectedItem(0.75);
    zoomBox.setRenderer(
        new DefaultListCellRenderer() {

          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            NumberFormat format = NumberFormat.getPercentInstance();
            value = format.format(value);
            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          }
        });
    zoomBox.setEditable(true);
    zoomBox.setEditor(new PercentEditor(zoomBox));
    zoomBox.setActionCommand(ZOOM_COMMAND);
    zoomBox.addActionListener(this);
    zoomInButton.setIcon(Icons.ZoomIn16.getImageIcon());
    zoomInButton.setActionCommand(ZOOM_IN_COMMAND);
    zoomInButton.addActionListener(this);
    zoomOutButton.setIcon(Icons.ZoomOut16.getImageIcon());
    zoomOutButton.setActionCommand(ZOOM_OUT_COMMAND);
    zoomOutButton.addActionListener(this);

    printButton.setText("Print");
    printButton.setActionCommand(PRINT_COMMAND);
    printButton.addActionListener(this);

    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CANCEL_COMMAND);
    cancelButton.addActionListener(this);

    enableEditGroup(false);

    Utility.installEscapeCloseOperation(this);
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
0
  /** Updates the available table entries */
  private void updateAvailableTable() {
    final List mAvailableData = new ArrayList();

    for (Iterator it = mAvailableList.iterator(); it.hasNext(); ) {
      mAvailableData.add(it.next().toString());
    }

    setData(mAvailableData);

    int row = avaRadioButton.length;

    GridBagLayout gridbag = new GridBagLayout();
    avaPane.removeAll();
    avaPane.setLayout(gridbag);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    for (int i = 0; i < row; ++i) {
      int cr = i;
      c.anchor = GridBagConstraints.WEST;
      Utility.buildConstraints(c, 0, cr, 2, 1, 1, 0);
      gridbag.setConstraints(avaRadioButton[i], c);
      avaPane.add(avaRadioButton[i]);

      // if there are more than 10 items make a double row
      if ((row > 11) && (i < (row - 1))) {
        ++i;
        c.anchor = GridBagConstraints.EAST;
        Utility.buildConstraints(c, 3, cr, 2, 1, 1, 0);
        gridbag.setConstraints(avaRadioButton[i], c);
        avaPane.add(avaRadioButton[i]);
      }
    }

    if (lblCombo != null) {
      Utility.buildConstraints(c, 0, row, 3, 1, 0, 0);
      gridbag.setConstraints(lblCombo, c);
      avaPane.add(lblCombo);

      Utility.buildConstraints(c, 0, row + 1, 3, 1, 0, 0);
      gridbag.setConstraints(cmbCombo, c);
      avaPane.add(cmbCombo);
    }
  }
Exemplo n.º 7
0
  /**
   * Overrides the default setVisible method to ensure controls are updated before showing the
   * dialog.
   *
   * @param b
   */
  @Override
  public void setVisible(boolean b) {
    if (b) {
      // Note we should not be updating the available list unless we are
      // showing the panel. Doing this on a 'hide' action will result in
      // duplicates of the radio buttons appearing.
      updateAvailableTable();

      // centre on parent
      // setLocationRelativeTo(getOwner());
      super.pack();
      pack();

      // make sure it's at least 120 wide
      if (getWidth() < 120) {
        setSize(120, getHeight());
      }
      Utility.centerDialog(this);
    }
    super.setVisible(b);
  }
Exemplo n.º 8
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);
    }
Exemplo n.º 9
0
  /** 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);
  }
Exemplo n.º 10
0
  /** Initializes the components of the dialog */
  private void initComponents() {
    // Initialize basic dialog settings
    setModal(true);

    // setSize(new Dimension(240, 400));
    // setTitle(in_chooser);
    final Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());

    TitledBorder title = BorderFactory.createTitledBorder(null, "Select One");
    avaPane.setBorder(title);

    // Create these labels with " " to force them to layout correctly
    mMessageText = new JLabelPane();
    mMessageText.setBackground(contentPane.getBackground());
    setMessageText(null);

    // Create buttons
    okButton = new JButton(in_ok);
    okButton.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok"));
    cancelButton = new JButton(in_cancel);
    cancelButton.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel"));

    final ActionListener eventListener =
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == okButton) {
              selectedOK();
            } else if (evt.getSource() == cancelButton) {
              close();
            }
          }
        };

    okButton.addActionListener(eventListener);
    cancelButton.addActionListener(eventListener);

    // Add controls to content pane
    GridBagConstraints c;

    // Add message text
    c = new GridBagConstraints();
    Utility.buildConstraints(c, 0, 0, 3, 1, 0, 0);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 4, 4, 4);
    contentPane.add(mMessageText, c);

    // Add available list
    c = new GridBagConstraints();
    Utility.buildConstraints(c, 0, 1, 3, 1, 1, 1);
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(4, 4, 4, 4);
    JScrollPane avaScrollPane = new JScrollPane();
    avaScrollPane.setViewportView(avaPane);
    contentPane.add(avaScrollPane, c);

    // Add 'OK' and 'Cancel buttons
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS));
    btnPanel.add(Box.createHorizontalGlue());
    btnPanel.add(okButton);
    btnPanel.add(Box.createHorizontalStrut(3));
    btnPanel.add(cancelButton);
    c = new GridBagConstraints();
    Utility.buildConstraints(c, 0, 2, 3, 1, 0, 0);
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(0, 4, 4, 4);
    contentPane.add(btnPanel, c);

    okButton.setEnabled(true);
    cancelButton.setEnabled(true);

    Utility.installEscapeCloseOperation(this);
  }
Exemplo n.º 11
0
 public static void showPrintPreviewDialog(PCGenFrame frame) {
   JDialog dialog = new PrintPreviewDialog(frame);
   Utility.setComponentRelativeLocation(frame, dialog);
   dialog.setVisible(true);
 }
Exemplo n.º 12
0
 public boolean isActive() {
   JTabbedPane tp = Utility.getTabbedPaneFor(theView);
   return tp != null
       && JOptionPane.getFrameForComponent(tp).isFocused()
       && tp.getSelectedComponent().equals(theView);
 }