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
|
package org.openslx.dozmod.gui.wizard.layout;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
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.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.thrifthelper.Comparators;
import org.openslx.virtualization.configuration.container.ContainerMeta;
import javax.swing.*;
public abstract class ImageMetaDataPageLayout extends WizardPage {
/**
* Version for serialization.
*/
private static final long serialVersionUID = -6627630305879774283L;
protected final QLabel lblOperatingSystem;
protected final JComboBox<OperatingSystem> cboOperatingSystem;
protected final JTextArea txtDescription;
protected final JCheckBox chkLicenseRestricted;
protected final JCheckBox chkIsTemplate;
protected final QLabel lblContainerImageType;
protected final ComboBox<ContainerMeta.ContainerImageType> cboContainerImageType;
/**
* wizard page for entering image data at creating or editing an image
*
* @param wizard The Wizard-object, which this extended {@link WizardPage} belongs to.
*/
public ImageMetaDataPageLayout(Wizard wizard) {
super(wizard, I18n.PAGE_LAYOUT.getString("ImageMetaData.WizardPage.title"));
setDescription(I18n.PAGE_LAYOUT.getString("ImageMetaData.WizardPage.description"));
GridManager grid = new GridManager(this, 2, false);
lblOperatingSystem = new QLabel(I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.OS.text"));
cboOperatingSystem = new ComboBox<OperatingSystem>(Comparators.operatingSystem,
new ComboBoxRenderer<OperatingSystem>() {
@Override public String renderItem(OperatingSystem item) {
if (item == null)
return null;
return item.getOsName();
}
}, OperatingSystem.class);
cboOperatingSystem.setEditable(false);
grid.add(lblOperatingSystem);
grid.add(cboOperatingSystem);
grid.nextRow();
// description
QLabel descriptionCaption = new QLabel(
I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.description.text"));
txtDescription = new JTextArea(3, 50);
txtDescription.setLineWrap(true);
txtDescription.setWrapStyleWord(true);
txtDescription.setMinimumSize(Gui.getScaledDimension(0, 70));
JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
grid.add(descriptionCaption);
grid.add(descPane).fill(true, true).expand(true, true);
grid.nextRow();
chkLicenseRestricted = new JCheckBox(
I18n.PAGE_LAYOUT.getString("ImageMetaData.CheckBox.licenseRestricted.text"));
chkLicenseRestricted.setSelected(true);
grid.add(chkLicenseRestricted, 2);
grid.nextRow();
// TODO copy-paste in ContainerPanel for this ContainerImageType component
lblContainerImageType = new QLabel("Container Image Type");
cboContainerImageType = new ComboBox<>(
new ComboBox.ComboBoxRenderer<ContainerMeta.ContainerImageType>() {
@Override public String renderItem(ContainerMeta.ContainerImageType item) {
if (item == null)
return "null";
return item.toString(); // shows the provided label
}
}, ContainerMeta.ContainerImageType.class);
for (ContainerMeta.ContainerImageType type : ContainerMeta.ContainerImageType.values()) {
cboContainerImageType.addItem(type);
}
cboContainerImageType.setSelectedItem(ContainerMeta.ContainerImageType.LECTURE);
grid.add(lblContainerImageType);
grid.add(cboContainerImageType).fill(true, false).expand(true, false);
lblContainerImageType.setVisible(false);
cboContainerImageType.setVisible(false);
grid.nextRow();
// -- end permissions group --
chkIsTemplate = new JCheckBox(I18n.PAGE_LAYOUT.getString("ImageMetaData.CheckBox.isTemplate.text"));
grid.add(chkIsTemplate, 2);
grid.nextRow();
grid.finish(true);
}
public String getImageDescription() {
return txtDescription.getText();
}
}
|