📄 uiscreensection.java
字号:
/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
* The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/
package com.sourcetap.sfa.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Vector;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.model.ModelEntity;
import com.sourcetap.sfa.event.DataBuffer;
import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.util.DelimitedPairDecoder;
import com.sourcetap.sfa.util.Preference;
import com.sourcetap.sfa.util.UserInfo;
/**
* DOCUMENT ME!
*
*/
public abstract class UIScreenSection {
public static final String module = UIScreenSection.class.getName();
private static final boolean TIMER = false;
public static final int LAYOUT_TYPE_UNDEFINED = 0;
public static final int LAYOUT_TYPE_FREEFORM = 1;
public static final int LAYOUT_TYPE_TABULAR = 2;
public static final int LAYOUT_TYPE_CROSSTAB = 3;
public static final int LAYOUT_TYPE_SELECT = 4;
public static final int LAYOUT_TYPE_COMPOSITE = 5;
// public static final int LAYOUT_TYPE_FREEFORM2 = 6;
public static final String ACTION_BUTTON = "button";
public static final String ACTION_COPY = "copy";
public static final String ACTION_DELETE = "delete";
public static final String ACTION_INSERT = "insert";
public static final String ACTION_NONE = "none";
public static final String ACTION_QUERY = "query";
public static final String ACTION_QUERY_UPDATE = "queryUpdate";
public static final String ACTION_QUERY_ALL = "queryAll";
public static final String ACTION_UPDATE = "update";
public static final String ACTION_UPDATE_SELECT = "updateSelect";
public static final String ACTION_SHOW = "show";
public static final String ACTION_SHOW_COPY = "showCopy";
public static final String ACTION_SHOW_INSERT = "showInsert";
public static final String ACTION_SHOW_QUERY = "showQuery";
public static final String ACTION_SHOW_QUERY_REPORT = "showQueryReport";
public static final String ACTION_SHOW_REPORT = "showReport";
public static final String ACTION_SHOW_SELECT = "showSelect";
public static final String ACTION_SHOW_UPDATE = "showUpdate";
public static final String PREFERENCE_ROWS_PER_PAGE = "ROWS_PER_PAGE";
protected int rowsPerPage = 0;
protected String sectionId = "";
protected String screenId = "";
protected String sectionName = "";
protected String sectionDescription = "";
protected int layoutTypeId = 0;
protected int displayOrder = 0;
protected int columnCount = 0;
protected int rowCount = 0;
protected String buttonKeys = "";
protected String sendQueryParameterList = "";
protected String useQueryParameterList = "";
protected HashMap sendQueryParameterMap = null;
protected HashMap useQueryParameterMap = null;
protected String titleDef = "";
protected String sortDef = "";
protected String searchAttributeId = "";
protected String buttonAction = "";
protected String buttonTarget = "";
protected String detailButtonAction = "";
protected String detailButtonTarget = "";
protected String searchAction = "";
protected String searchTarget = "";
protected String newButtonAction = "";
protected String newButtonTarget = "";
protected String editButtonAction = "";
protected String editButtonTarget = "";
protected String hideButtons = "";
protected String selectNameDef = "";
protected boolean isUpdateable = false;
protected UserInfo userInfo = null;
protected GenericDelegator delegator;
UIScreen uiScreen = null;
List uiFieldList = new ArrayList();
List uiScreenSectionEntityList = new ArrayList();
public UIScreenSection(UserInfo userInfo, String screenName,
String sectionName, GenericDelegator delegator, UICache uiCache)
throws GenericEntityException {
UtilTimer timer = new UtilTimer();
if (TIMER) {
timer.timerString(1, "[UIScreenSection.UIScreenSection] Start");
}
Debug.logVerbose( "-->[UIScreenSection.UIScreenSection] screenName: " + screenName, module);
Debug.logVerbose( "-->[UIScreenSection.UIScreenSection] sectionName: " + sectionName, module);
if (userInfo == null) {
throw new GenericEntityException(
"UserInfo passed in was null for UIScreenSection.");
} else {
setUserInfo(userInfo);
}
if (delegator == null) {
throw new GenericEntityException(
"GenericDelegator passed in was null for UIScreenSection.");
} else {
setDelegator(delegator);
}
if (screenName == null) {
throw new GenericEntityException(
"ScreenName passed in was null for UIScreenSection.");
}
if (sectionName == null) {
throw new GenericEntityException(
"SectionName passed in was null for UIScreenSection.");
}
// Get the uiScreen object.
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Looking for UIScreen in cache.");
}
UIScreen uiScreen = uiCache.getUiScreen(screenName);
if (uiScreen == null) {
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] UIScreen not found in cache. Creating a new one.");
}
uiScreen = new UIScreen(screenName, delegator);
uiCache.putUiScreen(screenName, uiScreen);
} else {
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Found UIScreen in cache.");
}
}
setUiScreen(uiScreen);
if (TIMER) {
timer.timerString(1, "[UIScreenSection.UIScreenSection] Got screen");
}
// Get the uiScreenSection object.
HashMap findHashMap = new HashMap();
findHashMap.put("screenId", getUiScreen().getScreenId());
findHashMap.put("sectionName", sectionName);
List uiScreenSectionGVL = delegator.findByAnd("UiScreenSection",
findHashMap, null);
if (uiScreenSectionGVL.size() == 0) {
throw new GenericEntityException("No screen section with name \"" +
sectionName + "\" for screen \"" + screenName +
"\" was found in database.");
}
if (uiScreenSectionGVL.size() > 1) {
throw new GenericEntityException(
"More than one screen section found with name \"" +
sectionName + "\" for screen \"" + screenName + "\".");
}
Iterator uiScreenSectionGVI = uiScreenSectionGVL.iterator();
GenericValue uiScreenSectionGV = (GenericValue) uiScreenSectionGVI.next();
if (uiScreenSectionGV.get("layoutTypeId") == null) {
throw new GenericEntityException(
"Layout type not set for screen section \"" + sectionName +
"\".");
}
setSectionId(uiScreenSectionGV.getString("sectionId"));
setScreenId(uiScreenSectionGV.getString("screenId"));
setSectionName(uiScreenSectionGV.getString("sectionName"));
setSectionDescription(uiScreenSectionGV.getString("sectionDescription"));
setLayoutTypeId(uiScreenSectionGV.getString("layoutTypeId"));
setDisplayOrder(uiScreenSectionGV.getString("displayOrder"));
setColumnCount(uiScreenSectionGV.getString("columnCount"));
setRowCount(uiScreenSectionGV.getString("rowCount"));
setButtonKeys(uiScreenSectionGV.getString("buttonKeys"));
setTitleDef(uiScreenSectionGV.getString("titleDef"));
setSortDef(uiScreenSectionGV.getString("sortDef"));
setSearchAttributeId(uiScreenSectionGV.getString("searchAttributeId"));
setButtonAction(uiScreenSectionGV.getString("buttonAction"));
setButtonTarget(uiScreenSectionGV.getString("buttonTarget"));
setDetailButtonAction(uiScreenSectionGV.getString("detailButtonAction"));
setDetailButtonTarget(uiScreenSectionGV.getString("detailButtonTarget"));
setSearchAction(uiScreenSectionGV.getString("searchAction"));
setSearchTarget(uiScreenSectionGV.getString("searchTarget"));
setNewButtonAction(uiScreenSectionGV.getString("newButtonAction"));
setNewButtonTarget(uiScreenSectionGV.getString("newButtonTarget"));
setEditButtonAction(uiScreenSectionGV.getString("editButtonAction"));
setEditButtonTarget(uiScreenSectionGV.getString("editButtonTarget"));
setHideButtons(uiScreenSectionGV.getString("hideButtons"));
setSelectNameDef(uiScreenSectionGV.getString("selectNameDef"));
setSendQueryParameterList(uiScreenSectionGV.getString("sendQueryParameterList"));
setUseQueryParameterList(uiScreenSectionGV.getString("useQueryParameterList"));
/* add after value added to screen settings
setRowsPerPage(uiScreenSectionGV.getString("rowsPerPage"));
*/
rowsPerPage = 0;
uiScreenSectionGVI = null;
if (TIMER) {
timer.timerString(1, "[UIScreenSection.UIScreenSection] Got section");
}
// if rowsPerPage = 0, then use the global prefernece ROWS_PER_PAGE.
if (rowsPerPage <= 0) {
Preference pref = Preference.getInstance(delegator);
rowsPerPage = pref.getPreference(userInfo.getPartyId(),
userInfo.getAccountId(), PREFERENCE_ROWS_PER_PAGE, 20);
}
// Get the uiScreenSectionEntity entities.
findHashMap = new HashMap();
findHashMap.put("sectionId", getSectionId());
ArrayList orderBy = new ArrayList();
orderBy.add("retrieveOrder");
List uiScreenSectionEntityGVL = delegator.findByAnd("UiScreenSectionEntity",
findHashMap, orderBy);
if ((uiScreenSectionEntityGVL == null) ||
(uiScreenSectionEntityGVL.size() == 0)) {
throw new GenericEntityException(
"No screen section entities were found in database for screen section \"" +
sectionName + "\" and screen \"" + screenName + "\".");
}
Iterator uiScreenSectionEntityGVI = uiScreenSectionEntityGVL.iterator();
while (uiScreenSectionEntityGVI.hasNext()) {
GenericValue uiScreenSectionEntityGV = (GenericValue) uiScreenSectionEntityGVI.next();
String entityId = uiScreenSectionEntityGV.getString("entityId");
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Looking for a UIScreenSectionEntity in cache.");
}
UIScreenSectionEntity uiScreenSectionEntity = uiCache.getUiScreenSectionEntity(getSectionId(),
entityId);
if (uiScreenSectionEntity == null) {
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] UIScreenSectionEntity not found in cache. Creating a new one.");
}
uiScreenSectionEntity = new UIScreenSectionEntity(uiScreenSectionEntityGV,
delegator, uiCache);
uiCache.putUiScreenSectionEntity(getSectionId(), entityId,
uiScreenSectionEntity);
} else {
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Found UIScreenSectionEntity in cache.");
}
}
uiScreenSectionEntityList.add(uiScreenSectionEntity);
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Got a UIScreenSectionEntity.");
}
if (uiScreenSectionEntity.getIsUpdateable()) {
setIsUpdateable(true);
}
}
uiScreenSectionEntityGVI = null; // Reset the iterator for next time.
Debug.logVerbose("-->[UIScreenSection.UIScreenSection] Finished getting the UiScreenSectionEntity's for sectionId " + getSectionId(), module);
Debug.logVerbose("-->[UIScreenSection.UIScreenSection] uiScreenSectionEntityList: " + uiScreenSectionEntityList.toString(), module);
if (TIMER) {
timer.timerString(1,
"[UIScreenSection.UIScreenSection] Calling getDisplayFields");
}
setUiFieldList(getDisplayFields(uiCache));
if (TIMER) {
timer.timerString(1, "[UIScreenSection.UIScreenSection] End");
}
}
/**
* DOCUMENT ME!
*
* @param sectionId_
*/
public void setSectionId(String sectionId_) {
sectionId = (sectionId_ == null) ? "" : sectionId_;
}
/**
* DOCUMENT ME!
*
* @return
*/
public String getSectionId() {
return sectionId;
}
/**
* DOCUMENT ME!
*
* @param screenId_
*/
public void setScreenId(String screenId_) {
screenId = (screenId_ == null) ? "" : screenId_;
}
/**
* DOCUMENT ME!
*
* @return
*/
public String getScreenId() {
return screenId;
}
/**
* DOCUMENT ME!
*
* @param sectionName_
*/
public void setSectionName(String sectionName_) {
sectionName = (sectionName_ == null) ? "" : sectionName_;
}
/**
* DOCUMENT ME!
*
* @return
*/
public String getSectionName() {
return sectionName;
}
/**
* DOCUMENT ME!
*
* @param sectionDescription_
*/
public void setSectionDescription(String sectionDescription_) {
sectionDescription = (sectionDescription_ == null) ? ""
: sectionDescription_;
}
/**
* DOCUMENT ME!
*
* @return
*/
public String getSectionDescription() {
return sectionDescription;
}
/**
* DOCUMENT ME!
*
* @param layoutTypeId_
*/
public void setLayoutTypeId(int layoutTypeId_) {
layoutTypeId = layoutTypeId_;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -