package org.openslx.dozmod.gui.window.layout;
import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.Window;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.DefaultBoundedRangeModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import org.openslx.dozmod.Branding;
import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.WordWrapLabel;
import org.openslx.dozmod.gui.helper.GridManager;
@SuppressWarnings("serial")
public class ConfigWindowLayout extends JDialog {
private static String title = Branding.getApplicationName() + " - Konfiguration";
protected final JRadioButton btnProxyNone;
protected final JRadioButton btnProxyAuto;
protected final JRadioButton btnProxySocks = null;
protected final JRadioButton btnProxyHttp = null;
protected final JCheckBox chkSendMeMail;
protected final QLabel lblYourAddress;
protected final JSlider sldFontSize;
protected final JSlider sldConnections;
protected ButtonGroup btnGroupLookAndFeel = null;
protected final JButton btnSave;
protected final JButton btnClose;
public ConfigWindowLayout(Window modalParent) {
super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL
: ModalityType.MODELESS);
// regular layout as a helper for the whole page
getContentPane().setLayout(new BorderLayout());
Insets headingInset = new Insets(16, 12, 3, 3);
// Panel to add everything into, needed for the border.
JPanel contentPanel = new JPanel();
getContentPane().add(contentPanel, BorderLayout.CENTER);
GridManager grid = new GridManager(contentPanel, 1, false, new Insets(4, 3, 1, 3));
// mail config
grid.add(new WordWrapLabel("E-Mail-Benachrichtigungen", true, false))
.insets(headingInset)
.expand(true, false)
.fill(true, false);
chkSendMeMail = new JCheckBox("Über VM- und Veranstaltungsänderungen per E-Mail informiert werden");
grid.add(chkSendMeMail).fill(true, false).expand(true, false);
grid.add(
new WordWrapLabel("Für diese Option muss der Server"
+ " für den Mailversand konfiguriert sein.", false, true))
.expand(true, false)
.fill(true, false);
lblYourAddress = new QLabel();
grid.add(lblYourAddress).fill(true, false).expand(true, false);
// proxy config
grid.add(new WordWrapLabel("Proxyserver", true, false))
.insets(headingInset)
.fill(true, false)
.expand(true, false);
JPanel radioGroupPanel = new JPanel();
radioGroupPanel.setLayout(new BoxLayout(radioGroupPanel, BoxLayout.LINE_AXIS));
// radio buttons
ButtonGroup radioGroup = new ButtonGroup();
btnProxyNone = new JRadioButton("Keinen Proxy verwenden");
btnProxyAuto = new JRadioButton("Automatisch nach Proxy suchen");
radioGroup.add(btnProxyNone);
radioGroup.add(btnProxyAuto);
radioGroupPanel.add(btnProxyNone);
radioGroupPanel.add(btnProxyAuto);
grid.add(radioGroupPanel).expand(true, false).fill(true, false);
// font config
grid.add(new WordWrapLabel("Schriftgröße (%)", true, false))
.insets(headingInset)
.fill(true, false)
.expand(true, false);
grid.add(
new WordWrapLabel("Diese Funktion ist experimentell. Es kann zu Anzeigefehlern kommen.",
false, true))
.expand(true, false)
.fill(true, false);
UIManager.put("Slider.paintValue", false);
sldFontSize = new JSlider(JSlider.HORIZONTAL);
sldFontSize.setModel(new DefaultBoundedRangeModel(100, 0, Config.FONT_SCALING_MIN,
Config.FONT_SCALING_MAX));
sldFontSize.setMinorTickSpacing(5);
sldFontSize.setMajorTickSpacing(25);
sldFontSize.setSnapToTicks(true);
sldFontSize.setPaintTicks(true);
sldFontSize.setPaintLabels(true);
grid.add(sldFontSize).fill(true, false).expand(true, false);
// look and feel
grid.add(new WordWrapLabel("LookAndFeel", true, false))
.insets(headingInset)
.fill(true, false)
.expand(true, false);
grid.add(
new WordWrapLabel("Hier können Sie die Darstellung der Oberfläche zwischen unterschiedlichen"
+ " 'LookAndFeels' umstellen.",
false, true))
.fill(true, false)
.expand(true, false);
JPanel lafGroupPanel = new JPanel();
lafGroupPanel.setLayout(new BoxLayout(lafGroupPanel, BoxLayout.LINE_AXIS));
btnGroupLookAndFeel = new ButtonGroup();
for (LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
JRadioButton btn = new JRadioButton(laf.getName());
btn.setToolTipText(laf.getClassName());
btnGroupLookAndFeel.add(btn);
lafGroupPanel.add(btn);
}
grid.add(lafGroupPanel).expand(true, false).fill(true, false);
// Concurrent Connections
grid.add(new WordWrapLabel("Verbindungen pro Transfer", true, false))
.insets(headingInset)
.fill(true, false)
.expand(true, false);
grid.add(
new WordWrapLabel("Im Normalfall werden beste Ergebnisse erzielt,"
+ " wenn die Einstellung auf 1 belassen wird. Falls die Übertragungsgeschwindigkeit"
+ " ihre Netzwerkanbindung nicht auslastet, probieren Sie den nächsthöheren"
+ " Wert. Zu hohe Werte können einen negativen Effekt auf die"
+ " Übertragungsgeschwindigkeit haben, und belasten den Satellitenserver stärker.",
false, true))
.fill(true, false)
.expand(true, false);
sldConnections = new JSlider(JSlider.HORIZONTAL);
sldConnections.setModel(new DefaultBoundedRangeModel(1, 0, 1, 4));
sldConnections.setMajorTickSpacing(1);
sldConnections.setPaintTicks(true);
sldConnections.setPaintLabels(true);
grid.add(sldConnections).expand(true, false).fill(true, false);
// Finish
grid.finish(true);
// bottom button panel
JPanel buttonPanel = new JPanel();
btnClose = new JButton("Schließen");
btnSave = new JButton("Speichern");
buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.add(Box.createGlue());
buttonPanel.add(btnClose);
buttonPanel.add(btnSave);
getContentPane().add(buttonPanel, BorderLayout.PAGE_END);
setPreferredSize(Gui.getScaledDimension(500, 650));
}
}