diff options
Diffstat (limited to 'dozentenmodul/src/main')
3 files changed, 67 insertions, 66 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/UserTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/UserTable.java index 2dd9122f..05431827 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/UserTable.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/UserTable.java @@ -6,14 +6,10 @@ import org.openslx.dozmod.util.FormatHelper; @SuppressWarnings("serial") public class UserTable extends ListTable<UserInfo> { - private static String[] columnNames = - { "Name" }; + private static String[] columnNames = { "Name", "Mail" }; - private static Class<?>[] columnClasses = - { String.class }; - public UserTable() { - super(columnNames, columnClasses); + super(columnNames, null); } @Override @@ -21,6 +17,8 @@ public class UserTable extends ListTable<UserInfo> { UserInfo row = getModelRow(rowIndex); if (columnIndex == 0) return FormatHelper.userName(row); + if (columnIndex == 1) + return row.eMail; throw new IndexOutOfBoundsException(); } } 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 index 680a934a..f7399beb 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/UserListWindow.java @@ -30,7 +30,7 @@ public class UserListWindow extends UserListWindowLayout { public UserListWindow(final Frame modalParent, final UserAddedCallback callback) { super(modalParent); - + addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { @@ -47,10 +47,10 @@ public class UserListWindow extends UserListWindowLayout { }); } }); - + } }); - + // filter the objects in the table depending on the search field searchUserField.getDocument().addDocumentListener(new DocumentListener() { @Override @@ -66,7 +66,8 @@ public class UserListWindow extends UserListWindowLayout { @Override public void changedUpdate(DocumentEvent e) { try { - userTable.getRowSorter().setRowFilter(RowFilter.regexFilter("(?i)"+searchUserField.getText(), 0)); + userTable.getRowSorter().setRowFilter( + RowFilter.regexFilter("(?i)" + searchUserField.getText())); searchUserField.setForeground(UIManager.getColor("TextField.foreground")); } catch (IllegalArgumentException ex) { // TODO set background color of search field to something redish @@ -75,28 +76,29 @@ public class UserListWindow extends UserListWindowLayout { } }); - // ActionListener for the two buttons - final ActionListener al = new ActionListener() { + // ActionListener for the two buttons + final ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if ("Set".equals(e.getActionCommand())) { + if ("Set".equals(e.getActionCommand())) { final UserInfo user = userTable.getSelectedItem(); - if (user == null) return; + if (user == null) + return; callback.userAdded(user); - } - if ("Cancel".equals(e.getActionCommand())) { - setVisible(false); - dispose(); - } + } + if ("Cancel".equals(e.getActionCommand())) { + setVisible(false); + dispose(); + } } }; setButton.setActionCommand("Set"); setButton.addActionListener(al); - cancelButton.setActionCommand("Cancel"); - cancelButton.addActionListener(al); - getRootPane().setDefaultButton(setButton); + cancelButton.setActionCommand("Cancel"); + cancelButton.addActionListener(al); + getRootPane().setDefaultButton(setButton); - userTable.addMouseListener(new MouseAdapter() { + userTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { @@ -104,6 +106,7 @@ public class UserListWindow extends UserListWindowLayout { } } }); + this.setLocationRelativeTo(modalParent); } public static void open(Frame modalParent, final UserAddedCallback callback) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/UserListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/UserListWindowLayout.java index 3548d61a..c3c5e228 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/UserListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/UserListWindowLayout.java @@ -18,13 +18,13 @@ import javax.swing.JTextField; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.UserInfo; -import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.table.UserTable; import org.openslx.dozmod.gui.helper.GridPos; /** * Credits for the first steps: - * https://docs.oracle.com/javase/tutorial/uiswing/examples/components/ListDialogRunnerProject/src/components/ListDialog.java + * https://docs.oracle.com/javase/tutorial/uiswing/examples/components/ + * ListDialogRunnerProject/src/components/ListDialog.java * * Adapted to use our UserInfo class */ @@ -34,9 +34,9 @@ public class UserListWindowLayout extends JDialog { private static final Logger LOGGER = Logger.getLogger(UserListWindowLayout.class); - public interface UserAddedCallback { - void userAdded(final UserInfo user); - } + public interface UserAddedCallback { + void userAdded(final UserInfo user); + } protected final UserTable userTable; @@ -46,42 +46,42 @@ public class UserListWindowLayout extends JDialog { private static String title = "Benutzerliste"; - protected UserListWindowLayout(Frame modalParent) { - super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); - - cancelButton = new JButton("Schliessen"); - setButton = new JButton("Hinzufügen"); - - userTable = new UserTable(); - - JPanel listPane = new JPanel(); - listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); - listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); - listPane.add(new JScrollPane(userTable)); - - // spaced buttons - JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); - buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); - buttonPane.add(Box.createHorizontalGlue()); - buttonPane.add(cancelButton); - buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); - buttonPane.add(setButton); - - // filter stuff - JPanel filterPanel = new JPanel(new GridBagLayout()); - searchUserField = new JTextField(); - filterPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10)); - filterPanel.add(new JLabel("Suchen: "), GridPos.get(0, 0, false, false)); - filterPanel.add(searchUserField, GridPos.get(1, 0, true, true)); - - // pack it all - Container contentPane = getContentPane(); - contentPane.add(filterPanel, BorderLayout.NORTH); - contentPane.add(listPane, BorderLayout.CENTER); - contentPane.add(buttonPane, BorderLayout.PAGE_END); - setPreferredSize(new Dimension(200, 300)); - pack(); - Gui.centerShellOverShell(modalParent, this); - } + protected UserListWindowLayout(Frame modalParent) { + super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL + : ModalityType.MODELESS); + + cancelButton = new JButton("Schließen"); + setButton = new JButton("Hinzufügen"); + + userTable = new UserTable(); + + JPanel listPane = new JPanel(); + listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); + listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + listPane.add(new JScrollPane(userTable)); + + // spaced buttons + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); + buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + buttonPane.add(Box.createHorizontalGlue()); + buttonPane.add(cancelButton); + buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); + buttonPane.add(setButton); + + // filter stuff + JPanel filterPanel = new JPanel(new GridBagLayout()); + searchUserField = new JTextField(); + filterPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); + filterPanel.add(new JLabel("Suchen: "), GridPos.get(0, 0, false, false)); + filterPanel.add(searchUserField, GridPos.get(1, 0, true, true)); + + // pack it all + Container contentPane = getContentPane(); + contentPane.add(filterPanel, BorderLayout.NORTH); + contentPane.add(listPane, BorderLayout.CENTER); + contentPane.add(buttonPane, BorderLayout.PAGE_END); + setPreferredSize(new Dimension(300, 350)); + pack(); + } } |