summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java
blob: bf37dc425c763db819af2a42eee280f0cbbbc70f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
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));
	}

}