summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-29 16:37:00 +0200
committerSimon Rettberg2015-09-29 16:37:00 +0200
commit283c1b75b95b08f8e6432499eac20f259982cc64 (patch)
treebd5fa587fd84307a5bbbea6efffd38e68ce34a0c /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java
parent[client] Don't run proxy search if master server is reachable (diff)
downloadtutor-module-283c1b75b95b08f8e6432499eac20f259982cc64.tar.gz
tutor-module-283c1b75b95b08f8e6432499eac20f259982cc64.tar.xz
tutor-module-283c1b75b95b08f8e6432499eac20f259982cc64.zip
[client] Remember last satellite used; support doubleclick on sat to connect without remembering
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.java84
1 files changed, 67 insertions, 17 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 734f8c5a..566cc99e 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,6 +3,9 @@ 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.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
@@ -11,7 +14,9 @@ import javax.swing.JRadioButton;
import org.openslx.bwlp.thrift.iface.Satellite;
import org.openslx.bwlp.thrift.iface.UserInfo;
+import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.window.layout.SatelliteListWindowLayout;
/**
@@ -31,12 +36,44 @@ public class SatelliteListWindow extends SatelliteListWindowLayout {
*/
public SatelliteListWindow(final Window modalParent, List<Satellite> satList) {
super(modalParent, satList);
+ // Prepare doubleclick listener
+ MouseListener radioDoubleClick = new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
+ if (e.getSource() instanceof JRadioButton) {
+ ((JRadioButton) e.getSource()).setSelected(true);
+ }
+ prepareSelection();
+ if (satellite != null) {
+ dispose();
+ }
+ }
+ }
+ };
// Check, whether we have any satellites
+ String lastSat = Config.getLastSatellite();
if (satList != null && !satList.isEmpty()) {
- radioToSat.keySet().iterator().next().setSelected(true);
- customIpField.setEnabled(false);
+ for (Entry<JRadioButton, Satellite> entry : radioToSat.entrySet()) {
+ if (!lastSat.isEmpty()) {
+ Satellite sat = entry.getValue();
+ if (sat.displayName.equals(lastSat)) {
+ entry.getKey().setSelected(true);
+ entry.getKey().requestFocus();
+ customIpField.setEnabled(false);
+ lastSat = "";
+ }
+ }
+ entry.getKey().addMouseListener(radioDoubleClick);
+ }
} else {
radioCustomIp.setSelected(true);
+ customIpField.requestFocus();
+ }
+ if (lastSat.startsWith("@")) {
+ customIpField.setText(lastSat.substring(1));
+ radioCustomIp.setSelected(true);
+ customIpField.requestFocus();
}
// deactivate the custom field when selecting a satellite to make things clearer for user
@@ -55,23 +92,17 @@ public class SatelliteListWindow extends SatelliteListWindowLayout {
nextButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- // satellite is selected
- if (!radioCustomIp.isSelected()) {
- // check, which satellite is selected
- for (Entry<JRadioButton, Satellite> entry : radioToSat.entrySet()) {
- if (entry.getKey().isSelected()) {
- satellite = entry.getValue();
- break;
- }
+ prepareSelection();
+ if (satellite != null) {
+ if (radioCustomIp.isSelected()) {
+ Config.setLastSatellite("@" + customIpField.getText());
+ } else if (satellite.displayName != null && !satellite.displayName.isEmpty()) {
+ Config.setLastSatellite(satellite.displayName);
}
+ dispose();
+ } else {
+ Gui.showMessageBox(rootPane, "Kein Satellit ausgewählt", MessageType.ERROR, null, null);
}
- // custom button selected
- if (radioCustomIp.isSelected()) {
- satellite = new Satellite();
- satellite.addressList = new ArrayList<String>();
- satellite.addressList.add(customIpField.getText());
- }
- dispose();
}
});
@@ -80,6 +111,25 @@ public class SatelliteListWindow extends SatelliteListWindowLayout {
Gui.centerShellOverShell(modalParent, this);
}
+ private void prepareSelection() {
+ // satellite is selected
+ if (!radioCustomIp.isSelected()) {
+ // check, which satellite is selected
+ for (Entry<JRadioButton, Satellite> entry : radioToSat.entrySet()) {
+ if (entry.getKey().isSelected()) {
+ satellite = entry.getValue();
+ break;
+ }
+ }
+ }
+ // custom button selected
+ if (radioCustomIp.isSelected() && !customIpField.getText().isEmpty()) {
+ satellite = new Satellite();
+ satellite.addressList = new ArrayList<String>();
+ satellite.addressList.add(customIpField.getText());
+ }
+ }
+
private Satellite runAndReturn() {
setVisible(true);
return satellite;