Example #1
0
  private void initComponents() {
    setTitle(chooser.getName());
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosed(WindowEvent e) {
            // detach listeners from the chooser
            treeViewModel.setDelegate(null);
            listModel.setListFacade(null);
            chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this);
          }
        });
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    JSplitPane split = new JSplitPane();
    JPanel leftPane = new JPanel(new BorderLayout());
    if (availTable != null) {
      availTable.setAutoCreateRowSorter(true);
      availTable.setTreeViewModel(treeViewModel);
      availTable.getRowSorter().toggleSortOrder(0);
      availTable.addActionListener(this);
      leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);
    } else {
      availInput.addActionListener(this);
      Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height);
      availInput.setMaximumSize(maxDim);
      JPanel availPanel = new JPanel();
      availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS));
      availPanel.add(Box.createRigidArea(new Dimension(10, 30)));
      availPanel.add(Box.createVerticalGlue());
      availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value")));
      availPanel.add(availInput);
      availPanel.add(Box.createVerticalGlue());
      leftPane.add(availPanel, BorderLayout.WEST);
    }

    JPanel buttonPane1 = new JPanel(new FlowLayout());
    JButton addButton = new JButton(chooser.getAddButtonName());
    addButton.setActionCommand("ADD");
    addButton.addActionListener(this);
    buttonPane1.add(addButton);
    buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon()));
    leftPane.add(buttonPane1, BorderLayout.SOUTH);

    split.setLeftComponent(leftPane);

    JPanel rightPane = new JPanel(new BorderLayout());
    JPanel labelPane = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints());
    remainingLabel.setText(chooser.getRemainingSelections().get().toString());
    labelPane.add(remainingLabel, gbc);
    labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc);
    rightPane.add(labelPane, BorderLayout.NORTH);

    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addActionListener(this);
    rightPane.add(new JScrollPane(list), BorderLayout.CENTER);

    JPanel buttonPane2 = new JPanel(new FlowLayout());
    buttonPane2.add(new JLabel(Icons.Back16.getImageIcon()));
    JButton removeButton = new JButton(chooser.getRemoveButtonName());
    removeButton.setActionCommand("REMOVE");
    removeButton.addActionListener(this);
    buttonPane2.add(removeButton);
    rightPane.add(buttonPane2, BorderLayout.SOUTH);

    split.setRightComponent(rightPane);

    if (chooser.isInfoAvailable()) {
      JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
      infoSplit.setTopComponent(split);
      infoSplit.setBottomComponent(infoPane);
      infoSplit.setResizeWeight(.8);
      pane.add(infoSplit, BorderLayout.CENTER);
      if (availTable != null) {
        availTable.getSelectionModel().addListSelectionListener(this);
      }
    } else {
      pane.add(split, BorderLayout.CENTER);
    }
    JPanel bottomPane = new JPanel(new FlowLayout());
    JButton button = new JButton(LanguageBundle.getString("in_ok")); // $NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok")); // $NON-NLS-1$
    button.setActionCommand("OK");
    button.addActionListener(this);
    bottomPane.add(button);
    button = new JButton(LanguageBundle.getString("in_cancel")); // $NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel")); // $NON-NLS-1$
    button.setActionCommand("CANCEL");
    button.addActionListener(this);
    bottomPane.add(button);
    pane.add(bottomPane, BorderLayout.SOUTH);
  }
Example #2
0
 public UnequipAction() {
   super(LanguageBundle.getString("in_equipUnequipSel")); // $NON-NLS-1$
   this.putValue(SMALL_ICON, Icons.Back16.getImageIcon());
 }
Example #3
0
 public RemoveSpellAction(CharacterFacade character) {
   this.character = character;
   putValue(SMALL_ICON, Icons.Back16.getImageIcon());
 }