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

import java.awt.FlowLayout;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JButton;
import javax.swing.text.StyledEditorKit;
import javax.swing.text.html.HTMLEditorKit;

import java.awt.Dimension;
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.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.WizardPage;
import org.openslx.thrifthelper.Comparators;

@SuppressWarnings("serial")
public abstract class ImageMetaDataPageLayout extends WizardPage {

	protected final JComboBox<OperatingSystem> cboOperatingSystem;
	protected final JEditorPane txtDescription;
	protected final JTextArea startCommand;
	protected final QLabel sCommandCaption;
	protected final JScrollPane startCommandPane;
	protected final JCheckBox chkLicenseRestricted;
	protected final JCheckBox chkIsTemplate;

	protected final JButton btnBold;
	protected final JButton btnItalic;
	protected final JButton btnUnderline;
	protected final JButton btnWysiwyg;
	
	protected final JComboBox cbTxtSize;
	protected final JComboBox cbTxtColor;
	protected final HTMLEditorKit kit;

	
	/**
	 * wizard page for entering image data at creating or editing an image
	 * 
	 * @param wizard
	 */
	public ImageMetaDataPageLayout(Wizard wizard) {
		super(wizard, "Metadaten");
		setDescription("Geben Sie bitte einen aussagekräftigen Namen für die neue VM ein.");

		GridManager grid = new GridManager(this, 3, false);

		QLabel osCaption = new QLabel("Betriebssystem");
		cboOperatingSystem = new ComboBox<>(Comparators.operatingSystem, new ComboBoxRenderer<OperatingSystem>() {
			@Override
			public String renderItem(OperatingSystem item) {
				if (item == null)
					return null;
				return item.getOsName();
			}
		});
		cboOperatingSystem.setEditable(false);
		grid.add(osCaption);
		grid.add(cboOperatingSystem, 2);
		grid.nextRow();

		sCommandCaption = new QLabel("Startbefehl");
		startCommand = new JTextArea(1, 50);
		startCommand.setMinimumSize(Gui.getScaledDimension(0, 35));
		startCommand.setLineWrap(true);
		startCommand.setWrapStyleWord(true);
		startCommandPane = new JScrollPane(startCommand, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
				JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		startCommandPane.setMinimumSize(startCommand.getMinimumSize());
		grid.add(sCommandCaption);
		grid.add(startCommandPane).fill(true, false).expand(true, false);
		grid.add(new JPanel());
		grid.nextRow();

		// buttons for text editing
		JPanel editingPanel = new JPanel();
		editingPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
		JPanel emptyPanel = new JPanel();
		grid.add(emptyPanel);
		btnBold = new JButton(new StyledEditorKit.BoldAction());
		btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 15, this));
		btnBold.setText("");
		btnItalic = new JButton(new StyledEditorKit.ItalicAction());
		btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 15, this));
		btnItalic.setText("");
		btnUnderline = new JButton(new StyledEditorKit.UnderlineAction());
		btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 15, this));
		btnUnderline.setText("");
		editingPanel.add(btnBold);
		editingPanel.add(btnItalic);
		editingPanel.add(btnUnderline);
		
		String[] textsizes = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"};
		cbTxtSize = new JComboBox<>(textsizes);
		cbTxtSize.setPreferredSize(new Dimension(65,25));
		editingPanel.add(cbTxtSize);

		Object[] colors = {"Black", "Blue", "Red", "Yellow", "Green"};
		cbTxtColor = new JComboBox<>(colors);
		cbTxtColor.setPreferredSize(new Dimension(95,25));
		editingPanel.add(cbTxtColor);

		grid.add(editingPanel);
		emptyPanel.setLayout(new FlowLayout());
		btnWysiwyg = new JButton("HTML");
		btnWysiwyg.setPreferredSize(new Dimension(100,25));
		emptyPanel.add(btnWysiwyg);
		grid.add(emptyPanel);
		grid.nextRow();

		// description
		QLabel descriptionCaption = new QLabel("Beschreibung");
		txtDescription = new JEditorPane();
		kit = new HTMLEditorKit();
		txtDescription.setEditorKit(kit);
		txtDescription.setContentType("text/html");
		JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		grid.add(descriptionCaption);
		grid.add(descPane, 2).fill(true, true).expand(true, true);
		grid.nextRow();

		chkLicenseRestricted = new JCheckBox("VM enthält lizenzpflichtige Software");
		chkLicenseRestricted.setSelected(true);
		grid.add(chkLicenseRestricted, 3);
		grid.nextRow();

		// -- end permissions group --
		chkIsTemplate = new JCheckBox("Vorlage erstellen");
		grid.add(chkIsTemplate, 3);
		grid.nextRow();

		grid.finish(true);
	}

	public String getImageDescription() {
		return txtDescription.getText();
	}
}