?? calleditpanel.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 crms.applet.company.CompanySearchWindow;import java.awt.event.*;import java.util.*;import java.text.*;import mseries.Calendar.*;import mseries.ui.*;/** * * @author dmurphy */public class CallEditPanel extends CRMSComponent implements StaffMemberSearcher, CallbackDestination { CallbackDestination destination = null; /** Creates a new instance of CallAddPanel */ int panelType = PANEL_TYPE_ADD; public static final int CLOSE_WINDOW = 0; public static final int CLOSE_WINDOW_DELETE = 1; public static final int PANEL_TYPE_ADD = 0; public static final int PANEL_TYPE_EDIT = 1; JPanel titlePanel = new JPanel(); JLabel titleLabel = new JLabel("Log Message"); //JPanel bodyPanel = new JPanel(); JPanel bodyPanel = new JPanel(); // JTextField textFrom = new JTextField(); // JButton buttonContactSearch = new JButton("Search"); JTextField textPhone = new JTextField(); AutoTextField textFor = new AutoTextField(PanelManager.getInstance().getUIDList(), AutoTextField.DEFAULT_MIN_COMPARE_LENGTH); JTextField textFirstName = new JTextField(); JTextField textLastName = new JTextField(); //JLabel companyLabel = new JLabel("Not Set"); JTextField textCompany = new JTextField(); JButton companySearchButton = new JButton("Assign"); JButton buttonStaffSearch = new JButton("Search"); JButton buttonAdd = new JButton("Add"); JButton buttonReset = new JButton("Reset"); JButton buttonCancel = new JButton("Close"); JButton buttonDelete = new JButton("Delete"); JCheckBox checkEmail = new JCheckBox("Send Email"); JCheckBox checkSMS = new JCheckBox("Send SMS"); JCheckBox checkWillCallBack = new JCheckBox("Will Call Back"); JCheckBox checkPleaseCall = new JCheckBox("Please Call"); JCheckBox checkUrgent = new JCheckBox("Urgent"); JTextArea textNote = new JTextArea(); JScrollPane noteScrollPane = new JScrollPane(textNote); MDateEntryField dateField = new MDateEntryField(); MDateSpinner timeField = new MDateSpinner(); //JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL); UtilityToolbar utilityToolbar = null; private Call call_data = null; private int callID = -1; private Company company = null; // The following two objects store entities grabbed from other // forms. StaffMember staffMember = null; Contact contact = null; //Permission entityPermission = null; boolean init_done = false; public CallEditPanel() { this.panelType = PANEL_TYPE_ADD; } public CallEditPanel(CallbackDestination destination) { super(); this.destination = destination; } /** * Create a call edit panel, initilising with the specified call data. The given call will * modify all the text fields based when the panel is activated. * * @param call Set the details of the form to be entered in initially **/ public CallEditPanel(Call call) { if (call.getCallID() >= 0) { this.panelType = PANEL_TYPE_EDIT; callID = call.getCallID(); } else { this.panelType = PANEL_TYPE_ADD; } this.call_data = call; } public CallEditPanel(int callID) { this.callID = callID; this.panelType = PANEL_TYPE_EDIT; } public CallEditPanel(int contactID, Company company) { setPanelType(PANEL_TYPE_EDIT, contactID); // only update the company if it is set if (company != null) { this.company = company; } } public void init() { final Object thisobj = this; if (init_done == false) { /*if (panelType == PANEL_TYPE_ADD) { titleLabel.setText("Add Message"); buttonAdd.setText("Add"); } else { titleLabel.setText("Edit Message"); buttonAdd.setText("Save"); } titleLabel.setFont(new java.awt.Font("Serif", 1, 18)); titleLabel.setBackground(Color.WHITE); titlePanel.add(titleLabel); titlePanel.setBackground(Color.WHITE); add(titlePanel, BorderLayout.NORTH); */ setLayout(new BorderLayout()); 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; dateField.setConstraints(c); MSimpleDateFormat dateFormat = new MSimpleDateFormat("d MMMM, yyyy"); dateField.setDateFormatter(dateFormat); timeField.setFormatter(new MSimpleDateFormat("h:mm a")); buttonReset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); loadData(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); buttonAdd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { if (validateForm()) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); updateCall(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); if (destination == null) { PanelManager.getInstance().activatePanel(new CallViewPanel()); } else { if (staffMember.getUID().compareTo(PanelManager.getInstance().getAuthenticatedUser()) != 0) { destination.callback(thisobj, CLOSE_WINDOW, null); } else { // this should be displayed only if the call is for "me" destination.callback(thisobj, CLOSE_WINDOW, call_data); } } } } }); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { if (destination == null) { PanelManager.getInstance().activatePanel(new CallViewPanel()); } else { destination.callback(thisobj, CLOSE_WINDOW, null); } } }); buttonDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); deleteCall(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); buttonStaffSearch.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { activateStaffSearch(); } }); companySearchButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { activateCompanySearch(); } }); // If staffMember isn't valid (ie, null) search for the text // that's been entered. textFor.addFocusListener( new FocusAdapter() { public void focusLost(FocusEvent ev) { // System.out.println("focus has been lost in the thing: " + textFor.getText()); // check the current entry is an auto completed, get the details and continue if (textFor.isAutomatic()) { // do a staff lookup 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; } } // even if the entry is auto completed, it may not locate the actual entry (handle normally) 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; } } }); textCompany.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent ev) { if (ev.getKeyCode() != KeyEvent.VK_TAB) { company = null; } } } ); /* textCompany.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent ev) { if (company == null && textCompany.getText().trim().length() > 0) { activateCompanySearch(); } } } ); */ JPanel notifyPanel = new JPanel(new GridLayout(1,0)); JPanel flagPanel = new JPanel(new GridLayout(1,0)); // fix checkbox and panel colours notifyPanel.setBackground(Color.WHITE); flagPanel.setBackground(Color.WHITE); checkEmail.setBackground(Color.WHITE); checkSMS.setBackground(Color.WHITE); checkWillCallBack.setBackground(Color.WHITE); checkPleaseCall.setBackground(Color.WHITE); checkUrgent.setBackground(Color.WHITE); notifyPanel.add(checkEmail); notifyPanel.add(checkSMS); flagPanel.add(checkUrgent); flagPanel.add(checkWillCallBack); flagPanel.add(checkPleaseCall); textNote.setLineWrap(true); Insets defaultInsets = new Insets(4,0,0,4); bodyPanel.add(new JLabel("To"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textFor, new GridBagConstraints(1, 0, 2, 1, 1.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(new JLabel("Date"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(dateField, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Time"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(timeField, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); /*bodyPanel.add(new JLabel("Notify"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));*/ bodyPanel.add(notifyPanel, new GridBagConstraints(1, 3, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Company", SwingConstants.RIGHT), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(textCompany, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(companySearchButton, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("From: First Name"), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textFirstName, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Last Name"), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textLastName, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Phone Number"), new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textPhone, new GridBagConstraints(1, 7, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Message"), new GridBagConstraints(0, 8, 1, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(noteScrollPane, // make the scroll pane taller than normal new GridBagConstraints(1, 8, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 44)); /*bodyPanel.add(new JLabel("Flags"), new GridBagConstraints(0, 9, 1, 2, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));*/ bodyPanel.add(flagPanel, new GridBagConstraints(1, 9, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0,0)); //CRMSUtil.fixGridBagLayout(gbl, bodyPanel); //utilityToolbar = new UtilityToolbar(EntityType.CALL, callID); //JPanel wrapper = new JPanel(new BorderLayout()); //if (callID > -1) { // wrapper.add(utilityToolbar, BorderLayout.NORTH); //}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -