diff options
author | Jonathan Bauer | 2015-08-05 15:59:03 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-05 15:59:03 +0200 |
commit | 6b6985ee3cfbdb2d93032a078a2986de90362bf3 (patch) | |
tree | 915b425e08b0a87332d610e22828b90f1592a528 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java | |
parent | [client] pointed to a small bug in wizard (diff) | |
download | tutor-module-6b6985ee3cfbdb2d93032a078a2986de90362bf3.tar.gz tutor-module-6b6985ee3cfbdb2d93032a078a2986de90362bf3.tar.xz tutor-module-6b6985ee3cfbdb2d93032a078a2986de90362bf3.zip |
[client] first draft at UserListWindow
Used a one-column table since we already have a lot to get from our ListTable.
Currently used a double-click control scheme, to be discussed...
TODO: filtering users and in general a way to query the existing users without UserCache.getAll()
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java new file mode 100644 index 00000000..a6df2332 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java @@ -0,0 +1,82 @@ +package org.openslx.dozmod.gui.window; + +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.List; + +import org.apache.log4j.Logger; +import org.openslx.bwlp.thrift.iface.UserInfo; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.window.layout.UserListWindowLayout; +import org.openslx.dozmod.thrift.UserCache; +import org.openslx.util.QuickTimer; +import org.openslx.util.QuickTimer.Task; + +@SuppressWarnings("serial") +public class UserListWindow extends UserListWindowLayout { + + private final static Logger LOGGER = Logger.getLogger(UserListWindow.class); + + public UserListWindow(final Frame modalParent, final UserAddedCallback callback) { + super(modalParent); + + addWindowListener(new WindowAdapter() { + @Override + public void windowOpened(WindowEvent e) { + // load the user cache async + QuickTimer.scheduleOnce(new Task() { + @Override + public void fire() { + final List<UserInfo> userList = UserCache.getAll(); + Gui.asyncExec(new Runnable() { + @Override + public void run() { + userTable.setData(userList, true); + } + }); + } + }); + + } + }); + + // ActionListener for the two buttons + final ActionListener al = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if ("Set".equals(e.getActionCommand())) { + final UserInfo user = userTable.getSelectedItem(); + if (user == null) return; + callback.userAdded(user); + } + if ("Cancel".equals(e.getActionCommand())) { + setVisible(false); + dispose(); + } + } + }; + setButton.setActionCommand("Set"); + setButton.addActionListener(al); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(al); + getRootPane().setDefaultButton(setButton); + + userTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + setButton.doClick(); + } + } + }); + } + + public static void open(Frame modalParent, final UserAddedCallback callback) { + new UserListWindow(modalParent, callback).setVisible(true); + } +} |