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 cboSound; protected final JComboBox cbo3DAcceleration; protected final JComboBox cboHWVersion; protected final JComboBox cboE0VirtDev; protected final JComboBox 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() { @Override public String renderItem(SoundCardType item) { return item.displayName; } }); // 3D accelerationBox cbo3DAcceleration = new ComboBox<>(new ComboBoxRenderer() { @Override public String renderItem(DDAcceleration item) { return item.displayName; } }); // HardwareVersioBox cboHWVersion = new ComboBox<>(new ComboBoxRenderer() { @Override public String renderItem(HWVersion item) { return item.displayName; } }); // HardwareVersioBox cboE0VirtDev = new ComboBox<>(new ComboBoxRenderer() { @Override public String renderItem(EthernetDevType item) { return item.displayName; } }); cboMaxUsbSpeed = new ComboBox<>(new ComboBoxRenderer() { @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, 375)); if (modalParent != null) { Gui.centerShellOverShell(modalParent, this); } } // SoundBox public void initializeSoundBox(List list) { for (SoundCardType i : list) { cboSound.addItem(i); } } // 3 D acceleration public void initializeDDABox(List list) { for (DDAcceleration i : list) { cbo3DAcceleration.addItem(i); } } // Hardware version public void initializeHWVersBox(List list) { for (HWVersion i : list) { cboHWVersion.addItem(i); } } // Ethernet Device type public void initializeEDTBox(List list) { for (EthernetDevType i : list) { cboE0VirtDev.addItem(i); } } // USB Speed public void initializeUsbBox(List list) { for (UsbSpeed i : list) { cboMaxUsbSpeed.addItem(i); } } }