2828
2929public class LoginPanel extends javax .swing .JFrame {
3030
31- private Client client ;
3231 private static final String ERROR_MESSAGE = "There was an error connecting to the server at the specified address. Please verify that the server is up and running." ;
3332 private static LoginPanel instance = null ;
3433
@@ -402,6 +401,7 @@ private void passwordActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST
402401 private void loginButtonActionPerformed (java .awt .event .ActionEvent evt )// GEN-FIRST:event_loginButtonActionPerformed
403402 {// GEN-HEADEREND:event_loginButtonActionPerformed
404403 errorPane .setVisible (false );
404+ LoginPanel loginPanel = this ;
405405
406406 SwingWorker <Void , Void > worker = new SwingWorker <Void , Void >() {
407407
@@ -410,7 +410,7 @@ public Void doInBackground() {
410410
411411 try {
412412 String server = serverName .getText ();
413- client = new Client (server , PlatformUI .HTTPS_PROTOCOLS , PlatformUI .HTTPS_CIPHER_SUITES );
413+ Client client = new Client (server , PlatformUI .HTTPS_PROTOCOLS , PlatformUI .HTTPS_CIPHER_SUITES );
414414 PlatformUI .SERVER_URL = server ;
415415
416416 // Attempt to login
@@ -435,8 +435,8 @@ public Void doInBackground() {
435435 // If SUCCESS or SUCCESS_GRACE_PERIOD
436436 if (loginStatus != null && loginStatus .isSuccess ()) {
437437 if (!Mirth .handleLoginSuccess (client , loginStatus , username .getText ())) {
438- LoginPanel . getInstance () .setVisible (false );
439- LoginPanel . getInstance () .initialize (PlatformUI .SERVER_URL , PlatformUI .CLIENT_VERSION , "" , "" );
438+ loginPanel .setVisible (false );
439+ loginPanel .initialize (PlatformUI .SERVER_URL , PlatformUI .CLIENT_VERSION , "" , "" );
440440 }
441441 } else {
442442 // Assume failure unless overridden by a plugin
@@ -454,8 +454,8 @@ public Void doInBackground() {
454454 if (loginStatus != null && loginStatus .isSuccess ()) {
455455 errorOccurred = false ;
456456 if (!Mirth .handleLoginSuccess (client , loginStatus , username .getText ())) {
457- LoginPanel . getInstance () .setVisible (false );
458- LoginPanel . getInstance () .initialize (PlatformUI .SERVER_URL , PlatformUI .CLIENT_VERSION , "" , "" );
457+ loginPanel .setVisible (false );
458+ loginPanel .initialize (PlatformUI .SERVER_URL , PlatformUI .CLIENT_VERSION , "" , "" );
459459 }
460460 }
461461 }
@@ -464,25 +464,16 @@ public Void doInBackground() {
464464
465465 if (errorOccurred ) {
466466 if (loginStatus != null ) {
467- errorTextArea . setText (loginStatus .getMessage ());
467+ setError (loginStatus .getMessage ());
468468 } else {
469- errorTextArea . setText (ERROR_MESSAGE );
469+ setError (ERROR_MESSAGE );
470470 }
471471 }
472472 } catch (Throwable t ) {
473- errorOccurred = true ;
474- errorTextArea .setText (ERROR_MESSAGE );
473+ setError (ERROR_MESSAGE );
475474 t .printStackTrace ();
476475 }
477476
478- if (errorOccurred ) {
479- errorPane .setVisible (true );
480- loggingIn .setVisible (false );
481- loginMain .setVisible (true );
482- loginProgress .setIndeterminate (false );
483- password .grabFocus ();
484- }
485-
486477 return null ;
487478 }
488479
@@ -509,6 +500,15 @@ public void setStatus(String status) {
509500 this .status .setText ("Please wait: " + status );
510501 }
511502
503+ public void setError (String status ) {
504+ errorTextArea .setText (status );
505+ errorPane .setVisible (true );
506+ loggingIn .setVisible (false );
507+ loginMain .setVisible (true );
508+ loginProgress .setIndeterminate (false );
509+ password .grabFocus ();
510+ }
511+
512512 // Variables declaration - do not modify//GEN-BEGIN:variables
513513 private javax .swing .JButton closeButton ;
514514 private javax .swing .JScrollPane errorPane ;
0 commit comments