📄 reportpanel.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 *//* * CallReportForm.java * * Created on 16 June 2003, 08:43 */package crms.applet;import crms.applet.*;import crms.module.ReportModule;import crms.util.*;import crms.report.*;import crms.report.form.*;import crms.vo.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.border.*;import java.awt.*;import java.awt.event.*;import java.util.*;/** * * @author Administrator */public class ReportPanel extends CRMSPanel { /** Creates a new instance of CallAddPanel */ JPanel titlePanel = new JPanel(); JLabel titleLabel = new JLabel("CRMS Reports"); //JPanel bodyPanel = new JPanel(); CRMSPanel bodyPanel = CRMSPanel.getEmptyPanel(); JButton buttonSelect = new JButton("Select"); DefaultListModel listModel = new DefaultListModel(); JList listReports = new JList(listModel); JScrollPane scrollPane = new JScrollPane(listReports); JTextArea labelDesc = new JTextArea(3, 30); JScrollPane descScrollPane = new JScrollPane(labelDesc); /** Creates a new instance of CallReportForm */ public ReportPanel() { } 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); labelDesc.setDisabledTextColor(Color.BLACK); labelDesc.setEnabled(false); labelDesc.setLineWrap(true); labelDesc.setWrapStyleWord(true); buttonSelect.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { ReportConfig config = (ReportConfig) listModel.getElementAt(listReports.getSelectedIndex()); selectReport(config); } }); listReports.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent ev) { ReportConfig config = (ReportConfig) listModel.getElementAt( listReports.getSelectedIndex() ); labelDesc.setText(config.getDescription().trim()); } }); Insets defaultInsets = new Insets(4,0,0,4); bodyPanel.add(new JLabel("Select Report"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(scrollPane, new GridBagConstraints(1, 0, 3, 5, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 45, 44)); bodyPanel.add(new JLabel("Description"), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0 ,GridBagConstraints.EAST, GridBagConstraints.NONE, defaultInsets, 0, 0)); bodyPanel.add(descScrollPane, new GridBagConstraints(1, 6, 3, 3, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, defaultInsets, 45, 44)); bodyPanel.add(buttonSelect, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, defaultInsets, 0, 0)); CRMSUtil.insertEmptyRows(8, 4, 11, bodyPanel); CRMSUtil.fixGridBagLayout(gbl, bodyPanel); add(bodyPanel, BorderLayout.CENTER); loadData(); setCurrentPanel(bodyPanel); } public void loadData() { ServerCommand command = new ServerCommand(ReportModule.COMMAND_REPORT_LIST); Server server = ServerFactory.getInstance().getServer(); ServerResponse response = server.sendCommand(command); ArrayList reports = (ArrayList) response.getPart("reports"); listModel = new DefaultListModel(); for (int i=0; i < reports.size(); i++) { listModel.addElement(reports.get(i)); } listReports.setModel(listModel); SwingUtilities.updateComponentTreeUI(listReports); } public void selectReport(ReportConfig config) { String className = config.getReportForm(); try { Class clazz = Class.forName(className); AbstractReportForm panel = (AbstractReportForm) clazz.newInstance(); panel.setReportConfig(config); PanelManager.getInstance().activatePanel(panel); } catch (Exception ex) { ex.printStackTrace(); throw new RuntimeException(ex); } } public boolean validateForm() { StringBuffer buf = new StringBuffer(); boolean valid = true; return valid; } public Class getPanel(int i) { return null; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -