Search in sources :

Example 1 with ItemSelectionListener

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());
        }
    }
}
Also used : ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) ScalingRule(delta.games.lotro.lore.items.stats.ScalingRule)

Example 2 with ItemSelectionListener

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;
}
Also used : ComboBoxController(delta.common.ui.swing.combobox.ComboBoxController) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) RelicType(delta.games.lotro.lore.items.legendary.relics.RelicType)

Example 3 with ItemSelectionListener

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;
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) List(java.util.List) LogItemType(delta.games.lotro.character.log.CharacterLogItem.LogItemType)

Example 4 with ItemSelectionListener

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Profession(delta.games.lotro.lore.crafting.Profession) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ComboBoxController(delta.common.ui.swing.combobox.ComboBoxController) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) JLabel(javax.swing.JLabel) Vocation(delta.games.lotro.lore.crafting.Vocation)

Example 5 with ItemSelectionListener

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;
}
Also used : JPanel(javax.swing.JPanel) Profession(delta.games.lotro.lore.crafting.Profession) FlowLayout(java.awt.FlowLayout) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener)

Aggregations

ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)23 JPanel (javax.swing.JPanel)10 FlowLayout (java.awt.FlowLayout)8 GridBagConstraints (java.awt.GridBagConstraints)7 GridBagLayout (java.awt.GridBagLayout)7 Insets (java.awt.Insets)7 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)2 DynamicTextEditionController (delta.common.ui.swing.text.DynamicTextEditionController)2 TextListener (delta.common.ui.swing.text.TextListener)2 Race (delta.games.lotro.common.Race)2 Profession (delta.games.lotro.lore.crafting.Profession)2 JLabel (javax.swing.JLabel)2 IntegerEditionController (delta.common.ui.swing.text.IntegerEditionController)1 DateEditionController (delta.common.ui.swing.text.dates.DateEditionController)1 TypedProperties (delta.common.utils.misc.TypedProperties)1 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)1 LogItemType (delta.games.lotro.character.log.CharacterLogItem.LogItemType)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 Size (delta.games.lotro.common.Size)1 VirtueId (delta.games.lotro.common.VirtueId)1