OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 132 Rev 177
Line 21... Line 21...
21
import java.awt.GridBagConstraints;
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
22
import java.awt.GridBagLayout;
23
import java.awt.event.MouseAdapter;
23
import java.awt.event.MouseAdapter;
24
import java.awt.event.MouseEvent;
24
import java.awt.event.MouseEvent;
25
import java.util.Arrays;
25
import java.util.Arrays;
-
 
26
import java.util.Locale;
26
 
27
 
27
import javax.swing.JLabel;
28
import javax.swing.JLabel;
28
import javax.swing.JPanel;
29
import javax.swing.JPanel;
29
 
30
 
30
/**
31
/**
31
 * A panel displaying various informations.
32
 * A panel displaying various informations.
32
 */
33
 */
33
public class InfoPanel extends JPanel {
34
public class InfoPanel extends JPanel {
34
 
35
 
-
 
36
    private final Locale locale;
-
 
37
 
35
    public InfoPanel() {
38
    public InfoPanel(final Locale locale) {
36
        super(new GridBagLayout());
39
        super(new GridBagLayout());
-
 
40
        this.locale = locale;
37
        final GridBagConstraints c = new DefaultGridBagConstraints();
41
        final GridBagConstraints c = new DefaultGridBagConstraints();
38
        c.weightx = 1;
42
        c.weightx = 1;
39
        c.weighty = 1;
43
        c.weighty = 1;
40
        this.add(createTitle("infoPanel.softwareTitle"), c);
44
        this.add(createTitle("infoPanel.softwareTitle"), c);
41
        c.gridy++;
45
        c.gridy++;
42
        this.add(new SoftwareInfoPanel(), c);
46
        this.add(new SoftwareInfoPanel(locale), c);
43
        c.gridy++;
47
        c.gridy++;
44
        this.add(createTitle("infoPanel.systemTitle"), c);
48
        this.add(createTitle("infoPanel.systemTitle"), c);
45
        c.gridy++;
49
        c.gridy++;
46
        this.add(new SystemInfoPanel(), c);
50
        this.add(new SystemInfoPanel(locale), c);
47
    }
51
    }
48
 
52
 
49
    private JLabel createTitle(final String text) {
53
    private JLabel createTitle(final String text) {
50
        final JLabel res = new JLabel(TM.tr(text));
54
        final JLabel res = new JLabel(TM.tr(this.locale, text));
51
        final Font font = res.getFont();
55
        final Font font = res.getFont();
52
        res.setFont(font.deriveFont(font.getSize2D() * 1.2f).deriveFont(Font.BOLD));
56
        res.setFont(font.deriveFont(font.getSize2D() * 1.2f).deriveFont(Font.BOLD));
53
        res.setToolTipText(TM.tr("infoPanel.refresh"));
57
        res.setToolTipText(TM.tr(this.locale, "infoPanel.refresh"));
54
        res.addMouseListener(new MouseAdapter() {
58
        res.addMouseListener(new MouseAdapter() {
55
            @Override
59
            @Override
56
            public void mouseClicked(MouseEvent e) {
60
            public void mouseClicked(MouseEvent e) {
57
                refresh(Arrays.asList(InfoPanel.this.getComponents()).indexOf(res) + 1);
61
                refresh(Arrays.asList(InfoPanel.this.getComponents()).indexOf(res) + 1);
58
            }
62
            }
Line 64... Line 68...
64
        this.refresh(-1);
68
        this.refresh(-1);
65
    }
69
    }
66
 
70
 
67
    private final void refresh(final int index) {
71
    private final void refresh(final int index) {
68
        if (index < 0 || index == 1)
72
        if (index < 0 || index == 1)
69
            ((SoftwareInfoPanel) this.getComponent(1)).refresh();
73
            ((SoftwareInfoPanel) this.getComponent(1)).refresh(this.locale);
70
        if (index < 0 || index == 3)
74
        if (index < 0 || index == 3)
71
            ((SystemInfoPanel) this.getComponent(3)).refresh();
75
            ((SystemInfoPanel) this.getComponent(3)).refresh(this.locale);
72
    }
76
    }
73
}
77
}