OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | Rev 182 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 177
Line 26... Line 26...
26
import java.net.URISyntaxException;
26
import java.net.URISyntaxException;
27
import java.util.ArrayList;
27
import java.util.ArrayList;
28
import java.util.Enumeration;
28
import java.util.Enumeration;
29
import java.util.Formatter;
29
import java.util.Formatter;
30
import java.util.List;
30
import java.util.List;
-
 
31
import java.util.Locale;
31
import java.util.NavigableMap;
32
import java.util.NavigableMap;
32
import java.util.TreeMap;
33
import java.util.TreeMap;
33
 
34
 
34
import javax.swing.LookAndFeel;
35
import javax.swing.LookAndFeel;
35
import javax.swing.UIManager;
36
import javax.swing.UIManager;
Line 45... Line 46...
45
        JAVA, OS, USER, NETWORK
46
        JAVA, OS, USER, NETWORK
46
    }
47
    }
47
 
48
 
48
    public static final String CLASS_PROTOCOL = "class";
49
    public static final String CLASS_PROTOCOL = "class";
49
 
50
 
50
    static public NavigableMap<Info, String> get(final boolean html) {
51
    static public NavigableMap<Info, String> get(final boolean html, final Locale locale) {
-
 
52
        final TM tm = TM.getInstance(locale);
51
        final NavigableMap<Info, String> res = new TreeMap<Info, String>();
53
        final NavigableMap<Info, String> res = new TreeMap<Info, String>();
52
 
54
 
53
        final String lineBreak = getLineBreak(html);
55
        final String lineBreak = getLineBreak(html);
54
 
56
 
55
        // * Version 1.6.0_13-b03 de Sun Microsystems Inc. ; dossier d'installation
57
        // * Version 1.6.0_13-b03 de Sun Microsystems Inc. ; dossier d'installation
Line 63... Line 65...
63
        } catch (URISyntaxException e1) {
65
        } catch (URISyntaxException e1) {
64
            // tant pis pas de lien
66
            // tant pis pas de lien
65
            e1.printStackTrace();
67
            e1.printStackTrace();
66
        }
68
        }
67
        final Runtime rt = Runtime.getRuntime();
69
        final Runtime rt = Runtime.getRuntime();
68
        final String stats = "<i>" + TM.tr("memory") + " :</i> " + formatBytes(rt.freeMemory()) + " / " + formatBytes(rt.totalMemory()) + " ; " + TM.tr("processors", rt.availableProcessors());
70
        final String stats = "<i>" + tm.translate("memory") + " :</i> " + formatBytes(tm, rt.freeMemory()) + " / " + formatBytes(tm, rt.totalMemory()) + " ; "
-
 
71
                + tm.translate("processors", rt.availableProcessors());
69
        final String lafDesc = lookAndFeel == null ? TM.tr("no.laf") : getLink(lookAndFeel.getName(), lafURI, html) + ", " + lookAndFeel.getDescription();
72
        final String lafDesc = lookAndFeel == null ? tm.translate("no.laf") : getLink(lookAndFeel.getName(), lafURI, html) + ", " + lookAndFeel.getDescription();
70
 
73
 
71
        final String p = TM.tr("javaVersion", version, getLink(getProperty("java.vendor"), vendorURI, html)) + " ; " + getLink(TM.tr("javaHome"), new File(getProperty("java.home")).toURI(), html)
74
        final String p = tm.translate("javaVersion", version, getLink(getProperty("java.vendor"), vendorURI, html)) + " ; "
72
                + lineBreak + stats + lineBreak + lafDesc;
75
                + getLink(tm.translate("javaHome"), new File(getProperty("java.home")).toURI(), html) + lineBreak + stats + lineBreak + lafDesc;
73
 
76
 
74
        res.put(Info.JAVA, p);
77
        res.put(Info.JAVA, p);
75
 
78
 
76
        // * Windows XP 5.1 (x86)
79
        // * Windows XP 5.1 (x86)
77
        res.put(Info.OS, "<b>" + getProperty("os.name") + "</b> " + getProperty("os.version") + " (" + getProperty("os.arch") + ")");
80
        res.put(Info.OS, "<b>" + getProperty("os.name") + "</b> " + getProperty("os.version") + " (" + getProperty("os.arch") + ")");
78
 
81
 
79
        // * Sylvain ; C:\Documents and Settings\Sylvain ; D:\workspace\CTech
82
        // * Sylvain ; C:\Documents and Settings\Sylvain ; D:\workspace\CTech
80
        res.put(Info.USER, getProperty("user.name") + " ; " + getLink(TM.tr("home.dir"), new File(getProperty("user.home")).toURI(), html) + " ; "
83
        res.put(Info.USER, getProperty("user.name") + " ; " + getLink(tm.translate("home.dir"), new File(getProperty("user.home")).toURI(), html) + " ; "
81
                + getLink(TM.tr("cwd"), new File(getProperty("user.dir")).toURI(), html));
84
                + getLink(tm.translate("cwd"), new File(getProperty("user.dir")).toURI(), html));
82
 
85
 
83
        // * eth0 192.168.28.52/24, état: inactif, nom complet: ""
86
        // * eth0 192.168.28.52/24, état: inactif, nom complet: ""
84
        final List<String> ifs = new ArrayList<String>();
87
        final List<String> ifs = new ArrayList<String>();
85
        try {
88
        try {
86
            final Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
89
            final Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
Line 94... Line 97...
94
                        @Override
97
                        @Override
95
                        public String transformChecked(InterfaceAddress input) {
98
                        public String transformChecked(InterfaceAddress input) {
96
                            return "<b>" + input.getAddress().getHostAddress() + "</b>" + "/" + input.getNetworkPrefixLength();
99
                            return "<b>" + input.getAddress().getHostAddress() + "</b>" + "/" + input.getNetworkPrefixLength();
97
                        }
100
                        }
98
                    }));
101
                    }));
99
                    sb.append(" ; <i>" + TM.tr("interfaceState") + " :</i> " + TM.tr(ni.isUp() ? "interfaceStateUp" : "interfaceStateDown"));
102
                    sb.append(" ; <i>" + tm.translate("interfaceState") + " :</i> " + tm.translate(ni.isUp() ? "interfaceStateUp" : "interfaceStateDown"));
100
                    sb.append(lineBreak);
103
                    sb.append(lineBreak);
101
                    sb.append(" <i>" + TM.tr("interfaceFullName") + " :</i> " + ni.getDisplayName());
104
                    sb.append(" <i>" + tm.translate("interfaceFullName") + " :</i> " + ni.getDisplayName());
102
 
105
 
103
                    sb.append(lineBreak);
106
                    sb.append(lineBreak);
104
                    sb.append(" <i>" + TM.tr("hardwareAddress") + " :</i> ");
107
                    sb.append(" <i>" + tm.translate("hardwareAddress") + " :</i> ");
105
                    final Formatter fmt = new Formatter(sb);
108
                    final Formatter fmt = new Formatter(sb);
106
                    final byte[] mac = ni.getHardwareAddress();
109
                    final byte[] mac = ni.getHardwareAddress();
107
                    for (int i = 0; i < mac.length; i++) {
110
                    for (int i = 0; i < mac.length; i++) {
108
                        fmt.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : "");
111
                        fmt.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : "");
109
                    }
112
                    }
Line 132... Line 135...
132
        } else {
135
        } else {
133
            return "[" + name + "](" + uri.toString() + ")";
136
            return "[" + name + "](" + uri.toString() + ")";
134
        }
137
        }
135
    }
138
    }
136
 
139
 
137
    private static String formatBytes(long b) {
140
    private static String formatBytes(final TM tm, final long b) {
138
        return TM.tr("megabytes", b / 1024 / 1024);
141
        return tm.translate("megabytes", b / 1024 / 1024);
139
    }
142
    }
140
}
143
}