diff options
author | Jonathan Bauer | 2015-09-15 17:06:20 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-09-15 17:06:20 +0200 |
commit | 28f84e5923208b3ff32dcd332a1212caf132cf89 (patch) | |
tree | e71ac6d8ca11b1e890493da7bfbbf09cc9401ee2 /dozentenmodul/src/main/java/org/openslx/dozmod/gui | |
parent | [client] reworked german text (diff) | |
parent | [client] Shift key for forcing satellite selection now works. (diff) | |
download | tutor-module-28f84e5923208b3ff32dcd332a1212caf132cf89.tar.gz tutor-module-28f84e5923208b3ff32dcd332a1212caf132cf89.tar.xz tutor-module-28f84e5923208b3ff32dcd332a1212caf132cf89.zip |
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui')
3 files changed, 38 insertions, 27 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index ee3727ab..7a0c1b56 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -192,24 +192,7 @@ public abstract class MainWindow { } }); - KeyEventDispatcher satelliteShiftDispatcher = new KeyEventDispatcher() { - // TODO Fix to register shift key - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - int type = event.getID(); - int code = event.getKeyChar(); - LOGGER.info("SHIFT!: " + " type: " + type + " code: " + code); - if (code == KeyEvent.VK_SHIFT) { // ESC or Ctrl-W closes current window - if (type == KeyEvent.KEY_PRESSED) { - ThriftActions.forceCustomSattelite = true; - } else if ( type == KeyEvent.KEY_RELEASED) - ThriftActions.forceCustomSattelite = false; - event.consume(); - } - return event.isConsumed(); - } - }; - KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(satelliteShiftDispatcher); + // Set layout for the mainshell, items added to the shell should get a gridData mainContainer.setLayout(new BoxLayout(mainContainer, BoxLayout.PAGE_AXIS)); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java index 877b8fc0..a097ec55 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LoginWindow.java @@ -1,6 +1,8 @@ package org.openslx.dozmod.gui.window; import java.awt.Frame; +import java.awt.KeyEventDispatcher; +import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -20,7 +22,6 @@ import javax.swing.SwingUtilities; import org.apache.log4j.Logger; import org.apache.thrift.TBaseHelper; import org.apache.thrift.TException; -import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Organization; import org.openslx.bwlp.thrift.iface.Satellite; import org.openslx.dozmod.App; @@ -41,7 +42,6 @@ import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.Sorters; import org.openslx.dozmod.thrift.ThriftActions; import org.openslx.dozmod.thrift.ThriftError; -import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.thrift.cache.OrganizationCache; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -74,6 +74,23 @@ public class LoginWindow extends LoginWindowLayout { // text constants private final String NO_USERNAME = "Kein Benutzername angegeben!"; private final String NO_PASSWORD = "Kein Passwort angegeben!"; + + public static boolean forceCustomSatellite; + private final KeyEventDispatcher satelliteShiftDispatcher = new KeyEventDispatcher() { + @Override + public boolean dispatchKeyEvent(KeyEvent event) { + int type = event.getID(); + int code = event.getKeyCode(); + if (code == KeyEvent.VK_SHIFT) { // shift key is pressed + if (type == KeyEvent.KEY_PRESSED) { + forceCustomSatellite = true; + } else if ( type == KeyEvent.KEY_RELEASED) + forceCustomSatellite = false; + event.consume(); + } + return event.isConsumed(); + } + }; public LoginWindow(Frame modalParent) { // call the constructor of the superclass @@ -154,6 +171,8 @@ public class LoginWindow extends LoginWindowLayout { } }); + KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(satelliteShiftDispatcher); + loginButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -372,6 +391,9 @@ public class LoginWindow extends LoginWindowLayout { Config.saveCurrentSession(Session.getSatelliteAddress(), Session.getSatelliteToken(), Session.getMasterToken()); } + // Remove the listener for the shift key. (For forcing the satellite selection) + KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(satelliteShiftDispatcher); + dispose(); return; } 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 ede91a12..8ab78823 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 @@ -17,6 +17,9 @@ import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.helper.UiFeedback; import org.openslx.dozmod.gui.window.layout.SatelliteListWindowLayout; +/** + * Window for selecting an available satellite or setting custom ip. + */ @SuppressWarnings("serial") public class SatelliteListWindow extends SatelliteListWindowLayout implements UiFeedback { @@ -28,26 +31,28 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui public void userAdded(UserInfo user, SatelliteListWindow window); } + /** + * Don't use this, use the static function open instead. + */ public SatelliteListWindow(final Window modalParent, List<Satellite> satList) { super(modalParent); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); - + if (satList != null && !satList.isEmpty()){ satelliteTable.setData(satList, true); radioSatelliteTable.setSelected(true); customIpField.setEnabled(false); + satelliteTable.setSelectedItem(satelliteTable.getModelRow(0)); } else { radioSatelliteTable.setEnabled(false); radioCustomIp.setSelected(true); } - - radioCustomIp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { satelliteTable.setEnabled(false); - customIpField.setEnabled(true); + customIpField.setEnabled(true); satelliteTable.clearSelection(); } }); @@ -57,13 +62,14 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui 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()) + if(radioSatelliteTable.isSelected() && satelliteTable.getSelectedItem() != null) satellite = satelliteTable.getSelectedItem(); else { satellite = new Satellite(); @@ -94,7 +100,7 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui * * @param modalParent * @param satList The list of satellites to display. - * @return satellite with adress to use. + * @return satellite with address to use. */ public static Satellite open(Window modalParent, List<Satellite> satList) { SatelliteListWindow win = new SatelliteListWindow( modalParent, satList ); @@ -111,5 +117,5 @@ public class SatelliteListWindow extends SatelliteListWindowLayout implements Ui public void escapePressed() { } - + } |