summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-29 16:37:00 +0200
committerSimon Rettberg2015-09-29 16:37:00 +0200
commit283c1b75b95b08f8e6432499eac20f259982cc64 (patch)
treebd5fa587fd84307a5bbbea6efffd38e68ce34a0c
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
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/Config.java38
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/SatelliteListWindow.java84
2 files changed, 94 insertions, 28 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
index 78124376..1066ff9b 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
@@ -39,7 +39,7 @@ public class Config {
public static final int FONT_SCALING_MIN = 75;
public static final int FONT_SCALING_MAX = 175;
public static final int FONT_SCALING_STEP = 5;
-
+
/**
* Out property holder with all the setting keys
*/
@@ -347,22 +347,37 @@ public class Config {
return null;
return session;
}
-
+
+ /**
+ * Set satellite used last time.
+ */
+ public static void setLastSatellite(String value) {
+ setString("session.last-satellite", value);
+ }
+
+ /**
+ * Get satellite last used.
+ */
+ public static String getLastSatellite() {
+ return getString("session.last-satellite", "");
+ }
+
/**
* Sets the scaling for font rendering (in percent, 100% = no scaling)
- *
+ *
* @param percent to set the font scaling to
*/
public static void setFontScaling(int percent) {
setInteger("gui.fontscaling", percent);
}
-
+
/**
* Get scaling for font rendering (in percent, 100% = no scaling)
* If the saved value is not within the declared boundary, it will be
* reseted to 100.
*
- * @return the saved value of 'gui.fontscaling' if within boundaries, 100 otherwise
+ * @return the saved value of 'gui.fontscaling' if within boundaries, 100
+ * otherwise
*/
public static int getFontScaling() {
int savedFontScaling = getInteger("gui.fontscaling", 100);
@@ -372,19 +387,19 @@ public class Config {
}
return savedFontScaling;
}
-
+
/**
* Set the mode in which the proxy server is configured.
- *
+ *
* @param mode
*/
public static void setProxyMode(ProxyMode mode) {
setString("proxy.mode", mode.toString());
}
-
+
/**
* Get the mode in which the proxy server is configured
- *
+ *
* @return the saved proxy mode, ProxyMode.AUTO otherwise
*/
public static ProxyMode getProxyMode() {
@@ -466,7 +481,8 @@ public class Config {
}
/**
- * Helper class to represent a saved session composed of the satellite adress,
+ * Helper class to represent a saved session composed of the satellite
+ * adress,
* the satellite and master tokens
*/
public static class SavedSession {
@@ -480,7 +496,7 @@ public class Config {
this.masterToken = masterToken;
}
}
-
+
/**
* Enum representing the proxy mode
*/
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;