Esempio n. 1
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));
 }
  /** 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);
  }
Esempio n. 3
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);
  }