public void onClick(ClickEvent event) { ChangePasswordDialog changePasswordDialog = new ChangePasswordDialog(UserRolesAdminPanelController.this); changePasswordDialog.show(); }
protected void okPressed() { String user = connectionDetails.getUserId(); String password = connectionDetails.getPassword(); UsersClient usersClient = new UsersClient(); try { usersClient.authenticate(user, password); } catch (Exception e) { MessageDialog.openError(getShell(), "Authentication Failed", e.getMessage()); setReturnCode(RETURN_CODE_ERROR); return; } // authentication successful. close the login dialog and open the next one. close(); IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean showClusterSelectionDialog = preferenceStore.getBoolean(PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG); // If the password is default, Let user to change the password if (password.equalsIgnoreCase(CoreConstants.DEFAULT_PASSWORD)) { ChangePasswordDialog dialog = new ChangePasswordDialog(getShell()); if (dialog.open() == Dialog.CANCEL) { MessageDialog.openError( getShell(), "Change password Cancelled", "Password must be changed on first login!" + CoreConstants.NEWLINE + "Application will close."); cancelPressed(); return; } // after first login, cluster selection dialog must be shown. showClusterSelectionDialog = true; } ClustersClient clustersClient = new ClustersClient(); CLUSTER_MODE mode; String clusterName = null; if (!showClusterSelectionDialog) { clusterName = preferenceStore.getString(PreferenceConstants.P_DEFAULT_CLUSTER_NAME); if (clusterName == null || clusterName.isEmpty()) { // Cluster name not available in preferences. Hence we must show the cluster selection // dialog. showClusterSelectionDialog = true; } else { mode = CLUSTER_MODE.SELECT; } } String serverName = null; if (showClusterSelectionDialog) { ClusterSelectionDialog clusterDialog = new ClusterSelectionDialog(getParentShell(), clustersClient.getClusterNames()); int userAction = clusterDialog.open(); if (userAction == Window.CANCEL) { MessageDialog.openError( getShell(), "Login Cancelled", "User cancelled login at cluster selection. Application will close!"); cancelPressed(); return; } mode = clusterDialog.getClusterMode(); clusterName = clusterDialog.getClusterName(); serverName = clusterDialog.getServerName(); } else { mode = CLUSTER_MODE.SELECT; } try { createOrRegisterCluster(clustersClient, clusterName, serverName, mode); final String clusterName1 = clusterName; new ProgressMonitorDialog(getShell()) .run( true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { GlusterDataModelManager.getInstance().initializeModel(clusterName1, monitor); } }); super.okPressed(); } catch (Exception e) { String errMsg; if (e instanceof InvocationTargetException) { errMsg = ((InvocationTargetException) e).getTargetException().getMessage(); } else { errMsg = e.getMessage(); } setReturnCode(RETURN_CODE_ERROR); MessageDialog.openError(getShell(), "Gluster Management Console", errMsg); } }