Line 28... |
Line 28... |
28 |
import org.openconcerto.utils.Tuple2;
|
28 |
import org.openconcerto.utils.Tuple2;
|
29 |
import org.openconcerto.utils.cc.IFactory;
|
29 |
import org.openconcerto.utils.cc.IFactory;
|
30 |
import org.openconcerto.utils.i18n.I18nUtils;
|
30 |
import org.openconcerto.utils.i18n.I18nUtils;
|
31 |
|
31 |
|
32 |
import java.util.HashMap;
|
32 |
import java.util.HashMap;
|
- |
|
33 |
import java.util.Locale;
|
33 |
import java.util.Map;
|
34 |
import java.util.Map;
|
34 |
|
35 |
|
35 |
import javax.swing.JLabel;
|
36 |
import javax.swing.JLabel;
|
36 |
import javax.swing.JPanel;
|
37 |
import javax.swing.JPanel;
|
37 |
|
38 |
|
Line 48... |
Line 49... |
48 |
}
|
49 |
}
|
49 |
|
50 |
|
50 |
public static final IFactory<String> FACTORY = new IFactory<String>() {
|
51 |
public static final IFactory<String> FACTORY = new IFactory<String>() {
|
51 |
@Override
|
52 |
@Override
|
52 |
public String createChecked() {
|
53 |
public String createChecked() {
|
53 |
return get(false).toString();
|
54 |
return get(false, Locale.ENGLISH).toString();
|
54 |
}
|
55 |
}
|
55 |
};
|
56 |
};
|
56 |
|
57 |
|
57 |
public static Map<Info, String> get(final boolean html) {
|
58 |
public static Map<Info, String> get(final boolean html, final Locale locale) {
|
58 |
final Map<Info, String> res = new HashMap<Info, String>();
|
59 |
final Map<Info, String> res = new HashMap<Info, String>();
|
59 |
|
60 |
|
60 |
final UserRightsManager userRightsManager = UserRightsManager.getInstance();
|
61 |
final UserRightsManager userRightsManager = UserRightsManager.getInstance();
|
61 |
res.put(Info.RIGHTS, org.openconcerto.utils.i18n.TM.tr(I18nUtils.getYesNoKey(userRightsManager != null)));
|
62 |
res.put(Info.RIGHTS, org.openconcerto.utils.i18n.TM.tr(locale, I18nUtils.getYesNoKey(userRightsManager != null)));
|
62 |
final User user = UserManager.getUser();
|
63 |
final User user = UserManager.getUser();
|
63 |
if (user != null) {
|
64 |
if (user != null) {
|
64 |
final UserRights userRights = UserRightsManager.getCurrentUserRights();
|
65 |
final UserRights userRights = UserRightsManager.getCurrentUserRights();
|
65 |
res.put(Info.USER, user.toString() + (userRights.isSuperUser() ? " (superuser)" : ""));
|
66 |
res.put(Info.USER, user.toString() + (userRights.isSuperUser() ? " (superuser)" : ""));
|
66 |
}
|
67 |
}
|
Line 76... |
Line 77... |
76 |
productInfo = ProductInfo.getInstance();
|
77 |
productInfo = ProductInfo.getInstance();
|
77 |
}
|
78 |
}
|
78 |
|
79 |
|
79 |
final String name, version;
|
80 |
final String name, version;
|
80 |
if (productInfo == null) {
|
81 |
if (productInfo == null) {
|
81 |
name = TM.tr("infoPanel.noAppName");
|
82 |
name = TM.tr(locale, "infoPanel.noAppName");
|
82 |
version = TM.tr("infoPanel.noVersion");
|
83 |
version = TM.tr(locale, "infoPanel.noVersion");
|
83 |
} else {
|
84 |
} else {
|
84 |
name = productInfo.getName();
|
85 |
name = productInfo.getName();
|
85 |
version = productInfo.getProperty(ProductInfo.VERSION, TM.tr("infoPanel.noVersion"));
|
86 |
version = productInfo.getProperty(ProductInfo.VERSION, TM.tr(locale, "infoPanel.noVersion"));
|
86 |
}
|
87 |
}
|
87 |
res.put(Info.APP_NAME, name);
|
88 |
res.put(Info.APP_NAME, name);
|
88 |
res.put(Info.APP_VERSION, version);
|
89 |
res.put(Info.APP_VERSION, version);
|
89 |
if (propsConf != null && propsConf.isUsingSSH()) {
|
90 |
if (propsConf != null && propsConf.isUsingSSH()) {
|
90 |
final Tuple2<String, Integer> serverAddressAndPort = propsConf.parseServerAddressAndPort();
|
91 |
final Tuple2<String, Integer> serverAddressAndPort = propsConf.parseServerAddressAndPort();
|
91 |
res.put(Info.SECURE_LINK, "localhost:" + propsConf.getTunnelLocalPort() + " ⟷ (" + propsConf.getWanHostAndPort() + ") " + serverAddressAndPort.get0() + ":" + serverAddressAndPort.get1());
|
92 |
res.put(Info.SECURE_LINK, "localhost:" + propsConf.getTunnelLocalPort() + " ⟷ (" + propsConf.getWanHostAndPort() + ") " + serverAddressAndPort.get0() + ":" + serverAddressAndPort.get1());
|
92 |
}
|
93 |
}
|
93 |
if (conf != null)
|
94 |
if (conf != null)
|
94 |
res.put(Info.DB_URL, conf.getSystemRoot().getDataSource().getUrl());
|
95 |
res.put(Info.DB_URL, conf.getSystemRoot().getDataSource().getUrl());
|
95 |
if (conf != null) {
|
96 |
if (conf != null) {
|
96 |
final String logs = propsConf == null ? "" : " ; " + SystemInfo.getLink(TM.tr("infoPanel.logs"), propsConf.getLogDir().toURI(), html);
|
97 |
final String logs = propsConf == null ? "" : " ; " + SystemInfo.getLink(TM.tr(locale, "infoPanel.logs"), propsConf.getLogDir().toURI(), html);
|
97 |
final BaseDirs baseDirs = conf.getBaseDirs();
|
98 |
final BaseDirs baseDirs = conf.getBaseDirs();
|
98 |
String dirs = " ; " + SystemInfo.getLink(TM.tr("infoPanel.dataDir"), baseDirs.getAppDataFolder().toURI(), html);
|
99 |
String dirs = " ; " + SystemInfo.getLink(TM.tr(locale, "infoPanel.dataDir"), baseDirs.getAppDataFolder().toURI(), html);
|
99 |
dirs = dirs + " ; " + SystemInfo.getLink(TM.tr("infoPanel.prefsDir"), baseDirs.getPreferencesFolder().toURI(), html);
|
100 |
dirs = dirs + " ; " + SystemInfo.getLink(TM.tr(locale, "infoPanel.prefsDir"), baseDirs.getPreferencesFolder().toURI(), html);
|
100 |
dirs = dirs + " ; " + SystemInfo.getLink(TM.tr("infoPanel.cacheDir"), baseDirs.getCacheFolder().toURI(), html);
|
101 |
dirs = dirs + " ; " + SystemInfo.getLink(TM.tr(locale, "infoPanel.cacheDir"), baseDirs.getCacheFolder().toURI(), html);
|
101 |
res.put(Info.DIRS, SystemInfo.getLink(TM.tr("infoPanel.docs"), conf.getWD().toURI(), html) + logs + dirs);
|
102 |
res.put(Info.DIRS, SystemInfo.getLink(TM.tr(locale, "infoPanel.docs"), conf.getWD().toURI(), html) + logs + dirs);
|
102 |
}
|
103 |
}
|
103 |
|
104 |
|
104 |
return res;
|
105 |
return res;
|
105 |
}
|
106 |
}
|
106 |
|
107 |
|
107 |
private final FormLayouter l;
|
108 |
private final FormLayouter l;
|
108 |
|
109 |
|
109 |
public SoftwareInfoPanel() {
|
110 |
public SoftwareInfoPanel(final Locale locale) {
|
110 |
this.l = new FormLayouter(this, 1);
|
111 |
this.l = new FormLayouter(this, 1);
|
111 |
this.refresh();
|
112 |
this.refresh(locale);
|
112 |
}
|
113 |
}
|
113 |
|
114 |
|
114 |
public final void refresh() {
|
115 |
public final void refresh(final Locale locale) {
|
115 |
this.l.clear();
|
116 |
this.l.clear();
|
116 |
final Map<Info, String> infos = get(true);
|
117 |
final Map<Info, String> infos = get(true, locale);
|
117 |
this.l.add(TM.tr("infoPanel.rights"), new JLabel(infos.get(Info.RIGHTS)));
|
118 |
this.l.add(TM.tr(locale, "infoPanel.rights"), new JLabel(infos.get(Info.RIGHTS)));
|
118 |
final String user = infos.get(Info.USER);
|
119 |
final String user = infos.get(Info.USER);
|
119 |
if (user != null) {
|
120 |
if (user != null) {
|
120 |
this.l.add(org.openconcerto.utils.i18n.TM.tr("user"), new JLabel(user));
|
121 |
this.l.add(org.openconcerto.utils.i18n.TM.tr(locale, "user"), new JLabel(user));
|
121 |
}
|
122 |
}
|
122 |
|
123 |
|
123 |
this.l.add(TM.tr("infoPanel.appName"), new JLabel(infos.get(Info.APP_NAME)));
|
124 |
this.l.add(TM.tr(locale, "infoPanel.appName"), new JLabel(infos.get(Info.APP_NAME)));
|
124 |
this.l.add(TM.tr("infoPanel.version"), new JLabel(infos.get(Info.APP_VERSION)));
|
125 |
this.l.add(TM.tr(locale, "infoPanel.version"), new JLabel(infos.get(Info.APP_VERSION)));
|
125 |
final String secureLink = infos.get(Info.SECURE_LINK);
|
126 |
final String secureLink = infos.get(Info.SECURE_LINK);
|
126 |
if (secureLink != null) {
|
127 |
if (secureLink != null) {
|
127 |
this.l.add(TM.tr("infoPanel.secureLink"), new JLabel(secureLink));
|
128 |
this.l.add(TM.tr(locale, "infoPanel.secureLink"), new JLabel(secureLink));
|
128 |
}
|
129 |
}
|
129 |
final JLabel dbURL = new JLabel(infos.get(Info.DB_URL));
|
130 |
final JLabel dbURL = new JLabel(infos.get(Info.DB_URL));
|
130 |
if (dbURL != null)
|
131 |
if (dbURL != null)
|
131 |
this.l.add(TM.tr("infoPanel.dbURL"), dbURL);
|
132 |
this.l.add(TM.tr(locale, "infoPanel.dbURL"), dbURL);
|
132 |
final String dirs = infos.get(Info.DIRS);
|
133 |
final String dirs = infos.get(Info.DIRS);
|
133 |
if (dirs != null)
|
134 |
if (dirs != null)
|
134 |
this.l.add(TM.tr("infoPanel.dirs"), new HTMLTextField(dirs));
|
135 |
this.l.add(TM.tr(locale, "infoPanel.dirs"), new HTMLTextField(dirs));
|
- |
|
136 |
|
- |
|
137 |
this.l.getComponent().revalidate();
|
135 |
}
|
138 |
}
|
136 |
}
|
139 |
}
|