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

📄 myqueuehandler.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Copyright 2006-2007 Queplix Corp.
 *
 * Licensed under the Queplix Public License, Version 1.1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.queplix.com/solutions/commercial-open-source/queplix-public-license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.queplix.qwoss.client.frames.mainframe;


import com.queplix.core.client.app.rpc.RPC;
import com.queplix.core.client.app.vo.DateFieldData;
import com.queplix.core.client.app.vo.EntityReferenceData;
import com.queplix.core.client.app.vo.FamgMeta;
import com.queplix.core.client.app.vo.FieldData;
import com.queplix.core.client.app.vo.ListboxFieldData;
import com.queplix.core.client.app.vo.MemoFieldData;
import com.queplix.core.client.app.vo.MetaData;
import com.queplix.core.client.app.vo.TextboxFieldData;
import com.queplix.core.client.common.StringUtil;
import com.queplix.core.client.common.ui.DialogHelper;
import com.queplix.core.client.frames.email.EmailComposeDialog;
import com.queplix.core.client.frames.email.EmailComposeHelper;
import com.queplix.core.client.frames.htmledit.HtmlEditFrame;
import com.queplix.core.client.frames.mainframe.DefaultOperationStrategy;
import com.queplix.core.client.frames.mainframe.FormOperations;
import com.queplix.core.client.frames.mainframe.FormState;
import com.queplix.core.client.frames.mainframe.OperationTypes;
import com.queplix.qwoss.client.app.rpc.CustomRPC;

import java.util.Collection;
import java.util.HashMap;

/**
 * Description:
 *
 * @author Ladnev Ilya
 * @since 06-Mar-2007
 */
final class MyQueueHandler extends DefaultOperationStrategy {
    private static final String TICKET_ID_CAPTION = "Ticket : ";
    private static final String INTERACTION_ID_CAPTION = "Interaction : ";

    private static final String INBOX_REPLY_BUTTON = "FORM_INBOX_REPLY";
    private static final String INBOX_FORWARD_BUTTON = "FORM_INBOX_FORWARD";
    private static final String INBOX_OPEN_BUTTON = "FORM_INBOX_OPEN_OBJECT";

    private static final String INBOX_MSG_TYPE_FIELD = "message_type";
    private static final String INBOX_MSG_SENDER_EMAIL_FIELD = "message_sender_email";
    private static final String INBOX_EMAIL_TO_FIELD = "email_to";
    private static final String INBOX_EMAIL_CC_FIELD = "email_cc";
    private static final String INBOX_SUBJCT_FIELD = "subject";
    private static final String INBOX_MESSAGE_FIELD = "message";
    private static final String INBOX_SENT_DATE_FIELD = "sent_date";
    private static final String INBOX_OBJ_TYPE_FIELD = "object_type";
    private static final String INBOX_OBJ_ID_FIELD = "object_id";
    private static final String INBOX_ACCOUNT_ID_FIELD = "account_id";

    private static final String TICKET_ID = "qw_ticketid";
    private static final String INTERACTION_ID = "qw_interactionid";
    private static final String OBJECT_TYPE = "object_type";
    private static final String OBJECT_ID = "object_id";

    private static final int INTERACTION = 1;
    private static final int TICKET = 2;
    private HashMap initVals;

    //events
//    private static final String CUSTOM_DELETE = "delete_custom";

    public static final int UNKNOWN_MESSAGE = -1;
    public static final int EMAIL_MESSAGE = 0;
    public static final int ALERT_MESSAGE = 1;

    private final int REPLY_TYPE = 0;
    private final int FORWARD_TYPE = 1;

    private ReplyComposeDialog replyDialog;
    private EmailComposeDialog forwardDialog;

    /*
     * Ticket and Interaction form ids
     * It should initialized in HandlerFactory or it's siblings
     */
    private String ticketFormId, interFormId;

    private int getMessageType(FamgMeta.Index form){
        FieldData msgType = getOperationContext().getFormOperations().getFieldData(
                form, INBOX_MSG_TYPE_FIELD);
        if(!msgType.isEmpty()) {
            return Integer.parseInt(((TextboxFieldData) msgType).getText());
        } else {
            return UNKNOWN_MESSAGE;
        }
    }

    public void handleCustomButtonEvent(String buttonId) {
        FamgMeta.Index formIndex = getFormIndex();
        if(buttonId.equalsIgnoreCase(INBOX_REPLY_BUTTON)) {
            switch(getOperationContext().getFormOperations().getFormState(formIndex)) {
                case FormState.SELECTED_STATE:
                    switch(getMessageType(formIndex)) {
                        case EMAIL_MESSAGE:
                            replyClick(formIndex);
                            return;
                        case ALERT_MESSAGE:
                        default:
                            DialogHelper.showModalMessageDialog( "This button is available only for email messages.");
                            return;
                    }
                default:
                    DialogHelper.showModalMessageDialog(
                            "This button is available only in SELECTED state.");
            }
        } else if(buttonId.equalsIgnoreCase(INBOX_FORWARD_BUTTON)) {
            switch(getOperationContext().getFormOperations().getFormState(formIndex)) {
                case FormState.SELECTED_STATE:
                    switch(getMessageType(formIndex)) {
                        case EMAIL_MESSAGE:
                            forwardClick(formIndex);
                            return;
                        case ALERT_MESSAGE:
                        default:
                            DialogHelper.showModalMessageDialog(
                                    "This button is available only for email messages.");
                            return;
                    }
                default:
                    DialogHelper.showModalMessageDialog(
                            "This button is available only in SELECTED state.");
            }
        } else if(buttonId.equalsIgnoreCase(INBOX_OPEN_BUTTON)) {
            switch(getOperationContext().getFormOperations().getFormState(formIndex)) {
                case FormState.SELECTED_STATE:
                    openClick(formIndex);
                    return ;
                default:
                    DialogHelper.showModalMessageDialog(
                            "This button is available only in SELECTED state.");
            }
        }
    }

    public void deleteRecord(Collection rowIds) {
        RPC.QAsyncCallback callback = new CreateDeleteAsyncCallback(getFormIndex());
        CustomRPC.getCustomRPC().deleteInbox(rowIds, callback);
    }

    public void openClick(FamgMeta.Index formIndex) {
        FormOperations context = getOperationContext().getFormOperations();
        ListboxFieldData objectType = (ListboxFieldData) context.getFieldData(
                formIndex, OBJECT_TYPE);
        long[] selIDs = objectType.getItemsSelected().getSelectedIDs();
        int selectedType = (int) selIDs[0];
        TextboxFieldData objectId = (TextboxFieldData) context.getFieldData(
                formIndex, OBJECT_ID);
        String selectedObjId = objectId.getText();
        MetaData metaData = getOperationContext().getMetaData();
        FamgMeta.Index searchFormIndex = null;

        switch (selectedType) {
            case INTERACTION: {
                TextboxFieldData data = new TextboxFieldData(INTERACTION_ID, selectedObjId);
                searchFormIndex = (FamgMeta.Index) metaData.getIndexByID(interFormId);
                getOperationContext().getGridOperations().activateGrid(searchFormIndex);
                context.activateForm(searchFormIndex);
                context.clearForm(searchFormIndex, true);
                context.setFieldData(searchFormIndex, data);
                break;
            }
            case TICKET: {
                TextboxFieldData data = new TextboxFieldData(TICKET_ID, selectedObjId);
                searchFormIndex = (FamgMeta.Index) metaData.getIndexByID(ticketFormId);
                getOperationContext().getGridOperations().activateGrid(searchFormIndex);
                context.activateForm(searchFormIndex);
                context.clearForm(searchFormIndex, true);
                context.setFieldData(searchFormIndex, data);
                break;
            }
        }
        //performSearch(searchFormIndex);
        getOperationContext().performOperation(OperationTypes.SEARCH_RECORDS, searchFormIndex);
    }

    //private void performSearch(FamgMeta.Index searchFormIndex) {
    //    //perform search
    //    getOperationContext().performOperation(OperationTypes.SEARCH_RECORDS, searchFormIndex);
    //}

    private void composeAnswer(int answerType, FamgMeta.Index form){
        initVals = new HashMap();
        FormOperations context = getOperationContext().getFormOperations();

        FieldData senderMailFld = context.getFieldData(form,
                INBOX_MSG_SENDER_EMAIL_FIELD);
        FieldData toFld         = context.getFieldData(form,
                INBOX_EMAIL_TO_FIELD);
        FieldData ccFld         = context.getFieldData(form,
                INBOX_EMAIL_CC_FIELD);
        FieldData subjectFld    = context.getFieldData(form, INBOX_SUBJCT_FIELD);
        FieldData messageFld    = context.getFieldData(form, INBOX_MESSAGE_FIELD);
        FieldData sentDateFld   = context.getFieldData(form,
                INBOX_SENT_DATE_FIELD);
        FieldData objTypeFld    = context.getFieldData(form,
                INBOX_OBJ_TYPE_FIELD);
        FieldData objIdFld      = context.getFieldData(form, INBOX_OBJ_ID_FIELD);
        FieldData accountIdFld  = context.getFieldData(form,
                INBOX_ACCOUNT_ID_FIELD);

        String senderMail = "";
        String emailTo = "";
        String emailCc = "";
        String sentDate = "";
        String oldSubject = "";
        if(!senderMailFld.isEmpty()){
            senderMail = ((TextboxFieldData)senderMailFld).getText();
        }
        if(!toFld.isEmpty()){
            emailTo = ((TextboxFieldData)toFld).getText();
        }
        if(!ccFld.isEmpty()){

⌨️ 快捷键说明

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