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

📄 peopleview.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

package net.adrianromero.tpv.admin;

import javax.swing.*;
import net.adrianromero.tpv.forms.AppLocal;
import net.adrianromero.tpv.util.Hashcypher;
import java.awt.image.BufferedImage;
import net.adrianromero.basic.BasicException;
import net.adrianromero.data.gui.ComboBoxValModel;
import net.adrianromero.data.gui.ListCellRendererBasic;
import net.adrianromero.data.loader.SentenceList;
import net.adrianromero.data.loader.TableDefinition;
import net.adrianromero.data.user.*;
import net.adrianromero.tpv.forms.AppView;

public class PeopleView extends JPanel implements EditorView {

    private ObjectContainer<String> m_sPassword;
    
    private SentenceList m_sentrole;
    private ComboBoxValModel m_RoleModel;  
    
    /** Creates new form PeopleEditor */
    public PeopleView(AppView app) {
        initComponents();
        
        m_sPassword = new ObjectContainer<String>();
        
        // El modelo de roles
        m_sentrole = app.lookupDataLogic(DataLogicAdmin.class).getRolesList();
        m_RoleModel = new ComboBoxValModel();
    }
    
    public void init(EditorRecordBasic editor) {
        editor.addTextComponent(m_jName, EditorItem.EDITABLE_PK);
        editor.addObjectContainer(m_sPassword);
        editor.addComboBox(m_jRole, EditorItem.EDITABLE_NORMAL);
        editor.addCheckBox(m_jVisible, EditorItem.EDITABLE_NORMAL);
        editor.addImageEditor(m_jImage, EditorItem.EDITABLE_NORMAL);
    }
    
    public void writeValue(Object value) {
        
        Object[] people = (Object[]) value;
        m_jName.setText((String) people[0]);
        m_sPassword.setObject((String) people[1]);
        m_RoleModel.setSelectedKey(people[2]);
        m_jVisible.setSelected(((Boolean) people[3]).booleanValue());
        m_jImage.setImage((BufferedImage) people[4]);
    }
    
    public Object readValue() throws BasicException {
        
        Object[] people = new Object[5];
        people[0] = m_jName.getText();
        people[1] = m_sPassword.getObject();
        people[2] = m_RoleModel.getSelectedKey();
        people[3] = new Boolean(m_jVisible.isSelected());
        people[4] = m_jImage.getImage();
        return people;
    }
    public JComponent getComponent() {
        return this;
    }
    
    public void activate() throws BasicException {
        
        m_RoleModel = new ComboBoxValModel(m_sentrole.list());
        m_jRole.setModel(m_RoleModel);
    }
     
    /** 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_jName = new javax.swing.JTextField();
        m_jVisible = new javax.swing.JCheckBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        m_jImage = new net.adrianromero.data.gui.JImageEditor();
        jButton1 = new javax.swing.JButton();
        m_jRole = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();

        setLayout(null);

        jLabel1.setText(AppLocal.getIntString("label.peoplename"));
        add(jLabel1);
        jLabel1.setBounds(20, 20, 80, 14);

        add(m_jName);
        m_jName.setBounds(110, 20, 180, 19);

        add(m_jVisible);
        m_jVisible.setBounds(110, 80, 140, 20);

        jLabel3.setText(AppLocal.getIntString("label.peoplevisible"));
        add(jLabel3);
        jLabel3.setBounds(20, 80, 90, 14);

        jLabel4.setText(AppLocal.getIntString("label.peopleimage"));
        add(jLabel4);
        jLabel4.setBounds(20, 110, 90, 14);

        m_jImage.setMaxDimensions(new java.awt.Dimension(32, 32));
        add(m_jImage);
        m_jImage.setBounds(110, 110, 250, 180);

        jButton1.setText(AppLocal.getIntString("button.peoplepassword"));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        add(jButton1);
        jButton1.setBounds(300, 20, 150, 23);

        add(m_jRole);
        m_jRole.setBounds(110, 50, 180, 20);

        jLabel2.setText(AppLocal.getIntString("label.role"));
        add(jLabel2);
        jLabel2.setBounds(20, 50, 90, 14);

    }
    // </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        String sNewPassword = Hashcypher.changePassword(this, m_sPassword.getObject());
        if (sNewPassword != null) {
            m_sPassword.setObject(sNewPassword);
        }

    }//GEN-LAST:event_jButton1ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private net.adrianromero.data.gui.JImageEditor m_jImage;
    private javax.swing.JTextField m_jName;
    private javax.swing.JComboBox m_jRole;
    private javax.swing.JCheckBox m_jVisible;
    // End of variables declaration//GEN-END:variables
    
}

⌨️ 快捷键说明

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