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

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridBagLayout;

import javax.swing.*;
import javax.swing.border.TitledBorder;

import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.table.LectureTable;
import org.openslx.dozmod.gui.control.table.QScrollPane;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.window.LectureListWindow.FilterType;

public abstract class LectureListWindowLayout extends CompositePage {
	
	/**
	 * Version for serialization.
	 */
	private static final long serialVersionUID = 5844801627900076060L;

	private static final int ICON_SIZE_Y = 24;

	// buttons
	protected final JButton btnNewLecture;
	protected final JButton btnDeleteLecture;
	protected final JButton btnEditLecture;
	protected final JButton btnSwitchView;
	protected final JComboBox<FilterType> cboFilter;
	protected final QLabel lblVisibleLectureCount;
	protected final JCheckBox chkSearchInDescription;

	protected final JTextField txtSearch;

	protected final LectureTable tblLectures;

	public LectureListWindowLayout() {
		super(new GridBagLayout());
		setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

		GridManager grid = new GridManager(this, 1);

		// --------- info group with title and text -------------------------
		JPanel infoPanel = new JPanel(new BorderLayout());
		QLabel infoTitle = new QLabel(I18n.WINDOW_LAYOUT.getString("LectureList.Label.title.text"));
		infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD));
		QLabel infoText = new QLabel(I18n.WINDOW_LAYOUT.getString("LectureList.Label.info.text"));
		infoPanel.add(infoTitle, BorderLayout.NORTH);
		infoPanel.add(infoText, BorderLayout.CENTER);
		// ---------------- end group of title ------------------------------

		// ------------ panel for the table and filter -----------------------
		JPanel tablePanel = new JPanel();
		GridManager tableGrid = new GridManager(tablePanel, 1);

		// filterPanel with filter text field and filter combo
		JPanel filterPanel = new JPanel();
		filterPanel.setBorder(new TitledBorder(
				I18n.WINDOW_LAYOUT.getString("LectureList.TitledBorder.filterPanel.title")));
		filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.LINE_AXIS));
		txtSearch = new JTextField();
		cboFilter = new JComboBox<FilterType>();
		for (FilterType s : FilterType.values()) {
			cboFilter.addItem(s);
		}
		filterPanel.add(txtSearch);
		filterPanel.add(cboFilter);

		// search in description
		chkSearchInDescription = new JCheckBox(
				I18n.WINDOW_LAYOUT.getString("LectureList.CheckBox.searchInDescription.text"));
		filterPanel.add(chkSearchInDescription);

		// Panel for itemCount
		JPanel lectureCountPanel = new JPanel();
		lblVisibleLectureCount = new QLabel();
		lectureCountPanel.add(new JLabel(I18n.WINDOW_LAYOUT.getString("LectureList.Label.visibleLectureCount.text")));
		lectureCountPanel.add(lblVisibleLectureCount);
		filterPanel.add(lectureCountPanel);

		// the actual table
		tblLectures = new LectureTable();

		tableGrid.add(filterPanel).fill(true, false).expand(true, false);
		tableGrid.nextRow();
		QScrollPane jsp = new QScrollPane(tblLectures);

		jsp.setBackground(UIManager.getColor("Table.background"));
		tableGrid.add(jsp).fill(true, true).expand(true, true);
		tableGrid.nextRow();
		tableGrid.finish(false);
		// ---------- end for table group  -----------------------------

		// ---------- button panel --------------------------------------
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
		buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

		btnNewLecture = new JButton(I18n.WINDOW_LAYOUT.getString("LectureList.Button.newLecture.text"),
				Gui.getScaledIconResource("/img/new-lecture-icon.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.newLecture.description"),
				ICON_SIZE_Y, buttonPanel));
		btnEditLecture = new JButton(I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.text"),
				Gui.getScaledIconResource("/img/edit-icon.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.description"),
				ICON_SIZE_Y, buttonPanel));
		btnDeleteLecture = new JButton(I18n.WINDOW_LAYOUT.getString("LectureList.Button.deleteLecture.text"),
				Gui.getScaledIconResource("/img/delete-icon.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.deleteLecture.description"),
				ICON_SIZE_Y, buttonPanel));
		btnSwitchView = new JButton(I18n.WINDOW_LAYOUT.getString("LectureList.Button.switchView.text"),
				Gui.getScaledIconResource("/img/switch-icon.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.switchView.description"),
				ICON_SIZE_Y, buttonPanel));
		buttonPanel.add(btnNewLecture);
		buttonPanel.add(btnEditLecture);
		buttonPanel.add(Box.createHorizontalStrut(5));
		buttonPanel.add(btnDeleteLecture);
		buttonPanel.add(Box.createHorizontalGlue());
		buttonPanel.add(btnSwitchView);
		// ----------------- end group for table -------------------------

		grid.add(infoPanel).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(tablePanel).fill(true, true).expand(true, true);
		grid.nextRow();
		grid.add(buttonPanel).fill(true, false).expand(true, false);
		grid.nextRow();

		grid.finish(false);
	}

	protected void setLectureCountLabel(int i) {
		lblVisibleLectureCount.setText(Integer.toString(i));
	}

}