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

import java.awt.Dimension;
import java.awt.Window;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.table.UserTable;
import org.openslx.dozmod.gui.helper.GridManager;

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

	private static final Logger LOGGER = Logger.getLogger(UserListWindowLayout.class);

	protected final UserTable userTable;

	protected final JButton setButton;
	protected final JButton cancelButton;
	protected final JTextField searchUserField;

	private static String title = "Benutzerliste";

	protected UserListWindowLayout(Window modalParent, String actionCaption) {
		super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL
				: ModalityType.MODELESS);

		GridManager grid = new GridManager(this, 1);

		// --------------- filter field --------------------------------------
		JPanel filterPanel = new JPanel();
		filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.LINE_AXIS));
		filterPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
		filterPanel.add(new QLabel("Suchen: "));
		searchUserField = new JTextField();
		filterPanel.add(searchUserField);
		// --------------- end filter field --------------------------------

		// --------------- user table --------------------------------------
		JPanel listPane = new JPanel();
		listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
		listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		userTable = new UserTable();
		listPane.add(new JScrollPane(userTable));
		// --------------- end user table ------------------------------------

		// --------------- button panel --------------------------------------
		JPanel buttonPane = new JPanel();
		buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
		buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
		buttonPane.add(Box.createHorizontalGlue());
		cancelButton = new JButton("Schließen");
		buttonPane.add(cancelButton);
		buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
		setButton = new JButton(actionCaption);
		buttonPane.add(setButton);
		// --------------- end button panel ----------------------------------

		// pack it all
		grid.add(filterPanel).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(listPane).fill(true, true).expand(true, true);
		grid.nextRow();
		grid.add(buttonPane).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.finish(false);

		setPreferredSize(new Dimension(300, 350));
		pack();
	}
}