// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works
// http://www.unicenta.net/unicentaopos
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS 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 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.openbravo.pos.inventory;
import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.loader.*;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.reports.ReportEditorCreator;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.List;
/**
*
* @author adrianromero
*/
public class AttributeSetFilter extends javax.swing.JPanel implements ReportEditorCreator {
private SentenceList attusesent;
private ComboBoxValModel attusemodel;
/** Creates new form AttributeUseFilter */
public AttributeSetFilter() {
initComponents();
}
@Override
public void init(AppView app) {
attusesent = new StaticSentence(app.getSession()
, "SELECT ID, NAME FROM ATTRIBUTESET ORDER BY NAME"
, null
, new SerializerRead() {@Override
public Object readValues(DataRead dr) throws BasicException {
return new AttributeSetInfo(dr.getString(1), dr.getString(2));
}});
attusemodel = new ComboBoxValModel();
}
@Override
public void activate() throws BasicException {
List a = attusesent.list();
attusemodel = new ComboBoxValModel(a);
attusemodel.setSelectedFirst();
jAttrSet.setModel(attusemodel);
}
@Override
public SerializerWrite getSerializerWrite() {
return SerializerWriteString.INSTANCE;
}
@Override
public Component getComponent() {
return this;
}
public void addActionListener(ActionListener l) {
jAttrSet.addActionListener(l);
}
public void removeActionListener(ActionListener l) {
jAttrSet.removeActionListener(l);
}
@Override
public Object createValue() throws BasicException {
AttributeSetInfo attset = (AttributeSetInfo) attusemodel.getSelectedItem();
return attset == null ? null : attset.getId();
}
/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel8 = new javax.swing.JLabel();
jAttrSet = new javax.swing.JComboBox();
setPreferredSize(new java.awt.Dimension(354, 61));
jLabel8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jLabel8.setText(AppLocal.getIntString("label.attributeset")); // NOI18N
jAttrSet.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jAttrSet.setPreferredSize(new java.awt.Dimension(28, 28));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jAttrSet, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jAttrSet, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE))
.addContainerGap(25, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox jAttrSet;
private javax.swing.JLabel jLabel8;
// End of variables declaration//GEN-END:variables
}