package org.openslx.dozmod.gui.wizard.layout; import org.openslx.dozmod.gui.Gui; 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 java.awt.event.MouseEvent; import javax.swing.*; import javax.swing.event.MouseInputAdapter; public abstract class ImageTypePageLayout extends WizardPage { /** * Version for serialization. */ private static final long serialVersionUID = 2548125409461846482L; protected final JTextArea txtInfoText; protected final JRadioButton rbtnNewVmImage; protected final JRadioButton rbtnNewDockerImage; protected final ButtonGroup btgrpImageTyp; /** * Page to choose between new VM-Image or Docker Image */ public ImageTypePageLayout(Wizard wizard) { super(wizard, I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.WizardPage.title")); setDescription(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.WizardPage.description")); // ##################################### // Create the Components txtInfoText = new JTextArea(); txtInfoText.setBorder(BorderFactory.createTitledBorder(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.newVmInformation.border"))); txtInfoText.setLineWrap(true); txtInfoText.setWrapStyleWord(true); txtInfoText.setEditable(false); txtInfoText.setFocusable(false); txtInfoText.setOpaque(false); txtInfoText.setText(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.newVmInformation.text")); QLabel lblVmImage = new QLabel(Gui.getScaledIconResource("/img/virtualization.png", I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.description"), 48, this)); lblVmImage.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { rbtnNewVmImage.doClick(); } }); QLabel lblDockerImage = new QLabel(Gui.getScaledIconResource("/img/docker-icon.png", I18n.WINDOW_LAYOUT.getString("LectureList.Button.editLecture.description"), 48, this)); lblDockerImage.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(MouseEvent e) { rbtnNewDockerImage.doClick(); } }); rbtnNewVmImage = new JRadioButton(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.button.newVM")); rbtnNewDockerImage = new JRadioButton(I18n.PAGE_LAYOUT.getString("ImageTypePageLayout.button.newDocker")); // center the radiobuttion in the gridbag cell rbtnNewVmImage.setHorizontalAlignment(SwingConstants.CENTER); rbtnNewDockerImage.setHorizontalAlignment(SwingConstants.CENTER); btgrpImageTyp = new ButtonGroup(); btgrpImageTyp.add(rbtnNewVmImage); btgrpImageTyp.add(rbtnNewDockerImage); // ##################################### // Create the Layout GridManager grid = new GridManager(this, 2, false); grid.add(txtInfoText, 2).fill(true, false).expand(true, false); grid.add(Box.createVerticalGlue(), 2).expand(true, true); grid.add(lblVmImage).fill(true, true).expand(true, true); grid.add(lblDockerImage).fill(true, true).expand(true, true); grid.nextRow(); grid.add(rbtnNewVmImage).fill(true, false).expand(true, true); grid.add(rbtnNewDockerImage).fill(true, false).expand(true, false); grid.nextRow(); grid.finish(true); } }