?? companyeditwindow.java
字號(hào):
/* 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.company;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.util.*;import org.w3c.dom.*;import crms.util.*;import crms.vo.*;import crms.module.*;import crms.ui.*;import java.awt.event.*;/** * * @author dmurphy */public class CompanyEditWindow extends UniqueWindow implements CallbackDestination { public static final int PANEL_TYPE_ADD = 0; public static final int PANEL_TYPE_EDIT = 1; public static final int COMPANY_SAVED = 0; JPanel bodyPanel = new JPanel(); JTextField textName = new JTextField(); JTextField textPhone = new JTextField(); JTextField textFax = new JTextField(); JTextField textAddress = new JTextField(); JTextField textSuburb = new JTextField(); JTextField textCountry = new JTextField(); JComboBox comboState = new JComboBox(StateCode.STATE_LIST); DefaultComboBoxModel companyIdentifierModel = new DefaultComboBoxModel(CompanyIdentifiersTypeCode.getTypes(CompanyIdentifiersTypeCode.class).toArray()); JComboBox companyIdentifier = new JComboBox(companyIdentifierModel); DefaultComboBoxModel companySizeModel = new DefaultComboBoxModel(CompanySizeCode.getTypes(CompanySizeCode.class).toArray()); JComboBox companySize = new JComboBox(companySizeModel); JTextField textPostcode = new JTextField(); MultiValueTextField mtextABN = new MultiValueTextField(); MultiValueTextField mtextACN = new MultiValueTextField(); MultiValueTextField mtextEmail = new MultiValueTextField(); MultiValueTextField mtextURL = new MultiValueTextField(); DefaultComboBoxModel forModel = new DefaultComboBoxModel(); JComboBox listFor = new JComboBox(forModel); JButton buttonAdd = new JButton(); JButton buttonReset = new JButton("Reset"); JButton buttonCancel = new JButton("Close"); JButton buttonDelete = new JButton("Delete"); JButton buttonMeetings = null; JButton buttonFiles = null; JButton buttonViewNotes = null; JTextArea textDesc = new JTextArea(); JScrollPane descScrollPane = new JScrollPane(textDesc); int panelType = PANEL_TYPE_ADD; CallbackDestination callback = null; boolean init_done = false; int companyID = -1; Company company = null; Permission entityPermission = null; CompanyLocationComponent locationComponent = new CompanyLocationComponent(); /** Create a new CompanyEditWindow for the purpose of adding a company. */ public CompanyEditWindow() { } /** Create a new instance of <code>CompanylEditPanel</code>. * @param panelType Specify the panel type @see PANEL_TYPE_ADD * @param company The a company ID that is to be loaded. */ public void setCompany(Company company) { if (company != null) { this.company = company; this.companyID = company.getCompanyID(); this.panelType = PANEL_TYPE_EDIT; } else { // blank company this.company = new Company(); this.company.setState(StateCode.STATE_LIST[0]); this.company.setCompanySize(CompanySizeCode.SMALL); this.company.setCompanyType(CompanyIdentifiersTypeCode.OTHER); this.panelType = PANEL_TYPE_ADD; } } public void setData(Object data) { setCompany((Company)data); } public String getUniqueID(Object data) { String id = getClass().getName() + ":"; if (data instanceof Company) { Company c = (Company)data; id += "Company:" + c.getCompanyID(); } return id; } public void setCallback(CallbackDestination callback) { this.callback = callback; } public void init() { // copy this for the raise callback subclasses final Object thisobj = this; if (init_done == false) { init_done = true; getContentPane().setLayout(new BorderLayout()); setSize(700,500); center(); bodyPanel.setBackground(Color.WHITE); if (panelType == PANEL_TYPE_ADD) { setTitle("Add Company"); buttonAdd.setText("Add"); } else { setTitle("Edit Company - " + company.getCompanyName()); buttonAdd.setText("Save"); } GridBagLayout gbl = new GridBagLayout(); bodyPanel.setLayout(gbl); bodyPanel.setBackground(Color.WHITE); bodyPanel.setBorder(new EmptyBorder(0,20,0, 20)); buttonReset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); resetFields(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); buttonAdd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { if (validateForm()) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); updateCompany(); // show company details if (callback != null) callback.callback(thisobj, COMPANY_SAVED, company); else { CompanyWindow window = (CompanyWindow)UniqueWindowFactory.getInstance().getUniqueWindow(new CompanyWindow(), company); window.display(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); closeWindow(); } } }); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { closeWindow(); } }); locationComponent.init(); locationComponent.setBackground(new Color(0xF0, 0xFF, 0xF0)); /* buttonDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); deleteCompany(); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); */ Insets defaultInsets = new Insets(4,0,0,4); comboState.setEditable(true); bodyPanel.add(new JLabel("Name"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textName, new GridBagConstraints(1, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); /* bodyPanel.add(new JLabel("Phone"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textPhone, new GridBagConstraints(1, 1, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Fax"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textFax, new GridBagConstraints(1, 2, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Address"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textAddress, new GridBagConstraints(1, 3, 3, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Suburb"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textSuburb, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("State"), new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(comboState, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Country"), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(textCountry, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0)); bodyPanel.add(new JLabel("Postcode"), new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -