package org.openslx.dozmod.gui.window.layout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Window;
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.helper.GridManager;
import org.openslx.util.vm.VmwareMetaData.DDAcceleration;
import org.openslx.util.vm.VmwareMetaData.EthernetDevType;
import org.openslx.util.vm.VmwareMetaData.HWVersion;
import org.openslx.util.vm.VmwareMetaData.SoundCardType;
@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 VirtDropDownConfigEditorWindowLayout(Window modalParent) {
super(modalParent, title,
modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS);
GridManager grid = new GridManager(this, 3, true, new Insets(2, 2, 2, 2));
/*
* extra JPanel for the Warning message
*/
JPanel pnlWarning = new JPanel();
pnlWarning.setBorder(BorderFactory.createTitledBorder("WARNUNG"));
pnlWarning.add(
new JLabel("<html>Änderungen an der VM-Konfiguration können zu Funktionsstörungen führen."
+ "<br>Benutzung auf eigene Gefahr!"
+ "<br>Erweiterungen clicken um die alte interface zu benutzen</html>"));
/*
* ComboBoxes - one for each device
*/
// SoundBox
cboSound = new ComboBox<>(new ComboBoxRenderer<SoundCardType>() {
@Override
public String renderItem(SoundCardType item) {
return item.displayName;
}
});
for (SoundCardType i : SoundCardType.values()) {
cboSound.addItem(i);
}
// 3D accelerationBox
cbo3DAcceleration = new ComboBox<>(new ComboBoxRenderer<DDAcceleration>() {
@Override
public String renderItem(DDAcceleration item) {
return item.displayName;
}
});
for (DDAcceleration i : DDAcceleration.values()) {
cbo3DAcceleration.addItem(i);
}
// HardwareVersioBox
cboHWVersion = new ComboBox<>(new ComboBoxRenderer<HWVersion>() {
@Override
public String renderItem(HWVersion item) {
return item.displayName;
}
});
for (HWVersion i : HWVersion.values()) {
cboHWVersion.addItem(i);
}
// HardwareVersioBox
cboE0VirtDev = new ComboBox<>(new ComboBoxRenderer<EthernetDevType>() {
@Override
public String renderItem(EthernetDevType item) {
return item.displayName;
}
});
for (EthernetDevType i : EthernetDevType.values()) {
cboE0VirtDev.addItem(i);
}
pnlEditor = new JEditorPane("text/plain", null);
pnlScrollPane = new JScrollPane(pnlEditor, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
grid.add(pnlWarning, 3).fill(true, false).expand(true, false);
grid.nextRow();
grid.add(new JLabel("Soundkarte")).fill(true, false).expand(false, false);
grid.add(new JLabel(" ")).fill(false, 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(new JLabel(" ")).fill(false, false).expand(false, false);
grid.add(cbo3DAcceleration).fill(true, false).expand(true, false);
grid.nextRow();
grid.add(new JLabel("Hardware Version Nummer")).fill(true, false).expand(false, false);
grid.add(new JLabel(" ")).fill(false, false).expand(false, false);
grid.add(cboHWVersion).fill(true, false).expand(true, false);
grid.nextRow();
grid.add(new JLabel("Virtuelle Netzwerkkarte")).fill(true, false).expand(false, false);
grid.add(new JLabel(" ")).fill(false, false).expand(false, false);
grid.add(cboE0VirtDev).fill(true, false).expand(true, false);
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("Erweiterungen");
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, 3).fill(true, false).expand(true, false);
grid.finish(false);
setPreferredSize(Gui.getScaledDimension(850, 250));
setMinimumSize(Gui.getScaledDimension(550, 300));
Gui.centerShellOverShell(modalParent, this);
}
}