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

📄 categoryeditor.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
字号:
//    Tina POS is a point of sales application designed for touch screens.//    Copyright (C) 2005 Adrian Romero Corchado.//    http://sourceforge.net/projects/tinapos////    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/* * JPanelCategories.java * * Created on 13 de mayo de 2004, 0:03 */package net.adrianromero.tpv.ticket;import javax.swing.*;import net.adrianromero.tpv.forms.AppLocal;import java.awt.image.BufferedImage;import net.adrianromero.format.Formats;import net.adrianromero.basic.BasicException;import net.adrianromero.data.gui.JMessageDialog;import net.adrianromero.data.gui.MessageInf;import net.adrianromero.data.loader.SentenceExec;import net.adrianromero.data.user.EditorRecord;import net.adrianromero.data.user.DirtyManager;import net.adrianromero.tpv.forms.AppView;import net.adrianromero.tpv.forms.SentenceContainer;/** * * @author  adrian */public class CategoryEditor extends JPanel implements EditorRecord {        private DirtyManager m_Dirty;    //private JImageEditor m_jImage;        private SentenceExec m_sentadd;    private SentenceExec m_sentdel;        /** Creates new form JPanelCategories */    public CategoryEditor(AppView app) {        initComponents();                m_sentadd = app.lookupDataLogic(SentenceContainer.class).getCatalogCategoryAdd();        m_sentdel = app.lookupDataLogic(SentenceContainer.class).getCatalogCategoryDel();                //m_jImage = new JImageEditor();        //m_jPanelImage.add(m_jImage, BorderLayout.CENTER);                m_Dirty = new DirtyManager();        m_jId.getDocument().addDocumentListener(m_Dirty);        m_jName.getDocument().addDocumentListener(m_Dirty);        m_jImage.addPropertyChangeListener("image", m_Dirty);        //        JLabel jlblDirty = new JLabelDirty(m_Dirty);//        jlblDirty.setBounds(0, 0, 16, 16);//        add(jlblDirty);                writeValueEOF();    }    public void writeValueEOF() {        m_jId.setText(null);        m_jName.setText(null);        m_jImage.setImage(null);        m_jId.setEnabled(false);        m_jName.setEnabled(false);        m_jImage.setEnabled(false);        m_jCatalogDelete.setEnabled(false);        m_jCatalogAdd.setEnabled(false);    }    public void writeValueInsert() {        m_jId.setText(null);        m_jName.setText(null);        m_jImage.setImage(null);        m_jId.setEnabled(true);        m_jName.setEnabled(true);        m_jImage.setEnabled(true);        m_jCatalogDelete.setEnabled(false);        m_jCatalogAdd.setEnabled(false);    }    public void writeValueDelete(Object value) {        Object[] cat = (Object[]) value;        m_jId.setText(Formats.INT.formatValue(cat[0]));        m_jName.setText(Formats.STRING.formatValue(cat[1]));        m_jImage.setImage((BufferedImage) cat[2]);        m_jId.setEnabled(false);        m_jName.setEnabled(false);        m_jImage.setEnabled(false);        m_jCatalogDelete.setEnabled(false);        m_jCatalogAdd.setEnabled(false);    }        public void writeValueEdit(Object value) {        Object[] cat = (Object[]) value;        m_jId.setText(Formats.INT.formatValue(cat[0]));        m_jName.setText(Formats.STRING.formatValue(cat[1]));        m_jImage.setImage((BufferedImage) cat[2]);        m_jId.setEnabled(false);        m_jName.setEnabled(true);        m_jImage.setEnabled(true);        m_jCatalogDelete.setEnabled(true);        m_jCatalogAdd.setEnabled(true);    }    public Object createValue() throws BasicException {                Object[] cat = new Object[3];        cat[0] = Formats.INT.parseValue(m_jId.getText());        cat[1] = m_jName.getText();        cat[2] = m_jImage.getImage();        return cat;    }            public DirtyManager getDirtyManager() {        return m_Dirty;    }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        jLabel1 = new javax.swing.JLabel();        m_jId = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        m_jName = new javax.swing.JTextField();        jLabel3 = new javax.swing.JLabel();        m_jImage = new net.adrianromero.data.gui.JImageEditor();        m_jCatalogAdd = new javax.swing.JButton();        m_jCatalogDelete = new javax.swing.JButton();        setLayout(null);        jLabel1.setText(AppLocal.getIntString("label.catid"));        add(jLabel1);        jLabel1.setBounds(20, 20, 80, 14);        add(m_jId);        m_jId.setBounds(100, 20, 60, 19);        jLabel2.setText(AppLocal.getIntString("label.catname"));        add(jLabel2);        jLabel2.setBounds(20, 50, 80, 14);        add(m_jName);        m_jName.setBounds(100, 50, 180, 19);        jLabel3.setText(AppLocal.getIntString("label.catimage"));        add(jLabel3);        jLabel3.setBounds(20, 80, 80, 14);        m_jImage.setMaxDimensions(new java.awt.Dimension(32, 32));        add(m_jImage);        m_jImage.setBounds(100, 80, 240, 180);        m_jCatalogAdd.setText(AppLocal.getIntString("button.catalogadd"));        m_jCatalogAdd.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                m_jCatalogAddActionPerformed(evt);            }        });        add(m_jCatalogAdd);        m_jCatalogAdd.setBounds(370, 20, 170, 23);        m_jCatalogDelete.setText(AppLocal.getIntString("button.catalogdel"));        m_jCatalogDelete.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                m_jCatalogDeleteActionPerformed(evt);            }        });        add(m_jCatalogDelete);        m_jCatalogDelete.setBounds(370, 50, 170, 23);    }// </editor-fold>//GEN-END:initComponents    private void m_jCatalogDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCatalogDeleteActionPerformed        try {            m_sentdel.exec(Formats.INT.parseValue(m_jId.getText()));        } catch (BasicException e) {            JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e));        }            }//GEN-LAST:event_m_jCatalogDeleteActionPerformed    private void m_jCatalogAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCatalogAddActionPerformed        try {            Object param = Formats.INT.parseValue(m_jId.getText());            m_sentdel.exec(param); // primero borramos            m_sentadd.exec(param); // y luego insertamos lo que queda        } catch (BasicException e) {            JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e));        }    }//GEN-LAST:event_m_jCatalogAddActionPerformed            // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JButton m_jCatalogAdd;    private javax.swing.JButton m_jCatalogDelete;    private javax.swing.JTextField m_jId;    private net.adrianromero.data.gui.JImageEditor m_jImage;    private javax.swing.JTextField m_jName;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

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