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

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

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

import org.apache.log4j.Logger;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.ImageListViewer;
import org.openslx.dozmod.gui.control.ImageListViewer.FilterType;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.helper.CompositePage;
import org.openslx.dozmod.gui.helper.GridManager;

@SuppressWarnings("serial")
public abstract class ImageListWindowLayout extends CompositePage {

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

	private static final int ICON_SIZE_Y = 24;
	private final ImageListWindowLayout me = this;
	protected final static String infoTextString = "Hier können Sie Virtuelle Maschinen hochladen, herunterladen, bearbeiten und löschen.";
	protected final static String infoTitleString = "Übersicht Virtuelle Maschinen";
	protected final static String newButtonLabel = "Neue VM";
	protected final static String newLectureButtonLabel = "Neue Veranstaltung";
	protected final static String editButtonLabel = "Bearbeiten";
	protected final static String downloadButtonLabel = "Download";
	protected final static String deleteButtonLabel = "Löschen";
	protected final static String switchViewButtonLabel = "Veranstaltungen zeigen";
	protected final static String showPublishedImagesLabel = "Öffentliche VMs"; 

	// --------------------------------------
	// search field, table and buttons
	protected final ImageListViewer ctlImageListViewer;
	protected final JButton btnNewVm;
	protected final JButton btnNewLecture;
	protected final JButton btnEditDetails;
	protected final JButton btnDownload;
	protected final JButton btnDelete;
	protected final JButton btnSwitchView;
	protected final JButton btnShowPublishedImages;

	public ImageListWindowLayout() {
		super(new BorderLayout());
		setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

		// --------------------------------------
		// Info panel on the top with a search box
		JPanel infoPanel = new JPanel(new BorderLayout());
		QLabel infoTitle = new QLabel(infoTitleString);
		infoTitle.setFont(infoTitle.getFont().deriveFont(Font.BOLD));
		QLabel infoText = new QLabel(infoTextString);
		infoPanel.add(infoTitle, BorderLayout.NORTH);
		infoPanel.add(infoText, BorderLayout.CENTER);

		ctlImageListViewer = new ImageListViewer(FilterType.USABLE);

		// --------------------------------------
		// the buttons at the bottom
		JPanel buttonPanel = new JPanel();
		buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
		buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
		btnNewVm = new JButton(newButtonLabel, Gui.getScaledIconResource("/img/new-vm-icon.png", "New VM",
				ICON_SIZE_Y, buttonPanel));
		btnEditDetails = new JButton(editButtonLabel, Gui.getScaledIconResource("/img/edit-icon.png",
				"Edit VM", ICON_SIZE_Y, buttonPanel));
		btnDelete = new JButton(deleteButtonLabel, Gui.getScaledIconResource("/img/delete-icon.png",
				"Delete VM", ICON_SIZE_Y, buttonPanel));
		btnDownload = new JButton(downloadButtonLabel, Gui.getScaledIconResource("/img/download-icon.png",
				"New VM", ICON_SIZE_Y, buttonPanel));
		btnNewLecture = new JButton(newLectureButtonLabel, Gui.getScaledIconResource("/img/new-lecture-icon.png",
				"New Lecture", ICON_SIZE_Y, buttonPanel));
		btnShowPublishedImages = new JButton(showPublishedImagesLabel, Gui.getScaledIconResource("/img/published-vm-icon.png",
				"Published Lectures", ICON_SIZE_Y, buttonPanel));
		btnShowPublishedImages.setVisible(false); // this gets enabled later when the API version can be queried
		btnSwitchView = new JButton(switchViewButtonLabel, Gui.getScaledIconResource("/img/switch-icon.png",
				"Switch", ICON_SIZE_Y, buttonPanel));
		buttonPanel.add(btnNewVm);
		buttonPanel.add(btnEditDetails);
		buttonPanel.add(btnDelete);
		buttonPanel.add(Box.createHorizontalStrut(5));
		buttonPanel.add(btnDownload);
		buttonPanel.add(Box.createHorizontalStrut(5));
		buttonPanel.add(btnNewLecture);
		buttonPanel.add(Box.createHorizontalStrut(5));
		buttonPanel.add(btnShowPublishedImages);
		buttonPanel.add(Box.createHorizontalGlue());
		buttonPanel.add(btnSwitchView);

		// put everything together
		GridManager grid = new GridManager(this, 1);
		grid.add(infoPanel).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(ctlImageListViewer).fill(true, true).expand(true, true);
		grid.nextRow();
		grid.add(buttonPanel).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.finish(false);
	}

}