use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class WebAppServlet method processAbout.
private void processAbout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(UTF8_APPLICATION_JSON);
Profile profile = ProfileManager.getDefault().getActiveProfile();
ObjectMapper mapper = new ObjectMapper();
ObjectNode about = mapper.createObjectNode();
// NOI18N
about.put("additionalInfo", "TRADEMARKS AND LICENSE GO HERE");
// NOI18N
about.put("copyright", Version.getCopyright());
// NOI18N
about.put("title", WebServerPreferences.getDefault().getRailRoadName());
// NOI18N
about.put("imgAlt", Application.getApplicationName());
// assuming Application.getLogo() is relative to program:
// NOI18N
about.put("imgSrc", "/" + Application.getLogo());
// NOI18N
ArrayNode productInfo = about.putArray("productInfo");
productInfo.add(mapper.createObjectNode().put(NAME, Application.getApplicationName()).put(VALUE, Version.name()));
// NOI18N
productInfo.add(mapper.createObjectNode().put(NAME, Bundle.getMessage(request.getLocale(), "ActiveProfile")).put(VALUE, profile.getName()));
productInfo.add(mapper.createObjectNode().put(NAME, // NOI18N
"Java").put(VALUE, Bundle.getMessage(request.getLocale(), "JavaVersion", // NOI18N
System.getProperty("java.version", Bundle.getMessage(request.getLocale(), "Unknown")), // NOI18N
System.getProperty("java.vm.name", Bundle.getMessage(request.getLocale(), "Unknown")), // NOI18N
System.getProperty("java.vm.version", ""), // NOI18N
System.getProperty("java.vendor", Bundle.getMessage(request.getLocale(), "Unknown")))));
productInfo.add(mapper.createObjectNode().put(NAME, Bundle.getMessage(request.getLocale(), "Runtime")).put(VALUE, Bundle.getMessage(request.getLocale(), "RuntimeVersion", // NOI18N
System.getProperty("java.runtime.name", Bundle.getMessage(request.getLocale(), "Unknown")), // NOI18N
System.getProperty("java.runtime.version", ""))));
for (ConnectionConfig conn : InstanceManager.getDefault(ConnectionConfigManager.class)) {
if (!conn.getDisabled()) {
productInfo.add(mapper.createObjectNode().put(NAME, Bundle.getMessage(request.getLocale(), "ConnectionName", conn.getConnectionName())).put(VALUE, Bundle.getMessage(request.getLocale(), "ConnectionValue", conn.name(), conn.getInfo())));
}
}
response.getWriter().print(mapper.writeValueAsString(about));
}
use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class AboutDialog method infoPane.
protected JPanel infoPane() {
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.Y_AXIS));
log.debug("start labels");
// add listener for Com port updates
for (ConnectionConfig conn : InstanceManager.getDefault(ConnectionConfigManager.class)) {
if (!conn.getDisabled()) {
pane1.add(new ConnectionLabel(conn));
}
}
pane1.add(Box.createRigidArea(new Dimension(0, 15)));
pane1.add(new JLabel(Bundle.getMessage("DefaultVersionCredit", Version.name())));
pane1.add(new JLabel(Version.getCopyright()));
pane1.add(new JLabel(Bundle.getMessage("JavaVersionCredit", System.getProperty("java.version", "<unknown>"), Locale.getDefault().toString())));
pane1.setAlignmentX(Component.CENTER_ALIGNMENT);
return pane1;
}
use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class JsonUtilHttpService method getSystemConnections.
/**
*
* @param locale the client's Locale.
* @return the JSON systemConnections message.
*/
public ArrayNode getSystemConnections(Locale locale) {
ArrayNode root = mapper.createArrayNode();
ArrayList<String> prefixes = new ArrayList<>();
for (ConnectionConfig config : InstanceManager.getDefault(ConnectionConfigManager.class)) {
if (!config.getDisabled()) {
ObjectNode connection = mapper.createObjectNode().put(JSON.TYPE, JSON.SYSTEM_CONNECTION);
ObjectNode data = connection.putObject(JSON.DATA);
data.put(JSON.NAME, config.getConnectionName());
data.put(JSON.MFG, config.getManufacturer());
data.put(JSON.PREFIX, config.getAdapter().getSystemConnectionMemo().getSystemPrefix());
data.put(JSON.DESCRIPTION, Bundle.getMessage(locale, "ConnectionSucceeded", config.getConnectionName(), config.name(), config.getInfo()));
prefixes.add(config.getAdapter().getSystemConnectionMemo().getSystemPrefix());
root.add(connection);
}
}
InstanceManager.getList(SystemConnectionMemo.class).stream().map((instance) -> instance).filter((memo) -> (!memo.getDisabled() && !prefixes.contains(memo.getSystemPrefix()))).forEach((memo) -> {
ObjectNode connection = mapper.createObjectNode().put(JSON.TYPE, JSON.SYSTEM_CONNECTION);
ObjectNode data = connection.putObject(JSON.DATA);
data.put(JSON.NAME, memo.getUserName());
data.put(JSON.PREFIX, memo.getSystemPrefix());
data.putNull(JSON.MFG);
data.putNull(JSON.DESCRIPTION);
prefixes.add(memo.getSystemPrefix());
root.add(connection);
});
// Following is required because despite there being a SystemConnectionMemo
// for the default internal connection, it is not used for the default internal
// connection. This allows a client to map the server's internal objects.
String prefix = "I";
if (!prefixes.contains(prefix)) {
ObjectNode connection = mapper.createObjectNode().put(JSON.TYPE, JSON.SYSTEM_CONNECTION);
ObjectNode data = connection.putObject(JSON.DATA);
data.put(JSON.NAME, ConnectionNameFromSystemName.getConnectionName(prefix));
data.put(JSON.PREFIX, prefix);
data.putNull(JSON.MFG);
data.putNull(JSON.DESCRIPTION);
root.add(connection);
}
return root;
}
use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class AppsLaunchPane method statusPanel.
/**
* Fill in the logo and status panel
*
* @return Properly-filled out JPanel
*/
protected JPanel statusPanel() {
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.X_AXIS));
log.debug("Fetch main logo: {}", logo());
pane1.add(new JLabel(new ImageIcon(getToolkit().getImage(FileUtil.findURL(logo(), FileUtil.Location.INSTALLED)), "JMRI logo"), JLabel.LEFT));
// Some spacing between logo and status panel
pane1.add(Box.createRigidArea(new Dimension(15, 0)));
log.debug("start labels");
JPanel pane2 = new JPanel();
pane2.setLayout(new BoxLayout(pane2, BoxLayout.Y_AXIS));
pane2.add(new JLabel(line1()));
pane2.add(new JLabel(line2()));
pane2.add(new JLabel(line3()));
// add listerner for Com port updates
ConnectionStatus.instance().addPropertyChangeListener(this);
int i = 0;
for (ConnectionConfig conn : InstanceManager.getDefault(ConnectionConfigManager.class)) {
if (!conn.getDisabled()) {
connection[i] = conn;
i++;
}
if (i > 3) {
break;
}
}
buildLine4(pane2);
buildLine5(pane2);
buildLine6(pane2);
buildLine7(pane2);
pane2.add(new JLabel(line8()));
pane2.add(new JLabel(line9()));
pane1.add(pane2);
return pane1;
}
use of jmri.jmrix.ConnectionConfig in project JMRI by JMRI.
the class Apps method statusPanel.
/**
* Fill in the logo and status panel
*
* @return Properly-filled out JPanel
*/
protected JPanel statusPanel() {
JPanel pane1 = new JPanel();
pane1.setLayout(new BoxLayout(pane1, BoxLayout.X_AXIS));
log.debug("Fetch main logo: {}", logo());
pane1.add(new JLabel(new ImageIcon(getToolkit().getImage(FileUtil.findURL(logo(), FileUtil.Location.INSTALLED)), "JMRI logo"), JLabel.LEFT));
// Some spacing between logo and status panel
pane1.add(Box.createRigidArea(new Dimension(15, 0)));
log.debug("start labels");
JPanel pane2 = new JPanel();
pane2.setLayout(new BoxLayout(pane2, BoxLayout.Y_AXIS));
pane2.add(new JLabel(line1()));
pane2.add(new JLabel(line2()));
pane2.add(new JLabel(line3()));
if (ProfileManager.getDefault() != null && ProfileManager.getDefault().getActiveProfile() != null) {
pane2.add(new JLabel(Bundle.getMessage("ActiveProfile", ProfileManager.getDefault().getActiveProfile().getName())));
} else {
pane2.add(new JLabel(Bundle.getMessage("FailedProfile")));
}
// add listener for Com port updates
ConnectionStatus.instance().addPropertyChangeListener(this);
int i = 0;
for (ConnectionConfig conn : InstanceManager.getDefault(ConnectionConfigManager.class)) {
if (!conn.getDisabled()) {
connection[i] = conn;
i++;
}
if (i > 3) {
break;
}
}
buildLine4(pane2);
buildLine5(pane2);
buildLine6(pane2);
buildLine7(pane2);
pane2.add(new JLabel(line8()));
pane2.add(new JLabel(line9()));
pane1.add(pane2);
return pane1;
}
Aggregations