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

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 org.openslx.dozmod.model.ContainerBuildContextMethod;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;

public class ContainerUploadPageLayout extends WizardPage {

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

	protected final JTextField txtImageName;
	protected final JButton btnBrowseForImage;
	protected final JTextField txtImageFile;
	protected final QLabel lblImageName;
	protected final JTextArea txtInfoText;

	protected final JTabbedPane tpInput;
	protected final JTextField txtGitRepo;

	protected final JTextField txtContainerImageFile;

	/**
	 * Constructor to define the Layout
	 */
	public ContainerUploadPageLayout(Wizard wizard) {

		super(wizard, I18n.PAGE_LAYOUT.getString("ContainerUploadPage.title"));
		setDescription(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.description"));
		GridManager grid = new GridManager(this, 3, false);

		JPanel p1 = new JPanel();
		p1.setVisible(true);
		GridManager g1 = new GridManager(p1, 3, true, new Insets(5, 0, 5, 0));
		QLabel imageFileCaption = new QLabel(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.DockerFile.label"));
		txtImageFile = new JTextField();
		txtImageFile.setEditable(false);
		btnBrowseForImage = new JButton(I18n.PAGE_LAYOUT.getString("ImageUpload.Button.browseForImage.text"));
		btnBrowseForImage.setMnemonic(KeyEvent.VK_B);
		g1.add(imageFileCaption);
		g1.add(txtImageFile).fill(true, false).expand(true, false);
		g1.add(btnBrowseForImage);
		g1.finish(false);

		JPanel p2 = new JPanel();
		p2.setVisible(false);
		GridManager g2 = new GridManager(p2, 2, true, new Insets(5, 0, 5, 0));
		QLabel lblGitRepo = new QLabel(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.GitRepository.label"));
		lblGitRepo.setToolTipText(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.GitRepository.toolTipText"));
		txtGitRepo = new JTextField();
		txtGitRepo.setToolTipText(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.GitRepository.toolTipText"));
		g2.add(lblGitRepo);
		g2.add(txtGitRepo).fill(true, false).expand(true, false);
		g2.finish(false);

		tpInput = new JTabbedPane();
		tpInput.addTab("Dockerfile", p1);
		tpInput.addTab("Git Repository", p2);
		tpInput.setSelectedIndex(ContainerBuildContextMethod.FILE.ordinal());

		grid.add(tpInput, 3).fill(true, false);

		// Start as with Dockerfile as input!
		tpInput.setSelectedIndex(0);

		lblImageName = new QLabel(I18n.PANEL.getString("ContainerPanel.Label.ImageName.text"));
		txtImageName = new JTextField();
		grid.add(lblImageName);
		grid.add(txtImageName, 2, 1).fill(true, false).expand(true, false);
		grid.nextRow();

		QLabel lblContainerImageFile = new QLabel(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ContainerImageFile.label"));
		lblContainerImageFile.setToolTipText(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ContainerImageFile.ToolTipText"));
		txtContainerImageFile = new JTextField();
		txtContainerImageFile.setEnabled(false);
		txtContainerImageFile.setToolTipText(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ContainerImageFile.ToolTipText")
		);
		grid.add(lblContainerImageFile);
		grid.add(txtContainerImageFile, 2).fill(true, false).expand(true, false);
		grid.nextRow();
		
		grid.add(Box.createVerticalGlue(), 3).expand(true, true);
		txtInfoText = new JTextArea();
		txtInfoText.setBorder(BorderFactory.createTitledBorder(
				I18n.PAGE_LAYOUT.getString("ContainerUploadPage.Infobox.label")));
		txtInfoText.setLineWrap(true);
		txtInfoText.setWrapStyleWord(true);
		txtInfoText.setEditable(false);
		txtInfoText.setFocusable(false);
		txtInfoText.setOpaque(false);
		txtInfoText.setText(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.Infobox.text"));

		grid.add(txtInfoText, 3).fill(true, false).expand(true, false);
		grid.nextRow();

		grid.finish(true);
	}

	protected ContainerBuildContextMethod getBuildContextMethod() {
		return ContainerBuildContextMethod.fromInt(tpInput.getSelectedIndex());
	}
}