📄 uicontroller.java
字号:
} else { String userName = accountInfo.getUserName(); String password = accountInfo.getPassword(); if (preferences.isSilentlyLoggingIn() && userName != null && password != null) { signOn(authorizedRunnable, userName, password); } else { signOnUI.init(authorizedRunnable); showInfoAlert( // getString(UIMessageCodes.SIGN_IN_FIRST), // getString(UIMessageCodes.SIGN_IN_FIRST_LONG), "Sign in first", "You must sign in first", signOnUI); } } } /** * Callback after user signs on, and finally executes the given * runnable. */ public void signOn(final Runnable authorizedRunnable, final String userName, final String password) { Thread thread = new Thread() { public void run() { try { model.login(userName, password); authorizedRunnable.run(); } catch (ApplicationException ae) { if (authorizedRunnable instanceof EventDispatcher) { showErrorAlert(ae, ((EventDispatcher) authorizedRunnable).fallbackUI); } else { showErrorAlert(ae, signOnUI); } } catch (Exception e) { showErrorAlert(e); } } }; runWithProgress(thread, // getString(UIMessageCodes.SIGNING_IN), "Signing in...", false); } public void mainMenuRequested() { display.setCurrent(mainMenuUI); } public void mySettingsRequested() { display.setCurrent(mySettingsUI); } public void accountSetupRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_ACCOUNTSETUPREQUESTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void accountSetupSaved(AccountInfo accountInfo, Preferences preferences) { newAccountInfo = accountInfo; newPreferences = preferences; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_ACCOUNTSETUPSAVED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void preferencesExited() { mySettingsRequested(); } public void preferencesSaved(Preferences preferences) { newPreferences = preferences; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_PREFERENCESSAVED, mySettingsUI), getString(UIConstants.PROCESSING), false); } public void changePasswordRequested() { if (accountInfo == null) { accountInfo = new AccountInfo(); accountInfoUI.init(accountInfo); } changePasswordUI.init(accountInfo); display.setCurrent(changePasswordUI); } public void manageTheaterSchedulesRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_MANAGETHEATERSCHEDULESREQUESTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void accountInfoRequested() { if (accountInfo == null) { accountInfo = new AccountInfo(); } accountInfoUI.init(accountInfo); display.setCurrent(accountInfoUI); } public void billingInfoSaved(AccountInfo accountInfo) { newAccountInfo = accountInfo; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_ACCOUNTINFOSAVED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void accountInfoSaved(AccountInfo accountInfo) { newAccountInfo = accountInfo; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_ACCOUNTINFOSAVED, mySettingsUI), getString(UIConstants.PROCESSING), false); } public void defaultsRequested() { defaultsUI.init(preferences); display.setCurrent(defaultsUI); } public void rateMyMoviesRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_RATEMYMOVIESREQUESTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void rateMyMoviesSyncRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_MOVIE_RATINGS_SYNC_REQUESTED, rateMyMoviesUI), getString(UIConstants.PROCESSING), false); } public void rateMyMoviesSaveRequested(MovieRating[] movieRatings) { selectedMovieRatings = movieRatings; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_MOVIE_RATINGS_SAVE_REQUESTED, rateMyMoviesUI), getString(UIConstants.PROCESSING), false); } public void rateMyMoviesDeleteRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_MOVIE_RATING_DELETE_REQUESTED, rateMyMoviesUI), getString(UIConstants.PROCESSING), false); } public void rateMyMoviesResolutionRequested(MovieRating[] movieRatings) { resolvedMovieRatings = movieRatings; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_MOVIE_RATINGS_RESOLUTION_REQUESTED, rateMyMoviesUI), getString(UIConstants.PROCESSING), false); } public void chooseMovieRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_CHOOSEMOVIEREQUESTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void lookupTheaterSchedule(Theater theater, int selection) { selectedTheater = theater; theaterSelection = selection; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_LOOKUPTHEATERSCHEDULE, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void downloadTheaterSchedule(Theater theater) { selectedTheater = theater; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_DOWNLOADTHEATERSCHEDULE, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void theaterScheduleDeletionRequested(Theater theater) { try { model.deleteTheater(theater.getPrimaryKey()); manageTheaterSchedulesRequested(); } catch (ApplicationException e) { System.err.println("Exception " + e); } } public void selectSeatsSelected(TheaterSchedule.MovieSchedule movieSchedule, int[] showTime) { selectedShowTime = showTime; selectedMovie = movieSchedule.getMovie(); selectedMovieSchedule = movieSchedule; runWithProgress(new EventDispatcher(EventIds.EVENT_ID_SELECTSEATSSELECTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void seatsSelected(Seat[] seats) { selectedSeats = seats; /* * runWithProgress( * new EventDispatcher(EventIds.EVENT_ID_SEATSSELECTED, mainMenuUI), * getString(UIConstants.PROCESSING), false); */ signOn(new EventDispatcher(EventIds.EVENT_ID_SEATSSELECTED, seatingPlanUI)); } public void signOnConfirmed() { confirmTicketUI.init(selectedTheater.getName(), selectedMovie.getTitle(), selectedShowTime, selectedSeats); display.setCurrent(confirmTicketUI); } public void purchaseRequested() { runWithProgress(new EventDispatcher(EventIds.EVENT_ID_PURCHASEREQUESTED, mainMenuUI), getString(UIConstants.PROCESSING), false); } public void exitRequested() { System.out.println("Bye Bye"); // FIXME - Not yet implemented. } class EventDispatcher extends Thread { private int taskId; private Displayable fallbackUI; EventDispatcher(int taskId, Displayable fallbackUI) { this.taskId = taskId; this.fallbackUI = fallbackUI; return; } public void run() { try { switch (taskId) { case EventIds.EVENT_ID_ACCOUNTSETUPREQUESTED: { AccountInfo accountInfo = new AccountInfo(); accountSetupUI.init(accountInfo, preferences); display.setCurrent(accountSetupUI); break; } case EventIds.EVENT_ID_ACCOUNTSETUPSAVED: { model.createAccount(newAccountInfo); model.setPreferences(newPreferences); accountInfo = newAccountInfo; preferences = newPreferences; billingInfoUI.init(accountInfo); display.setCurrent(billingInfoUI); break; } case EventIds.EVENT_ID_PREFERENCESSAVED: { model.setPreferences(newPreferences); preferences = newPreferences; preferencesExited(); break; } case EventIds.EVENT_ID_MANAGETHEATERSCHEDULESREQUESTED: { // will it possible preference is null? Theater[] theaterList = getTheaterList(); if (theaterList == null) { showErrorAlert(getString(UIConstants.NO_ZIP_ERROR), mainMenuUI); } else { manageTheaterSchedulesUI.init(theaterList, model.getPersistedTheaters(null)); display.setCurrent(manageTheaterSchedulesUI);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -