예제 #1
0
    @Override
    public void actionPerformed(ActionEvent arg0) {
      BoundaryAuthenticationDialog authenticationDialog = new BoundaryAuthenticationDialog(frame);
      authenticationDialog.setVisible(true);

      // Get results from login dialog
      if (authenticationDialog.isSucceeded()) {
        // If successfully logged in
        boolean isTenant = Session.getSessionInstance().isTenant();
        boolean isLandLord = Session.getSessionInstance().isLandLord();

        if (isLandLord) {
          // User authenticated as landlord
          if (!isTenant) {
            // LandLord, not Tenant
            if (confirmRegTenantMessage() == JOptionPane.YES_OPTION) {
              // Register as Tenant
              LandLord landLord = (LandLord) Session.getSessionInstance().getCustomer();
              try {
                Save.getInstance().deleteUser(landLord.getEmail());
                landLord.setTenant(true);
                Save.getInstance().insertCustomer(landLord);
                successfulRegistrationMessage();
              } catch (ClassNotFoundException | IOException e) {
                fileReadErrorMessage();
              } catch (AlreadyRegisteredException e) {
                alreadyRegisteredMessage();
              } catch (FileException e) {
                fileReadErrorMessage();
              } catch (UserNotFoundException e) {
                userNotFoundMessage();
              }
            }
          } else {
            // LandLord and Tenant
            // Cannot register
            errorMessage();
          }
        } else {
          if (isTenant) {
            // User authenticated as tenant
            if (confirmRegLandLordMessage() == JOptionPane.YES_OPTION) {
              // Register as Tenant
              BoundaryIbanDialog ibanDialog = new BoundaryIbanDialog(frame);
              ibanDialog.setVisible(true);
            }
          } else {
            // Administrator or scout or others
            errorMessage();
          }
        }
      }
    }
예제 #2
0
    @Override
    public void actionPerformed(ActionEvent e) {
      BoundaryLoginDialog loginDialog = new BoundaryLoginDialog(frame);
      loginDialog.setVisible(true);

      // Get results from login dialog
      if (loginDialog.isSucceeded()) {
        // If successfully logged in
        boolean isTenant = Session.getSessionInstance().isTenant();
        boolean isLandLord = Session.getSessionInstance().isLandLord();
        boolean isAdministrator = Session.getSessionInstance().isAdministrator();
        boolean isScout = Session.getSessionInstance().isScout();

        if (isLandLord) {
          // User authenticated as landlord
          BoundaryLandLordDialog landDialog = new BoundaryLandLordDialog(frame);
          landDialog.setVisible(true);
          // Logout when user exit dialog
          Session.getSessionInstance().logout();
        } else {
          if (isTenant) {
            // User authenticated as tenant
            BoundaryTenantDialog tenantDialog = new BoundaryTenantDialog(frame);
            tenantDialog.setVisible(true);
            // Logout when user exit dialog
            Session.getSessionInstance().logout();
          } else if (isAdministrator) {
            // User authenticated as administrator
            BoundaryAdministratorDialog adminDialog = new BoundaryAdministratorDialog(frame);
            adminDialog.setVisible(true);
            // Logout when user exit dialog
            Session.getSessionInstance().logout();
          } else if (isScout) {
            // User authenticated as scout
            BoundaryScoutDialog scoutDialog;
            do {
              scoutDialog = new BoundaryScoutDialog(frame);
              scoutDialog.setVisible(true);
            } while (scoutDialog.isReloadDialog());
            // Logout when user exit dialog
            Session.getSessionInstance().logout();
          }
        }
      }
    }