0001: /*
0002: *
0003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
0004: *
0005: * The contents of this file are subject to the SourceTap Public License
0006: * ("License"); You may not use this file except in compliance with the
0007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
0008: * Software distributed under the License is distributed on an "AS IS" basis,
0009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
0010: * the specific language governing rights and limitations under the License.
0011: *
0012: * The above copyright notice and this permission notice shall be included
0013: * in all copies or substantial portions of the Software.
0014: *
0015: */
0016:
0017: package com.sourcetap.sfa.ui;
0018:
0019: import java.util.ArrayList;
0020: import java.util.HashMap;
0021: import java.util.Iterator;
0022: import java.util.LinkedList;
0023: import java.util.List;
0024: import java.util.Vector;
0025:
0026: import org.ofbiz.base.util.Debug;
0027: import org.ofbiz.base.util.UtilTimer;
0028: import org.ofbiz.entity.GenericDelegator;
0029: import org.ofbiz.entity.GenericEntityException;
0030: import org.ofbiz.entity.GenericValue;
0031: import org.ofbiz.entity.model.ModelEntity;
0032:
0033: import com.sourcetap.sfa.event.DataBuffer;
0034: import com.sourcetap.sfa.event.DataMatrix;
0035: import com.sourcetap.sfa.util.DelimitedPairDecoder;
0036: import com.sourcetap.sfa.util.Preference;
0037: import com.sourcetap.sfa.util.UserInfo;
0038:
0039: /**
0040: * DOCUMENT ME!
0041: *
0042: */
0043: public abstract class UIScreenSection {
0044: public static final String module = UIScreenSection.class.getName();
0045: private static final boolean TIMER = false;
0046: public static final int LAYOUT_TYPE_UNDEFINED = 0;
0047: public static final int LAYOUT_TYPE_FREEFORM = 1;
0048: public static final int LAYOUT_TYPE_TABULAR = 2;
0049: public static final int LAYOUT_TYPE_CROSSTAB = 3;
0050: public static final int LAYOUT_TYPE_SELECT = 4;
0051: public static final int LAYOUT_TYPE_COMPOSITE = 5;
0052:
0053: // public static final int LAYOUT_TYPE_FREEFORM2 = 6;
0054: public static final String ACTION_BUTTON = "button";
0055: public static final String ACTION_COPY = "copy";
0056: public static final String ACTION_DELETE = "delete";
0057: public static final String ACTION_INSERT = "insert";
0058: public static final String ACTION_NONE = "none";
0059: public static final String ACTION_QUERY = "query";
0060: public static final String ACTION_QUERY_UPDATE = "queryUpdate";
0061: public static final String ACTION_QUERY_ALL = "queryAll";
0062: public static final String ACTION_UPDATE = "update";
0063: public static final String ACTION_UPDATE_SELECT = "updateSelect";
0064: public static final String ACTION_SHOW = "show";
0065: public static final String ACTION_SHOW_COPY = "showCopy";
0066: public static final String ACTION_SHOW_INSERT = "showInsert";
0067: public static final String ACTION_SHOW_QUERY = "showQuery";
0068: public static final String ACTION_SHOW_QUERY_REPORT = "showQueryReport";
0069: public static final String ACTION_SHOW_REPORT = "showReport";
0070: public static final String ACTION_SHOW_SELECT = "showSelect";
0071: public static final String ACTION_SHOW_UPDATE = "showUpdate";
0072: public static final String PREFERENCE_ROWS_PER_PAGE = "ROWS_PER_PAGE";
0073: protected int rowsPerPage = 0;
0074: protected String sectionId = "";
0075: protected String screenId = "";
0076: protected String sectionName = "";
0077: protected String sectionDescription = "";
0078: protected int layoutTypeId = 0;
0079: protected int displayOrder = 0;
0080: protected int columnCount = 0;
0081: protected int rowCount = 0;
0082: protected String buttonKeys = "";
0083: protected String sendQueryParameterList = "";
0084: protected String useQueryParameterList = "";
0085: protected HashMap sendQueryParameterMap = null;
0086: protected HashMap useQueryParameterMap = null;
0087: protected String titleDef = "";
0088: protected String sortDef = "";
0089: protected String searchAttributeId = "";
0090: protected String buttonAction = "";
0091: protected String buttonTarget = "";
0092: protected String detailButtonAction = "";
0093: protected String detailButtonTarget = "";
0094: protected String searchAction = "";
0095: protected String searchTarget = "";
0096: protected String newButtonAction = "";
0097: protected String newButtonTarget = "";
0098: protected String editButtonAction = "";
0099: protected String editButtonTarget = "";
0100: protected String hideButtons = "";
0101: protected String selectNameDef = "";
0102: protected boolean isUpdateable = false;
0103: protected UserInfo userInfo = null;
0104: protected GenericDelegator delegator;
0105: UIScreen uiScreen = null;
0106: List uiFieldList = new ArrayList();
0107: List uiScreenSectionEntityList = new ArrayList();
0108:
0109: public UIScreenSection(UserInfo userInfo, String screenName,
0110: String sectionName, GenericDelegator delegator,
0111: UICache uiCache) throws GenericEntityException {
0112: UtilTimer timer = new UtilTimer();
0113:
0114: if (TIMER) {
0115: timer.timerString(1,
0116: "[UIScreenSection.UIScreenSection] Start");
0117: }
0118:
0119: Debug.logVerbose(
0120: "-->[UIScreenSection.UIScreenSection] screenName: "
0121: + screenName, module);
0122: Debug.logVerbose(
0123: "-->[UIScreenSection.UIScreenSection] sectionName: "
0124: + sectionName, module);
0125:
0126: if (userInfo == null) {
0127: throw new GenericEntityException(
0128: "UserInfo passed in was null for UIScreenSection.");
0129: } else {
0130: setUserInfo(userInfo);
0131: }
0132:
0133: if (delegator == null) {
0134: throw new GenericEntityException(
0135: "GenericDelegator passed in was null for UIScreenSection.");
0136: } else {
0137: setDelegator(delegator);
0138: }
0139:
0140: if (screenName == null) {
0141: throw new GenericEntityException(
0142: "ScreenName passed in was null for UIScreenSection.");
0143: }
0144:
0145: if (sectionName == null) {
0146: throw new GenericEntityException(
0147: "SectionName passed in was null for UIScreenSection.");
0148: }
0149:
0150: // Get the uiScreen object.
0151: if (TIMER) {
0152: timer
0153: .timerString(1,
0154: "[UIScreenSection.UIScreenSection] Looking for UIScreen in cache.");
0155: }
0156:
0157: UIScreen uiScreen = uiCache.getUiScreen(screenName);
0158:
0159: if (uiScreen == null) {
0160: if (TIMER) {
0161: timer
0162: .timerString(
0163: 1,
0164: "[UIScreenSection.UIScreenSection] UIScreen not found in cache. Creating a new one.");
0165: }
0166:
0167: uiScreen = new UIScreen(screenName, delegator);
0168: uiCache.putUiScreen(screenName, uiScreen);
0169: } else {
0170: if (TIMER) {
0171: timer
0172: .timerString(1,
0173: "[UIScreenSection.UIScreenSection] Found UIScreen in cache.");
0174: }
0175: }
0176:
0177: setUiScreen(uiScreen);
0178:
0179: if (TIMER) {
0180: timer.timerString(1,
0181: "[UIScreenSection.UIScreenSection] Got screen");
0182: }
0183:
0184: // Get the uiScreenSection object.
0185:
0186: HashMap findHashMap = new HashMap();
0187: findHashMap.put("screenId", getUiScreen().getScreenId());
0188: findHashMap.put("sectionName", sectionName);
0189:
0190: List uiScreenSectionGVL = delegator.findByAnd(
0191: "UiScreenSection", findHashMap, null);
0192:
0193: if (uiScreenSectionGVL.size() == 0) {
0194: throw new GenericEntityException(
0195: "No screen section with name \"" + sectionName
0196: + "\" for screen \"" + screenName
0197: + "\" was found in database.");
0198: }
0199:
0200: if (uiScreenSectionGVL.size() > 1) {
0201: throw new GenericEntityException(
0202: "More than one screen section found with name \""
0203: + sectionName + "\" for screen \""
0204: + screenName + "\".");
0205: }
0206:
0207: Iterator uiScreenSectionGVI = uiScreenSectionGVL.iterator();
0208: GenericValue uiScreenSectionGV = (GenericValue) uiScreenSectionGVI
0209: .next();
0210:
0211: if (uiScreenSectionGV.get("layoutTypeId") == null) {
0212: throw new GenericEntityException(
0213: "Layout type not set for screen section \""
0214: + sectionName + "\".");
0215: }
0216:
0217: setSectionId(uiScreenSectionGV.getString("sectionId"));
0218: setScreenId(uiScreenSectionGV.getString("screenId"));
0219: setSectionName(uiScreenSectionGV.getString("sectionName"));
0220: setSectionDescription(uiScreenSectionGV
0221: .getString("sectionDescription"));
0222: setLayoutTypeId(uiScreenSectionGV.getString("layoutTypeId"));
0223: setDisplayOrder(uiScreenSectionGV.getString("displayOrder"));
0224: setColumnCount(uiScreenSectionGV.getString("columnCount"));
0225: setRowCount(uiScreenSectionGV.getString("rowCount"));
0226: setButtonKeys(uiScreenSectionGV.getString("buttonKeys"));
0227: setTitleDef(uiScreenSectionGV.getString("titleDef"));
0228: setSortDef(uiScreenSectionGV.getString("sortDef"));
0229: setSearchAttributeId(uiScreenSectionGV
0230: .getString("searchAttributeId"));
0231: setButtonAction(uiScreenSectionGV.getString("buttonAction"));
0232: setButtonTarget(uiScreenSectionGV.getString("buttonTarget"));
0233: setDetailButtonAction(uiScreenSectionGV
0234: .getString("detailButtonAction"));
0235: setDetailButtonTarget(uiScreenSectionGV
0236: .getString("detailButtonTarget"));
0237: setSearchAction(uiScreenSectionGV.getString("searchAction"));
0238: setSearchTarget(uiScreenSectionGV.getString("searchTarget"));
0239: setNewButtonAction(uiScreenSectionGV
0240: .getString("newButtonAction"));
0241: setNewButtonTarget(uiScreenSectionGV
0242: .getString("newButtonTarget"));
0243: setEditButtonAction(uiScreenSectionGV
0244: .getString("editButtonAction"));
0245: setEditButtonTarget(uiScreenSectionGV
0246: .getString("editButtonTarget"));
0247: setHideButtons(uiScreenSectionGV.getString("hideButtons"));
0248: setSelectNameDef(uiScreenSectionGV.getString("selectNameDef"));
0249: setSendQueryParameterList(uiScreenSectionGV
0250: .getString("sendQueryParameterList"));
0251: setUseQueryParameterList(uiScreenSectionGV
0252: .getString("useQueryParameterList"));
0253:
0254: /* add after value added to screen settings
0255: setRowsPerPage(uiScreenSectionGV.getString("rowsPerPage"));
0256:
0257: */
0258: rowsPerPage = 0;
0259: uiScreenSectionGVI = null;
0260:
0261: if (TIMER) {
0262: timer.timerString(1,
0263: "[UIScreenSection.UIScreenSection] Got section");
0264: }
0265:
0266: // if rowsPerPage = 0, then use the global prefernece ROWS_PER_PAGE.
0267: if (rowsPerPage <= 0) {
0268: Preference pref = Preference.getInstance(delegator);
0269: rowsPerPage = pref.getPreference(userInfo.getPartyId(),
0270: userInfo.getAccountId(), PREFERENCE_ROWS_PER_PAGE,
0271: 20);
0272: }
0273:
0274: // Get the uiScreenSectionEntity entities.
0275:
0276: findHashMap = new HashMap();
0277: findHashMap.put("sectionId", getSectionId());
0278:
0279: ArrayList orderBy = new ArrayList();
0280: orderBy.add("retrieveOrder");
0281:
0282: List uiScreenSectionEntityGVL = delegator.findByAnd(
0283: "UiScreenSectionEntity", findHashMap, orderBy);
0284:
0285: if ((uiScreenSectionEntityGVL == null)
0286: || (uiScreenSectionEntityGVL.size() == 0)) {
0287: throw new GenericEntityException(
0288: "No screen section entities were found in database for screen section \""
0289: + sectionName + "\" and screen \""
0290: + screenName + "\".");
0291: }
0292:
0293: Iterator uiScreenSectionEntityGVI = uiScreenSectionEntityGVL
0294: .iterator();
0295:
0296: while (uiScreenSectionEntityGVI.hasNext()) {
0297:
0298: GenericValue uiScreenSectionEntityGV = (GenericValue) uiScreenSectionEntityGVI
0299: .next();
0300: String entityId = uiScreenSectionEntityGV
0301: .getString("entityId");
0302:
0303: if (TIMER) {
0304: timer
0305: .timerString(
0306: 1,
0307: "[UIScreenSection.UIScreenSection] Looking for a UIScreenSectionEntity in cache.");
0308: }
0309:
0310: UIScreenSectionEntity uiScreenSectionEntity = uiCache
0311: .getUiScreenSectionEntity(getSectionId(), entityId);
0312:
0313: if (uiScreenSectionEntity == null) {
0314: if (TIMER) {
0315: timer
0316: .timerString(
0317: 1,
0318: "[UIScreenSection.UIScreenSection] UIScreenSectionEntity not found in cache. Creating a new one.");
0319: }
0320:
0321: uiScreenSectionEntity = new UIScreenSectionEntity(
0322: uiScreenSectionEntityGV, delegator, uiCache);
0323: uiCache.putUiScreenSectionEntity(getSectionId(),
0324: entityId, uiScreenSectionEntity);
0325: } else {
0326: if (TIMER) {
0327: timer
0328: .timerString(1,
0329: "[UIScreenSection.UIScreenSection] Found UIScreenSectionEntity in cache.");
0330: }
0331: }
0332:
0333: uiScreenSectionEntityList.add(uiScreenSectionEntity);
0334:
0335: if (TIMER) {
0336: timer
0337: .timerString(1,
0338: "[UIScreenSection.UIScreenSection] Got a UIScreenSectionEntity.");
0339: }
0340:
0341: if (uiScreenSectionEntity.getIsUpdateable()) {
0342: setIsUpdateable(true);
0343: }
0344: }
0345:
0346: uiScreenSectionEntityGVI = null; // Reset the iterator for next time.
0347:
0348: Debug
0349: .logVerbose(
0350: "-->[UIScreenSection.UIScreenSection] Finished getting the UiScreenSectionEntity's for sectionId "
0351: + getSectionId(), module);
0352: Debug.logVerbose(
0353: "-->[UIScreenSection.UIScreenSection] uiScreenSectionEntityList: "
0354: + uiScreenSectionEntityList.toString(), module);
0355:
0356: if (TIMER) {
0357: timer
0358: .timerString(1,
0359: "[UIScreenSection.UIScreenSection] Calling getDisplayFields");
0360: }
0361:
0362: setUiFieldList(getDisplayFields(uiCache));
0363:
0364: if (TIMER) {
0365: timer.timerString(1,
0366: "[UIScreenSection.UIScreenSection] End");
0367: }
0368: }
0369:
0370: /**
0371: * DOCUMENT ME!
0372: *
0373: * @param sectionId_
0374: */
0375: public void setSectionId(String sectionId_) {
0376: sectionId = (sectionId_ == null) ? "" : sectionId_;
0377: }
0378:
0379: /**
0380: * DOCUMENT ME!
0381: *
0382: * @return
0383: */
0384: public String getSectionId() {
0385: return sectionId;
0386: }
0387:
0388: /**
0389: * DOCUMENT ME!
0390: *
0391: * @param screenId_
0392: */
0393: public void setScreenId(String screenId_) {
0394: screenId = (screenId_ == null) ? "" : screenId_;
0395: }
0396:
0397: /**
0398: * DOCUMENT ME!
0399: *
0400: * @return
0401: */
0402: public String getScreenId() {
0403: return screenId;
0404: }
0405:
0406: /**
0407: * DOCUMENT ME!
0408: *
0409: * @param sectionName_
0410: */
0411: public void setSectionName(String sectionName_) {
0412: sectionName = (sectionName_ == null) ? "" : sectionName_;
0413: }
0414:
0415: /**
0416: * DOCUMENT ME!
0417: *
0418: * @return
0419: */
0420: public String getSectionName() {
0421: return sectionName;
0422: }
0423:
0424: /**
0425: * DOCUMENT ME!
0426: *
0427: * @param sectionDescription_
0428: */
0429: public void setSectionDescription(String sectionDescription_) {
0430: sectionDescription = (sectionDescription_ == null) ? ""
0431: : sectionDescription_;
0432: }
0433:
0434: /**
0435: * DOCUMENT ME!
0436: *
0437: * @return
0438: */
0439: public String getSectionDescription() {
0440: return sectionDescription;
0441: }
0442:
0443: /**
0444: * DOCUMENT ME!
0445: *
0446: * @param layoutTypeId_
0447: */
0448: public void setLayoutTypeId(int layoutTypeId_) {
0449: layoutTypeId = layoutTypeId_;
0450: }
0451:
0452: /**
0453: * DOCUMENT ME!
0454: *
0455: * @param layoutTypeId_
0456: */
0457: public void setLayoutTypeId(String layoutTypeId_) {
0458: layoutTypeId = (layoutTypeId_ == null) ? 0 : Integer.valueOf(
0459: layoutTypeId_).intValue();
0460: }
0461:
0462: /**
0463: * DOCUMENT ME!
0464: *
0465: * @return
0466: */
0467: public int getLayoutTypeId() {
0468: return layoutTypeId;
0469: }
0470:
0471: /**
0472: * DOCUMENT ME!
0473: *
0474: * @param displayOrder_
0475: */
0476: public void setDisplayOrder(int displayOrder_) {
0477: displayOrder = displayOrder_;
0478: }
0479:
0480: /**
0481: * DOCUMENT ME!
0482: *
0483: * @param displayOrder_
0484: */
0485: public void setDisplayOrder(String displayOrder_) {
0486: displayOrder = (displayOrder_ == null) ? 0 : Integer.valueOf(
0487: displayOrder_).intValue();
0488: }
0489:
0490: /**
0491: * DOCUMENT ME!
0492: *
0493: * @return
0494: */
0495: public int getDisplayOrder() {
0496: return displayOrder;
0497: }
0498:
0499: /**
0500: * DOCUMENT ME!
0501: *
0502: * @param columnCount_
0503: */
0504: public void setColumnCount(int columnCount_) {
0505: columnCount = columnCount_;
0506: }
0507:
0508: /**
0509: * DOCUMENT ME!
0510: *
0511: * @param columnCount_
0512: */
0513: public void setColumnCount(String columnCount_) {
0514: columnCount = (columnCount_ == null) ? 0 : Integer.valueOf(
0515: columnCount_).intValue();
0516: }
0517:
0518: /**
0519: * DOCUMENT ME!
0520: *
0521: * @return
0522: */
0523: public int getColumnCount() {
0524: return columnCount;
0525: }
0526:
0527: /**
0528: * DOCUMENT ME!
0529: *
0530: * @param rowCount_
0531: */
0532: public void setRowCount(int rowCount_) {
0533: rowCount = rowCount_;
0534: }
0535:
0536: /**
0537: * DOCUMENT ME!
0538: *
0539: * @param rowCount_
0540: */
0541: public void setRowCount(String rowCount_) {
0542: rowCount = (rowCount_ == null) ? 0 : Integer.valueOf(rowCount_)
0543: .intValue();
0544: }
0545:
0546: /**
0547: * DOCUMENT ME!
0548: *
0549: * @return
0550: */
0551: public int getRowCount() {
0552: return rowCount;
0553: }
0554:
0555: /**
0556: * DOCUMENT ME!
0557: *
0558: * @param rowsPerPage_
0559: */
0560: public void setRowsPerPage(int rowsPerPage_) {
0561: rowsPerPage = rowsPerPage_;
0562: }
0563:
0564: /**
0565: * DOCUMENT ME!
0566: *
0567: * @param rowsPerPage_
0568: */
0569: public void setRowsPerPage(String rowsPerPage_) {
0570: rowsPerPage = (rowsPerPage_ == null) ? 0 : Integer.valueOf(
0571: rowsPerPage_).intValue();
0572: }
0573:
0574: /**
0575: * DOCUMENT ME!
0576: *
0577: * @return
0578: */
0579: public int getRowsPerPage() {
0580: return rowsPerPage;
0581: }
0582:
0583: /**
0584: * DOCUMENT ME!
0585: *
0586: * @param buttonKeys_
0587: */
0588: public void setButtonKeys(String buttonKeys_) {
0589: buttonKeys = (buttonKeys_ == null) ? "" : buttonKeys_;
0590: }
0591:
0592: /**
0593: * DOCUMENT ME!
0594: *
0595: * @return
0596: */
0597: public String getButtonKeys() {
0598: return buttonKeys;
0599: }
0600:
0601: /**
0602: * DOCUMENT ME!
0603: *
0604: * @return
0605: *
0606: * @throws GenericEntityException
0607: */
0608: public HashMap getButtonKeyMap() throws GenericEntityException {
0609: DelimitedPairDecoder buttonKeysDecoder = new DelimitedPairDecoder(
0610: getButtonKeys());
0611: HashMap buttonKeyMap = buttonKeysDecoder.decode();
0612: buttonKeysDecoder = null;
0613:
0614: return buttonKeyMap;
0615: }
0616:
0617: /**
0618: * DOCUMENT ME!
0619: *
0620: * @param sendQueryParameterList_
0621: */
0622: public void setSendQueryParameterList(String sendQueryParameterList_) {
0623: sendQueryParameterList = sendQueryParameterList_;
0624: }
0625:
0626: /**
0627: * DOCUMENT ME!
0628: *
0629: * @return
0630: */
0631: public String getSendQueryParameterList() {
0632: return sendQueryParameterList;
0633: }
0634:
0635: /**
0636: * DOCUMENT ME!
0637: *
0638: * @return
0639: *
0640: * @throws GenericEntityException
0641: */
0642: public HashMap getSendQueryParameterMap()
0643: throws GenericEntityException {
0644: DelimitedPairDecoder sendQueryParameterDecoder = new DelimitedPairDecoder(
0645: getSendQueryParameterList());
0646: HashMap sendQueryParameterMap = sendQueryParameterDecoder
0647: .decode();
0648: sendQueryParameterDecoder = null;
0649:
0650: return sendQueryParameterMap;
0651: }
0652:
0653: /**
0654: * DOCUMENT ME!
0655: *
0656: * @param sendQueryParameterMap_
0657: */
0658: public void setSendQueryParameterValueMap(
0659: HashMap sendQueryParameterMap_) {
0660: sendQueryParameterMap = sendQueryParameterMap_;
0661: }
0662:
0663: /**
0664: * DOCUMENT ME!
0665: *
0666: * @return
0667: */
0668: public HashMap getSendQueryParameterValueMap() {
0669: return sendQueryParameterMap;
0670: }
0671:
0672: /**
0673: * DOCUMENT ME!
0674: *
0675: * @param useQueryParameterList_
0676: */
0677: public void setUseQueryParameterList(String useQueryParameterList_) {
0678: useQueryParameterList = useQueryParameterList_;
0679: }
0680:
0681: /**
0682: * DOCUMENT ME!
0683: *
0684: * @return
0685: */
0686: public String getUseQueryParameterList() {
0687: return useQueryParameterList;
0688: }
0689:
0690: /**
0691: * DOCUMENT ME!
0692: *
0693: * @return
0694: *
0695: * @throws GenericEntityException
0696: */
0697: public HashMap getUseQueryParameterMap()
0698: throws GenericEntityException {
0699: DelimitedPairDecoder useQueryParameterDecoder = new DelimitedPairDecoder(
0700: getUseQueryParameterList());
0701: HashMap useQueryParameterMap = useQueryParameterDecoder
0702: .decode();
0703: useQueryParameterDecoder = null;
0704:
0705: return useQueryParameterMap;
0706: }
0707:
0708: /**
0709: * DOCUMENT ME!
0710: *
0711: * @param useQueryParameterMap_
0712: */
0713: public void setUseQueryParameterValueMap(
0714: HashMap useQueryParameterMap_) {
0715: useQueryParameterMap = useQueryParameterMap_;
0716: }
0717:
0718: /**
0719: * DOCUMENT ME!
0720: *
0721: * @return
0722: */
0723: public HashMap getUseQueryParameterValueMap() {
0724: return useQueryParameterMap;
0725: }
0726:
0727: /**
0728: * DOCUMENT ME!
0729: *
0730: * @param titleDef_
0731: */
0732: public void setTitleDef(String titleDef_) {
0733: titleDef = (titleDef_ == null) ? "" : titleDef_;
0734: }
0735:
0736: /**
0737: * DOCUMENT ME!
0738: *
0739: * @return
0740: */
0741: public String getTitleDef() {
0742: return titleDef;
0743: }
0744:
0745: /**
0746: * DOCUMENT ME!
0747: *
0748: * @param sortDef_
0749: */
0750: public void setSortDef(String sortDef_) {
0751: sortDef = (sortDef_ == null) ? "" : sortDef_;
0752: }
0753:
0754: /**
0755: * DOCUMENT ME!
0756: *
0757: * @return
0758: */
0759: public String getSortDef() {
0760: return sortDef;
0761: }
0762:
0763: /**
0764: * DOCUMENT ME!
0765: *
0766: * @param searchAttributeId_
0767: */
0768: public void setSearchAttributeId(String searchAttributeId_) {
0769: searchAttributeId = (searchAttributeId_ == null) ? ""
0770: : searchAttributeId_;
0771: }
0772:
0773: /**
0774: * DOCUMENT ME!
0775: *
0776: * @return
0777: */
0778: public String getSearchAttributeId() {
0779: return searchAttributeId;
0780: }
0781:
0782: /**
0783: * DOCUMENT ME!
0784: *
0785: * @param buttonAction_
0786: */
0787: public void setButtonAction(String buttonAction_) {
0788: buttonAction = (buttonAction_ == null) ? "" : buttonAction_;
0789: }
0790:
0791: /**
0792: * DOCUMENT ME!
0793: *
0794: * @return
0795: */
0796: public String getButtonAction() {
0797: return buttonAction;
0798: }
0799:
0800: /**
0801: * DOCUMENT ME!
0802: *
0803: * @param buttonTarget_
0804: */
0805: public void setButtonTarget(String buttonTarget_) {
0806: buttonTarget = (buttonTarget_ == null) ? "" : buttonTarget_;
0807: }
0808:
0809: /**
0810: * DOCUMENT ME!
0811: *
0812: * @return
0813: */
0814: public String getButtonTarget() {
0815: return buttonTarget;
0816: }
0817:
0818: /**
0819: * DOCUMENT ME!
0820: *
0821: * @param detailButtonAction_
0822: */
0823: public void setDetailButtonAction(String detailButtonAction_) {
0824: detailButtonAction = (detailButtonAction_ == null) ? ""
0825: : detailButtonAction_;
0826: }
0827:
0828: /**
0829: * DOCUMENT ME!
0830: *
0831: * @return
0832: */
0833: public String getDetailButtonAction() {
0834: return detailButtonAction;
0835: }
0836:
0837: /**
0838: * DOCUMENT ME!
0839: *
0840: * @param detailButtonTarget_
0841: */
0842: public void setDetailButtonTarget(String detailButtonTarget_) {
0843: detailButtonTarget = (detailButtonTarget_ == null) ? ""
0844: : detailButtonTarget_;
0845: }
0846:
0847: /**
0848: * DOCUMENT ME!
0849: *
0850: * @return
0851: */
0852: public String getDetailButtonTarget() {
0853: return detailButtonTarget;
0854: }
0855:
0856: /**
0857: * DOCUMENT ME!
0858: *
0859: * @param searchAction_
0860: */
0861: public void setSearchAction(String searchAction_) {
0862: searchAction = (searchAction_ == null) ? "" : searchAction_;
0863: }
0864:
0865: /**
0866: * DOCUMENT ME!
0867: *
0868: * @return
0869: */
0870: public String getSearchAction() {
0871: return searchAction;
0872: }
0873:
0874: /**
0875: * DOCUMENT ME!
0876: *
0877: * @param searchTarget_
0878: */
0879: public void setSearchTarget(String searchTarget_) {
0880: searchTarget = (searchTarget_ == null) ? "" : searchTarget_;
0881: }
0882:
0883: /**
0884: * DOCUMENT ME!
0885: *
0886: * @return
0887: */
0888: public String getSearchTarget() {
0889: return searchTarget;
0890: }
0891:
0892: /**
0893: * DOCUMENT ME!
0894: *
0895: * @param newButtonAction_
0896: */
0897: public void setNewButtonAction(String newButtonAction_) {
0898: newButtonAction = (newButtonAction_ == null) ? ""
0899: : newButtonAction_;
0900: }
0901:
0902: /**
0903: * DOCUMENT ME!
0904: *
0905: * @return
0906: */
0907: public String getNewButtonAction() {
0908: return newButtonAction;
0909: }
0910:
0911: /**
0912: * DOCUMENT ME!
0913: *
0914: * @param newButtonTarget_
0915: */
0916: public void setNewButtonTarget(String newButtonTarget_) {
0917: newButtonTarget = (newButtonTarget_ == null) ? ""
0918: : newButtonTarget_;
0919: }
0920:
0921: /**
0922: * DOCUMENT ME!
0923: *
0924: * @return
0925: */
0926: public String getNewButtonTarget() {
0927: return newButtonTarget;
0928: }
0929:
0930: /**
0931: * DOCUMENT ME!
0932: *
0933: * @param editButtonAction_
0934: */
0935: public void setEditButtonAction(String editButtonAction_) {
0936: editButtonAction = (editButtonAction_ == null) ? ""
0937: : editButtonAction_;
0938: }
0939:
0940: /**
0941: * DOCUMENT ME!
0942: *
0943: * @return
0944: */
0945: public String getEditButtonAction() {
0946: return editButtonAction;
0947: }
0948:
0949: /**
0950: * DOCUMENT ME!
0951: *
0952: * @param editButtonTarget_
0953: */
0954: public void setEditButtonTarget(String editButtonTarget_) {
0955: editButtonTarget = (editButtonTarget_ == null) ? ""
0956: : editButtonTarget_;
0957: }
0958:
0959: /**
0960: * DOCUMENT ME!
0961: *
0962: * @return
0963: */
0964: public String getEditButtonTarget() {
0965: return editButtonTarget;
0966: }
0967:
0968: /**
0969: * DOCUMENT ME!
0970: *
0971: * @param hideButtons_
0972: */
0973: public void setHideButtons(String hideButtons_) {
0974: hideButtons = (hideButtons_ == null) ? "" : hideButtons_
0975: .toLowerCase();
0976: }
0977:
0978: /**
0979: * DOCUMENT ME!
0980: *
0981: * @return
0982: */
0983: public String getHideButtons() {
0984: return hideButtons;
0985: }
0986:
0987: /**
0988: * DOCUMENT ME!
0989: *
0990: * @param selectNameDef_
0991: */
0992: public void setSelectNameDef(String selectNameDef_) {
0993: selectNameDef = (selectNameDef_ == null) ? "" : selectNameDef_;
0994: }
0995:
0996: /**
0997: * DOCUMENT ME!
0998: *
0999: * @return
1000: */
1001: public String getSelectNameDef() {
1002: return selectNameDef;
1003: }
1004:
1005: /**
1006: * DOCUMENT ME!
1007: *
1008: * @param isUpdateable_
1009: */
1010: public void setIsUpdateable(boolean isUpdateable_) {
1011: isUpdateable = isUpdateable_;
1012: }
1013:
1014: /**
1015: * DOCUMENT ME!
1016: *
1017: * @return
1018: */
1019: public boolean getIsUpdateable() {
1020: return isUpdateable;
1021: }
1022:
1023: /**
1024: * DOCUMENT ME!
1025: *
1026: * @param delegator_
1027: */
1028: public void setDelegator(GenericDelegator delegator_) {
1029: delegator = delegator_;
1030: }
1031:
1032: /**
1033: * DOCUMENT ME!
1034: *
1035: * @return
1036: */
1037: public GenericDelegator getDelegator() {
1038: return delegator;
1039: }
1040:
1041: /**
1042: * DOCUMENT ME!
1043: *
1044: * @param userInfo_
1045: */
1046: public void setUserInfo(UserInfo userInfo_) {
1047: userInfo = userInfo_;
1048: }
1049:
1050: /**
1051: * DOCUMENT ME!
1052: *
1053: * @return
1054: */
1055: public UserInfo getUserInfo() {
1056: return userInfo;
1057: }
1058:
1059: /**
1060: * DOCUMENT ME!
1061: *
1062: * @param uiScreen_
1063: */
1064: public void setUiScreen(UIScreen uiScreen_) {
1065: uiScreen = uiScreen_;
1066: }
1067:
1068: /**
1069: * DOCUMENT ME!
1070: *
1071: * @return
1072: */
1073: public UIScreen getUiScreen() {
1074: return uiScreen;
1075: }
1076:
1077: /**
1078: * DOCUMENT ME!
1079: *
1080: * @param uiFieldList_
1081: */
1082: public void setUiFieldList(List uiFieldList_) {
1083: uiFieldList = uiFieldList_;
1084: }
1085:
1086: /**
1087: * DOCUMENT ME!
1088: *
1089: * @return
1090: */
1091: public List getUiFieldList() {
1092: return uiFieldList;
1093: }
1094:
1095: /**
1096: * DOCUMENT ME!
1097: *
1098: * @param fieldNumber
1099: *
1100: * @return
1101: */
1102: public UIFieldInfo getUiField(int fieldNumber) {
1103: return (UIFieldInfo) uiFieldList.get(fieldNumber);
1104: }
1105:
1106: /**
1107: * DOCUMENT ME!
1108: *
1109: * @param entityName
1110: * @param attributeName
1111: *
1112: * @return
1113: */
1114: public UIFieldInfo getUiField(String entityName,
1115: String attributeName) {
1116: for (int fieldNbr = 0; fieldNbr < uiFieldList.size(); fieldNbr++) {
1117: UIFieldInfo uiFieldInfo = getUiField(fieldNbr);
1118:
1119: if (uiFieldInfo.getUiAttribute().getUiEntity()
1120: .getEntityName().equals(entityName)
1121: && uiFieldInfo.getUiAttribute().getAttributeName()
1122: .equals(attributeName)) {
1123: return uiFieldInfo;
1124: }
1125: }
1126:
1127: return null;
1128: }
1129:
1130: /**
1131: * DOCUMENT ME!
1132: *
1133: * @param uiScreenSectionEntityList_
1134: */
1135: public void setUiScreenSectionEntityList(
1136: List uiScreenSectionEntityList_) {
1137: uiScreenSectionEntityList = uiScreenSectionEntityList_;
1138: }
1139:
1140: /**
1141: * DOCUMENT ME!
1142: *
1143: * @return
1144: */
1145: public List getUiScreenSectionEntityList() {
1146: return uiScreenSectionEntityList;
1147: }
1148:
1149: /**
1150: * DOCUMENT ME!
1151: *
1152: * @param entityNumber
1153: *
1154: * @return
1155: */
1156: public UIScreenSectionEntity getUiScreenSectionEntity(
1157: int entityNumber) {
1158: return (UIScreenSectionEntity) uiScreenSectionEntityList
1159: .get(entityNumber);
1160: }
1161:
1162: /**
1163: * DOCUMENT ME!
1164: *
1165: * @return
1166: */
1167: public Vector getEntityParamVector() {
1168:
1169: // Construct a vector of info about the entities in this screen section to be
1170: // passed to the data matrix so it will be independent of the UI.
1171: Vector entityParamVector = new Vector();
1172: int entityCount = getUiScreenSectionEntityList().size();
1173:
1174: for (int entityNbr = 0; entityNbr < entityCount; entityNbr++) {
1175: UIEntity uiEntity = getUiScreenSectionEntity(entityNbr)
1176: .getUiEntity();
1177: String entityName = uiEntity.getEntityName();
1178: Vector attributeVector = new Vector();
1179:
1180: for (int attributeNbr = 0; attributeNbr < uiEntity
1181: .getUiAttributeList().size(); attributeNbr++) {
1182: String attributeName = uiEntity.getUiAttribute(
1183: attributeNbr).getAttributeName();
1184: attributeVector.add(attributeName);
1185: }
1186:
1187: Boolean hasSequenceKey = new Boolean(
1188: getUiScreenSectionEntity(entityNbr)
1189: .getHasSequenceKey());
1190: Boolean isUpdateable = new Boolean(
1191: getUiScreenSectionEntity(entityNbr)
1192: .getIsUpdateable());
1193: HashMap parameterMap = new HashMap();
1194: parameterMap.put("entityName", entityName);
1195: parameterMap.put("attributeVector", attributeVector);
1196: parameterMap.put("hasSequenceKey", hasSequenceKey);
1197: parameterMap.put("isUpdateable", isUpdateable);
1198: entityParamVector.add(parameterMap);
1199: }
1200:
1201: return entityParamVector;
1202: }
1203:
1204: /**
1205: * DOCUMENT ME!
1206: *
1207: * @return
1208: *
1209: * @throws GenericEntityException
1210: */
1211: public List getEntityNameList() throws GenericEntityException {
1212: List entityNameList = new LinkedList();
1213: Iterator uiScreenSectionEntityI = getUiScreenSectionEntityList()
1214: .iterator();
1215:
1216: while (uiScreenSectionEntityI.hasNext()) {
1217: UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) uiScreenSectionEntityI
1218: .next();
1219: entityNameList.add(uiScreenSectionEntity.getUiEntity()
1220: .getEntityName());
1221: }
1222:
1223: return entityNameList;
1224: }
1225:
1226: /**
1227: * DOCUMENT ME!
1228: *
1229: * @param dataMatrix
1230: * @param action
1231: * @param queryId
1232: * @param isSubsection
1233: * @param tabOffset
1234: *
1235: * @return
1236: *
1237: * @throws GenericEntityException
1238: */
1239: public String display(DataMatrix dataMatrix, String action,
1240: String queryId, boolean isSubsection, int tabOffset)
1241: throws GenericEntityException {
1242:
1243: if ((getLayoutTypeId() == LAYOUT_TYPE_FREEFORM)
1244: && ((dataMatrix.getCurrentBuffer().getContents() == null) || (dataMatrix
1245: .getCurrentBuffer().getContents().size() < 1))) {
1246: // This is a free form section, and there is no data. Create an empty entity so the section will show up.
1247:
1248: dataMatrix.getCurrentBuffer().addEmptyRow();
1249: }
1250:
1251: // Vector genericValueVector = dataMatrix.getCurrentBuffer().getContentsRow(0);
1252: // GenericValue primaryEntityGV = dataMatrix.getCurrentBuffer().getGenericValue(0, 0);
1253: String primaryEntityTitle = "";
1254:
1255: if ((dataMatrix.getCurrentBuffer().getContents() == null)
1256: || (dataMatrix.getCurrentBuffer().getContents().size() < 1)) {
1257: // No rows in data matrix. Set the title using an empty string.
1258: DataBuffer tempBuffer = new DataBuffer(delegator,
1259: dataMatrix);
1260: primaryEntityTitle = UIWebUtility.decodeEntityDisplayDef(
1261: titleDef, tempBuffer.createEmptyRow(), "");
1262: } else {
1263: // There is data in the data matrix. Use the first row to set the title.
1264: primaryEntityTitle = UIWebUtility.decodeEntityDisplayDef(
1265: titleDef, dataMatrix.getCurrentBuffer()
1266: .getContentsRow(0), "");
1267: }
1268:
1269: String titleBar = ((primaryEntityTitle != null) ? primaryEntityTitle
1270: : "");
1271:
1272: switch (getLayoutTypeId()) {
1273: case LAYOUT_TYPE_FREEFORM:
1274: return displayFreeFormSection(dataMatrix, action,
1275: getFreeFormSectionTitle(action, titleBar),
1276: isSubsection, tabOffset);
1277:
1278: case LAYOUT_TYPE_TABULAR:
1279: return displayTabularSection(dataMatrix, action, titleBar,
1280: queryId);
1281:
1282: case LAYOUT_TYPE_CROSSTAB:
1283: throw new GenericEntityException(
1284: "Crosstab layout type not implemented yet.");
1285:
1286: case LAYOUT_TYPE_SELECT:
1287: return displaySelectSection(dataMatrix, action, titleBar,
1288: queryId);
1289:
1290: case LAYOUT_TYPE_COMPOSITE:
1291:
1292: // return displayCompositeSection(
1293: // dataMatrix,
1294: // action,
1295: // titleBar,
1296: // queryId);
1297: throw new GenericEntityException(
1298: "Composite layout type not implemented yet.");
1299:
1300: default:
1301: throw new GenericEntityException("Invalid layout type.");
1302: }
1303: }
1304:
1305: /**
1306: * DOCUMENT ME!
1307: *
1308: * @param dataMatrix
1309: * @param action
1310: * @param sectionTitle
1311: * @param isSubsection
1312: * @param tabOffset
1313: *
1314: * @return
1315: *
1316: * @throws GenericEntityException
1317: */
1318: public abstract String displayFreeFormSection(
1319: DataMatrix dataMatrix, String action, String sectionTitle,
1320: boolean isSubsection, int tabOffset)
1321: throws GenericEntityException;
1322:
1323: /**
1324: * DOCUMENT ME!
1325: *
1326: * @param dataMatrix
1327: * @param action
1328: * @param sectionTitle
1329: * @param queryId
1330: *
1331: * @return
1332: *
1333: * @throws GenericEntityException
1334: */
1335: public abstract String displayTabularSection(DataMatrix dataMatrix,
1336: String action, String sectionTitle, String queryId)
1337: throws GenericEntityException;
1338:
1339: /**
1340: * DOCUMENT ME!
1341: *
1342: * @param action
1343: * @param sectionTitle
1344: * @param queryId
1345: * @param rows
1346: * @param sendQueryParams
1347: *
1348: * @return
1349: *
1350: * @throws GenericEntityException
1351: */
1352: public abstract String displayTabularSectionHeader(String action,
1353: String sectionTitle, String queryId, int rows,
1354: String sendQueryParams) throws GenericEntityException;
1355:
1356: /**
1357: * DOCUMENT ME!
1358: *
1359: * @param row
1360: * @param rows
1361: * @param entityDetailsVector
1362: * @param action
1363: *
1364: * @return
1365: *
1366: * @throws GenericEntityException
1367: */
1368: public abstract String displayTabularSectionRow(int row, int rows,
1369: Vector entityDetailsVector, String action)
1370: throws GenericEntityException;
1371:
1372: /**
1373: * DOCUMENT ME!
1374: *
1375: * @param action
1376: * @param sendQueryParams
1377: *
1378: * @return
1379: */
1380: public abstract String displayTabularSectionFooter(String action,
1381: String sendQueryParams, String queryId);
1382:
1383: /**
1384: * DOCUMENT ME!
1385: *
1386: * @param dataMatrix
1387: * @param action
1388: * @param sectionTitle
1389: * @param queryId
1390: *
1391: * @return
1392: *
1393: * @throws GenericEntityException
1394: */
1395: public abstract String displaySelectSection(DataMatrix dataMatrix,
1396: String action, String sectionTitle, String queryId)
1397: throws GenericEntityException;
1398:
1399: /**
1400: * DOCUMENT ME!
1401: *
1402: * @param fieldInfo
1403: * @param entityDetailsVector
1404: * @param action
1405: * @param row
1406: * @param isSubsection
1407: * @param tabOffset
1408: *
1409: * @return
1410: */
1411: public abstract String displayField(UIFieldInfo fieldInfo,
1412: Vector entityDetailsVector, String action, int row,
1413: boolean isSubsection, int tabOffset);
1414:
1415: /**
1416: * DOCUMENT ME!
1417: *
1418: * @param uiCache
1419: *
1420: * @return
1421: *
1422: * @throws GenericEntityException
1423: */
1424: public List getDisplayFields(UICache uiCache)
1425: throws GenericEntityException {
1426: UtilTimer timer = new UtilTimer();
1427:
1428: if (TIMER) {
1429: timer.timerString(2,
1430: "[UIScreenSection.getDisplayFields] Start");
1431: }
1432:
1433: ArrayList uiFields = new ArrayList();
1434: boolean gotFields = false;
1435:
1436: // Get the primary key names for the primary entity.
1437: UIScreenSectionEntity primaryUiScreenSectionEntity = (UIScreenSectionEntity) (getUiScreenSectionEntityList()
1438: .get(0));
1439: UIEntity primaryUiEntity = primaryUiScreenSectionEntity
1440: .getUiEntity();
1441: String primaryEntityName = primaryUiEntity.getEntityName();
1442: ModelEntity primaryModelEntity = primaryUiScreenSectionEntity
1443: .getUiEntity().getModelEntity();
1444: List primaryPrimaryKeyFieldNameList = primaryModelEntity
1445: .getPkFieldNames();
1446:
1447: boolean[] primaryKeyIncluded = new boolean[20];
1448:
1449: for (int keyFieldNbr = 0; keyFieldNbr < primaryPrimaryKeyFieldNameList
1450: .size(); keyFieldNbr++) {
1451: primaryKeyIncluded[keyFieldNbr] = false;
1452: }
1453:
1454: for (int i = 0; i < 3; i++) {
1455: String partyId = getUserInfo().getPartyId();
1456:
1457: if (i == 1) {
1458: partyId = getUserInfo().getAccountId(); //search for the company settings the second time through the loop
1459: }
1460:
1461: if (i == 2) {
1462: partyId = "-1"; //search for default party the last time through the loop
1463: }
1464:
1465: HashMap findMap = new HashMap();
1466: findMap.put("sectionId", sectionId);
1467: findMap.put("partyId", partyId);
1468:
1469: ArrayList orderBy = new ArrayList();
1470: orderBy.add("displayOrder");
1471:
1472: List uiFieldInfoL = getDelegator().findByAnd(
1473: "UiScreenSectionInfo", findMap, orderBy);
1474:
1475: int numRows = 0;
1476:
1477: Iterator uiFieldInfoI = uiFieldInfoL.iterator();
1478:
1479: while (uiFieldInfoI.hasNext()) {
1480: numRows++;
1481:
1482: GenericValue uiScreenSectionInfoGV = (GenericValue) uiFieldInfoI
1483: .next();
1484: int displayOrder = (uiScreenSectionInfoGV
1485: .get("displayOrder") == null) ? 0 : Integer
1486: .valueOf(
1487: uiScreenSectionInfoGV
1488: .getString("displayOrder"))
1489: .intValue();
1490:
1491: if (displayOrder > 0) {
1492: // Only fields with display order > 0 get displayed.
1493: String attributeId = (uiScreenSectionInfoGV
1494: .getString("attributeId") == null) ? ""
1495: : uiScreenSectionInfoGV
1496: .getString("attributeId");
1497:
1498: if (TIMER) {
1499: timer.timerString(2,
1500: "[UIScreenSection.getDisplayFields] Processing field with attribute ID "
1501: + attributeId);
1502: }
1503:
1504: if (TIMER) {
1505: timer
1506: .timerString(1,
1507: "[UIScreenSection.getDisplayFields] Looking for UIScreenSectionInfo in cache.");
1508: }
1509:
1510: UIFieldInfo uiFieldInfo = uiCache.getUiFieldInfo(
1511: sectionId, partyId, attributeId);
1512:
1513: if (uiFieldInfo == null) {
1514: if (TIMER) {
1515: timer
1516: .timerString(
1517: 1,
1518: "[UIScreenSection.getDisplayFields] UIScreenSectionInfo not found in cache. Creating a new one.");
1519: }
1520:
1521: uiFieldInfo = new UIFieldInfo(
1522: uiScreenSectionInfoGV, getDelegator(),
1523: uiCache);
1524: uiCache.putUiFieldInfo(sectionId, partyId,
1525: attributeId, uiFieldInfo);
1526: } else {
1527: if (TIMER) {
1528: timer
1529: .timerString(1,
1530: "[UIScreenSection.getDisplayFields] Found UIScreenSectionInfo in cache.");
1531: }
1532: }
1533:
1534: uiFields.add(uiFieldInfo);
1535:
1536: String attributeName = uiFieldInfo.getUiAttribute()
1537: .getAttributeName();
1538:
1539: for (int keyFieldNbr = 0; keyFieldNbr < primaryPrimaryKeyFieldNameList
1540: .size(); keyFieldNbr++) {
1541: if (attributeName
1542: .equals(primaryPrimaryKeyFieldNameList
1543: .get(keyFieldNbr))) {
1544: primaryKeyIncluded[keyFieldNbr] = true;
1545: }
1546: }
1547: }
1548: }
1549:
1550: if (numRows > 0) {
1551: break;
1552: }
1553: }
1554:
1555: // Make sure all the primary key fields of the primary entity were included.
1556: for (int keyFieldNbr = 0; keyFieldNbr < primaryPrimaryKeyFieldNameList
1557: .size(); keyFieldNbr++) {
1558: if (!primaryKeyIncluded[keyFieldNbr]) {
1559: throw new GenericEntityException(
1560: "[UIScreenSection.getDisplayFields]: All primary key fields of the primary entity must be included in the field list.");
1561: }
1562: }
1563:
1564: if (TIMER) {
1565: timer.timerString(2,
1566: "[UIScreenSection.getDisplayFields] End");
1567: }
1568:
1569: return uiFields;
1570: }
1571:
1572: /**
1573: * DOCUMENT ME!
1574: *
1575: * @param uiFields
1576: *
1577: * @return
1578: */
1579: public static List getDisplayLabels(List uiFields) {
1580: List fields = new ArrayList();
1581:
1582: for (int i = 0; i < uiFields.size(); i++) {
1583: UIFieldInfo fldInfo = (UIFieldInfo) uiFields.get(i);
1584: fields.add(fldInfo.getDisplayLabel());
1585: }
1586:
1587: return fields;
1588: }
1589:
1590: /**
1591: * DOCUMENT ME!
1592: *
1593: * @param uiFields
1594: *
1595: * @return
1596: */
1597: public static int getRowWidth(List uiFields) {
1598: int width = 0;
1599:
1600: for (int i = 0; i < uiFields.size(); i++) {
1601: UIFieldInfo fldInfo = (UIFieldInfo) uiFields.get(i);
1602:
1603: if (fldInfo.getIsVisible()) {
1604: width += fldInfo.getDisplayLength();
1605: }
1606: }
1607:
1608: return width;
1609: }
1610:
1611: /**
1612: * DOCUMENT ME!
1613: *
1614: * @param action
1615: * @param defaultTitle
1616: *
1617: * @return
1618: */
1619: public String getFreeFormSectionTitle(String action,
1620: String defaultTitle) {
1621: if (action.equals(ACTION_SHOW_INSERT)
1622: || action.equals(ACTION_SHOW_COPY)
1623: || action.equals(ACTION_DELETE)) {
1624: // return "New " + getUiScreenSectionEntity(0).getUiEntity().getDescription();
1625: return defaultTitle + " New";
1626: } else if (action.equals(ACTION_SHOW_QUERY)) {
1627: // return getUiScreenSectionEntity(0).getUiEntity().getDescription() + " Query";
1628: return defaultTitle + " Query";
1629: } else {
1630: return defaultTitle;
1631: }
1632: }
1633:
1634: /**
1635: * DOCUMENT ME!
1636: *
1637: * @param action
1638: *
1639: * @return
1640: */
1641: public String getNextAction(String action) {
1642:
1643: String nextAction = "";
1644:
1645: if (action.equals(ACTION_INSERT)) {
1646: // A record was just inserted. The screen will be displayed in read only mode this time, so the Save
1647: // button won't be visible. No action will be required for the Save button.
1648: nextAction = ACTION_NONE;
1649: } else if (action.equals(ACTION_DELETE)) {
1650: // A record was just deleted. The screen will be displayed in insert mode this time,
1651: // so next time Save is pushed, need to insert a new record, and then show the screen in update mode.
1652: nextAction = ACTION_INSERT;
1653: } else if (action.equals(ACTION_QUERY)) {
1654: // A query was just executed. The screen will be displayed in read only mode this time, so the Save
1655: // button won't be visible. No action will be required for the Save button.
1656: nextAction = ACTION_NONE;
1657: } else if (action.equals(ACTION_QUERY_UPDATE)) {
1658: // A query was just executed. The screen will be displayed in update mode this time,
1659: // so next time Save is pushed, need to update and then show the screen in update mode the next time.
1660: nextAction = ACTION_UPDATE;
1661: } else if (action.equals(ACTION_SHOW_COPY)) {
1662: // The Copy button was just pushed. The screen will be displayed in insert mode this time,
1663: // so next time Save is pushed, need to insert a new record, and then show the screen in update mode.
1664: nextAction = ACTION_INSERT;
1665: } else if (action.equals(ACTION_SHOW_INSERT)) {
1666: // The Insert button was just pushed. The screen will be displayed in insert mode this time,
1667: // so next time Save is pushed, need to insert a new record, and then show the screen in update mode.
1668: nextAction = ACTION_INSERT;
1669: } else if (action.equals(ACTION_SHOW_QUERY)) {
1670: // The Query button was just pushed. The screen will be displayed in query mode this time,
1671: // so next time Save is pushed, need to execute the query, and show the query results in read only mode.
1672: nextAction = ACTION_QUERY;
1673: } else if (action.equals(ACTION_SHOW_QUERY_REPORT)) {
1674: // The menu item for a report was just pushed. The screen will be displayed in query_report mode this time,
1675: // and the Save button will submit the form with a next action of ACTION_SHOW_REPORT to show the report results.
1676: nextAction = ACTION_SHOW_REPORT;
1677: } else if (action.equals(ACTION_SHOW_REPORT)) {
1678: // A report was just displayed. The screen will be displayed in query report mode again this time so the user
1679: // can change the criteria and re-submit the report. The Save button will submit the form with a next action
1680: // of ACTION_SHOW_REPORT to show the report results again next time.
1681: nextAction = ACTION_SHOW_REPORT;
1682: } else if (action.equals(ACTION_SHOW_SELECT)) {
1683: // The Select button was just pushed. The screen will be displayed in select mode this time,
1684: // so next time Save is pushed, need to update and then show screen in select mode again.
1685: nextAction = ACTION_UPDATE_SELECT;
1686: } else if (action.equals(ACTION_SHOW_UPDATE)) {
1687: // The screen will be displayed in update mode this time,
1688: // so next time Save is pushed, need to update and then show the screen in update mode the next time.
1689: nextAction = ACTION_UPDATE;
1690: } else if (action.equals(ACTION_UPDATE)) {
1691: // A record was just updated. The screen will be displayed in read only mode this time, so the Save
1692: // button won't be visible. No action will be required for the Save button.
1693: nextAction = ACTION_NONE;
1694: } else if (action.equals(ACTION_UPDATE_SELECT)) {
1695: // Select list was saved last time. The screen will be displayed in select mode this time.
1696: // If the user pushes Save next time, need to update and put screen in select mode again.
1697: nextAction = ACTION_UPDATE_SELECT;
1698: }
1699:
1700: return nextAction;
1701: }
1702:
1703: /**
1704: * DOCUMENT ME!
1705: *
1706: * @param action
1707: *
1708: * @return
1709: */
1710: public boolean getProtect(String action) {
1711: if (action.equals(ACTION_SHOW) || action.equals(ACTION_INSERT)
1712: || action.equals(ACTION_UPDATE)
1713: || action.equals(ACTION_QUERY) || action.equals("")
1714: || (action == null)) {
1715: return true;
1716: } else {
1717: return false;
1718: }
1719: }
1720: }
|