📄 companysearchwindow.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 *//* * CRMSApplet.java * * Created on 27 March 2003, 05:25 */package crms.applet.company;import javax.swing.*;import java.applet.*;import java.awt.*;import java.awt.event.*;import java.util.*;import java.net.*;import crms.util.*;import crms.ui.*;import crms.vo.*;/** Company window master * * @author tnichols */public class CompanySearchWindow extends CRMSWindow implements CallbackDestination { JPanel bodyPanel = new JPanel(); CallbackDestination parent = null; CompanySearchComponent search = new CompanySearchComponent(this); CompanyTableComponent companyTable = new CompanyTableComponent(this); public void createWindow(String title) { final Component thisobj = this; // set window options setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); if (title == null) { setTitle("Companies"); } else { setTitle("Companies - " + title); } setBackground(Color.WHITE); // configure window contents Container pane = getContentPane(); pane.setLayout(new BorderLayout()); pane.setBackground(Color.WHITE); // create search panel search.init(); search.setVisible(true); // create search results panel companyTable.init(); companyTable.setVisible(true); // link search -> results search.setCompanyTable(companyTable); // create my buttons JButton addButton = new JButton("Create New Company"); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { CompanyEditWindow window = new CompanyEditWindow(); window.setCompany(null); window.display(); } } ); JButton btnSelect = new JButton("Select"); btnSelect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { Company company = companyTable.getSelected(); if (company == null) { JOptionPane.showMessageDialog(thisobj, "Please select a company before using this function.", "Company Search", JOptionPane.WARNING_MESSAGE); return; } if (parent != null) { parent.callback(thisobj, CompanyTableComponent.COMPANY_SELECTED, company); closeWindow(); } } } ); JButton viewButton = new JButton("View"); viewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { Company company = companyTable.getSelected(); if (company == null) { JOptionPane.showMessageDialog(thisobj, "Please select a company before using this function.", "Company Search", JOptionPane.WARNING_MESSAGE); return; } CompanyWindow window = (CompanyWindow)UniqueWindowFactory.getInstance().getUniqueWindow(new CompanyWindow(), company); window.display(); } } ); JButton exportButton = new JButton("Export"); exportButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { } } ); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { dispose(); } } ); CRMSButtonBar control = new CRMSButtonBar(); // selection only applies when we have a callback if (parent != null) { control.addButton(CRMSButtonBar.RIGHT, btnSelect); } control.addButton(CRMSButtonBar.RIGHT, viewButton); // control.addButton(CRMSButtonBar.RIGHT, exportButton); control.addButton(CRMSButtonBar.RIGHT, closeButton); control.addButton(CRMSButtonBar.LEFT, addButton); pane.add(search, BorderLayout.NORTH); pane.add(companyTable, BorderLayout.CENTER); pane.add(control, BorderLayout.SOUTH); // handle size / location setSize(660,500); center(); } public CompanySearchWindow(CallbackDestination parent, String title) { this.parent = parent; createWindow(title); } public CompanySearchWindow(CallbackDestination parent) { this(parent, null); } // interface functions public void display() { this.setVisible(true); } public void setSearchCompany(String company) { search.setSearchCompany(company); } public void callback(Object source, int mode, Object data) { if (parent != null) { // Having a parent means we were called to find a company if (source instanceof CompanyTableComponent && mode == CompanyTableComponent.COMPANY_SELECTED) { parent.callback(this, mode, data); closeWindow(); } } else { // no parent indicates that we are selecting a company if (source instanceof CompanyTableComponent && mode == CompanyTableComponent.COMPANY_SELECTED) { CompanyWindow window = (CompanyWindow)UniqueWindowFactory.getInstance().getUniqueWindow(new CompanyWindow(), (Company)data); window.setUser(((CompanyTableComponent)source).getUser()); window.display(); } } } //Main method public static void main(String[] args) { CompanySearchWindow window = new CompanySearchWindow(null); window.display(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -