/** * Process the "Back" toolbar command. * @return true if successful. */ public boolean onBack() { BasePanel parent = this.getParentScreen(); if (parent == null) return false; parent.popHistory(1, false); // Pop command for this screen String strLastCommand = parent.popHistory(1, false); if (strLastCommand != null) // I don't back up into the browser history if the user hit the java back button. { // If that wasn't the first screen, redo pop and update the browser this time parent.pushHistory(strLastCommand, false); strLastCommand = parent.popHistory(1, true); } if ((strLastCommand == null) || (strLastCommand.length() == 0)) { if (parent.getParentScreen() != null) if (!(parent.getParentScreen() instanceof FrameScreen)) return parent.onBack(); // ++Add++ No more to pop, display home screen (if push-down gets messed up) parent.pushHistory(this.getScreenURL(), false); // This is the first screen in the stack } else this.handleCommand(strLastCommand, this, ScreenConstants.USE_SAME_WINDOW | ScreenConstants.DONT_PUSH_TO_BROWSER); // Process the last command return true; // Handled } /**
/** * Get the environment to use for this record owner. * @return Record owner's environment, or null to use the default enviroment. */ public Task getTask() { return super.getTask(); } /**
/** * Lookup this record in this screen. * @param The file name of the record to find. * @param The record (or null if not found). */ public Record getRecord(String strFileName) { if (m_screenParent != null) return m_screenParent.getRecord(strFileName); // Look thru the parent window now else return null; } /**
/** * Get the environment to use for this record owner. * @return Record owner's environment, or null to use the default enviroment. */ public Task getTask() { if (this.getParentScreen() != null) return this.getParentScreen().getTask(); return null; // Never } /**
/** * Get the top applet screen. * @return The applet screen. */ public AppletScreen getAppletScreen() { // The root window is the ChildScreen if (this.getParentScreen() != null) return getParentScreen().getAppletScreen(); else return null; // This is the top level screen! } /**
/** * This is a special method that runs some code when this screen is opened as a task. */ public void run() { int iSFieldCount = this.getSFieldCount(); // Keep out of loop because of chance of free() during run() for (int iFieldSeq = 0; iFieldSeq < iSFieldCount; iFieldSeq++) { // See if any of my children want to handle this command ScreenField sField = this.getSField(iFieldSeq); if (sField instanceof BasePanel) // Run every basepanel { ((BasePanel)sField).run(); } } } /**
/** * Process the command. * <br />Step 1 - Process the command if possible and return true if processed. * <br />Step 2 - If I can't process, pass to all children (with me as the source). * <br />Step 3 - If children didn't process, pass to parent (with me as the source). * <br />Note: Never pass to a parent or child that matches the source (to avoid an endless loop). * @param strCommand The command to process. * @param sourceSField The source screen field (to avoid echos). * @param iCommandOptions If this command creates a new screen, create in a new window? * @return true if success. */ public boolean doCommand(String strCommand, ScreenField sourceSField, int iCommandOptions) { if ((strCommand.equalsIgnoreCase(MenuConstants.FORM)) || (strCommand.equalsIgnoreCase(MenuConstants.FORMLINK))) { BasePanel parentScreen = this.getParentScreen(); if (parentScreen != null) { parentScreen.popHistory(1, false); parentScreen.pushHistory(this.getScreenURL(), false); // Push this screen onto history stack } return (this.onForm(null, ArTrx.REFUND_SCREEN, true, iCommandOptions, null) != null); } else return super.doCommand(strCommand, sourceSField, iCommandOptions); }
/** * Save the current value of this field to the registration database. * and change the URL on the push-down stack to take this into consideration. */ public void saveValue(BasePanel recordOwner) { if (recordOwner != null) { BaseField field = this.getOwner(); String strCommand = ((BasePanel)recordOwner).getParentScreen().popHistory(1, false); if (m_recordOwnerCache != null) if (strCommand != null) if (strCommand.indexOf(m_recordOwnerCache.getClass().getName()) != -1) { // Yes this is the command to open this window Map<String,Object> properties = new Hashtable<String,Object>(); Util.parseArgs(properties, strCommand); properties.put(field.getFieldName(), field.toString()); strCommand = Utility.propertiesToURL(null, properties); } ((BasePanel)recordOwner).getParentScreen().pushHistory(strCommand, false); } } }
/** * Process the "Help" toolbar command. * @param bUseSameWindow Use the same window? * @retrun true if successful. */ public boolean onHelp(int iOptions) { String strPrevAction = this.getScreenURL(); if ((strPrevAction == null) || (strPrevAction.length() == 0)) return false; // Can't handle help if I'm not the target screen. // Note: The following is a hack to make the demo screen stop displaying after the first help is pressed if (this.getProperty("displayInitialHelp") != null) if ((this.getProperty("helplanguage") != null) && (this.getProperty("helplanguage").length() > 0)) if (this.getTask() != null) if (this.getTask().getApplication() != null) this.getTask().getApplication().setProperty("helplanguage", this.getTask().getApplication().getLanguage(true)); strPrevAction = Utility.fixDisplayURL(strPrevAction, true, true, true, this); BaseApplet applet = null; if (this.getAppletScreen() != null) if (this.getAppletScreen().getScreenFieldView() != null) applet = (BaseApplet)this.getAppletScreen().getScreenFieldView().getControl(); if (applet != null) iOptions = applet.getHelpPageOptions(iOptions); if ((MenuConstants.HELP_WEB_OPTION & iOptions) == MenuConstants.HELP_WEB_OPTION) return this.getScreenFieldView().showDocument(strPrevAction, iOptions & 1); // Not standalone else return this.getAppletScreen().showHelpScreen(strPrevAction, iOptions); } /**
/** * Free all the child sFields. * @param bIncludeToolScreens If true, also free the toolScreens. */ public void freeAllSFields(boolean bIncludeToolScreens) { int iToolScreens = 0; while (this.getSFieldCount() > iToolScreens) { // First, get rid of all child screens. ScreenField sField = this.getSField(iToolScreens); if ((!bIncludeToolScreens) && (sField instanceof ToolScreen)) iToolScreens++; else sField.free(); } } /**
/** * Process the "Home" command. * @return true if successful. */ public boolean onHome() { if (!(this instanceof BaseScreen)) return false; // This can only be called from the main screen BasePanel screenParent = this.getParentScreen(); int count = 0; while (screenParent.popHistory(1, false) != null) { // Pop all the history. count++; } count--; // Want to move back to the first one if (count > 0) screenParent.popHistory(count, true); // Dump all browser history String strLastCommand = Utility.addURLParam(null, Params.MENU, Constant.BLANK); //"?menu="; // Blank command = home this.handleCommand(strLastCommand, this, ScreenConstants.USE_SAME_WINDOW | ScreenConstants.DONT_PUSH_TO_BROWSER); // Process the last command in this window return true; // Handled } /**
/** * User clicked to button to add the booking passengers to the profile. */ public int doCommand(boolean bDisplayOption, int iMoveMode) { BookingPax recBookingPax = (BookingPax)m_screenParent.getRecord(BookingPax.BOOKING_PAX_FILE); Profile recProfile = (Profile)m_screenParent.getRecord(Profile.PROFILE_FILE); Profile recProfileDetail = (Profile)((ReferenceField)recBookingPax.getField(BookingPax.PROFILE_ID)).getReferenceRecord(); recBookingPax.addPaxDetail(recBookingPax, recProfileDetail); // Now create the maint screen for this new record if (recProfileDetail.getEditMode() == DBConstants.EDIT_CURRENT) { BasePanel parentScreen = Screen.makeWindow(m_screenParent.getTask().getApplication()); ScreenParent screen = recProfileDetail.makeScreen(null, parentScreen, ScreenConstants.MAINT_MODE, true, true, true, true, null); } return DBConstants.NORMAL_RETURN; }
/** * Constructor. * @param record The main record for this screen. * @param itsLocation The location of this component within the parent. * @param parentScreen The parent screen. * @param fieldConverter The field this screen field is linked to. * @param iDisplayFieldDesc Do I display the field desc?. */ public void init(Record record, ScreenLocation itsLocation, BasePanel parentScreen, Converter fieldConverter, int iDisplayFieldDesc, Map<String,Object> properties) { parentScreen.setProperty(BookingScreenHandler.SUB_SCREEN_PARAM, Integer.toString(BookingScreenHandler.CRUISE_SCREEN)); super.init(record, itsLocation, parentScreen, fieldConverter, iDisplayFieldDesc, properties); } /**
while (parentScreen.popHistory(1, false) != null) parentScreen.popHistory(count, true); // Dump all browser history BaseScreen screen = null; BaseField useAgency = null; screen = new BookingAgencyScreen(null, screenLocation, parentScreen, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC | ScreenConstants.DONT_PUSH_TO_BROWSER, properties);break; case PAX_SCREEN: // Pax display if ( parentScreen.getRecord(Booking.BOOKING_FILE).getField(Booking.PAX).getValue() == 0) screen = new BookingPaxScreen(null, screenLocation, parentScreen, null, ScreenConstants.DONT_DISPLAY_FIELD_DESC | ScreenConstants.DONT_PUSH_TO_BROWSER, properties); else
/** * Pop a command off the history stack. * @return The command at the top of the history stack or null if empty. */ public String popHistory() { return this.popHistory(1, true); } /**
/** * Pop this command off the history stack. * NOTE: Do not use this method in most cases, use the method in BaseApplet. * @return The history command on top of the stack. */ public String popHistory(int quanityToPop, boolean bPopFromBrowser) { String strHistory = null; for (int i = 0; i < quanityToPop; i++) { strHistory = null; if (m_vHistory != null) if (m_vHistory.size() > 0) strHistory = (String)m_vHistory.remove(m_vHistory.size() - 1); } if (bPopFromBrowser) if (this.getAppletScreen() != null) if (this.getAppletScreen().getTask() instanceof BaseAppletReference) ((BaseAppletReference)this.getAppletScreen().getTask()).popBrowserHistory(quanityToPop, strHistory != null, this.getTitle()); // Let browser know about the new screen return strHistory; } /**
/** * Get the main record for this screen. * @return The main record. */ public Record getMainRecord() { if (m_screenParent != null) return m_screenParent.getMainRecord(); // Look thru the parent window now else return null; } /**
/** * Process the Refresh Command. * @return true if successful. */ public boolean onRefresh() { Record record = this.getMainRecord(); if (record == null) return false; try { if (record.getEditMode() == Constants.EDIT_IN_PROGRESS) { // If they're adding, can't delete nothing! if (record.isRefreshedRecord()) return this.onDelete(); Object bookmark = record.getHandle(DBConstants.BOOKMARK_HANDLE); record.setHandle(bookmark, DBConstants.BOOKMARK_HANDLE); } if (record.getEditMode() == Constants.EDIT_ADD) record.addNew(); this.clearStatusText(); } catch (DBException ex) { this.displayError(ex); return false; } return true; } /**
/** * Process the "Delete" toolbar command. * @return true If command was handled */ public boolean onDelete() { Record record = this.getMainRecord(); if (record == null) return false; if (record.getEditMode() == Constants.EDIT_NONE) return true; if (record.getEditMode() == Constants.EDIT_ADD) { // If they're adding, can't delete nothing! this.onRefresh(); return true; } try { if (record.getEditMode() != Constants.EDIT_IN_PROGRESS) record.edit(); record.remove(); record.addNew(); this.clearStatusText(); } catch(DBException ex) { this.displayError(ex); return false; } return true; } /**
/** * Set up m_iScreenSeq so I can find this sub-screen. * @param subScreen The current sub-screen. */ public void setCurrentSubScreen(BasePanel subScreen) { m_screenParent = null; // Screen's parent m_iScreenSeq = -1; if (subScreen != null) m_screenParent = subScreen.getParentScreen(); // Screen's parent if (m_screenParent == null) if (this.getOwner() != null) if (this.getOwner().getRecord() != null) m_screenParent = (BaseScreen)this.getOwner().getRecord().getRecordOwner(); if (m_screenParent == null) if (this.getOwner() != null) if (this.getOwner().getSFieldAt(0) != null) m_screenParent = this.getOwner().getSFieldAt(0).getParentScreen(); if (m_screenParent == null) return; int iBestGuess = -1; for (m_iScreenSeq = 0; m_iScreenSeq < m_screenParent.getSFieldCount(); m_iScreenSeq++) { ScreenField sField = m_screenParent.getSField(m_iScreenSeq); if (sField == subScreen) return; // Found (m_iScreenSeq is correct) if (sField instanceof BaseScreen) iBestGuess = m_iScreenSeq; } m_iScreenSeq = iBestGuess; } public void setCurrentScreenNo(int iCurrentScreenNo)