Search in sources :

Example 6 with DateEditionController

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

the class LevelHistoryEditionPanelController method initTab.

private void initTab(JTabbedPane pane, int startLevel, int endLevel) {
    JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    int nbLevels = endLevel - startLevel + 1;
    int nbColumns = (nbLevels / LEVELS_BY_COLUMNS) + (((nbLevels % LEVELS_BY_COLUMNS) == 0) ? 0 : 1);
    int currentLevel = startLevel;
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
    for (int i = 0; i < nbColumns; i++) {
        int row = 0;
        while ((row < LEVELS_BY_COLUMNS) && (currentLevel <= endLevel)) {
            DateEditionController editor = _editors.get(Integer.valueOf(currentLevel));
            JLabel label = GuiFactory.buildLabel(String.valueOf(currentLevel) + ": ");
            c.gridx = i * 2;
            c.gridy = row;
            panel.add(label, c);
            c.gridx++;
            panel.add(editor.getTextField(), c);
            currentLevel++;
            row++;
        }
    }
    // Add glue (bottom and east)
    JPanel bottomGlue = GuiFactory.buildPanel(new BorderLayout());
    GridBagConstraints bottomGlueC = new GridBagConstraints(0, LEVELS_BY_COLUMNS, nbColumns * 2 + 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
    panel.add(bottomGlue, bottomGlueC);
    JPanel eastGlue = GuiFactory.buildPanel(new BorderLayout());
    GridBagConstraints eastGlueC = new GridBagConstraints(nbColumns * 2, 0, 1, LEVELS_BY_COLUMNS, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
    panel.add(eastGlue, eastGlueC);
    // Add tab
    String title = String.valueOf(startLevel) + "-" + String.valueOf(endLevel);
    pane.add(title, panel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) DateEditionController(delta.common.ui.swing.text.dates.DateEditionController)

Example 7 with DateEditionController

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

the class LevelHistoryEditionPanelController method buildPanel.

private JPanel buildPanel() {
    JPanel panel = GuiFactory.buildPanel(new BorderLayout());
    DateCodec codec = DateFormat.getDateTimeCodec();
    for (int level = 1; level <= _maxLevel; level++) {
        DateEditionController editor = new DateEditionController(codec);
        _editors.put(Integer.valueOf(level), editor);
    }
    JTabbedPane pane = GuiFactory.buildTabbedPane();
    int nbLevels = _maxLevel;
    int nbTabs = (nbLevels / LEVELS_BY_TAB) + (((nbLevels % LEVELS_BY_TAB) == 0) ? 0 : 1);
    int currentLevel = 1;
    for (int i = 0; i < nbTabs; i++) {
        int endLevel = Math.min(nbLevels, currentLevel + LEVELS_BY_TAB - 1);
        initTab(pane, currentLevel, endLevel);
        currentLevel = endLevel + 1;
    }
    panel.add(pane, BorderLayout.CENTER);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) DateCodec(delta.common.ui.swing.text.dates.DateCodec) JTabbedPane(javax.swing.JTabbedPane) DateEditionController(delta.common.ui.swing.text.dates.DateEditionController)

Example 8 with DateEditionController

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

the class LevelHistoryEditionPanelController method dispose.

/**
 * Release all managed resources.
 */
public void dispose() {
    if (_panel != null) {
        _panel.removeAll();
        _panel = null;
    }
    if (_editors != null) {
        for (DateEditionController editor : _editors.values()) {
            editor.dispose();
        }
        _editors.clear();
        _editors = null;
    }
    _data = null;
}
Also used : DateEditionController(delta.common.ui.swing.text.dates.DateEditionController)

Example 9 with DateEditionController

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

the class ProfessionStatusEditionPanelController method buildStatusEditionPanel.

private JPanel buildStatusEditionPanel() {
    JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
    // Header row 1
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
    JLabel tier = GuiFactory.buildLabel("Tier");
    panel.add(tier, c);
    c.gridx = 1;
    c.gridwidth = 3;
    c.gridheight = 1;
    JLabel proficiency = GuiFactory.buildLabel("Proficiency");
    panel.add(proficiency, c);
    c.gridx = 4;
    c.gridwidth = 3;
    c.gridheight = 1;
    JLabel mastery = GuiFactory.buildLabel("Mastery");
    panel.add(mastery, c);
    // Header row 2
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    for (int i = 0; i < 2; i++) {
        panel.add(GuiFactory.buildLabel("Completed"), c);
        c.gridx++;
        panel.add(GuiFactory.buildLabel("XP"), c);
        c.gridx++;
        panel.add(GuiFactory.buildLabel("Completion date"), c);
        c.gridx++;
    }
    c.gridy++;
    ActionListener l = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            handleCompletionChange(e.getSource());
        }
    };
    DateListener dateListener = new DateListener() {

        @Override
        public void dateChanged(DateEditionController controller, Long newDate) {
            long date = (newDate != null) ? newDate.longValue() : 0;
            handleDateChange(controller, date);
        }
    };
    // Data rows
    CraftingLevel[] levels = CraftingLevel.ALL_TIERS;
    for (CraftingLevel level : levels) {
        CraftingLevelStatus levelStatus = _status.getLevelStatus(level);
        c.gridx = 0;
        JLabel tierLabel = GuiFactory.buildLabel(level.toString());
        panel.add(tierLabel, c);
        c.gridx++;
        // Proficiency
        CraftingLevelTierStatus proficiencyStatus = levelStatus.getProficiency();
        CraftingLevelTierEditionGadgets proficiencyGadgets = new CraftingLevelTierEditionGadgets(proficiencyStatus);
        JCheckBox checkbox = proficiencyGadgets.getCompleted().getCheckbox();
        panel.add(checkbox, c);
        checkbox.addActionListener(l);
        c.gridx++;
        panel.add(proficiencyGadgets.getXp().getTextField(), c);
        c.gridx++;
        DateEditionController dateCompletion = proficiencyGadgets.getCompletionDate();
        dateCompletion.addListener(dateListener);
        panel.add(dateCompletion.getTextField(), c);
        c.gridx++;
        _proficiencyGadgets.add(proficiencyGadgets);
        // Mastery
        CraftingLevelTierStatus masteryStatus = levelStatus.getMastery();
        CraftingLevelTierEditionGadgets masteryGadgets = new CraftingLevelTierEditionGadgets(masteryStatus);
        checkbox = masteryGadgets.getCompleted().getCheckbox();
        panel.add(checkbox, c);
        checkbox.addActionListener(l);
        c.gridx++;
        panel.add(masteryGadgets.getXp().getTextField(), c);
        c.gridx++;
        dateCompletion = masteryGadgets.getCompletionDate();
        dateCompletion.addListener(dateListener);
        panel.add(dateCompletion.getTextField(), c);
        c.gridx++;
        _masteryGadgets.add(masteryGadgets);
        c.gridy++;
        if (level == CraftingLevel.BEGINNER) {
            proficiencyGadgets.getCompleted().setState(false);
            masteryGadgets.getCompleted().setState(false);
        }
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) CraftingLevelTierStatus(delta.games.lotro.character.crafting.CraftingLevelTierStatus) ActionListener(java.awt.event.ActionListener) DateListener(delta.common.ui.swing.text.dates.DateListener) DateEditionController(delta.common.ui.swing.text.dates.DateEditionController) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel) CraftingLevelStatus(delta.games.lotro.character.crafting.CraftingLevelStatus)

Aggregations

DateEditionController (delta.common.ui.swing.text.dates.DateEditionController)9 JPanel (javax.swing.JPanel)6 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 Insets (java.awt.Insets)4 DateListener (delta.common.ui.swing.text.dates.DateListener)3 JLabel (javax.swing.JLabel)3 BorderLayout (java.awt.BorderLayout)2 FlowLayout (java.awt.FlowLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JCheckBox (javax.swing.JCheckBox)2 CheckboxController (delta.common.ui.swing.checkbox.CheckboxController)1 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 DateCodec (delta.common.ui.swing.text.dates.DateCodec)1 CraftingLevelStatus (delta.games.lotro.character.crafting.CraftingLevelStatus)1 CraftingLevelTierStatus (delta.games.lotro.character.crafting.CraftingLevelTierStatus)1 CharacterEvent (delta.games.lotro.character.events.CharacterEvent)1 FactionLevelStatus (delta.games.lotro.character.reputation.FactionLevelStatus)1 CraftingLevel (delta.games.lotro.lore.crafting.CraftingLevel)1