use of delta.common.ui.swing.combobox.ItemSelectionListener in project lotro-companion by dmorcellet.
the class ItemEditionPanelController method configureScaling.
private void configureScaling(Item item) {
ScalingRule rule = Scaling.getScalingRule(item);
if (rule != null) {
// Min level
List<Integer> minLevels = rule.getRequiredLevels();
for (Integer minLevel : minLevels) {
_minLevel.addItem(minLevel, minLevel.toString());
}
ItemSelectionListener<Integer> listenerRequiredLevel = new ItemSelectionListener<Integer>() {
@Override
public void itemSelected(Integer requiredLevel) {
selectRequiredLevel(requiredLevel);
}
};
_minLevel.addListener(listenerRequiredLevel);
// Item level
List<Integer> itemLevels = rule.getItemLevels();
for (Integer itemLevel : itemLevels) {
_itemLevel.addItem(itemLevel, itemLevel.toString());
}
ItemSelectionListener<Integer> listener = new ItemSelectionListener<Integer>() {
@Override
public void itemSelected(Integer itemLevel) {
selectItemLevel(itemLevel);
}
};
_itemLevel.addListener(listener);
} else {
// Min level
_minLevel.addEmptyItem("");
Integer minLevel = item.getMinLevel();
if (minLevel != null) {
_minLevel.addItem(minLevel, minLevel.toString());
}
// Item level
_itemLevel.addEmptyItem("");
Integer itemLevel = item.getItemLevel();
if (itemLevel != null) {
_itemLevel.addItem(itemLevel, itemLevel.toString());
}
}
}
use of delta.common.ui.swing.combobox.ItemSelectionListener in project lotro-companion by dmorcellet.
the class RelicsFilterController method buildTypesCombo.
private ComboBoxController<RelicType> buildTypesCombo() {
final ComboBoxController<RelicType> ctrl = new ComboBoxController<RelicType>();
ctrl.addEmptyItem("");
for (RelicType type : RelicType.values()) {
ctrl.addItem(type, type.getName());
}
ItemSelectionListener<RelicType> l = new ItemSelectionListener<RelicType>() {
@Override
public void itemSelected(RelicType type) {
_filter.setRelicType(type);
updateFilter();
}
};
ctrl.addListener(l);
return ctrl;
}
use of delta.common.ui.swing.combobox.ItemSelectionListener in project lotro-companion by dmorcellet.
the class CharacterLogFilterController method build.
private JPanel build() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
// Dates
JPanel datesPanel = GuiFactory.buildPanel(new GridBagLayout());
{
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
List<Long> dates = _log.getDates();
datesPanel.add(GuiFactory.buildLabel("After:"), c);
_minDates = buildDatesChooser(dates);
c.gridx = 1;
datesPanel.add(_minDates.getComboBox(), c);
c.gridy = 1;
c.gridx = 0;
datesPanel.add(GuiFactory.buildLabel("Before:"), c);
_maxDates = buildDatesChooser(dates);
c.gridx = 1;
datesPanel.add(_maxDates.getComboBox(), c);
ItemSelectionListener<Long> listenerMinDates = new ItemSelectionListener<Long>() {
@Override
public void itemSelected(Long selected) {
_filter.setMinDate(selected);
updateFilter();
}
};
_minDates.addListener(listenerMinDates);
ItemSelectionListener<Long> listenerMaxDates = new ItemSelectionListener<Long>() {
@Override
public void itemSelected(Long selected) {
_filter.setMaxDate(selected);
updateFilter();
}
};
_maxDates.addListener(listenerMaxDates);
}
// Label filter
JPanel containsPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
{
containsPanel.add(GuiFactory.buildLabel("Label filter:"));
_contains = GuiFactory.buildTextField("");
_contains.setColumns(20);
containsPanel.add(_contains);
DocumentListener dl = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
doIt();
}
@Override
public void insertUpdate(DocumentEvent e) {
doIt();
}
@Override
public void changedUpdate(DocumentEvent e) {
doIt();
}
private void doIt() {
String text = _contains.getText();
if (text.length() == 0)
text = null;
_filter.setLabelFilter(text);
updateFilter();
}
};
_contains.getDocument().addDocumentListener(dl);
}
// Checkboxes
JPanel cbPanel = GuiFactory.buildPanel(new GridBagLayout());
{
LogItemType[] types = { LogItemType.QUEST, LogItemType.DEED, LogItemType.LEVELUP, LogItemType.PROFESSION, LogItemType.VOCATION, LogItemType.PVMP };
String[] labels = { "Quests", "Deeds", "Level-ups", "Profession", "Vocation", "PvM" };
_types.clear();
int nbInRow = 3;
int nbTypes = types.length;
for (int i = 0; i < nbTypes; i++) {
LogItemType type = types[i];
JCheckBox checkbox = GuiFactory.buildCheckbox(labels[i]);
_types.put(type, checkbox);
checkbox.addItemListener(this);
GridBagConstraints c = new GridBagConstraints(i % nbInRow, i / nbInRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
cbPanel.add(checkbox, c);
}
}
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
panel.add(datesPanel, c);
c = new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
panel.add(cbPanel, c);
c = new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
panel.add(containsPanel, c);
return panel;
}
use of delta.common.ui.swing.combobox.ItemSelectionListener in project lotro-companion by dmorcellet.
the class CraftingWindowController method buildFormPanel.
@Override
protected JPanel buildFormPanel() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
// Vocation panel
JPanel vocationPanel = GuiFactory.buildPanel(new FlowLayout());
{
_vocation = buildVocationCombo();
JLabel vocationLabel = GuiFactory.buildLabel("Vocation:");
vocationPanel.add(vocationLabel);
vocationPanel.add(_vocation.getComboBox());
}
// Guild panel
JPanel guildPanel = GuiFactory.buildPanel(new FlowLayout());
{
_guild = new ComboBoxController<Profession>();
JLabel guildLabel = GuiFactory.buildLabel("Guild:");
guildPanel.add(guildLabel);
guildPanel.add(_guild.getComboBox());
}
// Vocation panel
JPanel vocationEditionPanel = _vocationController.getPanel();
// Assembly
JPanel topPanel = GuiFactory.buildPanel(new FlowLayout());
topPanel.add(vocationPanel);
topPanel.add(guildPanel);
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 10, 0, 10), 0, 0);
panel.add(topPanel, c);
GridBagConstraints c2 = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0);
panel.add(vocationEditionPanel, c2);
// Update vocation edition panel
_vocationController.updateUiFromData();
Vocation vocation = _stats.getVocation();
// Init combos
Profession currentGuild = _stats.getGuildStatus().getProfession();
_vocation.selectItem(vocation);
_guild.addEmptyItem("");
updateGuildCombo(vocation);
_guild.selectItem(currentGuild);
// Init vocation combo
ItemSelectionListener<Vocation> vocationListener = new ItemSelectionListener<Vocation>() {
@Override
public void itemSelected(Vocation selectedVocation) {
handleVocationUpdate(selectedVocation);
}
};
_vocation.addListener(vocationListener);
// Init guild combo
ItemSelectionListener<Profession> guildListener = new ItemSelectionListener<Profession>() {
@Override
public void itemSelected(Profession selectedGuild) {
handleGuildUpdate(selectedGuild);
}
};
_guild.addListener(guildListener);
return panel;
}
use of delta.common.ui.swing.combobox.ItemSelectionListener in project lotro-companion by dmorcellet.
the class CraftingSynopsisFilterController method build.
private JPanel build() {
JPanel panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
// Professions
List<Profession> professions = Profession.getAll();
_professions = new ComboBoxController<Profession>();
_professions.addEmptyItem(" ");
for (Profession profession : professions) {
_professions.addItem(profession, profession.getLabel());
}
ItemSelectionListener<Profession> listener = new ItemSelectionListener<Profession>() {
@Override
public void itemSelected(Profession profession) {
_filter.setProfession(profession);
updateFilter();
}
};
_professions.addListener(listener);
panel.add(GuiFactory.buildLabel("Profession:"));
panel.add(_professions.getComboBox());
return panel;
}
Aggregations