summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
blob: 1fca5e07f6efac433642cc58b485d40ae1f5c2a6 (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
package org.openslx.dozmod.gui.window.layout;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.ShareMode;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.ComboBox;
import org.openslx.dozmod.gui.control.ComboBox.ComboBoxRenderer;
import org.openslx.dozmod.gui.control.PersonLabel;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.table.ImageVersionTable;
import org.openslx.dozmod.gui.control.table.QScrollPane;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.thrifthelper.Comparators;

@SuppressWarnings("serial")
public abstract class ImageDetailsWindowLayout extends JDialog {
	
	private static final int ICON_SIZE_Y = 24;

	protected final JTextField txtTitle;
	protected final JTextArea txtDescription;

	protected QLabel lblError;
	protected final PersonLabel lblOwner;
	protected final JButton btnChangeOwner;
	protected final QLabel lblCreateTime;
	protected final PersonLabel lblUpdater;
	protected final QLabel lblUpdateTime;

	protected final ComboBox<OperatingSystem> cboOperatingSystem;
	protected final QLabel lblVirtualizer;
	protected final JTextField txtTags;
	protected final JCheckBox chkIsTemplate;
	protected final JComboBox<ShareMode> cboShareMode;

	protected final JTextField txtId;
	protected final JTextField txtVersion;

	protected final JButton btnPermissions;

	protected final JButton btnSaveChanges;
	protected final JButton btnUpdateImage;
	protected final JButton btnClose;

	protected final JButton btnShowLinkingLectures;
	protected final QLabel lblLinkedLectureCount;

	protected final ImageVersionTable tblVersions;
	protected final QScrollPane scpVersions;

	public ImageDetailsWindowLayout(Frame modalParent) {
		super(modalParent, "<init>", ModalityType.APPLICATION_MODAL);
		setResizable(true);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

		// create left panel for info and buttons and right panel for the table and add
		// them to split pane

		// use panel to put every info related widget in it
		// then we we'll set the panel with BorderLayout.CENTER
		JPanel infoPanel = new JPanel();
		GridManager grid = new GridManager(infoPanel, 3, true, new Insets(2, 2, 2, 2));
		infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		// -- name --
		txtTitle = new JTextField();
		txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2));
		grid.add(txtTitle, 3).expand(true, false).fill(true, false);
		grid.nextRow();

		// description
		txtDescription = new JTextArea();
		txtDescription.setLineWrap(true);
		txtDescription.setWrapStyleWord(true);
		grid.add(new QLabel("Beschreibung")).anchor = GridBagConstraints.FIRST_LINE_START;
		JScrollPane jsp = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		jsp.setMinimumSize(Gui.getScaledDimension(0, 120));
		jsp.setPreferredSize(Gui.getScaledDimension(0, 120));
		grid.add(jsp, 2).expand(true, true).fill(true, true);
		grid.nextRow();

		// owner
		lblOwner = new PersonLabel();
		btnChangeOwner = new JButton("Ändern");
		grid.add(new QLabel("Besitzer"));
		grid.add(lblOwner).expand(true, false);
		grid.add(btnChangeOwner).fill(true, false);
		grid.nextRow();

		// creation time
		lblCreateTime = new QLabel();
		grid.add(new QLabel("Erstellt am"));
		grid.add(lblCreateTime, 2);
		grid.nextRow();

		// last updater
		lblUpdater = new PersonLabel();
		grid.add(new QLabel("Geändert durch"));
		grid.add(lblUpdater, 2);
		grid.nextRow();

		// last updated
		lblUpdateTime = new QLabel();
		grid.add(new QLabel("Geändert am"));
		grid.add(lblUpdateTime, 2);
		grid.nextRow();

		// os
		cboOperatingSystem = new ComboBox<OperatingSystem>(Comparators.operatingSystem,
				new ComboBoxRenderer<OperatingSystem>() {
					@Override
					public String renderItem(OperatingSystem item) {
						if (item == null)
							return null;
						return item.getOsName();
					}
				});
		cboOperatingSystem.setEditable(false);

		grid.add(new QLabel("Betriebssystem"));
		grid.add(cboOperatingSystem, 2).expand(true, false).fill(true, false);
		grid.nextRow();

		// tags
		txtTags = new JTextField();
		/* TODO
		grid.add(new QLabel("Tags"), GridPos.get(0, row, false, false));
		grid.add(txtTags, GridPos.get(1, row++, true, false));
		grid.nextRow();
		*/

		// share mode
		cboShareMode = new JComboBox<ShareMode>();
		grid.add(new QLabel("Freigabemodus"));
		grid.add(cboShareMode, 2).expand(true, false).fill(true, false);
		grid.nextRow();

		// template
		chkIsTemplate = new JCheckBox("Vorlage");
		grid.add(Box.createGlue());
		grid.add(chkIsTemplate, 2);
		grid.nextRow();

		// version
		txtVersion = new JTextField();
		grid.add(new QLabel("Versions-ID"));
		grid.add(txtVersion, 2).expand(true, false).fill(true, false);
		grid.nextRow();

		// id
		txtId = new JTextField();
		txtId.setEditable(false);
		grid.add(new QLabel("VM-ID"));
		grid.add(txtId, 2).expand(true, false).fill(true, false);
		grid.nextRow();

		// virtualizer
		lblVirtualizer = new QLabel();
		grid.add(new QLabel("Virtualisierer"));
		grid.add(lblVirtualizer, 2);
		grid.nextRow();

		btnPermissions = new JButton("Berechtigungen");
		grid.skip();
		grid.add(btnPermissions, 2);
		grid.nextRow();

		grid.add(new QLabel("Veranstaltungen"));
		lblLinkedLectureCount = new QLabel();
		grid.add(lblLinkedLectureCount).expand(true, false);
		btnShowLinkingLectures = new JButton("Anzeigen");
		grid.add(btnShowLinkingLectures).fill(true, false);
		grid.nextRow();
		grid.add(Box.createVerticalStrut(10), 3);
		grid.nextRow();
		grid.finish(true);

		infoPanel.setPreferredSize(Gui.getScaledDimension(500, 400));
		infoPanel.setMinimumSize(Gui.getScaledDimension(350, 300));

		// finally add the infoPanel itself to the left panel
		// button panel at the bottom
		JPanel buttonPanel = new JPanel();
		buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
		btnSaveChanges = new JButton("Speichern");
		btnClose = new JButton("Schließen");
		btnUpdateImage = new JButton("Neue VM-Version hochladen", Gui.getScaledIconResource("/img/upload-icon.png", "New VM", ICON_SIZE_Y, buttonPanel));
		buttonPanel.add(btnUpdateImage);
		buttonPanel.add(Box.createGlue());
		// user feedback slot
		lblError = new QLabel("");
		lblError.setForeground(Color.RED);
		buttonPanel.add(lblError);
		buttonPanel.add(Box.createGlue());
		buttonPanel.add(btnClose);
		buttonPanel.add(btnSaveChanges);

		// --- Version table on the right (EAST) side
		JPanel versionTablePanel = new JPanel();
		versionTablePanel.setLayout(new BorderLayout());
		versionTablePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		QLabel lblVersion = new QLabel("VM-Versionen");
		lblVersion.setFont(lblVersion.getFont().deriveFont(Font.BOLD));
		versionTablePanel.add(lblVersion, BorderLayout.PAGE_START);
		tblVersions = new ImageVersionTable();
		scpVersions = new QScrollPane(tblVersions);
		scpVersions.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		versionTablePanel.add(scpVersions, BorderLayout.CENTER);

		// add the tabel panel to the right panel
		JPanel rightPanel = new JPanel();
		rightPanel.setLayout(new BorderLayout());
		rightPanel.add(versionTablePanel, BorderLayout.CENTER);

		// add left and right panel to the split pane
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, infoPanel, rightPanel);
		splitPane.setResizeWeight(0.5);
		// add the split pane
		add(splitPane, BorderLayout.CENTER);
		add(buttonPanel, BorderLayout.PAGE_END);
	}
}