Search in sources :

Example 1 with DialogCompleteWithResponse

use of org.exist.client.DialogCompleteWithResponse in project exist by eXist-db.

the class UserManagerDialog method showEditUserDialog.

private void showEditUserDialog(final Account account) {
    final UserManagerDialog that = this;
    final DialogCompleteWithResponse<String> callback = response -> {
        // get client to reconnect with edited users new password
        try {
            System.out.println("Detected logged-in user password change, reconnecting to server...");
            that.userManagementService = reconnectClientAndUserManager(response);
            System.out.println("Reconnected.");
        } catch (final XMLDBException xmldbe) {
            JOptionPane.showMessageDialog(that, "Could not edit user '" + getSelectedUsername() + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
        }
    };
    final EditUserDialog userDialog = new EditUserDialog(userManagementService, account);
    if (getSelectedUsername().equals(currentUser)) {
        // register for password update event, if we are changing the password
        // of the current user
        userDialog.addDialogCompleteWithResponseCallback(callback);
    }
    userDialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(final WindowEvent e) {
            refreshUsersTableModel();
        }
    });
    userDialog.setVisible(true);
}
Also used : XMLDBException(org.xmldb.api.base.XMLDBException) Arrays(java.util.Arrays) Properties(java.util.Properties) HighlightedTableCellRenderer(org.exist.client.HighlightedTableCellRenderer) DefaultTableModel(javax.swing.table.DefaultTableModel) Group(org.exist.security.Group) AXSchemaType(org.exist.security.AXSchemaType) AccountComparator(org.exist.security.AccountComparator) DialogCompleteWithResponse(org.exist.client.DialogCompleteWithResponse) WindowAdapter(java.awt.event.WindowAdapter) JOptionPane(javax.swing.JOptionPane) WindowEvent(java.awt.event.WindowEvent) EXistSchemaType(org.exist.security.EXistSchemaType) Account(org.exist.security.Account) SecurityManager(org.exist.security.SecurityManager) InteractiveClient(org.exist.client.InteractiveClient) ClientFrame(org.exist.client.ClientFrame) UserManagementService(org.exist.xmldb.UserManagementService) TableModel(javax.swing.table.TableModel) WindowEvent(java.awt.event.WindowEvent) XMLDBException(org.xmldb.api.base.XMLDBException) WindowAdapter(java.awt.event.WindowAdapter)

Aggregations

WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 Arrays (java.util.Arrays)1 Properties (java.util.Properties)1 JOptionPane (javax.swing.JOptionPane)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1 TableModel (javax.swing.table.TableModel)1 ClientFrame (org.exist.client.ClientFrame)1 DialogCompleteWithResponse (org.exist.client.DialogCompleteWithResponse)1 HighlightedTableCellRenderer (org.exist.client.HighlightedTableCellRenderer)1 InteractiveClient (org.exist.client.InteractiveClient)1 AXSchemaType (org.exist.security.AXSchemaType)1 Account (org.exist.security.Account)1 AccountComparator (org.exist.security.AccountComparator)1 EXistSchemaType (org.exist.security.EXistSchemaType)1 Group (org.exist.security.Group)1 SecurityManager (org.exist.security.SecurityManager)1 UserManagementService (org.exist.xmldb.UserManagementService)1 XMLDBException (org.xmldb.api.base.XMLDBException)1