package org.openslx.dozmod.gui.window.layout; import java.awt.Dimension; import java.awt.Window; import java.util.HashMap; import java.util.List; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import org.openslx.bwlp.thrift.iface.Satellite; import org.openslx.dozmod.gui.helper.GridManager; @SuppressWarnings("serial") public class SatelliteListWindowLayout extends JDialog { protected final JButton exitButton; protected final JTextField customIpField; protected final JRadioButton radioCustomIp; protected final JRadioButton[] satelliteButtons; protected final int satCount; protected final HashMap radioToSat = new HashMap(); protected final ButtonGroup btnGroup; private static String title = "Liste an Satelliten"; protected SatelliteListWindowLayout(Window modalParent, List satList) { super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); GridManager windowGrid = new GridManager(this, 1); JPanel radioPanel = new JPanel(); radioPanel.setBorder(BorderFactory.createTitledBorder( "Satelliten Auswahl")); GridManager selectionPanelGrid = new GridManager(radioPanel, 2); btnGroup = new ButtonGroup(); // --------------- radio buttons sat selection -------------------------------------- satCount = satList.size(); satelliteButtons = new JRadioButton[satCount]; // create the radioButtons, add them to the map, button group and the selection grid. for (int index = 0; index < satCount; index++ ){ satelliteButtons[index] = new JRadioButton(satList.get(index).getDisplayName()); radioToSat.put(satelliteButtons[index], satList.get(index)); btnGroup.add(satelliteButtons[index]); selectionPanelGrid.add(satelliteButtons[index], 2).fill(true, false).expand(true, false); selectionPanelGrid.nextRow(); } // --------------- end radio buttons for sat selection ------------------------------------ // --------------- custom ip button and field -------------------------------------- radioCustomIp = new JRadioButton("Benutzerdefiniert"); btnGroup.add(radioCustomIp); customIpField = new JTextField(); customIpField.setPreferredSize(new Dimension(120, 25)); selectionPanelGrid.add(radioCustomIp).fill(true, false).expand(false, false); selectionPanelGrid.add(customIpField).fill(true, false).expand(true, false); selectionPanelGrid.nextRow(); selectionPanelGrid.finish(true); // --------------- end custom ip field -------------------------------- // --------------- button panel -------------------------------------- JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); exitButton = new JButton("Weiter"); buttonPane.add(exitButton); // --------------- end button panel ---------------------------------- // pack it all windowGrid.add(radioPanel).fill(true, true).expand(true, true); windowGrid.nextRow(); windowGrid.add(buttonPane).fill(true, false).expand(true, false); windowGrid.nextRow(); windowGrid.finish(false); pack(); } }