|
|
@@ -2,17 +2,19 @@ package org.leumasjaffe.charsheet.view.level;
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
+import org.leumasjaffe.charsheet.model.DDCharacterClass;
|
|
|
import org.leumasjaffe.charsheet.model.features.DDPropertyChooser;
|
|
|
import java.awt.GridBagLayout;
|
|
|
import javax.swing.JLabel;
|
|
|
import java.awt.GridBagConstraints;
|
|
|
import javax.swing.JComboBox;
|
|
|
import java.awt.Insets;
|
|
|
+import java.awt.event.ItemEvent;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
public class PropertyChoicePanel extends JPanel {
|
|
|
|
|
|
- public PropertyChoicePanel(DDPropertyChooser prop) {
|
|
|
+ public PropertyChoicePanel(DDCharacterClass dchara, DDPropertyChooser prop, int idx) {
|
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
|
gridBagLayout.columnWidths = new int[]{0, 0, 0};
|
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
|
@@ -29,12 +31,23 @@ public class PropertyChoicePanel extends JPanel {
|
|
|
add(lblName, gbc_lblName);
|
|
|
|
|
|
if (!prop.getChoices().isEmpty()) {
|
|
|
+ DDPropertyChooser.State state = new DDPropertyChooser.State(dchara, prop);
|
|
|
+
|
|
|
JComboBox<String> comboBox = new JComboBox<>(prop.getChoices().toArray(new String[0]));
|
|
|
GridBagConstraints gbc_comboBox = new GridBagConstraints();
|
|
|
gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
|
|
|
gbc_comboBox.gridx = 1;
|
|
|
gbc_comboBox.gridy = 0;
|
|
|
add(comboBox, gbc_comboBox);
|
|
|
+
|
|
|
+ comboBox.setSelectedIndex(idx);
|
|
|
+ state.apply(idx);
|
|
|
+ comboBox.addItemListener(e -> {
|
|
|
+ if (e.getStateChange() == ItemEvent.SELECTED) {
|
|
|
+ state.apply(comboBox.getSelectedIndex());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|