summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtDropDownConfigEditorWindowLayout.java
blob: 6e8cc7490b5eeb3ade11dd8224d6a09cf81c1db9 (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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package org.openslx.dozmod.gui.window.layout;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Window;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.ComboBox;
import org.openslx.dozmod.gui.control.ComboBox.ComboBoxRenderer;
import org.openslx.dozmod.gui.control.WordWrapLabel;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.thrift.Session;
import org.openslx.sat.thrift.version.Feature;
import org.openslx.util.vm.VmMetaData.DDAcceleration;
import org.openslx.util.vm.VmMetaData.EthernetDevType;
import org.openslx.util.vm.VmMetaData.HWVersion;
import org.openslx.util.vm.VmMetaData.SoundCardType;
import org.openslx.util.vm.VmMetaData.UsbSpeed;

@SuppressWarnings("serial")
public class VirtDropDownConfigEditorWindowLayout extends JDialog {

	private static String title = "VM-Konfiguration Editor";
	protected final JScrollPane pnlScrollPane;
	protected final JEditorPane pnlEditor;
	protected final JButton btnSave;
	protected final JButton btnCancel;
	protected final JButton btnMore;
	protected final JComboBox<SoundCardType> cboSound;
	protected final JComboBox<DDAcceleration> cbo3DAcceleration;
	protected final JComboBox<HWVersion> cboHWVersion;
	protected final JComboBox<EthernetDevType> cboE0VirtDev;
	protected final JComboBox<UsbSpeed> cboMaxUsbSpeed;

	protected VirtDropDownConfigEditorWindowLayout(Window modalParent) {
		super(modalParent, title,
				modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);

		GridManager grid = new GridManager(getContentPane(), 2, true, new Insets(2, 2, 2, 2));

		/* 
		 * extra JPanel for the Warning message
		 */
		JPanel pnlWarning = new JPanel();
		pnlWarning.setBorder(BorderFactory.createTitledBorder("WARNUNG"));
		pnlWarning.setLayout(new BorderLayout());
		pnlWarning.add(new WordWrapLabel("Hier können Sie einige Einstellungen bzgl. der"
				+ " verwendeten virtuallen Hardware ändern. Bitte beachten Sie,"
				+ " dass Änderungen erfordern können, dass in der VM neue Treiber"
				+ " vorhanden sein müssen. In diesem Fall ist es notwendig, dass"
				+ " Sie die Änderung nach dem Herunterladen einer VM lokal"
				+ " durchführen, die notwendigen Treiber installieren, und die VM wieder hochladen."),
				BorderLayout.CENTER);

		/*
		 * ComboBoxes - one for each device
		 */

		cboSound = new ComboBox<>(new ComboBoxRenderer<SoundCardType>() {
			@Override
			public String renderItem(SoundCardType item) {
				return item.displayName;
			}
		});

		// 3D accelerationBox
		cbo3DAcceleration = new ComboBox<>(new ComboBoxRenderer<DDAcceleration>() {
			@Override
			public String renderItem(DDAcceleration item) {
				return item.displayName;
			}
		});

		// HardwareVersioBox
		cboHWVersion = new ComboBox<>(new ComboBoxRenderer<HWVersion>() {
			@Override
			public String renderItem(HWVersion item) {
				return item.displayName;
			}
		});

		// HardwareVersioBox
		cboE0VirtDev = new ComboBox<>(new ComboBoxRenderer<EthernetDevType>() {
			@Override
			public String renderItem(EthernetDevType item) {
				return item.displayName;
			}
		});
		
		cboMaxUsbSpeed = new ComboBox<>(new ComboBoxRenderer<UsbSpeed>() {
			@Override
			public String renderItem(UsbSpeed item) {
				return item.displayName;
			}
		});

		pnlEditor = new JEditorPane("text/plain", null);
		pnlScrollPane = new JScrollPane(pnlEditor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

		grid.add(pnlWarning, 2).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(new JLabel("Soundkarte")).fill(true, false).expand(false, false);
		grid.add(cboSound).fill(true, false).expand(false, false);
		grid.nextRow();
		grid.add(new JLabel("3D-Beschleunigung")).fill(true, false).expand(false, false);
		grid.add(cbo3DAcceleration).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(new JLabel("VMWare HW-Version")).fill(true, false).expand(false, false);
		grid.add(cboHWVersion).fill(true, false).expand(true, false);
		grid.nextRow();
		grid.add(new JLabel("Netzwerkkarte")).fill(true, false).expand(false, false);
		grid.add(cboE0VirtDev).fill(true, false).expand(true, false);
		grid.nextRow();
		if (Session.hasFeature(Feature.CONFIGURE_USB)) {
			grid.add(new JLabel("USB")).fill(true, false).expand(false, false);
			grid.add(cboMaxUsbSpeed).fill(true, false).expand(true, false);
			grid.nextRow();
		}

		grid.add(Box.createVerticalGlue(), 2).expand(true, true);
		grid.nextRow();

		JPanel buttonPane = new JPanel();
		buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
		buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
		buttonPane.add(Box.createHorizontalGlue());
		btnMore = new JButton("Expertenmodus");
		buttonPane.add(btnMore);
		buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
		btnCancel = new JButton("Abbrechen");
		buttonPane.add(btnCancel);
		buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
		btnSave = new JButton("Speichern");
		buttonPane.add(btnSave);
		grid.add(buttonPane, 2).fill(true, false).expand(true, false);
		grid.finish(false);

		setPreferredSize(Gui.getScaledDimension(600, 400));
		setMinimumSize(Gui.getScaledDimension(450, 350));
		if (modalParent != null) {
			Gui.centerShellOverShell(modalParent, this);
		}
	}

	// SoundBox
	public void initializeSoundBox(List<SoundCardType> list) {
		for (SoundCardType i : list) {
			cboSound.addItem(i);
		}
	}

	// 3 D acceleration
	public void initializeDDABox(List<DDAcceleration> list) {
		for (DDAcceleration i : list) {
			cbo3DAcceleration.addItem(i);
		}
	}

	// Hardware version
	public void initializeHWVersBox(List<HWVersion> list) {
		for (HWVersion i : list) {
			cboHWVersion.addItem(i);
		}
	}

	// Ethernet Device type
	public void initializeEDTBox(List<EthernetDevType> list) {
		for (EthernetDevType i : list) {
			cboE0VirtDev.addItem(i);
		}
	}

	// USB Speed
	public void initializeUsbBox(List<UsbSpeed> list) {
		for (UsbSpeed i : list) {
			cboMaxUsbSpeed.addItem(i);
		}
	}
}