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

import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.control.table.ContainerBindMountTable;
import org.openslx.dozmod.gui.control.table.QScrollPane;
import org.openslx.dozmod.gui.helper.GridManager;
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.*;

public class ContainerUploadPageLayout extends WizardPage {

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

	protected final JTextField txtContainerRun;
	protected final QLabel lblContainerRun;

	protected final JTabbedPane tpInput;
	protected final JTextField txtGitRepo;

	protected final ContainerBindMountTable bindMountTable;
	protected final JButton btnAddBindMount;
	protected final JButton btnDelBindMount;



	// TODO set proper Text labels

	/**
	 * Page for uploading an imagefile
	 */
	public ContainerUploadPageLayout(Wizard wizard) {

		super(wizard, "Neue VM anlegen");
		setDescription("Please provide an Input for a Docker Image");
		GridManager grid = new GridManager(this, 3, false);

		// -- Browse for VM --

		JPanel p1 = new JPanel();
		p1.setVisible(true);
		GridManager g1 = new GridManager(p1, 3, true, new Insets(5, 0, 5, 0));
		QLabel imageFileCaption = new QLabel("Docker File");
		txtImageFile = new JTextField();
		txtImageFile.setEditable(false);
		btnBrowseForImage = new JButton("Durchsuchen");
		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("Git Repository");
		lblGitRepo.setToolTipText(
				"Set clone address of Git Repository [git@ | http://] [.git]. Currently no Checks!");
		txtGitRepo = new JTextField();
		txtGitRepo.setToolTipText(
				"Set clone address of Git Repository [git@ | http://] [.git]. Currently no Checks!");
		g2.add(lblGitRepo);
		g2.add(txtGitRepo).fill(true, false).expand(true, false);
		g2.finish(false);

		JPanel p3 = new JPanel();
		p3.setVisible(false);
		GridManager g3 = new GridManager(p3, 3, true, new Insets(5, 0, 5, 0));
		QLabel tmp = new QLabel("DUMMY");
		g3.add(tmp).fill(true, false).expand(true, false);
		g3.finish(false);

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

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

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

		lblImageName = new QLabel("Name");
		txtImageName = new JTextField();
		grid.add(lblImageName);
		grid.add(txtImageName, 2, 1).fill(true, false).expand(true, false);
		grid.nextRow();

		// -- Software license changed - shown only in UploadWizard --
		chkLicenseRestricted = new JCheckBox("enthält lizenzpflichtige Software");
		chkLicenseRestricted.setVisible(false);
		grid.skip();
		grid.add(chkLicenseRestricted, 2, 1).fill(false, false).expand(true, false);
		grid.nextRow();

		lblContainerRun = new QLabel("Container Start Optionen");
		lblContainerRun.setToolTipText("Geben Sie die Container Run Optionen an (Port, Name, Env,...)");
		txtContainerRun = new JTextField();
		grid.add(lblContainerRun);
		grid.add(txtContainerRun, 2, 1).fill(true, false).expand(true, false);
		grid.nextRow();

		bindMountTable = new ContainerBindMountTable();
		QScrollPane jsp = new QScrollPane(bindMountTable);
		grid.add(jsp, 3).fill(true, true).expand(true, true);
		grid.nextRow();
		btnAddBindMount = new JButton("Add Bind Mount");
		btnDelBindMount = new JButton("Remove Bind Mount");
		grid.add(Box.createHorizontalBox(), 1).fill(true, false).expand(true, false);
		grid.add(btnAddBindMount);
		grid.add(btnDelBindMount);

		//grid.add(Box.createVerticalGlue(), 3).expand(true, true);
		txtInfoText = new JTextArea();
		txtInfoText.setBorder(BorderFactory.createTitledBorder("Hinweis"));
		txtInfoText.setLineWrap(true);
		txtInfoText.setWrapStyleWord(true);
		txtInfoText.setEditable(false);
		txtInfoText.setFocusable(false);
		txtInfoText.setOpaque(false);
		txtInfoText.setText("Container Info Text");
		grid.add(txtInfoText, 3).fill(true, false).expand(true, false);
		grid.nextRow();

		grid.finish(true);
	}

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