JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, ypos, 9), colSpec, orientation));
cmp = (JComponent) cmp.getComponent(0);
cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));
ypos = 7; // we hardcode here (promise last time)
builder.addLabel(Messages.getString("NetworkTab.0"), FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(new Object[] {
"ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "en_uk", "fi", "fr",
"de", "el", "iw", "is", "it", "ja", "ko", "no", "pl", "pt", "br",
"ro", "ru", "sl", "es", "sv", "tr"}, new Object[] {
"Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)",
"Chinese (Traditional)", "Czech", "Danish", "Dutch", "English (US)", "English (UK)",
"Finnish", "French", "German", "Greek", "Hebrew", "Icelandic", "Italian",
"Japanese", "Korean", "Norwegian", "Polish", "Portuguese",
"Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian",
"Spanish", "Swedish", "Turkish"});
langs = new JComboBox(kcbm);
langs.setEditable(false);
String defaultLang;
if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
defaultLang = configuration.getLanguage();
} else {
defaultLang = Locale.getDefault().getLanguage();
}
if (defaultLang == null) {
defaultLang = "en";
}
kcbm.setSelectedKey(defaultLang);
if (langs.getSelectedIndex() == -1) {
langs.setSelectedIndex(0);
}
langs.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setLanguage((String) kcbm.getSelectedKey());
}
}
});
builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, ypos, 7), colSpec, orientation));
ypos += 2;
if (!configuration.isHideAdvancedOptions()) {
serverName = new JTextField(configuration.getServerName());
serverName.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setServerName(serverName.getText());
}
});
builder.addLabel(Messages.getString("NetworkTab.71"), FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
builder.add(serverName, FormLayoutUtil.flip(cc.xyw(3, ypos, 3), colSpec, orientation));
appendProfileName = new JCheckBox(Messages.getString("NetworkTab.72"), configuration.isAppendProfileName());
appendProfileName.setToolTipText(Messages.getString("NetworkTab.73"));
appendProfileName.setContentAreaFilled(false);
appendProfileName.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setAppendProfileName((e.getStateChange() == ItemEvent.SELECTED));
}
});
builder.add(appendProfileName, FormLayoutUtil.flip(cc.xy(7, ypos), colSpec, orientation));
ypos += 2;
}
builder.add(smcheckBox, FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
if (Platform.isWindows()) {
autoStart = new JCheckBox(Messages.getString("NetworkTab.57"), configuration.isAutoStart());
autoStart.setContentAreaFilled(false);
autoStart.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setAutoStart((e.getStateChange() == ItemEvent.SELECTED));
}
});
builder.add(autoStart, FormLayoutUtil.flip(cc.xyw(3, ypos, 7), colSpec, orientation));
}
ypos += 2;
if (!configuration.isHideAdvancedOptions()) {
CustomJButton service = new CustomJButton(Messages.getString("NetworkTab.4"));
service.setToolTipText(Messages.getString("NetworkTab.63"));
service.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (PMS.get().installWin32Service()) {
LOGGER.info(Messages.getString("PMS.41"));
JOptionPane.showMessageDialog(
looksFrame,
Messages.getString("NetworkTab.11") +
Messages.getString("NetworkTab.12"),
Messages.getString("Dialog.Information"),
JOptionPane.INFORMATION_MESSAGE
);
} else {
JOptionPane.showMessageDialog(
looksFrame,
Messages.getString("NetworkTab.14"),
Messages.getString("Dialog.Error"),
JOptionPane.ERROR_MESSAGE
);
}
}
});
builder.add(service, FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
service.setEnabled(false);
}
CustomJButton serviceUninstall = new CustomJButton(Messages.getString("GeneralTab.2"));
serviceUninstall.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PMS.get().uninstallWin32Service();
LOGGER.info(Messages.getString("GeneralTab.3"));
JOptionPane.showMessageDialog(
looksFrame,
Messages.getString("GeneralTab.3"),
Messages.getString("Dialog.Information"),
JOptionPane.INFORMATION_MESSAGE
);
}
});
builder.add(serviceUninstall, FormLayoutUtil.flip(cc.xy(3, ypos), colSpec, orientation));
if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
serviceUninstall.setEnabled(false);
}
ypos += 2;
}
CustomJButton checkForUpdates = new CustomJButton(Messages.getString("NetworkTab.8"));
checkForUpdates.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
looksFrame.checkForUpdates(false);
}
});
builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9"), configuration.isAutoUpdate());
autoUpdateCheckBox.setContentAreaFilled(false);
autoUpdateCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED));
}
});
builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(3, ypos, 7), colSpec, orientation));
ypos += 2;
if (!Build.isUpdatable()) {
checkForUpdates.setEnabled(false);
autoUpdateCheckBox.setEnabled(false);
}
hideAdvancedOptions = new JCheckBox(Messages.getString("NetworkTab.61"), configuration.isHideAdvancedOptions());
hideAdvancedOptions.setContentAreaFilled(false);
hideAdvancedOptions.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
configuration.setHideAdvancedOptions(hideAdvancedOptions.isSelected());
}
});
builder.add(hideAdvancedOptions, FormLayoutUtil.flip(cc.xyw(1, ypos, 9), colSpec, orientation));
ypos += 2;
runWizardOnProgramStartup = new JCheckBox(Messages.getString("GeneralTab.9"), configuration.isRunWizard());
runWizardOnProgramStartup.setContentAreaFilled(false);
runWizardOnProgramStartup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
configuration.setRunWizard(runWizardOnProgramStartup.isSelected());
}
});
builder.add(runWizardOnProgramStartup, FormLayoutUtil.flip(cc.xyw(1, ypos, 9), colSpec, orientation));
ypos += 2;
if (!configuration.isHideAdvancedOptions()) {
singleInstance = new JCheckBox(Messages.getString("GeneralTab.10"), configuration.isRunSingleInstance());
singleInstance.setContentAreaFilled(false);
singleInstance.setToolTipText(Messages.getString("GeneralTab.11"));
singleInstance.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
configuration.setRunSingleInstance(singleInstance.isSelected());
}
});
builder.add(singleInstance, FormLayoutUtil.flip(cc.xyw(1, ypos, 9), colSpec, orientation));
ypos += 2;
}
ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getEnabledRenderersConfigurations();
ArrayList<Object> keyValues = new ArrayList<>();
ArrayList<Object> nameValues = new ArrayList<>();
keyValues.add("");
nameValues.add(Messages.getString("NetworkTab.37"));
if (allConfs != null) {
sortRendererConfiurationsByName(allConfs);
for (RendererConfiguration renderer : allConfs) {
if (renderer != null) {
keyValues.add(renderer.getRendererName());
nameValues.add(renderer.getRendererName());
}
}
}
final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel(
(Object[]) keyValues.toArray(new Object[keyValues.size()]),
(Object[]) nameValues.toArray(new Object[nameValues.size()]));
renderers = new JComboBox(renderersKcbm);
renderers.setEditable(false);
String defaultRenderer = configuration.getRendererDefault();
renderersKcbm.setSelectedKey(defaultRenderer);
if (renderers.getSelectedIndex() == -1) {
renderers.setSelectedIndex(0);
}
if (!configuration.isHideAdvancedOptions()) {
// Edit UMS configuration file manually
CustomJButton confEdit = new CustomJButton(Messages.getString("NetworkTab.51"));
confEdit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JPanel tPanel = new JPanel(new BorderLayout());
final File conf = new File(configuration.getProfilePath());
final JTextArea textArea = new JTextArea();
textArea.setFont(new Font("Courier", Font.PLAIN, 12));
JScrollPane scrollPane = new JScrollPane(textArea);
scrollPane.setPreferredSize(new java.awt.Dimension(900, 450));
try {
try (FileInputStream fis = new FileInputStream(conf); BufferedReader in = new BufferedReader(new InputStreamReader(fis))) {
String line;
StringBuilder sb = new StringBuilder();
while ((line = in.readLine()) != null) {
sb.append(line);
sb.append("\n");
}
textArea.setText(sb.toString());
}
} catch (IOException e1) {
return;
}
tPanel.add(scrollPane, BorderLayout.NORTH);
Object[] options = {Messages.getString("LooksFrame.9"), Messages.getString("NetworkTab.45")};
if (JOptionPane.showOptionDialog(looksFrame,
tPanel, Messages.getString("NetworkTab.51"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null, options, null) == JOptionPane.OK_OPTION) {
String text = textArea.getText();
try {
try (FileOutputStream fos = new FileOutputStream(conf)) {
fos.write(text.getBytes());
fos.flush();
}
configuration.reload();
} catch (Exception e1) {
JOptionPane.showMessageDialog(looksFrame, Messages.getString("NetworkTab.52") + e1.toString());
}
}
}
});
builder.add(confEdit, FormLayoutUtil.flip(cc.xy(1, ypos), colSpec, orientation));
ypos += 2;
host = new JTextField(configuration.getServerHostname());
host.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
configuration.setHostname(host.getText());
}
});
port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
port.setToolTipText(Messages.getString("NetworkTab.64"));
port.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
try {
String p = port.getText();
if (StringUtils.isEmpty(p)) {
p = "5001";
}
int ab = Integer.parseInt(p);
configuration.setServerPort(ab);
} catch (NumberFormatException nfe) {
LOGGER.debug("Could not parse port from \"" + port.getText() + "\"");
}
}
});
cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), FormLayoutUtil.flip(cc.xyw(1, ypos, 9), colSpec, orientation));
ypos += 2;
cmp = (JComponent) cmp.getComponent(0);
cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));
final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel();
networkinterfacesCBX = new JComboBox(networkInterfaces);
networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
networkinterfacesCBX.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
}
}
});
ip_filter = new JTextField(configuration.getIpFilter());