📄 smartticket.java
字号:
startLoading(true, getMsg(MessageConstants.MOVIES)); } else if (d == accountForm) { if (c == cancelCmd) { display.setCurrent(splashCanvas); return; } try { accountForm.validateAll(); } catch (Exception e) { Alert a = createAlert(getMsg(MessageConstants.ERROR)); a.setString(e.getMessage()); display.setCurrent(a, accountForm); return; } session.message = MessageConstants.CREATE_USER; nextScreen = splashCanvas; previousScreen = accountForm; alertScreen = createAlert(getMsg(MessageConstants.HAVE_ACCOUNT)); startLoading(false, getMsg(MessageConstants.CREATING_USER)); } else if (d == movieList) { if (c == backCmd) { display.setCurrent(signedInForm); return; } if (session.previewMode == AccountForm.PREVIEW_NONE) { session.message = MessageConstants.DISPLAY_LOCATIONS; nextScreen = locationList; previousScreen = movieList; startLoading(true, getMsg(MessageConstants.LOADING_LOCS)); } else { session.message = MessageConstants.DISPLAY_POSTER; nextScreen = posterCanvas; previousScreen = movieList; startLoading(true, getMsg(MessageConstants.LOADING_POSTER)); } } else if (d == posterCanvas) { if (c == backCmd) { display.setCurrent(movieList); return; } session.message = MessageConstants.DISPLAY_LOCATIONS; nextScreen = locationList; previousScreen = movieList; startLoading(true, getMsg(MessageConstants.LOADING_LOCS)); } else if (d == locationList) { if (c == backCmd) { display.setCurrent(movieList); return; } session.message = MessageConstants.DISPLAY_SHOWTIMES; nextScreen = showtimeList; previousScreen = locationList; startLoading(true, getMsg(MessageConstants.LOADING_SHOWTIMES)); } else if (d == showtimeList) { if (c == backCmd) { display.setCurrent(locationList); return; } session.message = MessageConstants.DISPLAY_SEATINGPLAN; nextScreen = seatingCanvas; previousScreen = showtimeList; startLoading(true, getMsg(MessageConstants.LOADING_PLAN)); } else if (d == seatingCanvas) { if (c == cancelCmd) { display.setCurrent(showtimeList); return; } session.message = MessageConstants.RESERVE_SEATS; nextScreen = confirmForm; previousScreen = seatingCanvas; startLoading(false, getMsg(MessageConstants.RESERVING_SEATS)); } else if (d == confirmForm) { if (c == cancelCmd) { session.message = MessageConstants.CANCEL_SEATS; nextScreen = movieList; previousScreen = confirmForm; alertScreen = createAlert(getMsg(MessageConstants.PURCHASE_CANCELLED)); startLoading(false, getMsg(MessageConstants.CANCELLING_PURCHASE)); return; } // check that we have the last 4 digits if (confirmForm.getCreditCardCheck().length() < 4) { return; } session.message = MessageConstants.CONFIRM_SEATS; nextScreen = splashCanvas; previousScreen = confirmForm; alertScreen = createAlert(getMsg(MessageConstants.THANK_YOU)); startLoading(false, getMsg(MessageConstants.CONFIRMING_PURCHASE)); } } /* Helper methods. */ /** * Load the base servlet URL. This URL is concatenated with the * session id at login time. Subsequent logins use the base URL. */ String getBaseServletURL() { return getAppProperty("SMARTicket-Servlet-URL"); } /** * Start an operation that requires a separate thread. * * @param stoppable indicates whether the operation can be stopped * by the user. * @param title the title of the progress gauge to show to the user. * @see stopLoading() */ void startLoading(boolean stoppable, String title) { gaugeForm.init(title, stoppable); display.setCurrent(gaugeForm); new Thread(session).start(); } /** * Finish the operation that required a separate thread. * * @see startLoading(Runnable, boolean, String), stopLoading(Exception) */ public void stopLoading() { if (alertScreen != null) { display.setCurrent(alertScreen, nextScreen); alertScreen = null; } else { display.setCurrent(nextScreen); } previousScreen = null; nextScreen = null; } /** * Finish the operation that required a separate thread, but ended * prematurely (either because it was stopped or encountered an exception.) * * @see startLoading(Runnable, boolean, String), stopLoading() */ public void stopLoading(Exception e) { if (gaugeForm.stopped) { display.setCurrent(previousScreen); return; } Alert alert = createAlert(e.getMessage() != null ? e.getMessage() : getMsg(MessageConstants.CANNOT_CONNECT)); display.setCurrent(alert, previousScreen); } /** * Create an alert with the given message. */ Alert createAlert(String message) { Alert result = new Alert(getMsg(MessageConstants.SMART_TICKET)); result.setTimeout(Alert.FOREVER); result.setString(message); return result; } /** * Update the progress gauge with the given value. */ public void updateGauge(int value) throws ApplicationException { gaugeForm.update(value); } /** * Initialize the table of localized messages. */ private void initMsg() { msgTab = new String[MessageConstants.NUM_MSG]; DataInputStream isr = null; try { RecordStore rs = session.openMessageStore(false); if (rs != null && locale.equals(new String(rs.getRecord(1))) == false) { isr = new DataInputStream( new ByteArrayInputStream(rs.getRecord(2))); } else { InputStream is = getClass().getResourceAsStream("/default.properties"); isr = new DataInputStream(is); } if (isr != null) { int c, idx; int i = 0, msgid = 0; byte cb[] = new byte[1]; byte buf[] = new byte[100]; String l; while ((c = isr.read(cb, 0, 1)) != -1) { // Consider both \n and \r to be line terminators. // Hopefully that covers all platforms. Note that // we ignore any line not containing an "=", and // that includes empty lines. if (cb[0] == (byte)'\n' || cb[0] == '\r') { l = new String(buf, 0, i); i = 0; idx = l.indexOf('='); if (idx > 0) { msgTab[msgid++] = l.substring(idx+1); } } else { buf[i++] = cb[0]; } } } } catch (Exception e) { // do nothing } } /** * Return the localized message for the given key. */ protected static String getMsg(int key) { return msgTab[key] != null ? msgTab[key] : "General application error"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -