summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/SatelliteListWindowLayout.java
blob: cb1dc3a1b3ffba04102b6c370e045736458717e0 (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
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<JRadioButton, Satellite> radioToSat = new HashMap<JRadioButton, Satellite>();
	protected final ButtonGroup btnGroup;

	private static String title = "Liste an Satelliten";

	protected SatelliteListWindowLayout(Window modalParent, List<Satellite> 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();
	}
}