mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Merge pull request #1062 from brodee/master
random booster draft UI improvement
This commit is contained in:
commit
d24777cd15
3 changed files with 356 additions and 66 deletions
|
@ -35,17 +35,15 @@
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.JButton;
|
||||||
import javax.swing.DefaultListSelectionModel;
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
||||||
import static javax.swing.ListSelectionModel.SINGLE_SELECTION;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
|
@ -80,12 +78,12 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
private UUID roomId;
|
private UUID roomId;
|
||||||
private final Session session;
|
private final Session session;
|
||||||
private String lastSessionId;
|
private String lastSessionId;
|
||||||
private JList randomList = new JList();
|
private RandomPacksSelectorDialog randomPackSelector;
|
||||||
|
private JTextArea txtRandomPacks;
|
||||||
private final List<TournamentPlayerPanel> players = new ArrayList<>();
|
private final List<TournamentPlayerPanel> players = new ArrayList<>();
|
||||||
private final List<JComboBox> packs = new ArrayList<>();
|
private final List<JComboBox> packs = new ArrayList<>();
|
||||||
private final int CONSTRUCTION_TIME_MIN = 6;
|
private final int CONSTRUCTION_TIME_MIN = 6;
|
||||||
private final int CONSTRUCTION_TIME_MAX = 30;
|
private final int CONSTRUCTION_TIME_MAX = 30;
|
||||||
private final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
|
||||||
|
|
||||||
private boolean automaticChange = false;
|
private boolean automaticChange = false;
|
||||||
|
|
||||||
|
@ -534,15 +532,8 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
if (tournamentType.isCubeBooster()) {
|
if (tournamentType.isCubeBooster()) {
|
||||||
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
|
||||||
} else if (tournamentType.isRandom()) {
|
} else if (tournamentType.isRandom()) {
|
||||||
for (Object pack : randomList.getSelectedValuesList()) {
|
tOptions.getLimitedOptions().getSetCodes().clear();
|
||||||
String packStr = (String) pack;
|
tOptions.getLimitedOptions().getSetCodes().addAll(randomPackSelector.getSelectedPacks());
|
||||||
String code = packStr.substring(0, 3);
|
|
||||||
tOptions.getLimitedOptions().getSetCodes().add(code);
|
|
||||||
}
|
|
||||||
if (tOptions.getLimitedOptions().getSetCodes().size() < 2) {
|
|
||||||
// At least two sets must be chosen.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (JComboBox pack: packs) {
|
for (JComboBox pack: packs) {
|
||||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
|
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
|
||||||
|
@ -724,60 +715,54 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
|
|
||||||
private void createRandomPacks() {
|
private void createRandomPacks() {
|
||||||
if (pnlRandomPacks.getComponentCount() == 0) {
|
if (pnlRandomPacks.getComponentCount() == 0) {
|
||||||
|
if (randomPackSelector == null) {
|
||||||
DefaultListModel randomListModel = new DefaultListModel();
|
randomPackSelector = new RandomPacksSelectorDialog();
|
||||||
randomList = new JList(randomListModel);
|
|
||||||
randomList.setToolTipText(randomDraftDescription);
|
|
||||||
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
|
||||||
for (ExpansionInfo expansion : allExpansions) {
|
|
||||||
String exp = expansion.getCode() + " - " + expansion.getName();
|
|
||||||
randomListModel.addElement(exp);
|
|
||||||
}
|
}
|
||||||
randomList.setSelectionModel(new DefaultListSelectionModel() {
|
txtRandomPacks = new JTextArea();
|
||||||
private boolean mGestureStarted;
|
txtRandomPacks.setEnabled(false);
|
||||||
|
txtRandomPacks.setLineWrap(true);
|
||||||
@Override
|
|
||||||
public void setSelectionInterval(int index0, int index1) {
|
|
||||||
// Toggle only one element while the user is dragging the mouse
|
|
||||||
if (!mGestureStarted) {
|
|
||||||
if (isSelectedIndex(index0)) {
|
|
||||||
super.removeSelectionInterval(index0, index1);
|
|
||||||
} else {
|
|
||||||
if (getSelectionMode() == SINGLE_SELECTION) {
|
|
||||||
super.setSelectionInterval(index0, index1);
|
|
||||||
} else {
|
|
||||||
super.addSelectionInterval(index0, index1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Disable toggling till the adjusting is over, or keep it
|
|
||||||
// enabled in case setSelectionInterval was called directly.
|
|
||||||
mGestureStarted = getValueIsAdjusting();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValueIsAdjusting(boolean isAdjusting) {
|
|
||||||
super.setValueIsAdjusting(isAdjusting);
|
|
||||||
|
|
||||||
if (isAdjusting == false) {
|
|
||||||
// Enable toggling
|
|
||||||
mGestureStarted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
|
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
|
||||||
if (randomPrefs.length() > 0) {
|
if (randomPrefs.length() > 0) {
|
||||||
for (String exp : randomPrefs.split(";")) {
|
txtRandomPacks.setText(randomPrefs);
|
||||||
randomList.setSelectedValue(exp, false);
|
ArrayList<String> theList = new ArrayList<>();
|
||||||
}
|
theList.addAll(Arrays.asList(randomPrefs.split(";")));
|
||||||
|
randomPackSelector.setSelectedPacks(theList);
|
||||||
} else {
|
} else {
|
||||||
randomList.setSelectionInterval(0, randomListModel.size() - 1);
|
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||||
|
StringBuilder packList = new StringBuilder();
|
||||||
|
for (ExpansionInfo exp : allExpansions) {
|
||||||
|
packList.append(exp.getCode());
|
||||||
|
packList.append(";");
|
||||||
|
}
|
||||||
|
txtRandomPacks.setText(packList.toString());
|
||||||
}
|
}
|
||||||
JScrollPane list1scr = new JScrollPane(randomList);
|
|
||||||
randomList.setVisibleRowCount(4);
|
pnlRandomPacks.add(txtRandomPacks);
|
||||||
pnlRandomPacks.add(list1scr);
|
JButton btnSelectRandomPacks = new JButton();
|
||||||
|
btnSelectRandomPacks.setText("Select packs to be included in the pool");
|
||||||
|
btnSelectRandomPacks.setToolTipText(RandomPacksSelectorDialog.randomDraftDescription);
|
||||||
|
btnSelectRandomPacks.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
showRandomPackSelectorDialog();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pnlRandomPacks.add(btnSelectRandomPacks);
|
||||||
|
}
|
||||||
|
this.pack();
|
||||||
|
this.revalidate();
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showRandomPackSelectorDialog() {
|
||||||
|
randomPackSelector.showDialog();
|
||||||
|
StringBuilder packList = new StringBuilder();
|
||||||
|
for (String str : randomPackSelector.getSelectedPacks()) {
|
||||||
|
packList.append(str);
|
||||||
|
packList.append(";");
|
||||||
}
|
}
|
||||||
|
this.txtRandomPacks.setText(packList.toString());
|
||||||
this.pack();
|
this.pack();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
this.repaint();
|
this.repaint();
|
||||||
|
@ -1006,8 +991,8 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
if (tOptions.getLimitedOptions().getIsRandom()){
|
if (tOptions.getLimitedOptions().getIsRandom()){
|
||||||
// save random boosters to prefs
|
// save random boosters to prefs
|
||||||
StringBuilder packlist = new StringBuilder();
|
StringBuilder packlist = new StringBuilder();
|
||||||
for (Object pack: randomList.getSelectedValuesList()){
|
for (String pack : this.randomPackSelector.getSelectedPacks()){
|
||||||
packlist.append((String)pack);
|
packlist.append(pack);
|
||||||
packlist.append(";");
|
packlist.append(";");
|
||||||
}
|
}
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, packlist.toString());
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="title" type="java.lang.String" value="Random Booster Draft Packs Selector"/>
|
||||||
|
<Property name="modal" type="boolean" value="true"/>
|
||||||
|
<Property name="modalExclusionType" type="java.awt.Dialog$ModalExclusionType" editor="org.netbeans.modules.form.editors.EnumEditor">
|
||||||
|
<Value id="APPLICATION_EXCLUDE"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[600, 450]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="resizable" type="boolean" value="false"/>
|
||||||
|
</Properties>
|
||||||
|
<SyntheticProperties>
|
||||||
|
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||||
|
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||||
|
</SyntheticProperties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<Component id="pnlSelect" min="-2" pref="241" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace pref="300" max="32767" attributes="0"/>
|
||||||
|
<Component id="pnlApply" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<Group type="102" attributes="0">
|
||||||
|
<Component id="pnlPacks" max="32767" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<Component id="pnlPacks" min="-2" pref="372" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="pnlApply" min="-2" pref="32" max="-2" attributes="0"/>
|
||||||
|
<Component id="pnlSelect" min="-2" pref="32" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Container class="java.awt.Panel" name="pnlPacks">
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||||
|
<Property name="columns" type="int" value="12"/>
|
||||||
|
<Property name="rows" type="int" value="11"/>
|
||||||
|
</Layout>
|
||||||
|
</Container>
|
||||||
|
<Container class="javax.swing.JPanel" name="pnlSelect">
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JButton" name="btnNone">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Select none"/>
|
||||||
|
<Property name="actionCommand" type="java.lang.String" value="none"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNoneActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="btnAll">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Select all"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnAllActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
<Container class="javax.swing.JPanel" name="pnlApply">
|
||||||
|
|
||||||
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JButton" name="btnApply">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Apply"/>
|
||||||
|
<Property name="toolTipText" type="java.lang.String" value="At least two packs must be selected"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnApplyActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Container>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
|
@ -0,0 +1,199 @@
|
||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package mage.client.dialog;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import mage.cards.repository.ExpansionInfo;
|
||||||
|
import mage.cards.repository.ExpansionRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author BrodyL
|
||||||
|
*/
|
||||||
|
public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new form RandomPacksSelectorDialog
|
||||||
|
*/
|
||||||
|
private boolean boxesCreated;
|
||||||
|
public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||||
|
|
||||||
|
public RandomPacksSelectorDialog() {
|
||||||
|
initComponents();
|
||||||
|
this.pnlApply.setToolTipText(randomDraftDescription);
|
||||||
|
this.pnlSelect.setToolTipText(randomDraftDescription);
|
||||||
|
boxesCreated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog() {
|
||||||
|
createCheckboxes();
|
||||||
|
pnlPacks.setVisible(true);
|
||||||
|
pnlPacks.revalidate();
|
||||||
|
pnlPacks.repaint();
|
||||||
|
this.pack();
|
||||||
|
this.revalidate();
|
||||||
|
this.repaint();
|
||||||
|
this.setVisible(true);
|
||||||
|
this.setModal(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedPacks(ArrayList<String> packs){
|
||||||
|
if (!boxesCreated){
|
||||||
|
createCheckboxes();
|
||||||
|
}
|
||||||
|
for (Component pack : pnlPacks.getComponents()) {
|
||||||
|
JCheckBox thePack = (JCheckBox) pack;
|
||||||
|
if (packs.contains(thePack.getText())) {
|
||||||
|
thePack.setSelected(true);
|
||||||
|
} else{
|
||||||
|
thePack.setSelected(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getSelectedPacks() {
|
||||||
|
ArrayList<String> returnVal = new ArrayList<>();
|
||||||
|
for (Component pack: pnlPacks.getComponents()){
|
||||||
|
JCheckBox thePack = (JCheckBox) pack;
|
||||||
|
if (thePack.isSelected()){
|
||||||
|
returnVal.add(thePack.getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCheckboxes() {
|
||||||
|
if (!boxesCreated) {
|
||||||
|
ExpansionInfo[] allExpansions = ExpansionRepository.instance.getWithBoostersSortedByReleaseDate();
|
||||||
|
for (ExpansionInfo exp : allExpansions) {
|
||||||
|
JCheckBox pack = new JCheckBox();
|
||||||
|
pack.setSelected(true);
|
||||||
|
pack.setText(exp.getCode());
|
||||||
|
pack.setToolTipText(exp.getName());
|
||||||
|
pnlPacks.add(pack);
|
||||||
|
}
|
||||||
|
pnlPacks.setVisible(true);
|
||||||
|
this.pack();
|
||||||
|
boxesCreated = true;
|
||||||
|
pnlPacks.validate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
pnlPacks = new java.awt.Panel();
|
||||||
|
pnlSelect = new javax.swing.JPanel();
|
||||||
|
btnNone = new javax.swing.JButton();
|
||||||
|
btnAll = new javax.swing.JButton();
|
||||||
|
pnlApply = new javax.swing.JPanel();
|
||||||
|
btnApply = new javax.swing.JButton();
|
||||||
|
|
||||||
|
setTitle("Random Booster Draft Packs Selector");
|
||||||
|
setModal(true);
|
||||||
|
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
|
||||||
|
setPreferredSize(new java.awt.Dimension(600, 450));
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
pnlPacks.setLayout(new java.awt.GridLayout(11, 12));
|
||||||
|
|
||||||
|
pnlSelect.setLayout(new javax.swing.BoxLayout(pnlSelect, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
btnNone.setText("Select none");
|
||||||
|
btnNone.setActionCommand("none");
|
||||||
|
btnNone.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnNoneActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pnlSelect.add(btnNone);
|
||||||
|
|
||||||
|
btnAll.setText("Select all");
|
||||||
|
btnAll.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnAllActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pnlSelect.add(btnAll);
|
||||||
|
|
||||||
|
pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
btnApply.setText("Apply");
|
||||||
|
btnApply.setToolTipText("At least two packs must be selected");
|
||||||
|
btnApply.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnApplyActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pnlApply.add(btnApply);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
|
getContentPane().setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 300, Short.MAX_VALUE)
|
||||||
|
.addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(pnlPacks, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(pnlApply, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(pnlSelect, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
|
||||||
|
pack();
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void btnAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAllActionPerformed
|
||||||
|
setAllCheckBoxes(true);
|
||||||
|
}//GEN-LAST:event_btnAllActionPerformed
|
||||||
|
|
||||||
|
private void btnNoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoneActionPerformed
|
||||||
|
setAllCheckBoxes(false);
|
||||||
|
}//GEN-LAST:event_btnNoneActionPerformed
|
||||||
|
|
||||||
|
private void btnApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplyActionPerformed
|
||||||
|
if (getSelectedPacks().size() < 2) {
|
||||||
|
// at least 2 packs must be selected.
|
||||||
|
} else {
|
||||||
|
this.setVisible(false);
|
||||||
|
}
|
||||||
|
}//GEN-LAST:event_btnApplyActionPerformed
|
||||||
|
|
||||||
|
private void setAllCheckBoxes(boolean value) {
|
||||||
|
for (Component pack : pnlPacks.getComponents()) {
|
||||||
|
JCheckBox thePack = (JCheckBox) pack;
|
||||||
|
thePack.setSelected(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JButton btnAll;
|
||||||
|
private javax.swing.JButton btnApply;
|
||||||
|
private javax.swing.JButton btnNone;
|
||||||
|
private javax.swing.JPanel pnlApply;
|
||||||
|
private java.awt.Panel pnlPacks;
|
||||||
|
private javax.swing.JPanel pnlSelect;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
Loading…
Reference in a new issue