OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
41 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.sql.ui;
15
 
73 ilm 16
import org.openconcerto.sql.TM;
41 ilm 17
import org.openconcerto.ui.DefaultGridBagConstraints;
18
import org.openconcerto.ui.SystemInfoPanel;
19
 
20
import java.awt.Font;
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
132 ilm 23
import java.awt.event.MouseAdapter;
24
import java.awt.event.MouseEvent;
25
import java.util.Arrays;
177 ilm 26
import java.util.Locale;
41 ilm 27
 
28
import javax.swing.JLabel;
29
import javax.swing.JPanel;
30
 
31
/**
32
 * A panel displaying various informations.
33
 */
34
public class InfoPanel extends JPanel {
35
 
177 ilm 36
    private final Locale locale;
37
 
38
    public InfoPanel(final Locale locale) {
41 ilm 39
        super(new GridBagLayout());
177 ilm 40
        this.locale = locale;
41 ilm 41
        final GridBagConstraints c = new DefaultGridBagConstraints();
42
        c.weightx = 1;
43
        c.weighty = 1;
73 ilm 44
        this.add(createTitle("infoPanel.softwareTitle"), c);
41 ilm 45
        c.gridy++;
177 ilm 46
        this.add(new SoftwareInfoPanel(locale), c);
41 ilm 47
        c.gridy++;
73 ilm 48
        this.add(createTitle("infoPanel.systemTitle"), c);
41 ilm 49
        c.gridy++;
177 ilm 50
        this.add(new SystemInfoPanel(locale), c);
41 ilm 51
    }
52
 
53
    private JLabel createTitle(final String text) {
177 ilm 54
        final JLabel res = new JLabel(TM.tr(this.locale, text));
41 ilm 55
        final Font font = res.getFont();
56
        res.setFont(font.deriveFont(font.getSize2D() * 1.2f).deriveFont(Font.BOLD));
177 ilm 57
        res.setToolTipText(TM.tr(this.locale, "infoPanel.refresh"));
132 ilm 58
        res.addMouseListener(new MouseAdapter() {
59
            @Override
60
            public void mouseClicked(MouseEvent e) {
61
                refresh(Arrays.asList(InfoPanel.this.getComponents()).indexOf(res) + 1);
62
            }
63
        });
41 ilm 64
        return res;
65
    }
132 ilm 66
 
67
    public final void refresh() {
68
        this.refresh(-1);
69
    }
70
 
71
    private final void refresh(final int index) {
72
        if (index < 0 || index == 1)
177 ilm 73
            ((SoftwareInfoPanel) this.getComponent(1)).refresh(this.locale);
132 ilm 74
        if (index < 0 || index == 3)
177 ilm 75
            ((SystemInfoPanel) this.getComponent(3)).refresh(this.locale);
132 ilm 76
    }
41 ilm 77
}