Search in sources :

Example 1 with TextListener

use of delta.common.ui.swing.text.TextListener in project lotro-companion by dmorcellet.

the class ItemFilterController method build.

private JPanel build() {
    JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
    JPanel line1Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    // Quality
    {
        JPanel qualityPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
        qualityPanel.add(GuiFactory.buildLabel("Quality:"));
        _quality = ItemUiTools.buildQualityCombo();
        ItemSelectionListener<ItemQuality> qualityListener = new ItemSelectionListener<ItemQuality>() {

            @Override
            public void itemSelected(ItemQuality quality) {
                _qualityFilter.setQuality(quality);
                filterUpdated();
            }
        };
        _quality.addListener(qualityListener);
        qualityPanel.add(_quality.getComboBox());
        line1Panel.add(qualityPanel);
    }
    // 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);
        TextListener listener = new TextListener() {

            @Override
            public void textChanged(String newText) {
                if (newText.length() == 0)
                    newText = null;
                _nameFilter.setPattern(newText);
                filterUpdated();
            }
        };
        _textController = new DynamicTextEditionController(_contains, listener);
        line1Panel.add(containsPanel);
    }
    // Line 2: weapon type, armour type, shield type
    JPanel line2Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
    // Weapon type
    if (_weaponType != null) {
        JPanel weaponTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
        weaponTypePanel.add(GuiFactory.buildLabel("Weapon type:"));
        ItemSelectionListener<WeaponType> weaponTypeListener = new ItemSelectionListener<WeaponType>() {

            @Override
            public void itemSelected(WeaponType type) {
                _weaponTypeFilter.setWeaponType(type);
                // If a weapon type is selected,
                if (type != null) {
                    // Reset the shield type combo
                    if (_armourType != null) {
                        _armourType.selectItem(null);
                    }
                    // Reset the shield type combo
                    if (_shieldType != null) {
                        _shieldType.selectItem(null);
                    }
                }
                filterUpdated();
            }
        };
        _weaponType.addListener(weaponTypeListener);
        weaponTypePanel.add(_weaponType.getComboBox());
        line2Panel.add(weaponTypePanel);
    }
    // Armour type
    if (_armourType != null) {
        JPanel armourTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
        armourTypePanel.add(GuiFactory.buildLabel("Armour type:"));
        ItemSelectionListener<ArmourType> armourTypeListener = new ItemSelectionListener<ArmourType>() {

            @Override
            public void itemSelected(ArmourType type) {
                _armourTypeFilter.setArmourType(type);
                // If an armour type is selected,
                if (type != null) {
                    // Reset the weapon type combo
                    if (_weaponType != null) {
                        _weaponType.selectItem(null);
                    }
                    // Reset the shield type combo
                    if (_shieldType != null) {
                        _shieldType.selectItem(null);
                    }
                }
                filterUpdated();
            }
        };
        _armourType.addListener(armourTypeListener);
        armourTypePanel.add(_armourType.getComboBox());
        line2Panel.add(armourTypePanel);
    }
    // Shield type
    if (_shieldType != null) {
        JPanel shieldTypePanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING));
        shieldTypePanel.add(GuiFactory.buildLabel("Shield type:"));
        ItemSelectionListener<ArmourType> shieldTypeListener = new ItemSelectionListener<ArmourType>() {

            @Override
            public void itemSelected(ArmourType type) {
                _shieldTypeFilter.setArmourType(type);
                // If a shield type is selected,
                if (type != null) {
                    // Reset the weapon type combo
                    if (_weaponType != null) {
                        _weaponType.selectItem(null);
                    }
                    // Reset the armour type combo
                    if (_armourType != null) {
                        _armourType.selectItem(null);
                    }
                }
                filterUpdated();
            }
        };
        _shieldType.addListener(shieldTypeListener);
        shieldTypePanel.add(_shieldType.getComboBox());
        line2Panel.add(shieldTypePanel);
    }
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
    panel.add(line1Panel, c);
    c = new GridBagConstraints(0, 1, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
    panel.add(line2Panel, c);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) ArmourType(delta.games.lotro.lore.items.ArmourType) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) TextListener(delta.common.ui.swing.text.TextListener) ItemQuality(delta.games.lotro.lore.items.ItemQuality) DynamicTextEditionController(delta.common.ui.swing.text.DynamicTextEditionController) WeaponType(delta.games.lotro.lore.items.WeaponType)

Example 2 with TextListener

use of delta.common.ui.swing.text.TextListener in project lotro-companion by dmorcellet.

the class DeedFilterController method buildDeedPanel.

private JPanel buildDeedPanel() {
    JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
    int y = 0;
    JPanel line1Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    // Label filter
    {
        JPanel containsPanel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
        containsPanel.add(GuiFactory.buildLabel("Name filter:"));
        _contains = GuiFactory.buildTextField("");
        _contains.setColumns(20);
        containsPanel.add(_contains);
        TextListener listener = new TextListener() {

            @Override
            public void textChanged(String newText) {
                if (newText.length() == 0)
                    newText = null;
                DeedNameFilter nameFilter = _filter.getNameFilter();
                nameFilter.setPattern(newText);
                filterUpdated();
            }
        };
        _textController = new DynamicTextEditionController(_contains, listener);
        line1Panel.add(containsPanel);
    }
    GridBagConstraints c = new GridBagConstraints(0, y, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
    panel.add(line1Panel, c);
    y++;
    JPanel line2Panel = GuiFactory.buildPanel(new FlowLayout(FlowLayout.LEADING, 5, 0));
    // Type
    {
        JLabel label = GuiFactory.buildLabel("Type:");
        line2Panel.add(label);
        _type = DeedUiUtils.buildDeedTypeCombo();
        ItemSelectionListener<DeedType> typeListener = new ItemSelectionListener<DeedType>() {

            @Override
            public void itemSelected(DeedType type) {
                DeedTypeFilter typeFilter = _filter.getTypeFilter();
                typeFilter.setDeedType(type);
                filterUpdated();
            }
        };
        _type.addListener(typeListener);
        line2Panel.add(_type.getComboBox());
    }
    // Category
    {
        JLabel label = GuiFactory.buildLabel("Category:");
        line2Panel.add(label);
        _category = DeedUiUtils.buildCategoryCombo();
        ItemSelectionListener<String> categoryListener = new ItemSelectionListener<String>() {

            @Override
            public void itemSelected(String category) {
                DeedCategoryFilter categoryFilter = _filter.getCategoryFilter();
                categoryFilter.setDeedCategory(category);
                filterUpdated();
            }
        };
        _category.addListener(categoryListener);
        line2Panel.add(_category.getComboBox());
    }
    c = new GridBagConstraints(0, y, 1, 1, 1.0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
    panel.add(line2Panel, c);
    y++;
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ItemSelectionListener(delta.common.ui.swing.combobox.ItemSelectionListener) JLabel(javax.swing.JLabel) TextListener(delta.common.ui.swing.text.TextListener) DeedTypeFilter(delta.games.lotro.lore.deeds.filters.DeedTypeFilter) DynamicTextEditionController(delta.common.ui.swing.text.DynamicTextEditionController) DeedCategoryFilter(delta.games.lotro.lore.deeds.filters.DeedCategoryFilter) DeedNameFilter(delta.games.lotro.lore.deeds.filters.DeedNameFilter) DeedType(delta.games.lotro.lore.deeds.DeedType)

Aggregations

ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)2 DynamicTextEditionController (delta.common.ui.swing.text.DynamicTextEditionController)2 TextListener (delta.common.ui.swing.text.TextListener)2 FlowLayout (java.awt.FlowLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 JPanel (javax.swing.JPanel)2 DeedType (delta.games.lotro.lore.deeds.DeedType)1 DeedCategoryFilter (delta.games.lotro.lore.deeds.filters.DeedCategoryFilter)1 DeedNameFilter (delta.games.lotro.lore.deeds.filters.DeedNameFilter)1 DeedTypeFilter (delta.games.lotro.lore.deeds.filters.DeedTypeFilter)1 ArmourType (delta.games.lotro.lore.items.ArmourType)1 ItemQuality (delta.games.lotro.lore.items.ItemQuality)1 WeaponType (delta.games.lotro.lore.items.WeaponType)1 JLabel (javax.swing.JLabel)1