📄 faqlist.java
字号:
package jm.form.msn.form;import java.awt.BorderLayout;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.File;import java.util.Vector;import javax.imageio.ImageIO;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.ListSelectionModel;import javax.swing.WindowConstants;import jm.entity.ESM000500;import jm.form.msn.config.JMMRConfigConstants;import jm.form.msn.util.Manager;import jm.framework.util.DBOutValue;import jm.framework.util.SimpleEntityTable;import jm.util.JMEntity;import jm.util.JMVector;/** * 维护FAQ * 梦界家园MSNP15 * @author ISHome * @since 0.1 * @version 0.5.0.1 */public class FaqList extends javax.swing.JDialog implements JMMRConfigConstants{ private JPanel topPanel; private JButton view; private JButton delete; private JButton search; private JButton add; private JTable tableList; private JScrollPane bottomScrollPane; private Vector rowData; private Vector columnNames; private Manager manager = null; public FaqList(JFrame form, Manager server) { super(form, true); manager = server; initGUI(); } public FaqList(JDialog form, Manager server) { super(form, true); manager = server; initGUI(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setBackground(new java.awt.Color(255, 255, 255)); { topPanel = new JPanel(); GridLayout jPanel1Layout = new GridLayout(1, 1); jPanel1Layout.setColumns(1); jPanel1Layout.setHgap(5); jPanel1Layout.setVgap(5); topPanel.setLayout(jPanel1Layout); getContentPane().add(topPanel, BorderLayout.NORTH); topPanel.setPreferredSize(new java.awt.Dimension(632, 30)); topPanel.setBackground(new java.awt.Color(255, 255, 255)); { add = new JButton(); topPanel.add(add); add.setText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_ADD_TEXT)); add.setToolTipText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_ADD_HELP)); add.setFont(BUTTON_FOUNT); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { add(); } }); } { search = new JButton(); topPanel.add(search); search.setText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_SEARCH_TEXT)); search.setToolTipText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_SEARCH_HELP)); search.setFont(BUTTON_FOUNT); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { search(); } }); } { delete = new JButton(); topPanel.add(delete); delete.setText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_DELETE_TEXT)); delete.setToolTipText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_DELETE_HELP)); delete.setFont(BUTTON_FOUNT); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { delete(); } }); } { view = new JButton(); topPanel.add(view); view.setText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_VIEW_TEXT)); view.setToolTipText(manager.getConfigMap().get(LANG_FAQLIST_BUTTON_VIEW_HELP)); view.setFont(BUTTON_FOUNT); view.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { view(); } }); } } { bottomScrollPane = new JScrollPane(); getContentPane().add(bottomScrollPane, BorderLayout.CENTER); bottomScrollPane.setBackground(new java.awt.Color(255, 255, 255)); { rowData = new Vector(); columnNames = new Vector(); ESM000500 faq = new ESM000500(); String[] names = faq.getNames().split(JMEntity.SPLIT); for (int i = 0; i < names.length; i++) { columnNames.add(names[i]); } tableList = new JTable(rowData, columnNames); tableList.setFont(LABEL_FOUNT); tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bottomScrollPane.setViewportView(tableList); } } { this.setTitle(manager.getConfigMap().get(LANG_FAQLIST_FORM_TITLE)); this.addWindowListener(new WindowAdapter() { /** * 窗口正处在关闭过程中时调用。此时可重写关闭操作。 * * @param e */ public void windowClosing(WindowEvent e) { dispose();// 关闭画面 } }); } // 配置系统图标 this.setIconImage(ImageIO.read(new File(manager.getConfigMap().get(STYLES_MAIN_FORM_FAQ)))); this.pack(); this.setSize(640, 480); } catch (Exception e) { manager.showErrorMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_FAILED)); } } /** * 追加 */ private void add(){ this.setVisible(false); FaqEdit form = new FaqEdit(manager.getMainForm(), manager); manager.openFrame(form); this.setVisible(true); } /** * 删除 */ private void delete() { try { // 读取数据库全部TAG ESM000500 faq = new ESM000500(); int selelt = tableList.getSelectedRow(); if (rowData.size() == 0) { return; } Vector item = (Vector) rowData.get(selelt); faq.setNumID("" + item.get(0)); SimpleEntityTable _set = new SimpleEntityTable(faq, true); DBOutValue _out = _set.delete(); if (!_out.getResult()) { return; } rowData.remove(selelt); tableList.updateUI(); manager.showInfoMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_DELETE_OK)); } catch (Exception e) { if (tableList.getSelectedRow() < 0) { manager.showErrorMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_NO_SELECT_FAILED)); } else { manager.showErrorMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_NO_DELETE_FAILED)); } } } /** * 浏览 */ private void view() { try{ ESM000500 faq = new ESM000500(); Vector item = (Vector) rowData.get(tableList.getSelectedRow()); faq.setNumID("" + item.get(0)); faq.setTitle("" + item.get(1)); faq.setTag("" + item.get(2)); faq.setFaqValue("" + item.get(3)); FaqEdit form = new FaqEdit(manager.getMainForm(), manager); form.reLoad(faq); this.setVisible(false); manager.openFrame(form); this.setVisible(true); } catch (Exception e) { if (tableList.getSelectedRow() < 0) { manager.showInfoMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_NO_SELECT_FAILED)); } else { manager.showErrorMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_NO_VIEW_FAILED)); } } } /** * 检索 */ private void search() { try { rowData.clear(); tableList.updateUI(); // 读取数据库全部TAG ESM000500 faq = new ESM000500(); SimpleEntityTable _set = new SimpleEntityTable(faq, true); DBOutValue _out = _set.select(); if (!_out.getResult() || _out.getResultCount() == 0) { return; } // 整理列表 JMVector faqs = _out.getResultList(); Vector item; for (int i = 0; i < faqs.size(); i++) { item = new Vector(); faq = (ESM000500) faqs.get(i); item.add(faq.getNumID()); item.add(faq.getTitle()); item.add(faq.getTag()); item.add(faq.getFaqValue()); rowData.add(item); } tableList.updateUI(); } catch (Exception e) { manager.showErrorMessageDialog(manager.getConfigMap().get(LANG_FAQLIST_FORM_NO_SEARCH_FAILED)); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -