summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
diff options
context:
space:
mode:
authorStephan Schwaer2015-09-15 17:45:22 +0200
committerStephan Schwaer2015-09-15 17:45:22 +0200
commite407b8814bdb45c8b7ab7343b53647ea6a84bc95 (patch)
tree3d89adb782686d6e32e9f61c6694e7ccacf64d94 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
parent[client] Fix shade goal removing required logging classes (diff)
downloadtutor-module-e407b8814bdb45c8b7ab7343b53647ea6a84bc95.tar.gz
tutor-module-e407b8814bdb45c8b7ab7343b53647ea6a84bc95.tar.xz
tutor-module-e407b8814bdb45c8b7ab7343b53647ea6a84bc95.zip
[client] Reworked the satellite selection window.
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java57
1 files changed, 26 insertions, 31 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
index 8ab78823..3980f315 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
@@ -3,12 +3,11 @@ package org.openslx.dozmod.gui.window;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame;
+import javax.swing.JRadioButton;
import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.Satellite;
@@ -35,43 +34,49 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui
* Don't use this, use the static function open instead.
*/
public SatelliteListWindow(final Window modalParent, List<Satellite> satList) {
- super(modalParent);
+ super(modalParent, satList);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ // Check, whether we have any satellites
if (satList != null && !satList.isEmpty()){
- satelliteTable.setData(satList, true);
- radioSatelliteTable.setSelected(true);
+ satelliteButtons[0].setSelected(true);
customIpField.setEnabled(false);
- satelliteTable.setSelectedItem(satelliteTable.getModelRow(0));
} else {
- radioSatelliteTable.setEnabled(false);
radioCustomIp.setSelected(true);
}
+ // deactivate the custom field when selecting a satellite to make things clearer for user
+ for ( int i = 0; i < satCount; i++ ){
+ satelliteButtons[i].addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ customIpField.setEnabled(false);
+ }
+ });
+ }
+
radioCustomIp.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
- satelliteTable.setEnabled(false);
customIpField.setEnabled(true);
- satelliteTable.clearSelection();
- }
- });
-
- radioSatelliteTable.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- satelliteTable.setEnabled(true);
- customIpField.setEnabled(false);
- satelliteTable.setSelectedItem(satelliteTable.getModelRow(0));
}
});
exitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- if(radioSatelliteTable.isSelected() && satelliteTable.getSelectedItem() != null)
- satellite = satelliteTable.getSelectedItem();
- else {
+ // satellite is selected
+ if(!radioCustomIp.isSelected()){
+ // check, which satellite is selected
+ for (JRadioButton button : satelliteButtons) {
+ if(button.isSelected()){
+ // return it.
+ satellite = radioToSat.get(button);
+ }
+ }
+ }
+ // custom button selected or something went wrong
+ if (satellite == null || radioCustomIp.isSelected()) {
satellite = new Satellite();
satellite.addressList = new ArrayList<String>();
satellite.addressList.add(customIpField.getText());
@@ -82,16 +87,6 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui
getRootPane().setDefaultButton(exitButton);
- satelliteTable.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- if(satelliteTable.isEnabled()){
- if (e.getClickCount() == 2) {
- exitButton.doClick();
- }
- }
- }
- });
Gui.centerShellOverShell(modalParent, this);
}