summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageTypePageLayout.java
blob: 7c1789408e90682dc7e409106e884b3d4c5ca9fa (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
package org.openslx.dozmod.gui.wizard.layout;

import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.WizardPage;

import java.awt.event.MouseEvent;

import javax.swing.*;
import javax.swing.event.MouseInputAdapter;

public abstract class ImageTypePageLayout extends WizardPage {

	/**
	 * Version for serialization.
	 */
	private static final long serialVersionUID = 2548125409461846482L;

	protected final JTextArea txtInfoText;
	protected final JRadioButton rbtnNewVmImage;
	protected final JRadioButton rbtnNewDockerImage;
	protected final ButtonGroup btgrpImageTyp;

	/**
	 * Page to choose between new VM-Image or Docker Image
	 */
	public ImageTypePageLayout(Wizard wizard) {

		super(wizard, I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.WizardPage.title"));
		setDescription(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.WizardPage.description"));


		// #####################################
		// Create the Components
		txtInfoText = new JTextArea();
		txtInfoText.setBorder(BorderFactory.createTitledBorder(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.newVmInformation.border")));
		txtInfoText.setLineWrap(true);
		txtInfoText.setWrapStyleWord(true);
		txtInfoText.setEditable(false);
		txtInfoText.setFocusable(false);
		txtInfoText.setOpaque(false);
		txtInfoText.setText(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.newVmInformation.text"));

		QLabel lblVmImage = new QLabel(Gui.getScaledIconResource("/img/virtualization.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.description"), 48, this));

		lblVmImage.addMouseListener(new MouseInputAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				rbtnNewVmImage.doClick();
			}
		});
		QLabel lblDockerImage = new QLabel(Gui.getScaledIconResource("/img/docker-icon.png",
				I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.description"), 48, this));
		lblDockerImage.addMouseListener(new MouseInputAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				rbtnNewDockerImage.doClick();
			}
		});
		rbtnNewVmImage = new JRadioButton(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.button.newVM"));
		rbtnNewDockerImage = new JRadioButton(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.button.newDocker"));

		// center the radiobuttion in the gridbag cell
		rbtnNewVmImage.setHorizontalAlignment(SwingConstants.CENTER);
		rbtnNewDockerImage.setHorizontalAlignment(SwingConstants.CENTER);

		btgrpImageTyp = new ButtonGroup();
		btgrpImageTyp.add(rbtnNewVmImage);
		btgrpImageTyp.add(rbtnNewDockerImage);

		// #####################################
		// Create the Layout
		GridManager grid = new GridManager(this, 2, false);
		grid.add(txtInfoText, 2).fill(true, false).expand(true, false);
		grid.add(Box.createVerticalGlue(), 2).expand(true, true);

		grid.add(lblVmImage).fill(true, true).expand(true, true);
		grid.add(lblDockerImage).fill(true, true).expand(true, true);
		grid.nextRow();

		grid.add(rbtnNewVmImage).fill(true, false).expand(true, true);
		grid.add(rbtnNewDockerImage).fill(true, false).expand(true, false);

		grid.nextRow();
		grid.finish(true);
	}
}