⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uiwebscreensection.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
 * 
 * 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.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilTimer;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;

import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.util.Preference;
import com.sourcetap.sfa.util.StringHelper;
import com.sourcetap.sfa.util.UserInfo;


/**
 * DOCUMENT ME!
 *
 */
public class UIWebScreenSection extends UIScreenSection {
	public static final String module = UIWebScreenSection.class.getName();

    private static final boolean WEB_DEBUG = false;
    private static final boolean TIMER = false;
    protected final String IMAGE_COPY = "/sfaimages/Copy24.gif";
    protected final String IMAGE_DELETE = "/sfaimages/Delete24.gif";
    protected final String IMAGE_EDIT = "/sfaimages/Edit24.gif";
    protected final String IMAGE_FIND = "/sfaimages/Find24.gif";
    protected final String IMAGE_NEW = "/sfaimages/New24.gif";
    protected final String IMAGE_OPEN = "/sfaimages/Open24.gif";
    protected final String IMAGE_PRINT = "/sfaimages/Print24.gif";
    protected final String IMAGE_PROPERTIES = "/sfaimages/Properties24.gif";
    protected final String IMAGE_SAVE = "/sfaimages/Save24.gif";
    protected final String IMAGE_SEARCH = "/sfaimages/Search24.gif";
    protected final String IMAGE_SELECT = "/sfaimages/Refresh24.gif";
    protected final String IMAGE_STOP = "/sfaimages/Stop24.gif";
    protected final String IMAGE_ZOOM = "/sfaimages/Zoom24.gif";
    protected final String IMAGE_ZOOM_SELECTED = "/sfaimages/Zoom24Selected.gif";
    protected final String IMAGE_COPY_DISABLED = "/sfaimages/Copy24Disabled.gif";
    protected final String IMAGE_DELETE_DISABLED = "/sfaimages/Delete24Disabled.gif";
    protected final String IMAGE_EDIT_DISABLED = "/sfaimages/Edit24Disabled.gif";
    protected final String IMAGE_FIND_DISABLED = "/sfaimages/Find24Disabled.gif";
    protected final String IMAGE_NEW_DISABLED = "/sfaimages/New24Disabled.gif";
    protected final String IMAGE_OPEN_DISABLED = "/sfaimages/Open24Disabled.gif";
    protected final String IMAGE_PRINT_DISABLED = "/sfaimages/Print24Disabled.gif";
    protected final String IMAGE_PROPERTIES_DISABLED = "/sfaimages/Properties24Disabled.gif";
    protected final String IMAGE_SAVE_DISABLED = "/sfaimages/Save24Disabled.gif";
    protected final String IMAGE_SEARCH_DISABLED = "/sfaimages/Search24Disabled.gif";
    protected final String IMAGE_SELECT_DISABLED = "/sfaimages/Refresh24Disabled.gif";
    protected final String IMAGE_STOP_DISABLED = "/sfaimages/Stop24Disabled.gif";
    protected final String IMAGE_ZOOM_DISABLED = "/sfaimages/Zoom24Disabled.gif";
//    protected final int FREE_FORM_ROW_HEIGHT = 16;
//    protected final int FREE_FORM2_ROW_HEIGHT = 16;

    // used for handling large result sets.  start and end row can be set prior to calling display in order to handle
    // paging of data.
    protected int firstVisibleRow = 0;
    protected boolean hasPriorPage = false;
    protected boolean hasNextPage = false;
    protected int priorPageStartRow = 0;
    protected int nextPageStartRow = 0;
    protected int totalRows = 0;

     protected String queryMode = "standard";

    public UIWebScreenSection(UserInfo userInfo, String screenName,
        String sectionName, GenericDelegator delegator, UICache uiCache)
        throws GenericEntityException {
        super(userInfo, screenName, sectionName, delegator, uiCache);
    }

    /**
     * DOCUMENT ME!
     *
     * @param rows 
     */
    public void setTotalRows(int rows) {
        totalRows = rows;
    }

    /**
     * DOCUMENT ME!
     *
     * @param dataMatrix 
     * @param action 
     * @param sectionTitle 
     * @param isSubsection 
     * @param tabOffset 
     *
     * @return 
     *
     * @throws GenericEntityException 
     */
    public String displayFreeFormSection(DataMatrix dataMatrix, String action,
        String sectionTitle, boolean isSubsection, int tabOffset)
        throws GenericEntityException {
        UtilTimer timer = new UtilTimer();

        if (TIMER) {
            timer.timerString(1,
                "[UIWebScreenSection.displayFreeFormSection] Start");
        }

        Debug.logVerbose("[displayFreeFormSection] Start", module);

        Vector entityDetailsVector = dataMatrix.getCurrentBuffer()
                                               .getContentsRow(0);
        GenericValue primaryEntityDetails = dataMatrix.getCurrentBuffer()
                                                      .getGenericValue(0, 0);

            Debug.logVerbose("[displayFreeFormSection()] Primary entity name: " +
                primaryEntityDetails.getEntityName(), module);

        StringBuffer displayHtml = new StringBuffer(5000);

        // Get the key values so the form can pass them to the next page for the 4 buttons.
        String keyParams = UIWebUtility.getHiddenArgs(getButtonKeyMap(),
                entityDetailsVector, "       ");

        // Get the extra query parameters so the form can pass them to the next page.
        String sendQueryParams = UIWebUtility.getHiddenArgs(getSendQueryParameterValueMap(),
                "       ");

            Debug.logVerbose("[displayFreeFormSection] sendQueryParams: " +
                sendQueryParams, module);

        String keyUrlArgs = UIWebUtility.getUrlArgs(getButtonKeyMap(),
                entityDetailsVector);
        String queryUrlArgs = UIWebUtility.getUrlArgs(getSendQueryParameterMap(),
                entityDetailsVector);

        // Append script to refresh the list or detail section when this free form section is saved.
        if (!getDetailButtonTarget().equals("") && !isSubsection &&
                (action.equals(ACTION_UPDATE) || action.equals(ACTION_INSERT) ||
                action.equals(ACTION_DELETE))) {
            displayHtml.append(
                "<SCRIPT FOR=\"window\" EVENT=\"onload\" LANGUAGE=\"JavaScript\">\n");

            if (WEB_DEBUG) {
                displayHtml.append("  alert('parent." +
                    getDetailButtonTarget() + ".location.href = ' + parent." +
                    getDetailButtonTarget() + ".location.href)\n");
            }

            displayHtml.append("  if (parent." + getDetailButtonTarget() +
                ".location.href.indexOf('" +
                getDetailButtonAction().substring(13) + "') > 0) {\n");
            displayHtml.append(
                "   // This is the detail section of the current screen section.  Refresh it with new arguments.\n");

            if (WEB_DEBUG) {
                displayHtml.append(
                    "   alert('Reloading related section using HREF: " +
                    getDetailButtonAction() + "?x=" + keyUrlArgs +
                    queryUrlArgs + "');\n");
            }

            displayHtml.append("   parent." + getDetailButtonTarget() +
                ".location.href = \"" + getDetailButtonAction() + "?x=" +
                keyUrlArgs + queryUrlArgs + "\";\n");
            displayHtml.append("  } else {\n");
            displayHtml.append(
                "   // This is a list section.  Refresh it with same arguments used last time.\n");

            if (WEB_DEBUG) {
                displayHtml.append(
                    "   alert('Reloading related section using HREF: ' + parent." +
                    getDetailButtonTarget() + ".location.href);\n");
            }

            displayHtml.append("   parent." + getDetailButtonTarget() +
                ".location.href = parent." + getDetailButtonTarget() +
                ".location.href;\n");
            displayHtml.append("  }\n");
            displayHtml.append("</SCRIPT>\n");
        }

        // Insert the preSubmit function to prevent the onBeforeUnload popup window from being displayed
        // if the Save button was just clicked.
        if (getIsUpdateable()) {
            displayHtml.append("<SCRIPT LANGUAGE=\"JavaScript\">\n");
            displayHtml.append(" function preSubmit" + getSectionName() +
                "() {\n");
            displayHtml.append("  // Prevent the onBeforeUnload popup window\n");
            displayHtml.append("  window.onbeforeunload = null;\n");
            displayHtml.append("  return false;\n");
            displayHtml.append(" }\n");
            displayHtml.append("</SCRIPT>\n");
        }

        displayHtml.append(
            "   <TABLE WIDTH=\"100%\" CLASS=\"freeFormSectionTitleTable\">\n");
        displayHtml.append("    <TR>\n");

        String titleTdName = getSectionName() + "TitleTD";
        displayHtml.append("     <TD NAME=\"" + titleTdName + "\" ID=\"" +
            titleTdName + "\">\n");
        displayHtml.append(sectionTitle + "\n");
        displayHtml.append("     </TD>\n");
        displayHtml.append("     <TD ALIGN=\"right\">\n");
        displayHtml.append("      <TABLE>\n");
        displayHtml.append("       <TR>\n");
        displayHtml.append("\n");

        if (!isSubsection) {
            // Buttons with configurable targets.
            // Don't send query parameters when the new button is clicked from a free-form tab. This will
            // prevent fields from be initialized to the same as the current record.
            displayHtml.append(displayNewButton("", action));
            displayHtml.append(displayEditButton(action, keyParams,
                    sendQueryParams, ACTION_BUTTON));
            displayHtml.append(displayDetailButton(keyParams, sendQueryParams,
                    action));

            // Buttons with same target as current window.
            displayHtml.append("     <TD>\n");
            displayHtml.append("      <FORM NAME=\"" + getSectionName() +
                "FormButton\" METHOD=\"post\"" + " ACTION=\"" +
                getButtonAction() + "\"");

            if ((getButtonTarget() != null) && !getButtonTarget().equals("")) {
                displayHtml.append(" TARGET=\"" + getButtonTarget() + "\"");
            }

            displayHtml.append(">\n");
            displayHtml.append(keyParams);
            displayHtml.append(sendQueryParams);
            displayHtml.append(
                "       <INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"" +
                ACTION_BUTTON + "\">\n");

            displayHtml.append(displayQueryButton(action));
            displayHtml.append(displayDeleteButton(action));
            displayHtml.append(displayCopyButton(action));
            displayHtml.append(displayPrintButton(action));
            displayHtml.append("      </FORM>\n");
            displayHtml.append("     </TD>\n");
            displayHtml.append("\n");

            displayHtml.append(displayCustomizeButton());
        }

        displayHtml.append("       </TR>\n");
        displayHtml.append("      </TABLE>\n");
        displayHtml.append("     </TD>\n");
        displayHtml.append("    </TR>\n");
        displayHtml.append("   </TABLE>\n");
        displayHtml.append("\n");

        if (TIMER) {
            timer.timerString(1,
                "[UIWebScreenSection.displayFreeFormSection] Finished title bar");
        }

        displayHtml.append("   <TABLE CLASS=\"freeFormSectionDisplayTable\" ");

        if (!isSubsection) {
//            displayHtml.append("HEIGHT=\"100%\"");
        }

        displayHtml.append(">\n");

        if (!isSubsection) {
            boolean isMultiPart = false;

            for (int fieldNbr = 0; fieldNbr < getUiFieldList().size();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -