summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java
blob: fdcc69d1787043f5809a61b59d2d21c5ac162018 (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
package org.openslx.dozmod.gui.window.layout;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;

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 org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.thrift.Session;

@SuppressWarnings("serial")
public class ConfigWindowLayout extends JDialog {

	private static String title = "bwLehrpool Suite - Konfiguration";

	protected JRadioButton btnProxyNone;
	protected JRadioButton btnProxyAuto;
	protected JRadioButton btnProxySocks;
	protected JRadioButton btnProxyHttp;
	protected JCheckBox btnSendMeMail;
	protected JSlider btnFontSize;
	protected final JSlider sldConnections;

	protected JButton btnSave;
	protected JButton btnClose;

	protected ButtonGroup radioGroup;

	public ConfigWindowLayout(Frame modalParent) {
		super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL
				: ModalityType.MODELESS);

		// regular layout as a helper for the whole page
		setLayout(new BorderLayout());
		setMinimumSize(Gui.getScaledDimension(500, 300));

		// Panel to add everything into, needed for the border.
		JPanel contentPanel = new JPanel();
		getContentPane().add(contentPanel, BorderLayout.CENTER);

		// -- one panel per option for borders --
		// mail config panel
		JPanel mailPanel = new JPanel();
		mailPanel.setLayout(new BoxLayout(mailPanel, BoxLayout.PAGE_AXIS));
		mailPanel.setBorder(BorderFactory.createTitledBorder("eMail-Benachrichtigungen"));
		btnSendMeMail = new JCheckBox("Über Image- und Veranstaltungsänderungen per eMail informiert werden");
		mailPanel.add(btnSendMeMail);
		// TODO center the label horizontally 
		QLabel mailNotice = new QLabel(
				"Für diese Option muss der Server für den Mailversand konfiguriert sein.");
		mailPanel.add(mailNotice);
		QLabel mailNote = new QLabel("Ihre eMail-Adresse ist " + Session.getEMail());
		mailNote.setFont(mailNote.getFont().deriveFont(Font.ITALIC));
		mailPanel.add(mailNote);

		// proxy config panel
		JPanel proxyPanel = new JPanel();
		proxyPanel.setBorder(BorderFactory.createTitledBorder("Proxy"));
		GridManager proxyGrid = new GridManager(proxyPanel, 2);
		proxyGrid.skip(2).fill(true, false).expand(true, false);
		proxyGrid.nextRow();

		// radio button for proxy mode
		JPanel radioGroupPanel = new JPanel();
		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);
		proxyGrid.add(radioGroupPanel, 2);
		proxyGrid.nextRow();
		proxyGrid.finish(false);

		// font config panel
		JPanel fontPanel = new JPanel();
		fontPanel.setBorder(BorderFactory.createTitledBorder("Schriftgröße (%)"));
		GridManager fontGrid = new GridManager(fontPanel, 1);
		QLabel fontNote = new QLabel("Diese Funktion ist experimentell. Es kann zu Anzeigefehlern kommen.");
		fontNote.setFont(fontNote.getFont().deriveFont(Font.ITALIC));
		fontGrid.add(fontNote);
		fontGrid.nextRow();
		btnFontSize = new JSlider(JSlider.HORIZONTAL);
		btnFontSize.setModel(new DefaultBoundedRangeModel(100, Config.FONT_SCALING_STEP,
				Config.FONT_SCALING_MIN, Config.FONT_SCALING_MAX));
		btnFontSize.setMinorTickSpacing(Config.FONT_SCALING_STEP);
		btnFontSize.setMajorTickSpacing(25);
		btnFontSize.setSnapToTicks(true);
		btnFontSize.setPaintTicks(true);
		btnFontSize.setPaintLabels(true);
		fontGrid.add(btnFontSize).fill(true, false).expand(true, false);
		fontGrid.nextRow();
		fontGrid.finish(false);

		// Concurrent Connections
		sldConnections = new JSlider(JSlider.HORIZONTAL);
		sldConnections.setModel(new DefaultBoundedRangeModel(1, 1, 1, 4));
		sldConnections.setSnapToTicks(true);
		JPanel pnlConnections = new JPanel();
		pnlConnections.setLayout(new BoxLayout(pnlConnections, BoxLayout.PAGE_AXIS));
		pnlConnections.setBorder(BorderFactory.createTitledBorder("Verbindungen pro Transfer (DEBUG/TESTING)"));
		pnlConnections.add(new QLabel("Anzahl Verbindungen pro Up/Download. Empfohlene Einstellung: 1"));
		pnlConnections.add(sldConnections);

		// 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);
		
		// Start the grid stuff
		GridManager grid = new GridManager(contentPanel, 1);
		grid.add(mailPanel).fill(true, false).expand(false, false);
		grid.nextRow();
		grid.add(Box.createRigidArea(new Dimension(0, 10)));
		grid.nextRow();
		grid.add(proxyPanel).fill(true, false).expand(false, false);
		grid.nextRow();
		grid.add(Box.createRigidArea(new Dimension(0, 10)));
		grid.nextRow();
		grid.add(fontPanel).fill(true, false).expand(false, false);
		grid.nextRow();
		grid.add(Box.createRigidArea(new Dimension(0, 10)));
		grid.nextRow();
		grid.add(pnlConnections).fill(true, false).expand(false, false);
		grid.nextRow();
		grid.finish(false);

		getContentPane().add(buttonPanel, BorderLayout.PAGE_END);
		pack();
	}
}