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

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

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
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.control.PersonLabel;
import org.openslx.dozmod.gui.control.table.ImageVersionTable;
import org.openslx.dozmod.gui.helper.GridPos;

@SuppressWarnings("serial")
public abstract class ImageDetailsWindowLayout extends JDialog {

	protected final JLabel txtTitle;
	protected final JTextArea txtDescription;

	protected final PersonLabel lblOwner;
	protected final JLabel lblCreateTime;
	protected final PersonLabel lblUpdater;
	protected final JLabel lblUpdateTime;

	protected final JComboBox<OperatingSystem> cboOperatingSystem;
	protected final JLabel lblVirtualizer;
	protected final JTextField txtTags;
	protected final JCheckBox btnIsTemplate;
	protected final JComboBox<ShareMode> cboShareMode;

	protected final JTextField txtId;
	protected final JTextField txtVersion;

	protected final JButton btnSaveChanges;
	protected final JButton btnClose;

	protected final ImageVersionTable versionTable;

	// TODO: Permissions, ...

	public ImageDetailsWindowLayout(Frame modalParent) {
		super(modalParent, "Platzhalter wärend das Fenster sich noch nicht gefüllt hat", ModalityType.APPLICATION_MODAL);
		setResizable(true);
		setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		setLayout(new BorderLayout());

		// helper for row index
		int row = 0;

		// use panel to put every info related widget in it
		// then we will set the panel in BorderLayout.CENTER
		JPanel infoPanel = new JPanel();
		infoPanel.setLayout(new GridBagLayout());
		infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		// -- name --
		txtTitle = new JLabel();
		txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2));
		infoPanel.add(txtTitle, GridPos.get(0,  row++, 2, 1, true, false));

		// description
		txtDescription = new JTextArea();
		infoPanel.add(new JLabel("Beschreibung"), GridPos.get(0, row, false, false));
		infoPanel.add(new JScrollPane(txtDescription), GridPos.get(1, row++, true, false));

		// owner
		lblOwner = new PersonLabel();
		infoPanel.add(new JLabel("Besitzer"), GridPos.get(0,  row, false, false));
		infoPanel.add(lblOwner, GridPos.get(1,  row++, true, false));
		// creation time
		lblCreateTime = new JLabel();
		infoPanel.add(new JLabel("Erstellt"), GridPos.get(0,  row, false, false));
		infoPanel.add(lblCreateTime, GridPos.get(1,  row++, true, false));
		// last updater
		lblUpdater = new PersonLabel();
		infoPanel.add(new JLabel("Geändert durch"), GridPos.get(0,  row, false, false));
		infoPanel.add(lblUpdater, GridPos.get(1,  row++, true, false));
		// last updated
		lblUpdateTime = new JLabel();
		infoPanel.add(new JLabel("Änderungszeitpunkt"), GridPos.get(0,  row, false, false));
		infoPanel.add(lblUpdateTime, GridPos.get(1,  row++, true, false));
		// os
		cboOperatingSystem = new JComboBox<>();
		cboOperatingSystem.setEditable(false);
		cboOperatingSystem.setRenderer(new DefaultListCellRenderer() {
			@Override
			public Component getListCellRendererComponent(JList<?> list, Object value, int index,
					boolean isSelected, boolean cellHasFocus) {
				if (value instanceof OperatingSystem) {
					OperatingSystem org = (OperatingSystem) value;
					setText(org.getOsName());
				}
				return this;
			}
		});
		infoPanel.add(new JLabel("Betriebssystem"), GridPos.get(0,  row, false, false));
		infoPanel.add(cboOperatingSystem, GridPos.get(1,  row++, true, false));
		// virtualizer
		lblVirtualizer = new JLabel();
		infoPanel.add(new JLabel("Virtualizer"), GridPos.get(0,  row, false, false));
		infoPanel.add(lblVirtualizer, GridPos.get(1,  row++, true, false));
		// tags
		txtTags = new JTextField();
		infoPanel.add(new JLabel("Tags"), GridPos.get(0,  row, false, false));
		infoPanel.add(txtTags, GridPos.get(1,  row++, true, false));
		// share mode
		cboShareMode = new JComboBox<ShareMode>();
		infoPanel.add(new JLabel("Freigabemodus"), GridPos.get(0,  row, false, false));
		infoPanel.add(cboShareMode, GridPos.get(1,  row++, true, false));
		// template
		btnIsTemplate = new JCheckBox();
		infoPanel.add(new JLabel("Vorlage"), GridPos.get(0,  row, false, false));
		infoPanel.add(btnIsTemplate, GridPos.get(1,  row++, true, false));

		txtVersion = new JTextField();
		infoPanel.add(new JLabel("Version"), GridPos.get(0,  row, false, false));
		infoPanel.add(txtVersion, GridPos.get(1,  row++, true, false));

		txtId = new JTextField();
		infoPanel.add(new JLabel("ID"), GridPos.get(0,  row, false, false));
		infoPanel.add(txtId, GridPos.get(1,  row++, true, false));

		infoPanel.setPreferredSize(new Dimension(500, 400));

		// finally add the infoPanel itself to the main view
		add(infoPanel, BorderLayout.CENTER);
		// button panel on the bottom
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
		btnSaveChanges = new JButton("Speichern");
		btnClose = new JButton("Schließen");
		buttonPanel.add(btnSaveChanges);
		buttonPanel.add(Box.createGlue());
		buttonPanel.add(btnClose);
		add(buttonPanel, BorderLayout.SOUTH);

		JPanel versionTablePanel = new JPanel();
		versionTablePanel.setLayout(new BorderLayout());
		JLabel lblVersion = new JLabel("Image Versionen");
		lblVersion.setFont(lblVersion.getFont().deriveFont(Font.BOLD));
		versionTablePanel.add(lblVersion, BorderLayout.NORTH);
		versionTable = new ImageVersionTable();
		versionTablePanel.setPreferredSize(new Dimension(400, 200));
		versionTablePanel.add(new JScrollPane(versionTable), BorderLayout.CENTER);
		add(versionTablePanel, BorderLayout.EAST);
	}
}