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

📄 companysearchcomponent.java

📁 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网! 发泄网!
💻 JAVA
字号:
	/* CRMS, customer relationship management system	Copyright (C) 2003Service 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, MA02111-1307USA	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	*//* * CompanySearchComponent * * Created on 04/12/2003 */package crms.applet.company;import javax.swing.*;import javax.swing.border.*;import javax.swing.event.*;import java.awt.*;import java.awt.event.*;import java.util.*;import org.w3c.dom.*;import crms.util.*;import crms.vo.*;import crms.module.*;import crms.ui.*;/** * * @authortnichols */public class CompanySearchComponent extends CRMSComponent {	public static final int COMPANY_SELECTED = 1;		/** Creates a new instance of CallAddPanel */		JPanel bodyPanel = new JPanel();		JTextField textName = new JTextField();	JTextField textSuburb = new JTextField();	JComboBox comboState = new JComboBox(StateCode.STATE_LIST);	JTextField textPostcode = new JTextField();	JTextField textABN = new JTextField();		JTextArea textNote = new JTextArea();	JScrollPane noteScrollPane = new JScrollPane(textNote);	JComboBox comboIndustry = null;	DefaultComboBoxModel companyIdentifierModel = null;	CompanyTableComponent companyTable = null;		String criteria = null;	CallbackDestination parent = null;		/** Create a new company search panel. */	public CompanySearchComponent(CallbackDestination parent) {		this.parent = parent;	}	public void setCompanyTable(CompanyTableComponent table) {		companyTable = table;	}		public void init() {		GridBagLayout gbl = new GridBagLayout();				setBackground(Color.WHITE);				setLayout(new BorderLayout());		bodyPanel.setLayout(gbl);		bodyPanel.setBackground(Color.WHITE);		bodyPanel.setBorder(new EmptyBorder(5,5,5,5));		Insets defaultInsets = new Insets(4,0,0,4);		comboState.setEditable(true);		comboState.setSelectedItem("");		// prepare the industry list		java.util.List companyTypes = CompanyIdentifiersTypeCode.getTypes(CompanyIdentifiersTypeCode.class);		companyTypes.add(0, new CompanyIdentifiersTypeCode("NONE", "- None Selected -"));		companyIdentifierModel = new DefaultComboBoxModel(companyTypes.toArray());		comboIndustry = new JComboBox(companyIdentifierModel);				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, 167, 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, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));		bodyPanel.add(new JLabel("State"),			new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));		bodyPanel.add(comboState,			new GridBagConstraints(1, 5, 1, 1, 1.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));		bodyPanel.add(textPostcode,			new GridBagConstraints(3, 5, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));		bodyPanel.add(new JLabel("Industry"),			new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0));		bodyPanel.add(comboIndustry,			new GridBagConstraints(1, 6, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 0, 0));				//CRMSUtil.fixGridBagLayout(gbl, bodyPanel);		// create the control buttons		CRMSButtonBar buttonPanel = new CRMSButtonBar();		JButton buttonSearch= new JButton("Search");		JButton buttonReset = new JButton("Reset");		buttonPanel.addButton(CRMSButtonBar.RIGHT, buttonSearch);		buttonPanel.addButton(CRMSButtonBar.RIGHT, buttonReset);		buttonReset.addActionListener( new ActionListener() {			public void actionPerformed(ActionEvent ev) {				setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));				resetFields();				setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));			}		});				buttonSearch.addActionListener( new ActionListener() {			public void actionPerformed(ActionEvent ev) {				if (validateForm()) {					setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));					searchCompany();					setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));				}			}		});				// assemble the final panel		add(bodyPanel, BorderLayout.NORTH);		add(buttonPanel, BorderLayout.SOUTH);		resetFields();		if (criteria != null && criteria.trim().length() > 0) {			textName.setText(criteria);			searchCompany();		}	}		public void resetFields() {				Company company = new Company();		company.setState(StateCode.STATE_LIST[0]);				textName.setText("");		textSuburb.setText("");		textPostcode.setText("");		if (companyTable == null) return;				companyTable.clear();		SwingUtilities.updateComponentTreeUI(companyTable);	}	public void setSearchCompany(String company) {		textName.setText(company);		searchCompany();	}		public void searchCompany() {				ServerCommand command = new ServerCommand(CompanyModule.COMPANY_SEARCH);		Location location = new Location();		location.setSuburb(textSuburb.getText());		location.setState((String)comboState.getSelectedItem());		location.setPostCode(textPostcode.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_LOCATIONS, location);		command.setParameter(CompanyModule.PARAM_COMPANY_NAME, textName.getText());/*		command.setParameter(CompanyModule.PARAM_COMPANY_SUBURB, textSuburb.getText());		command.setParameter(CompanyModule.PARAM_COMPANY_STATE, comboState.getSelectedItem());		command.setParameter(CompanyModule.PARAM_COMPANY_POSTCODE, textPostcode.getText());*/		CompanyIdentifiersTypeCode type  = (CompanyIdentifiersTypeCode)companyIdentifierModel.getSelectedItem();		if (type.getCode().compareTo("NONE") != 0) {			command.setParameter(CompanyModule.PARAM_COMPANY_TYPE,type);		}				Server server = ServerFactory.getInstance().getServer();				ServerResponse result = server.sendCommand(command);				if (companyTable == null) return;		companyTable.setCompanyList((ArrayList) result.getPart("results"));		companyTable.setUser((StaffMember) result.getPart("user"));	}		public boolean validateForm() {		boolean valid = true;		CompanyIdentifiersTypeCode type  = (CompanyIdentifiersTypeCode)companyIdentifierModel.getSelectedItem();		String state = (String)comboState.getSelectedItem();		valid = (type.getCode().compareTo("NONE") != 0)				|| (textName.getText().trim().length() > 0)				|| (textSuburb.getText().trim().length() > 0)				|| (state != null && state.trim().length() > 0)				|| (textPostcode.getText().trim().length() > 0);		if (!valid) {			JOptionPane.showMessageDialog(this, "Please enter some search details.", "Company Search", JOptionPane.WARNING_MESSAGE);		}		return valid;	}		}

⌨️ 快捷键说明

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