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

📄 callsearchpanel.java

📁 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网!
💻 JAVA
字号:
    /* CRMS, customer relationship management system    Copyright (C) 2003  Service To Youth Council    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    For further information contact the SYC ICT department on GPL@syc.net.au    98 Kermode Street    North Adelaide    South Australia    SA 5006     +61 (0)8 8367 0755    *//* * CallAddPanel.java * * Created on 27 March 2003, 06:34 */package crms.applet;import javax.swing.*;import java.awt.*;import org.w3c.dom.*;import crms.util.*;import crms.vo.*;import crms.module.*;import crms.ui.*;import java.awt.event.*;import java.util.*;import mseries.Calendar.*;import mseries.ui.*;/** * * @author  dmurphy */public class CallSearchPanel extends CRMSPanel implements StaffMemberSearcher {        /** Creates a new instance of CallAddPanel */        JPanel titlePanel = new JPanel();    JLabel titleLabel = new JLabel("Search for Message");        //JPanel bodyPanel = new JPanel();    CRMSPanel bodyPanel = CRMSPanel.getEmptyPanel();        JTextField textPhone = new JTextField();        //JTextField textFor = new JTextField();	AutoTextField textFor = new AutoTextField(PanelManager.getInstance().getUIDList(), AutoTextField.DEFAULT_MIN_COMPARE_LENGTH);    JTextField textFirstName = new JTextField();    JTextField textLastName = new JTextField();        JButton buttonStaffSearch = new JButton("Search");        JButton buttonSearch = new JButton("Search");    JButton buttonReset = new JButton("Reset");    JButton buttonCancel = new JButton("Back");        JTextArea textNote = new JTextArea();    JScrollPane noteScrollPane = new JScrollPane(textNote);        MDateEntryField dateFromField = new MDateEntryField();    MDateEntryField dateToField = new MDateEntryField();        JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);    UtilityToolbar utilityToolbar = null;        // The following two objects store entities grabbed from other    // forms.         StaffMember staffMember = null;        public CallSearchPanel() {    }            public void init() {                setLayout(new BorderLayout());                titleLabel.setFont(new java.awt.Font("Serif", 1, 18));        titleLabel.setBackground(Color.WHITE);        titlePanel.add(titleLabel);        titlePanel.setBackground(Color.WHITE);                add(titlePanel, BorderLayout.NORTH);                GridBagLayout gbl = new GridBagLayout();        bodyPanel.setLayout(gbl);        bodyPanel.setBackground(Color.WHITE);                toolBar.setLayout(new BorderLayout());        toolBar.setFloatable(false);        toolBar.setBackground(Color.WHITE);                // Toolbar icons        JButton button = new JButton();                        MDefaultPullDownConstraints c = new MDefaultPullDownConstraints();        c.firstDay = Calendar.MONDAY;        dateFromField.setConstraints(c);        dateToField.setConstraints(c);        MSimpleDateFormat dateFormat = new MSimpleDateFormat("d MMMM, yyyy");        dateFromField.setDateFormatter(dateFormat);        dateToField.setDateFormatter(dateFormat);       		// from 7 days ago to now         dateToField.setValue(null); //new Date(System.currentTimeMillis() + 24 * 3600 * 1000));        dateFromField.setValue(new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000));                buttonReset.addActionListener( new ActionListener() {            public void actionPerformed(ActionEvent ev) {                // Clear all fields            }        });                buttonSearch.addActionListener( new ActionListener() {            public void actionPerformed(ActionEvent ev) {                if (validateForm()) {                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));                    searchCall();                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                }            }        });                buttonCancel.addActionListener( new ActionListener() {            public void actionPerformed(ActionEvent ev) {                PanelManager.getInstance().activatePanel(new CallViewPanel());            }        });                        buttonStaffSearch.addActionListener( new ActionListener() {            public void actionPerformed(ActionEvent ev) {                activateStaffSearch();            }        });                // If staffMember isn't valid (ie, null) search for the text        // that's been entered.                textFor.addFocusListener( new FocusAdapter() {            public void focusLost(FocusEvent ev) {				if (textFor.isAutomatic()) {					Server server = ServerFactory.getInstance().getServer();					ServerCommand command = new ServerCommand(StaffModule.STAFF_SEARCH_SUBMIT);					command.setParameter(StaffModule.PARAM_STAFF_UID, textFor.getText());					ServerResponse sr = server.sendCommand(command);					ArrayList staff = (ArrayList) sr.getPart("staff");					if (staff != null && staff.size() == 1) {						setStaffMemberFound((StaffMember)staff.get(0));						return;					}				}                if (staffMember == null && !textFor.getText().trim().equals("")) {                    activateStaffSearch();                }            }        });                // Clear staffMember, it may be no longer valid                textFor.addKeyListener( new KeyAdapter() {           public void keyTyped(KeyEvent ev) {               if (ev.getKeyCode() != KeyEvent.VK_TAB) {                    System.out.println("Reseting staffMember from keycode: " + ev.getKeyCode());                   staffMember = null;               }           }        });                Insets defaultInsets = new Insets(4,0,0,4);                bodyPanel.add(textFor,                  new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(buttonStaffSearch,                  new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.NONE, defaultInsets, 0, 0));                bodyPanel.add(dateFromField,                  new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(dateToField,                  new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(textFirstName,                  new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(textLastName,                  new GridBagConstraints(1, 4, 2, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(textPhone,          new GridBagConstraints(1, 5, 3, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));        bodyPanel.add(noteScrollPane,                    new GridBagConstraints(1, 6, 3, 1, 0.0, 0.0        ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 45, 44));                bodyPanel.add(new JLabel("To"),                  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel("Date From"),                  new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel("Date To"),                    new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));//        CallAdd_MessageScrollPane.getViewport().add(CallAdd_Message, null);        bodyPanel.add(new JLabel("From: First Name"),                   new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel("Last Name"),                   new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel("Phone Number"),      new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));        bodyPanel.add(new JLabel("Message"),                     new GridBagConstraints(0, 6, 1, 2, 0.0, 0.0        ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));                CRMSUtil.fixGridBagLayout(gbl, bodyPanel);		JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));		buttonPanel.setBackground(Color.WHITE);		buttonPanel.add(buttonSearch);		buttonPanel.add(buttonReset);		buttonPanel.add(buttonCancel);                add(bodyPanel, BorderLayout.CENTER);        add(buttonPanel, BorderLayout.SOUTH);                setCurrentPanel(bodyPanel);    }            public void activateStaffSearch() {        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));                CallSearchPanel returnPanel = new CallSearchPanel();                returnPanel.textNote.setText(textNote.getText());        returnPanel.textPhone.setText(textPhone.getText());        returnPanel.textFirstName.setText(textFirstName.getText());        returnPanel.textLastName.setText(textLastName.getText());        try {            returnPanel.dateFromField.setValue(dateFromField.getValue());            returnPanel.dateToField.setValue(dateToField.getValue());        }        catch (java.text.ParseException ex) {            // This shouldn't happen!        }                StaffMemberSearchPanel panel =             new StaffMemberSearchPanel("Select Staff Member",                returnPanel,                returnPanel,                textFor.getText()                );        setCursor(Cursor.getDefaultCursor());        PanelManager.getInstance().activatePanel(panel);    }    public void searchCall() {                Server server = ServerFactory.getInstance().getServer();        ServerCommand command = new ServerCommand(CallModule.CALL_SEARCH);                CallSearch search = new CallSearch();        if (staffMember != null) {            search.setOwner(staffMember.getUID());        }        try {            search.setDate(dateFromField.getValue());        }catch (java.text.ParseException ex) {            search.setDate(null);        }        try {            search.setDateTo(dateToField.getValue());        }        catch (java.text.ParseException ex) {            search.setDateTo(null);        }                search.setFromFirstName(textFirstName.getText());        search.setFromLastName(textLastName.getText());        search.setNote(textNote.getText());        search.setNumber(textPhone.getText());                command.setParameter(CallModule.PARAM_CALL_SEARCH, search);                ServerResponse response = server.sendCommand(command);                java.util.List calls = (ArrayList) response.getPart("calls");                CallViewPanel panel = new CallViewPanel(calls);        PanelManager.getInstance().activatePanel(panel);            }        public boolean validateForm() {        StringBuffer buf = new StringBuffer();        boolean valid = true;        return valid;    }        public void setStaffMemberFound(StaffMember staffMember) {        this.staffMember = staffMember;        textFor.setText(staffMember.getFirstName() + " " + staffMember.getLastName());    }    }

⌨️ 快捷键说明

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