5.0 Source Code
Committing 5.0 Source Code
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.IKeyGetter;
|
||||
import com.unicenta.data.loader.KeyGetterBuilder;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class ComboBoxValModel extends AbstractListModel implements ComboBoxModel {
|
||||
|
||||
private List m_aData;
|
||||
private IKeyGetter m_keygetter;
|
||||
private Object m_selected;
|
||||
|
||||
/** Creates a new instance of ComboBoxValModel
|
||||
* @param aData
|
||||
* @param keygetter */
|
||||
public ComboBoxValModel(List aData, IKeyGetter keygetter) {
|
||||
m_aData = aData;
|
||||
m_keygetter = keygetter;
|
||||
m_selected = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aData
|
||||
*/
|
||||
public ComboBoxValModel(List aData) {
|
||||
this(aData, KeyGetterBuilder.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param keygetter
|
||||
*/
|
||||
public ComboBoxValModel(IKeyGetter keygetter) {
|
||||
this(new ArrayList(), keygetter);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ComboBoxValModel() {
|
||||
this(new ArrayList(), KeyGetterBuilder.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void add(Object c) {
|
||||
m_aData.add(c);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param c
|
||||
*/
|
||||
public void del(Object c) {
|
||||
m_aData.remove(c);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
* @param c
|
||||
*/
|
||||
public void add(int index, Object c) {
|
||||
m_aData.add(index, c);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aData
|
||||
*/
|
||||
public void refresh(List aData) {
|
||||
m_aData = aData;
|
||||
m_selected = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object getSelectedKey() {
|
||||
if (m_selected == null) {
|
||||
return null;
|
||||
} else {
|
||||
return m_keygetter.getKey(m_selected); // Si casca, excepcion parriba
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getSelectedText() {
|
||||
if (m_selected == null) {
|
||||
return null;
|
||||
} else {
|
||||
return m_selected.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aKey
|
||||
*/
|
||||
public void setSelectedKey(Object aKey) {
|
||||
setSelectedItem(getElementByKey(aKey));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setSelectedFirst() {
|
||||
m_selected = (m_aData.isEmpty()) ? null : m_aData.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aKey
|
||||
* @return
|
||||
*/
|
||||
public Object getElementByKey(Object aKey) {
|
||||
if (aKey != null) {
|
||||
Iterator it = m_aData.iterator();
|
||||
while (it.hasNext()) {
|
||||
Object value = it.next();
|
||||
if (aKey.equals(m_keygetter.getKey(value))) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return m_aData.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return m_selected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return m_aData.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object anItem) {
|
||||
|
||||
if ((m_selected != null && !m_selected.equals(anItem)) || m_selected == null && anItem != null) {
|
||||
m_selected = anItem;
|
||||
fireContentsChanged(this, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class CompoundIcon implements Icon {
|
||||
|
||||
private Icon m_icon1;
|
||||
private Icon m_icon2;
|
||||
|
||||
/** Creates a new instance of CompoundIcon
|
||||
* @param icon1
|
||||
* @param icon2 */
|
||||
public CompoundIcon(Icon icon1, Icon icon2) {
|
||||
m_icon1 = icon1;
|
||||
m_icon2 = icon2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return Math.max(m_icon1.getIconHeight(), m_icon2.getIconHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return m_icon1.getIconWidth() + m_icon2.getIconWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) {
|
||||
m_icon1.paintIcon(c, g, x, y);
|
||||
m_icon2.paintIcon(c, g, x + m_icon1.getIconWidth(), y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.Vectorer;
|
||||
import com.unicenta.data.user.Finder;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class FindInfo implements Finder {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final int MATCH_STARTFIELD = 0;
|
||||
public static final int MATCH_WHOLEFIELD = 1;
|
||||
public static final int MATCH_ANYPARTFIELD = 2;
|
||||
public static final int MATCH_REGEXP = 3;
|
||||
|
||||
private String m_sTextCompare;
|
||||
private Pattern m_TextPattern;
|
||||
|
||||
private String m_sText; // Texto a buscar
|
||||
private int m_iField; // Campo de busqueda
|
||||
private int m_iMatch; // Tipo de busqueda
|
||||
private boolean m_bMatchCase; // Mayusculas / Minusculas
|
||||
|
||||
private Vectorer m_vec;
|
||||
|
||||
/** Creates a new instance of FindInfo
|
||||
* @param vec
|
||||
* @param sText
|
||||
* @param iField
|
||||
* @param iMatch
|
||||
* @param bMatchCase */
|
||||
public FindInfo(Vectorer vec, String sText, int iField, boolean bMatchCase, int iMatch) {
|
||||
m_vec = vec;
|
||||
m_sText = sText;
|
||||
m_iField = iField;
|
||||
m_bMatchCase = bMatchCase;
|
||||
m_iMatch = iMatch;
|
||||
|
||||
if (iMatch == MATCH_REGEXP) {
|
||||
m_TextPattern = m_bMatchCase
|
||||
? Pattern.compile(m_sText)
|
||||
: Pattern.compile(m_sText, Pattern.CASE_INSENSITIVE);
|
||||
} else {
|
||||
m_sTextCompare = m_bMatchCase
|
||||
? m_sText
|
||||
: m_sText.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a new instance of FindInfo
|
||||
* @param vec */
|
||||
public FindInfo(Vectorer vec) {
|
||||
this(vec, "", 0, true, MATCH_ANYPARTFIELD);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Vectorer getVectorer() {
|
||||
return m_vec;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getText() {
|
||||
return m_sText;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getField() {
|
||||
return m_iField;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isMatchCase() {
|
||||
return m_bMatchCase;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMatch() {
|
||||
return m_iMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public boolean match(Object obj) throws BasicException {
|
||||
|
||||
String[] v = m_vec.getValues(obj);
|
||||
|
||||
String sField = m_bMatchCase
|
||||
? v[m_iField]
|
||||
: v[m_iField].toUpperCase();
|
||||
|
||||
switch (m_iMatch) {
|
||||
case MATCH_STARTFIELD:
|
||||
return sField.startsWith(m_sTextCompare);
|
||||
case MATCH_WHOLEFIELD:
|
||||
return sField.equals(m_sTextCompare);
|
||||
case MATCH_ANYPARTFIELD:
|
||||
return sField.contains(m_sTextCompare);
|
||||
case MATCH_REGEXP:
|
||||
return m_TextPattern.matcher(sField).matches();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[80, 20]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[80, 20]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[80, 20]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,22,0,0,0,108"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jlblIndex">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="XX"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="/"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jlblCounter">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="XX"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="
"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,104 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import com.unicenta.format.Formats;
|
||||
import com.unicenta.data.user.BrowseListener;
|
||||
import com.unicenta.data.user.BrowsableEditableData;
|
||||
import com.unicenta.data.user.StateListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class JCounter extends JPanel implements BrowseListener, StateListener {
|
||||
|
||||
/** Creates new form JCounter
|
||||
* @param bd */
|
||||
public JCounter(BrowsableEditableData bd) {
|
||||
initComponents();
|
||||
bd.addBrowseListener(this);
|
||||
bd.addStateListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iState
|
||||
*/
|
||||
public void updateState(int iState) {
|
||||
if (iState == BrowsableEditableData.ST_INSERT) {
|
||||
// Insert
|
||||
jlblIndex.setText("*");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iIndex
|
||||
* @param iCounter
|
||||
*/
|
||||
public void updateIndex(int iIndex, int iCounter) {
|
||||
|
||||
if (iIndex >= 0 && iIndex < iCounter) {
|
||||
jlblIndex.setText(Formats.INT.formatValue(new Integer(iIndex + 1)));
|
||||
} else {
|
||||
jlblIndex.setText("-");
|
||||
}
|
||||
jlblCounter.setText(Formats.INT.formatValue(new Integer(iCounter)));
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jlblIndex = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jlblCounter = new javax.swing.JLabel();
|
||||
|
||||
setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
setMaximumSize(new java.awt.Dimension(80, 20));
|
||||
setMinimumSize(new java.awt.Dimension(80, 20));
|
||||
setPreferredSize(new java.awt.Dimension(80, 20));
|
||||
|
||||
jlblIndex.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jlblIndex.setText("XX");
|
||||
add(jlblIndex);
|
||||
|
||||
jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel2.setText("/");
|
||||
add(jLabel2);
|
||||
|
||||
jlblCounter.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jlblCounter.setText("XX");
|
||||
add(jlblCounter);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jlblCounter;
|
||||
private javax.swing.JLabel jlblIndex;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="title.find" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-5,0,0,1,-78"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="m_jFind" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="m_jWhere" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="m_jMatchCase" min="-2" pref="230" max="-2" attributes="0"/>
|
||||
<Component id="m_jMatch" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jFind" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jWhere" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jMatch" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="m_jMatchCase" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.findwhat" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="m_jFind">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[250, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.where" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="m_jWhere">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[250, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.match" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="m_jMatch">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[250, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="m_jMatchCase">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.casesensitive" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jcmdCancel">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/cancel.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.cancel" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jcmdOK">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/ok.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.OK" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,269 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import com.unicenta.data.loader.Vectorer;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JFind extends JDialog {
|
||||
|
||||
private FindInfo m_FindInfo;
|
||||
private Vectorer m_vec;
|
||||
|
||||
/** Creates new form JFind */
|
||||
private JFind(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
/** Creates new form JFind */
|
||||
private JFind(java.awt.Dialog parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
private FindInfo init(FindInfo lastFindInfo) throws BasicException {
|
||||
|
||||
initComponents();
|
||||
|
||||
getRootPane().setDefaultButton(jcmdOK);
|
||||
|
||||
// El texto
|
||||
m_jFind.setText(lastFindInfo.getText());
|
||||
// Pinto la caja
|
||||
m_jWhere.removeAllItems();
|
||||
for (int i = 0; i < lastFindInfo.getVectorer().getHeaders().length; i++) {
|
||||
m_jWhere.addItem(lastFindInfo.getVectorer().getHeaders()[i]);
|
||||
}
|
||||
m_jWhere.setSelectedIndex(lastFindInfo.getField());
|
||||
// El Match
|
||||
m_jMatch.removeAllItems();
|
||||
m_jMatch.addItem(LocalRes.getIntString("list.startfield"));
|
||||
m_jMatch.addItem(LocalRes.getIntString("list.wholefield"));
|
||||
m_jMatch.addItem(LocalRes.getIntString("list.anypart"));
|
||||
m_jMatch.addItem(LocalRes.getIntString("list.re"));
|
||||
m_jMatch.setSelectedIndex(lastFindInfo.getMatch());
|
||||
// El case
|
||||
m_jMatchCase.setSelected(lastFindInfo.isMatchCase());
|
||||
|
||||
m_vec = lastFindInfo.getVectorer();
|
||||
|
||||
m_FindInfo = null;
|
||||
|
||||
//show();
|
||||
setVisible(true);
|
||||
|
||||
return m_FindInfo;
|
||||
}
|
||||
|
||||
private static Window getWindow(Component parent) {
|
||||
if (parent == null) {
|
||||
return new JFrame();
|
||||
} else if (parent instanceof Frame || parent instanceof Dialog) {
|
||||
return (Window)parent;
|
||||
} else {
|
||||
return getWindow(parent.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
* @param lastFindInfo
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public static FindInfo showMessage(Component parent, FindInfo lastFindInfo) throws BasicException {
|
||||
|
||||
Window window = getWindow(parent);
|
||||
|
||||
JFind myMsg;
|
||||
if (window instanceof Frame) {
|
||||
myMsg = new JFind((Frame) window, true);
|
||||
} else {
|
||||
myMsg = new JFind((Dialog) window, true);
|
||||
}
|
||||
return myMsg.init(lastFindInfo);
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
m_jFind = new javax.swing.JTextField();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
m_jWhere = new javax.swing.JComboBox();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
m_jMatch = new javax.swing.JComboBox();
|
||||
m_jMatchCase = new javax.swing.JCheckBox();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
jcmdCancel = new javax.swing.JButton();
|
||||
jcmdOK = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(LocalRes.getIntString("title.find")); // NOI18N
|
||||
setResizable(false);
|
||||
|
||||
jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel1.setText(LocalRes.getIntString("label.findwhat")); // NOI18N
|
||||
jLabel1.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jFind.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jFind.setPreferredSize(new java.awt.Dimension(250, 30));
|
||||
|
||||
jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel2.setText(LocalRes.getIntString("label.where")); // NOI18N
|
||||
jLabel2.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jWhere.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jWhere.setPreferredSize(new java.awt.Dimension(250, 30));
|
||||
|
||||
jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel3.setText(LocalRes.getIntString("label.match")); // NOI18N
|
||||
jLabel3.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jMatch.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jMatch.setPreferredSize(new java.awt.Dimension(250, 30));
|
||||
|
||||
m_jMatchCase.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jMatchCase.setText(LocalRes.getIntString("label.casesensitive")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(m_jFind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(m_jWhere, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(m_jMatchCase, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jMatch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jFind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jWhere, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jMatch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(m_jMatchCase)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
|
||||
|
||||
jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N
|
||||
jcmdCancel.setText(LocalRes.getIntString("button.cancel")); // NOI18N
|
||||
jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45));
|
||||
jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdCancel);
|
||||
|
||||
jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N
|
||||
jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N
|
||||
jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45));
|
||||
jcmdOK.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdOKActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdOK);
|
||||
|
||||
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
setSize(new java.awt.Dimension(434, 251));
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
|
||||
|
||||
dispose();
|
||||
|
||||
}//GEN-LAST:event_jcmdCancelActionPerformed
|
||||
|
||||
private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
|
||||
|
||||
m_FindInfo = new FindInfo(m_vec,
|
||||
m_jFind.getText(),
|
||||
m_jWhere.getSelectedIndex(),
|
||||
m_jMatchCase.isSelected(),
|
||||
m_jMatch.getSelectedIndex());
|
||||
|
||||
dispose();
|
||||
|
||||
}//GEN-LAST:event_jcmdOKActionPerformed
|
||||
|
||||
|
||||
|
||||
// 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.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JButton jcmdCancel;
|
||||
private javax.swing.JButton jcmdOK;
|
||||
private javax.swing.JTextField m_jFind;
|
||||
private javax.swing.JComboBox m_jMatch;
|
||||
private javax.swing.JCheckBox m_jMatchCase;
|
||||
private javax.swing.JComboBox m_jWhere;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-16,0,0,1,44"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="m_jScr">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="m_jImage">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/no_photo.png"/>
|
||||
</Property>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="false"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="5" right="5" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="0" width="-1" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="rows" type="int" value="0"/>
|
||||
<Property name="verticalGap" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnopen">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/camera.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Open Folder"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnopenActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnclose">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/fileclose.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Remove Picture"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtncloseActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomin">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag+.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom In"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoominActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="m_jPercent">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
|
||||
<CompoundBorder>
|
||||
<Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder>
|
||||
<Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
<Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="1" left="4" right="4" top="1"/>
|
||||
</Border>
|
||||
</CompoundBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[10, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomout">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag-.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom Out"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoomoutActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,444 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JImageEditor extends javax.swing.JPanel {
|
||||
|
||||
private Dimension m_maxsize;
|
||||
private ZoomIcon m_icon;
|
||||
private BufferedImage m_Img = null;
|
||||
|
||||
private static File m_fCurrentDirectory = null;
|
||||
private static NumberFormat m_percentformat = new DecimalFormat("#,##0.##%");
|
||||
|
||||
/** Creates new form JImageEditor */
|
||||
public JImageEditor() {
|
||||
initComponents();
|
||||
|
||||
m_Img = null;
|
||||
m_maxsize = null;
|
||||
m_icon = new ZoomIcon();
|
||||
m_jImage.setIcon(m_icon);
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
privateSetEnabled(isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setMaxDimensions(Dimension size) {
|
||||
m_maxsize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Dimension getMaxDimensions() {
|
||||
return m_maxsize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
|
||||
privateSetEnabled(value);
|
||||
super.setEnabled(value);
|
||||
}
|
||||
|
||||
private void privateSetEnabled(boolean value) {
|
||||
m_jbtnopen.setEnabled(value);
|
||||
m_jbtnclose.setEnabled(value && (m_Img != null));
|
||||
m_jbtnzoomin.setEnabled(value && (m_Img != null));
|
||||
m_jbtnzoomout.setEnabled(value && (m_Img != null));
|
||||
m_jPercent.setEnabled(value && (m_Img != null));
|
||||
m_jScr.setEnabled(value && (m_Img != null));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param img
|
||||
*/
|
||||
public void setImage(BufferedImage img) {
|
||||
BufferedImage oldimg = m_Img;
|
||||
m_Img = img;
|
||||
m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img));
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
privateSetEnabled(isEnabled());
|
||||
|
||||
firePropertyChange("image", oldimg, m_Img);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BufferedImage getImage() {
|
||||
return m_Img;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getZoom() {
|
||||
return m_icon.getZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
public void setZoom(double zoom) {
|
||||
double oldzoom = m_icon.getZoom();
|
||||
m_icon.setZoom(zoom);
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
firePropertyChange("zoom", oldzoom, zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void incZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void decZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void doLoad() {
|
||||
JFileChooser fc = new JFileChooser(m_fCurrentDirectory);
|
||||
|
||||
fc.addChoosableFileFilter(new ExtensionsFilter(LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp"));
|
||||
|
||||
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
BufferedImage img = ImageIO.read(fc.getSelectedFile());
|
||||
if (img != null) {
|
||||
// compruebo que no exceda el tamano maximo.
|
||||
if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) {
|
||||
if (JOptionPane.showConfirmDialog(this,
|
||||
LocalRes.getIntString("message.resizeimage"),
|
||||
LocalRes.getIntString("title.editor"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
// Redimensionamos la imagen para que se ajuste
|
||||
img = resizeImage(img);
|
||||
}
|
||||
}
|
||||
setImage(img);
|
||||
m_fCurrentDirectory = fc.getCurrentDirectory();
|
||||
}
|
||||
} catch (IOException eIO) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage resizeImage(BufferedImage img) {
|
||||
|
||||
int myheight = img.getHeight();
|
||||
int mywidth = img.getWidth();
|
||||
|
||||
if (myheight > m_maxsize.height) {
|
||||
mywidth = (int) (mywidth * m_maxsize.height / myheight);
|
||||
myheight = m_maxsize.height;
|
||||
}
|
||||
if (mywidth > m_maxsize.width) {
|
||||
myheight = (int) (myheight * m_maxsize.width / mywidth);
|
||||
mywidth = m_maxsize.width;
|
||||
}
|
||||
|
||||
BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
|
||||
double scalex = (double) mywidth / (double) img.getWidth(null);
|
||||
double scaley = (double) myheight / (double) img.getHeight(null);
|
||||
|
||||
Graphics2D g2d = thumb.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
//g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
|
||||
g2d.setColor(new Color(0, 0, 0, 0)); // Transparent
|
||||
|
||||
g2d.fillRect(0, 0, mywidth, myheight);
|
||||
if (scalex < scaley) {
|
||||
g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0)
|
||||
, mywidth, (int) (img.getHeight(null) * scalex), null);
|
||||
} else {
|
||||
g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0
|
||||
, (int) (img.getWidth(null) * scaley), myheight, null);
|
||||
}
|
||||
g2d.dispose();
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private static class ZoomIcon implements Icon {
|
||||
|
||||
private Icon ico;
|
||||
private double zoom;
|
||||
|
||||
public ZoomIcon() {
|
||||
this.ico = null;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconHeight());
|
||||
}
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconWidth());
|
||||
}
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
if (ico != null) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
AffineTransform oldt = g2d.getTransform();
|
||||
g2d.transform(AffineTransform.getScaleInstance(zoom, zoom));
|
||||
ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom));
|
||||
g2d.setTransform(oldt);
|
||||
}
|
||||
}
|
||||
public void setIcon(Icon ico) {
|
||||
this.ico = ico;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
public void setZoom(double zoom) {
|
||||
this.zoom = zoom;
|
||||
}
|
||||
public double getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
}
|
||||
private static class ExtensionsFilter extends FileFilter {
|
||||
|
||||
private String message;
|
||||
private String[] extensions;
|
||||
|
||||
public ExtensionsFilter(String message, String... extensions) {
|
||||
this.message = message;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(java.io.File f) {
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
} else {
|
||||
String sFileName = f.getName();
|
||||
int ipos = sFileName.lastIndexOf('.');
|
||||
if (ipos >= 0) {
|
||||
String sExt = sFileName.substring(ipos + 1);
|
||||
for(String s : extensions) {
|
||||
if (s.equalsIgnoreCase(sExt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
m_jScr = new javax.swing.JScrollPane();
|
||||
m_jImage = new javax.swing.JLabel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
m_jbtnopen = new javax.swing.JButton();
|
||||
m_jbtnclose = new javax.swing.JButton();
|
||||
m_jbtnzoomin = new javax.swing.JButton();
|
||||
m_jPercent = new javax.swing.JLabel();
|
||||
m_jbtnzoomout = new javax.swing.JButton();
|
||||
|
||||
setBackground(new java.awt.Color(255, 255, 255));
|
||||
setOpaque(false);
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
m_jScr.setBackground(new java.awt.Color(255, 255, 255));
|
||||
m_jScr.setOpaque(false);
|
||||
|
||||
m_jImage.setBackground(new java.awt.Color(255, 255, 255));
|
||||
m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N
|
||||
m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
m_jScr.setViewportView(m_jImage);
|
||||
|
||||
add(m_jScr, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
|
||||
jPanel1.setOpaque(false);
|
||||
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
|
||||
|
||||
jPanel2.setBackground(new java.awt.Color(255, 255, 255));
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
|
||||
jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jPanel2.setOpaque(false);
|
||||
jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2));
|
||||
|
||||
m_jbtnopen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/camera.png"))); // NOI18N
|
||||
m_jbtnopen.setToolTipText("Open Folder");
|
||||
m_jbtnopen.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnopen.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnopenActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnopen);
|
||||
|
||||
m_jbtnclose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileclose.png"))); // NOI18N
|
||||
m_jbtnclose.setToolTipText("Remove Picture");
|
||||
m_jbtnclose.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnclose.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtncloseActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnclose);
|
||||
|
||||
m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N
|
||||
m_jbtnzoomin.setToolTipText("Zoom In");
|
||||
m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoominActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomin);
|
||||
|
||||
m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4)));
|
||||
m_jPercent.setOpaque(true);
|
||||
m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30));
|
||||
jPanel2.add(m_jPercent);
|
||||
|
||||
m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N
|
||||
m_jbtnzoomout.setToolTipText("Zoom Out");
|
||||
m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoomoutActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomout);
|
||||
|
||||
jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
|
||||
|
||||
add(jPanel1, java.awt.BorderLayout.LINE_END);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
decZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
incZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
private void m_jbtncloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtncloseActionPerformed
|
||||
|
||||
setImage(null);
|
||||
|
||||
}//GEN-LAST:event_m_jbtncloseActionPerformed
|
||||
|
||||
private void m_jbtnopenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnopenActionPerformed
|
||||
|
||||
doLoad();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnopenActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JLabel m_jImage;
|
||||
private javax.swing.JLabel m_jPercent;
|
||||
private javax.swing.JScrollPane m_jScr;
|
||||
private javax.swing.JButton m_jbtnclose;
|
||||
private javax.swing.JButton m_jbtnopen;
|
||||
private javax.swing.JButton m_jbtnzoomin;
|
||||
private javax.swing.JButton m_jbtnzoomout;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-16,0,0,1,44"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="m_jScr">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="m_jImage">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/no_photo.png"/>
|
||||
</Property>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="false"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="5" right="5" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="0" width="-1" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="rows" type="int" value="0"/>
|
||||
<Property name="verticalGap" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomin">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag+.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom In"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoominActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="m_jPercent">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
|
||||
<CompoundBorder>
|
||||
<Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder>
|
||||
<Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
<Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="1" left="4" right="4" top="1"/>
|
||||
</Border>
|
||||
</CompoundBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[10, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomout">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag-.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom Out"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoomoutActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,395 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JImageViewerCustomer extends javax.swing.JPanel {
|
||||
|
||||
private Dimension m_maxsize;
|
||||
private final ZoomIcon m_icon;
|
||||
private BufferedImage m_Img = null;
|
||||
|
||||
private static File m_fCurrentDirectory = null;
|
||||
private static final NumberFormat m_percentformat = new DecimalFormat("#,##0.##%");
|
||||
|
||||
public JImageViewerCustomer() {
|
||||
initComponents();
|
||||
|
||||
m_Img = null;
|
||||
m_maxsize = null;
|
||||
m_icon = new ZoomIcon();
|
||||
m_jImage.setIcon(m_icon);
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
privateSetEnabled(isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setMaxDimensions(Dimension size) {
|
||||
m_maxsize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Dimension getMaxDimensions() {
|
||||
return m_maxsize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
|
||||
privateSetEnabled(value);
|
||||
super.setEnabled(value);
|
||||
}
|
||||
|
||||
private void privateSetEnabled(boolean value) {
|
||||
m_jbtnzoomin.setEnabled(value && (m_Img != null));
|
||||
m_jbtnzoomout.setEnabled(value && (m_Img != null));
|
||||
m_jPercent.setEnabled(value && (m_Img != null));
|
||||
m_jScr.setEnabled(value && (m_Img != null));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param img
|
||||
*/
|
||||
public void setImage(BufferedImage img) {
|
||||
BufferedImage oldimg = m_Img;
|
||||
m_Img = img;
|
||||
m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img));
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
privateSetEnabled(isEnabled());
|
||||
|
||||
firePropertyChange("image", oldimg, m_Img);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BufferedImage getImage() {
|
||||
return m_Img;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getZoom() {
|
||||
return m_icon.getZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
public void setZoom(double zoom) {
|
||||
double oldzoom = m_icon.getZoom();
|
||||
m_icon.setZoom(zoom);
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
firePropertyChange("zoom", oldzoom, zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void incZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void decZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void doLoad() {
|
||||
JFileChooser fc = new JFileChooser(m_fCurrentDirectory);
|
||||
|
||||
fc.addChoosableFileFilter(new ExtensionsFilter(
|
||||
LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp"));
|
||||
|
||||
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
BufferedImage img = ImageIO.read(fc.getSelectedFile());
|
||||
if (img != null) {
|
||||
// compruebo que no exceda el tamano maximo.
|
||||
if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) {
|
||||
if (JOptionPane.showConfirmDialog(this,
|
||||
LocalRes.getIntString("message.resizeimage"),
|
||||
LocalRes.getIntString("title.editor"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
// Redimensionamos la imagen para que se ajuste
|
||||
img = resizeImage(img);
|
||||
}
|
||||
}
|
||||
setImage(img);
|
||||
m_fCurrentDirectory = fc.getCurrentDirectory();
|
||||
}
|
||||
} catch (IOException eIO) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage resizeImage(BufferedImage img) {
|
||||
|
||||
int myheight = img.getHeight();
|
||||
int mywidth = img.getWidth();
|
||||
|
||||
if (myheight > m_maxsize.height) {
|
||||
mywidth = (int) (mywidth * m_maxsize.height / myheight);
|
||||
myheight = m_maxsize.height;
|
||||
}
|
||||
if (mywidth > m_maxsize.width) {
|
||||
myheight = (int) (myheight * m_maxsize.width / mywidth);
|
||||
mywidth = m_maxsize.width;
|
||||
}
|
||||
|
||||
BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
|
||||
double scalex = (double) mywidth / (double) img.getWidth(null);
|
||||
double scaley = (double) myheight / (double) img.getHeight(null);
|
||||
|
||||
Graphics2D g2d = thumb.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
|
||||
g2d.setColor(new Color(0, 0, 0, 0));
|
||||
|
||||
g2d.fillRect(0, 0, mywidth, myheight);
|
||||
if (scalex < scaley) {
|
||||
g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0)
|
||||
, mywidth, (int) (img.getHeight(null) * scalex), null);
|
||||
} else {
|
||||
g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0
|
||||
, (int) (img.getWidth(null) * scaley), myheight, null);
|
||||
}
|
||||
g2d.dispose();
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private static class ZoomIcon implements Icon {
|
||||
|
||||
private Icon ico;
|
||||
private double zoom;
|
||||
|
||||
public ZoomIcon() {
|
||||
this.ico = null;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconHeight());
|
||||
}
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconWidth());
|
||||
}
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
if (ico != null) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
AffineTransform oldt = g2d.getTransform();
|
||||
g2d.transform(AffineTransform.getScaleInstance(zoom, zoom));
|
||||
ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom));
|
||||
g2d.setTransform(oldt);
|
||||
}
|
||||
}
|
||||
public void setIcon(Icon ico) {
|
||||
this.ico = ico;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
public void setZoom(double zoom) {
|
||||
this.zoom = zoom;
|
||||
}
|
||||
public double getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
}
|
||||
private static class ExtensionsFilter extends FileFilter {
|
||||
|
||||
private final String message;
|
||||
private final String[] extensions;
|
||||
|
||||
public ExtensionsFilter(String message, String... extensions) {
|
||||
this.message = message;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(java.io.File f) {
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
} else {
|
||||
String sFileName = f.getName();
|
||||
int ipos = sFileName.lastIndexOf('.');
|
||||
if (ipos >= 0) {
|
||||
String sExt = sFileName.substring(ipos + 1);
|
||||
for(String s : extensions) {
|
||||
if (s.equalsIgnoreCase(sExt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
m_jScr = new javax.swing.JScrollPane();
|
||||
m_jImage = new javax.swing.JLabel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
m_jbtnzoomin = new javax.swing.JButton();
|
||||
m_jPercent = new javax.swing.JLabel();
|
||||
m_jbtnzoomout = new javax.swing.JButton();
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N
|
||||
m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
m_jScr.setViewportView(m_jImage);
|
||||
|
||||
add(m_jScr, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
|
||||
jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2));
|
||||
|
||||
m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N
|
||||
m_jbtnzoomin.setToolTipText("Zoom In");
|
||||
m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoominActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomin);
|
||||
|
||||
m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4)));
|
||||
m_jPercent.setOpaque(true);
|
||||
m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30));
|
||||
jPanel2.add(m_jPercent);
|
||||
|
||||
m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N
|
||||
m_jbtnzoomout.setToolTipText("Zoom Out");
|
||||
m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoomoutActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomout);
|
||||
|
||||
jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
|
||||
|
||||
add(jPanel1, java.awt.BorderLayout.LINE_END);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
decZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
incZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JLabel m_jImage;
|
||||
private javax.swing.JLabel m_jPercent;
|
||||
private javax.swing.JScrollPane m_jScr;
|
||||
private javax.swing.JButton m_jbtnzoomin;
|
||||
private javax.swing.JButton m_jbtnzoomout;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-16,0,0,1,44"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="m_jScr">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="m_jImage">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/no_photo.png"/>
|
||||
</Property>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
|
||||
<Property name="useNullLayout" type="boolean" value="false"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="0" left="5" right="5" top="0"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="0" y="0" width="-1" height="-1"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="1"/>
|
||||
<Property name="rows" type="int" value="0"/>
|
||||
<Property name="verticalGap" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomin">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag+.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom In"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoominActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="m_jPercent">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="4"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
|
||||
<CompoundBorder>
|
||||
<Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder>
|
||||
<Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/>
|
||||
</LineBorder>
|
||||
</Border>
|
||||
<Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="1" left="4" right="4" top="1"/>
|
||||
</Border>
|
||||
</CompoundBorder>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[10, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jbtnzoomout">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/viewmag-.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Zoom Out"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[50, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnzoomoutActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,395 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JImageViewerProduct extends javax.swing.JPanel {
|
||||
|
||||
private Dimension m_maxsize;
|
||||
private final ZoomIcon m_icon;
|
||||
private BufferedImage m_Img = null;
|
||||
|
||||
private static File m_fCurrentDirectory = null;
|
||||
private static final NumberFormat m_percentformat = new DecimalFormat("#,##0.##%");
|
||||
|
||||
public JImageViewerProduct() {
|
||||
initComponents();
|
||||
|
||||
m_Img = null;
|
||||
m_maxsize = null;
|
||||
m_icon = new ZoomIcon();
|
||||
m_jImage.setIcon(m_icon);
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
privateSetEnabled(isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setMaxDimensions(Dimension size) {
|
||||
m_maxsize = size;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Dimension getMaxDimensions() {
|
||||
return m_maxsize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
|
||||
privateSetEnabled(value);
|
||||
super.setEnabled(value);
|
||||
}
|
||||
|
||||
private void privateSetEnabled(boolean value) {
|
||||
m_jbtnzoomin.setEnabled(value && (m_Img != null));
|
||||
m_jbtnzoomout.setEnabled(value && (m_Img != null));
|
||||
m_jPercent.setEnabled(value && (m_Img != null));
|
||||
m_jScr.setEnabled(value && (m_Img != null));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param img
|
||||
*/
|
||||
public void setImage(BufferedImage img) {
|
||||
BufferedImage oldimg = m_Img;
|
||||
m_Img = img;
|
||||
m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img));
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
privateSetEnabled(isEnabled());
|
||||
|
||||
firePropertyChange("image", oldimg, m_Img);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BufferedImage getImage() {
|
||||
return m_Img;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double getZoom() {
|
||||
return m_icon.getZoom();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
public void setZoom(double zoom) {
|
||||
double oldzoom = m_icon.getZoom();
|
||||
m_icon.setZoom(zoom);
|
||||
|
||||
m_jPercent.setText(m_percentformat.format(m_icon.getZoom()));
|
||||
|
||||
m_jImage.revalidate();
|
||||
m_jScr.revalidate();
|
||||
m_jScr.repaint();
|
||||
|
||||
firePropertyChange("zoom", oldzoom, zoom);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void incZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void decZoom() {
|
||||
double zoom = m_icon.getZoom();
|
||||
setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void doLoad() {
|
||||
JFileChooser fc = new JFileChooser(m_fCurrentDirectory);
|
||||
|
||||
fc.addChoosableFileFilter(new ExtensionsFilter(
|
||||
LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp"));
|
||||
|
||||
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
try {
|
||||
BufferedImage img = ImageIO.read(fc.getSelectedFile());
|
||||
if (img != null) {
|
||||
// compruebo que no exceda el tamano maximo.
|
||||
if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) {
|
||||
if (JOptionPane.showConfirmDialog(this,
|
||||
LocalRes.getIntString("message.resizeimage"),
|
||||
LocalRes.getIntString("title.editor"),
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
// Redimensionamos la imagen para que se ajuste
|
||||
img = resizeImage(img);
|
||||
}
|
||||
}
|
||||
setImage(img);
|
||||
m_fCurrentDirectory = fc.getCurrentDirectory();
|
||||
}
|
||||
} catch (IOException eIO) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BufferedImage resizeImage(BufferedImage img) {
|
||||
|
||||
int myheight = img.getHeight();
|
||||
int mywidth = img.getWidth();
|
||||
|
||||
if (myheight > m_maxsize.height) {
|
||||
mywidth = (int) (mywidth * m_maxsize.height / myheight);
|
||||
myheight = m_maxsize.height;
|
||||
}
|
||||
if (mywidth > m_maxsize.width) {
|
||||
myheight = (int) (myheight * m_maxsize.width / mywidth);
|
||||
mywidth = m_maxsize.width;
|
||||
}
|
||||
|
||||
BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR);
|
||||
|
||||
double scalex = (double) mywidth / (double) img.getWidth(null);
|
||||
double scaley = (double) myheight / (double) img.getHeight(null);
|
||||
|
||||
Graphics2D g2d = thumb.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
|
||||
g2d.setColor(new Color(0, 0, 0, 0));
|
||||
|
||||
g2d.fillRect(0, 0, mywidth, myheight);
|
||||
if (scalex < scaley) {
|
||||
g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0)
|
||||
, mywidth, (int) (img.getHeight(null) * scalex), null);
|
||||
} else {
|
||||
g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0
|
||||
, (int) (img.getWidth(null) * scaley), myheight, null);
|
||||
}
|
||||
g2d.dispose();
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
private static class ZoomIcon implements Icon {
|
||||
|
||||
private Icon ico;
|
||||
private double zoom;
|
||||
|
||||
public ZoomIcon() {
|
||||
this.ico = null;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconHeight());
|
||||
}
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return ico == null ? 0 : (int) (zoom * ico.getIconWidth());
|
||||
}
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
if (ico != null) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
AffineTransform oldt = g2d.getTransform();
|
||||
g2d.transform(AffineTransform.getScaleInstance(zoom, zoom));
|
||||
ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom));
|
||||
g2d.setTransform(oldt);
|
||||
}
|
||||
}
|
||||
public void setIcon(Icon ico) {
|
||||
this.ico = ico;
|
||||
this.zoom = 1.0;
|
||||
}
|
||||
public void setZoom(double zoom) {
|
||||
this.zoom = zoom;
|
||||
}
|
||||
public double getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
}
|
||||
private static class ExtensionsFilter extends FileFilter {
|
||||
|
||||
private final String message;
|
||||
private final String[] extensions;
|
||||
|
||||
public ExtensionsFilter(String message, String... extensions) {
|
||||
this.message = message;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(java.io.File f) {
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
} else {
|
||||
String sFileName = f.getName();
|
||||
int ipos = sFileName.lastIndexOf('.');
|
||||
if (ipos >= 0) {
|
||||
String sExt = sFileName.substring(ipos + 1);
|
||||
for(String s : extensions) {
|
||||
if (s.equalsIgnoreCase(sExt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
m_jScr = new javax.swing.JScrollPane();
|
||||
m_jImage = new javax.swing.JLabel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
m_jbtnzoomin = new javax.swing.JButton();
|
||||
m_jPercent = new javax.swing.JLabel();
|
||||
m_jbtnzoomout = new javax.swing.JButton();
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N
|
||||
m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
m_jScr.setViewportView(m_jImage);
|
||||
|
||||
add(m_jScr, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
|
||||
jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2));
|
||||
|
||||
m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N
|
||||
m_jbtnzoomin.setToolTipText("Zoom In");
|
||||
m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoominActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomin);
|
||||
|
||||
m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
||||
m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4)));
|
||||
m_jPercent.setOpaque(true);
|
||||
m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30));
|
||||
jPanel2.add(m_jPercent);
|
||||
|
||||
m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N
|
||||
m_jbtnzoomout.setToolTipText("Zoom Out");
|
||||
m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45));
|
||||
m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jbtnzoomoutActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(m_jbtnzoomout);
|
||||
|
||||
jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
|
||||
|
||||
add(jPanel1, java.awt.BorderLayout.LINE_END);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
decZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoomoutActionPerformed
|
||||
|
||||
private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
incZoom();
|
||||
|
||||
}//GEN-LAST:event_m_jbtnzoominActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JLabel m_jImage;
|
||||
private javax.swing.JLabel m_jPercent;
|
||||
private javax.swing.JScrollPane m_jScr;
|
||||
private javax.swing.JButton m_jbtnzoomin;
|
||||
private javax.swing.JButton m_jbtnzoomout;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.user.DirtyListener;
|
||||
import com.unicenta.data.user.DirtyManager;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JLabelDirty extends JLabel {
|
||||
|
||||
private static Icon m_IconModif = null;
|
||||
private static Icon m_IconNull = null;
|
||||
|
||||
/** Creates a new instance of JDirtyPicture
|
||||
* @param dm */
|
||||
public JLabelDirty(DirtyManager dm) {
|
||||
|
||||
if (m_IconModif == null) {
|
||||
m_IconModif = new ImageIcon(getClass().getResource("/com/unicenta/images/edit.png"));
|
||||
}
|
||||
if (m_IconNull == null) {
|
||||
m_IconNull = new NullIcon(16, 16);
|
||||
}
|
||||
|
||||
dm.addDirtyListener(new DirtyListener() {
|
||||
public void changedDirty(boolean bDirty) {
|
||||
setIcon(bDirty ? m_IconModif : m_IconNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,81,0,0,1,8"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="m_jOK">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Accept"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jOKActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="m_jCancel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Cancel"/>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="m_jData">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JToolBar" name="jToolBar1">
|
||||
<Properties>
|
||||
<Property name="floatable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="North"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButton2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton2"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,175 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JListData extends javax.swing.JDialog {
|
||||
|
||||
private Object m_selected;
|
||||
|
||||
/** Creates new form JListData
|
||||
* @param parent */
|
||||
public JListData(java.awt.Frame parent) {
|
||||
super(parent, true);
|
||||
initComponents();
|
||||
|
||||
getRootPane().setDefaultButton(m_jOK);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public Object showList(List data) {
|
||||
|
||||
return showList(new MyListData(data));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
public Object showList(javax.swing.ListModel model) {
|
||||
|
||||
m_jData.setModel(model);
|
||||
m_selected = null;
|
||||
|
||||
setVisible(true);
|
||||
//show();
|
||||
|
||||
return m_selected;
|
||||
}
|
||||
|
||||
private static class MyListData extends javax.swing.AbstractListModel {
|
||||
|
||||
private List m_data;
|
||||
|
||||
public MyListData(List data) {
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return m_data.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return m_data.size();
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
m_jOK = new javax.swing.JButton();
|
||||
m_jCancel = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
m_jData = new javax.swing.JList();
|
||||
jToolBar1 = new javax.swing.JToolBar();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
jButton2 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
|
||||
|
||||
m_jOK.setText("Accept");
|
||||
m_jOK.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
m_jOK.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
m_jOK.setPreferredSize(new java.awt.Dimension(65, 33));
|
||||
m_jOK.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jOKActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel1.add(m_jOK);
|
||||
|
||||
m_jCancel.setText("Cancel");
|
||||
m_jCancel.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
m_jCancel.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
m_jCancel.setPreferredSize(new java.awt.Dimension(65, 33));
|
||||
m_jCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
m_jCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel1.add(m_jCancel);
|
||||
|
||||
getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
m_jData.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jData.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
jScrollPane1.setViewportView(m_jData);
|
||||
|
||||
getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jToolBar1.setFloatable(false);
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
jToolBar1.add(jButton1);
|
||||
|
||||
jButton2.setText("jButton2");
|
||||
jToolBar1.add(jButton2);
|
||||
|
||||
getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);
|
||||
|
||||
setSize(new java.awt.Dimension(264, 337));
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void m_jCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCancelActionPerformed
|
||||
|
||||
dispose();
|
||||
}//GEN-LAST:event_m_jCancelActionPerformed
|
||||
|
||||
private void m_jOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jOKActionPerformed
|
||||
|
||||
m_selected = m_jData.getSelectedValue();
|
||||
|
||||
dispose();
|
||||
}//GEN-LAST:event_m_jOKActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JToolBar jToolBar1;
|
||||
private javax.swing.JButton m_jCancel;
|
||||
private javax.swing.JList m_jData;
|
||||
private javax.swing.JButton m_jOK;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[300, 2]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-12,0,0,0,-56"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<Properties>
|
||||
<Property name="autoscrolls" type="boolean" value="true"/>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="m_jlist">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="selectionMode" type="int" value="0"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,150 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import com.unicenta.data.user.BrowsableEditableData;
|
||||
import com.unicenta.data.user.BrowseListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JListNavigator extends javax.swing.JPanel implements BrowseListener, ListSelectionListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected BrowsableEditableData m_bd;
|
||||
|
||||
/** Creates new form JListBrowse
|
||||
* @param bd */
|
||||
public JListNavigator(BrowsableEditableData bd) {
|
||||
this(bd, false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bd
|
||||
* @param bTouchable
|
||||
*/
|
||||
public JListNavigator(BrowsableEditableData bd, boolean bTouchable) {
|
||||
|
||||
m_bd = bd;
|
||||
|
||||
initComponents();
|
||||
|
||||
// if (bTouchable) {
|
||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35));
|
||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(35, 35));
|
||||
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
// }
|
||||
|
||||
|
||||
m_jlist.addListSelectionListener(this);
|
||||
m_jlist.setModel(m_bd.getListModel());
|
||||
|
||||
m_bd.addBrowseListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cellRenderer
|
||||
*/
|
||||
public void setCellRenderer(ListCellRenderer cellRenderer) {
|
||||
m_jlist.setCellRenderer(cellRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iIndex
|
||||
* @param iCounter
|
||||
*/
|
||||
@Override
|
||||
public void updateIndex(int iIndex, int iCounter) {
|
||||
|
||||
if (iIndex >= 0 && iIndex < iCounter) {
|
||||
m_jlist.setSelectedIndex(iIndex);
|
||||
} else {
|
||||
m_jlist.setSelectedIndex(-1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent evt) {
|
||||
|
||||
if (!evt.getValueIsAdjusting()) {
|
||||
int i = m_jlist.getSelectedIndex();
|
||||
if (i >= 0) {
|
||||
if (!m_bd.isAdjusting()) {
|
||||
|
||||
try {
|
||||
m_bd.moveTo(i);
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
Rectangle oRect = m_jlist.getCellBounds(i, i);
|
||||
m_jlist.scrollRectToVisible(oRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 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() {
|
||||
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
m_jlist = new javax.swing.JList();
|
||||
|
||||
setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
setPreferredSize(new java.awt.Dimension(300, 2));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jScrollPane1.setAutoscrolls(true);
|
||||
jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
|
||||
m_jlist.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jlist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
|
||||
m_jlist.setFocusable(false);
|
||||
m_jlist.setRequestFocusEnabled(false);
|
||||
jScrollPane1.setViewportView(m_jlist);
|
||||
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JList m_jlist;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="title.message" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,21,0,0,1,-57"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</SyntheticProperties>
|
||||
<Events>
|
||||
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel4">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
|
||||
</Border>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
|
||||
<Property name="axis" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jlblErrorCode">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jlblErrorCode"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jlblMessage">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="jlblMessage"/>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 100]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 100]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jscrException">
|
||||
<Properties>
|
||||
<Property name="alignmentX" type="float" value="0.0"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="jtxtException">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="jlblIcon">
|
||||
<Properties>
|
||||
<Property name="verticalAlignment" type="int" value="1"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Before"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jcmdOK">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.OK" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jcmdMore">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.information" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdMoreActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,249 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class JMessageDialog extends javax.swing.JDialog {
|
||||
|
||||
/** Creates new form JMessageDialog */
|
||||
private JMessageDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
/** Creates new form JMessageDialog */
|
||||
private JMessageDialog(java.awt.Dialog parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
private static Window getWindow(Component parent) {
|
||||
if (parent == null) {
|
||||
return new JFrame();
|
||||
} else if (parent instanceof Frame || parent instanceof Dialog) {
|
||||
return (Window) parent;
|
||||
} else {
|
||||
return getWindow(parent.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
* @param inf
|
||||
*/
|
||||
public static void showMessage(Component parent, MessageInf inf) {
|
||||
|
||||
Window window = getWindow(parent);
|
||||
|
||||
JMessageDialog myMsg;
|
||||
if (window instanceof Frame) {
|
||||
myMsg = new JMessageDialog((Frame) window, true);
|
||||
} else {
|
||||
myMsg = new JMessageDialog((Dialog) window, true);
|
||||
}
|
||||
|
||||
myMsg.initComponents();
|
||||
myMsg.applyComponentOrientation(parent.getComponentOrientation());
|
||||
myMsg.jscrException.setVisible(false);
|
||||
myMsg.getRootPane().setDefaultButton(myMsg.jcmdOK);
|
||||
|
||||
myMsg.jlblIcon.setIcon(inf.getSignalWordIcon());
|
||||
myMsg.jlblErrorCode.setText(inf.getErrorCodeMsg());
|
||||
myMsg.jlblMessage.setText("<html>" + inf.getMessageMsg());
|
||||
|
||||
// Capturamos el texto de la excepcion...
|
||||
if (inf.getCause() == null) {
|
||||
myMsg.jtxtException.setText(null);
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (inf.getCause() instanceof Throwable) {
|
||||
Throwable t = (Throwable) inf.getCause();
|
||||
while (t != null) {
|
||||
sb.append(t.getClass().getName());
|
||||
sb.append(": \n");
|
||||
sb.append(t.getMessage());
|
||||
sb.append("\n\n");
|
||||
t = t.getCause();
|
||||
}
|
||||
} else if (inf.getCause() instanceof Throwable[]) {
|
||||
Throwable[] m_aExceptions = (Throwable[]) inf.getCause();
|
||||
for (int i = 0; i < m_aExceptions.length; i++) {
|
||||
sb.append(m_aExceptions[i].getClass().getName());
|
||||
sb.append(": \n");
|
||||
sb.append(m_aExceptions[i].getMessage());
|
||||
sb.append("\n\n");
|
||||
}
|
||||
} else if (inf.getCause() instanceof Object[]) {
|
||||
Object [] m_aObjects = (Object []) inf.getCause();
|
||||
for (int i = 0; i < m_aObjects.length; i++) {
|
||||
sb.append(m_aObjects[i].toString());
|
||||
sb.append("\n\n");
|
||||
}
|
||||
} else if (inf.getCause() instanceof String) {
|
||||
sb.append(inf.getCause().toString());
|
||||
} else {
|
||||
sb.append(inf.getCause().getClass().getName());
|
||||
sb.append(": \n");
|
||||
sb.append(inf.getCause().toString());
|
||||
}
|
||||
myMsg.jtxtException.setText(sb.toString());
|
||||
}
|
||||
myMsg.jtxtException.setCaretPosition(0);
|
||||
|
||||
//myMsg.show();
|
||||
myMsg.setVisible(true);
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jPanel4 = new javax.swing.JPanel();
|
||||
jlblErrorCode = new javax.swing.JLabel();
|
||||
jlblMessage = new javax.swing.JLabel();
|
||||
jscrException = new javax.swing.JScrollPane();
|
||||
jtxtException = new javax.swing.JTextArea();
|
||||
jlblIcon = new javax.swing.JLabel();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
jcmdOK = new javax.swing.JButton();
|
||||
jcmdMore = new javax.swing.JButton();
|
||||
|
||||
setTitle(LocalRes.getIntString("title.message")); // NOI18N
|
||||
setResizable(false);
|
||||
addWindowListener(new java.awt.event.WindowAdapter() {
|
||||
public void windowClosing(java.awt.event.WindowEvent evt) {
|
||||
closeDialog(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));
|
||||
|
||||
jlblErrorCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jlblErrorCode.setText("jlblErrorCode");
|
||||
jPanel4.add(jlblErrorCode);
|
||||
|
||||
jlblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jlblMessage.setText("jlblMessage");
|
||||
jlblMessage.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
jlblMessage.setMinimumSize(new java.awt.Dimension(200, 100));
|
||||
jlblMessage.setPreferredSize(new java.awt.Dimension(200, 100));
|
||||
jPanel4.add(jlblMessage);
|
||||
|
||||
jscrException.setAlignmentX(0.0F);
|
||||
|
||||
jtxtException.setEditable(false);
|
||||
jtxtException.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jscrException.setViewportView(jtxtException);
|
||||
|
||||
jPanel4.add(jscrException);
|
||||
|
||||
getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jlblIcon.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
||||
jlblIcon.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
getContentPane().add(jlblIcon, java.awt.BorderLayout.LINE_START);
|
||||
|
||||
jPanel3.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N
|
||||
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N
|
||||
jcmdOK.setActionCommand(bundle.getString("button.OK")); // NOI18N
|
||||
jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setPreferredSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdOKActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdOK);
|
||||
|
||||
jcmdMore.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdMore.setText(LocalRes.getIntString("button.information")); // NOI18N
|
||||
jcmdMore.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdMore.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdMore.setPreferredSize(new java.awt.Dimension(65, 33));
|
||||
jcmdMore.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdMoreActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdMore);
|
||||
|
||||
jPanel3.add(jPanel2, java.awt.BorderLayout.LINE_END);
|
||||
|
||||
getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
setSize(new java.awt.Dimension(455, 277));
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jcmdMoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdMoreActionPerformed
|
||||
|
||||
// Add your handling code here:
|
||||
jcmdMore.setEnabled(false);
|
||||
jscrException.setVisible(true);
|
||||
setSize(getWidth(), 310);
|
||||
// JG 25 May 2013 change for JDK 7
|
||||
validate();
|
||||
// validateTree();
|
||||
|
||||
}//GEN-LAST:event_jcmdMoreActionPerformed
|
||||
|
||||
private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
|
||||
// Add your handling code here:
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}//GEN-LAST:event_jcmdOKActionPerformed
|
||||
|
||||
/** Closes the dialog */
|
||||
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}//GEN-LAST:event_closeDialog
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JPanel jPanel4;
|
||||
private javax.swing.JButton jcmdMore;
|
||||
private javax.swing.JButton jcmdOK;
|
||||
private javax.swing.JLabel jlblErrorCode;
|
||||
private javax.swing.JLabel jlblIcon;
|
||||
private javax.swing.JLabel jlblMessage;
|
||||
private javax.swing.JScrollPane jscrException;
|
||||
private javax.swing.JTextArea jtxtException;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,50,0,0,2,88"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
</Form>
|
||||
@@ -0,0 +1,372 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import java.util.*;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.ComparatorCreator;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import com.unicenta.data.loader.Vectorer;
|
||||
import com.unicenta.data.user.BrowseListener;
|
||||
import com.unicenta.data.user.BrowsableEditableData;
|
||||
import com.unicenta.data.user.StateListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JNavigator extends javax.swing.JPanel implements BrowseListener, StateListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int BUTTONS_ALL = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int BUTTONS_NONAVIGATE = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected BrowsableEditableData m_bd;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected ComparatorCreator m_cc;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected FindInfo m_LastFindInfo;
|
||||
|
||||
private javax.swing.JButton jbtnFind = null;
|
||||
private javax.swing.JButton jbtnSort = null;
|
||||
private javax.swing.JButton jbtnFirst = null;
|
||||
private javax.swing.JButton jbtnLast = null;
|
||||
private javax.swing.JButton jbtnNext = null;
|
||||
private javax.swing.JButton jbtnPrev = null;
|
||||
private javax.swing.JButton jbtnRefresh = null;
|
||||
private javax.swing.JButton jbtnReload = null;
|
||||
|
||||
/** Creates new form JNavigator
|
||||
* @param bd
|
||||
* @param vec
|
||||
* @param cc
|
||||
* @param iButtons */
|
||||
public JNavigator(BrowsableEditableData bd, Vectorer vec, ComparatorCreator cc, int iButtons) {
|
||||
|
||||
initComponents();
|
||||
|
||||
if (iButtons == BUTTONS_ALL) {
|
||||
jbtnFirst = new javax.swing.JButton();
|
||||
jbtnFirst.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnFirst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png")));
|
||||
jbtnFirst.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnFirst.setFocusPainted(false);
|
||||
jbtnFirst.setFocusable(false);
|
||||
jbtnFirst.setRequestFocusEnabled(false);
|
||||
jbtnFirst.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnFirstActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnFirst);
|
||||
}
|
||||
|
||||
if (iButtons == BUTTONS_ALL) {
|
||||
jbtnPrev = new javax.swing.JButton();
|
||||
jbtnPrev.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")));
|
||||
jbtnPrev.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnPrev.setFocusPainted(false);
|
||||
jbtnPrev.setFocusable(false);
|
||||
jbtnPrev.setRequestFocusEnabled(false);
|
||||
jbtnPrev.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnPrevActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnPrev);
|
||||
}
|
||||
|
||||
jbtnRefresh = new javax.swing.JButton();
|
||||
jbtnRefresh.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1downarrow.png")));
|
||||
jbtnRefresh.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnRefresh.setFocusPainted(false);
|
||||
jbtnRefresh.setFocusable(false);
|
||||
jbtnRefresh.setRequestFocusEnabled(false);
|
||||
jbtnRefresh.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnRefreshActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnRefresh);
|
||||
|
||||
if (iButtons == BUTTONS_ALL) {
|
||||
jbtnNext = new javax.swing.JButton();
|
||||
jbtnNext.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")));
|
||||
jbtnNext.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnNext.setFocusPainted(false);
|
||||
jbtnNext.setFocusable(false);
|
||||
jbtnNext.setRequestFocusEnabled(false);
|
||||
jbtnNext.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnNextActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnNext);
|
||||
}
|
||||
|
||||
if (iButtons == BUTTONS_ALL) {
|
||||
jbtnLast = new javax.swing.JButton();
|
||||
jbtnLast.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnLast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png")));
|
||||
jbtnLast.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnLast.setFocusPainted(false);
|
||||
jbtnLast.setFocusable(false);
|
||||
jbtnLast.setRequestFocusEnabled(false);
|
||||
jbtnLast.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnLastActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnLast);
|
||||
}
|
||||
|
||||
add(new javax.swing.JSeparator());
|
||||
|
||||
if (bd.canLoadData()) {
|
||||
jbtnReload = new javax.swing.JButton();
|
||||
jbtnReload.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png")));
|
||||
jbtnReload.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnReload.setFocusPainted(false);
|
||||
jbtnReload.setFocusable(false);
|
||||
jbtnReload.setRequestFocusEnabled(false);
|
||||
jbtnReload.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnReloadActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnReload);
|
||||
|
||||
add(new javax.swing.JSeparator());
|
||||
}
|
||||
|
||||
if (vec == null) {
|
||||
m_LastFindInfo = null;
|
||||
} else {
|
||||
m_LastFindInfo = new FindInfo(vec);
|
||||
jbtnFind = new javax.swing.JButton();
|
||||
jbtnFind.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png")));
|
||||
jbtnFind.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnFind.setFocusPainted(false);
|
||||
jbtnFind.setFocusable(false);
|
||||
jbtnFind.setRequestFocusEnabled(false);
|
||||
jbtnFind.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnFindActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnFind);
|
||||
}
|
||||
|
||||
m_cc = cc;
|
||||
if (m_cc != null) {
|
||||
jbtnSort = new javax.swing.JButton();
|
||||
jbtnSort.setPreferredSize(new java.awt.Dimension(60,45));
|
||||
jbtnSort.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sort_incr.png")));
|
||||
jbtnSort.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnSort.setFocusPainted(false);
|
||||
jbtnSort.setFocusable(false);
|
||||
jbtnSort.setRequestFocusEnabled(false);
|
||||
jbtnSort.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnSortActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
add(jbtnSort);
|
||||
}
|
||||
|
||||
m_bd = bd;
|
||||
bd.addBrowseListener(this);
|
||||
bd.addStateListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bd
|
||||
*/
|
||||
public JNavigator(BrowsableEditableData bd) {
|
||||
this(bd, null, null, BUTTONS_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bd
|
||||
* @param vec
|
||||
* @param cc
|
||||
*/
|
||||
public JNavigator(BrowsableEditableData bd, Vectorer vec, ComparatorCreator cc) {
|
||||
this(bd, vec, cc, BUTTONS_ALL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iState
|
||||
*/
|
||||
public void updateState(int iState) {
|
||||
if (iState == BrowsableEditableData.ST_INSERT || iState == BrowsableEditableData.ST_DELETE) {
|
||||
// Insert o Delete
|
||||
if (jbtnFirst != null) jbtnFirst.setEnabled(false);
|
||||
if (jbtnPrev != null) jbtnPrev.setEnabled(false);
|
||||
if (jbtnNext != null) jbtnNext.setEnabled(false);
|
||||
if (jbtnLast != null) jbtnLast.setEnabled(false);
|
||||
if (jbtnRefresh != null) jbtnRefresh.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iIndex
|
||||
* @param iCounter
|
||||
*/
|
||||
public void updateIndex(int iIndex, int iCounter) {
|
||||
|
||||
if (iIndex >= 0 && iIndex < iCounter) {
|
||||
// Reposicionamiento
|
||||
if (jbtnFirst != null) jbtnFirst.setEnabled(iIndex > 0);
|
||||
if (jbtnPrev != null) jbtnPrev.setEnabled(iIndex > 0);
|
||||
if (jbtnNext != null) jbtnNext.setEnabled(iIndex < iCounter - 1);
|
||||
if (jbtnLast != null) jbtnLast.setEnabled(iIndex < iCounter - 1);
|
||||
if (jbtnRefresh != null) jbtnRefresh.setEnabled(true);
|
||||
} else {
|
||||
// EOF
|
||||
if (jbtnFirst != null) jbtnFirst.setEnabled(false);
|
||||
if (jbtnPrev != null) jbtnPrev.setEnabled(false);
|
||||
if (jbtnNext != null) jbtnNext.setEnabled(false);
|
||||
if (jbtnLast != null) jbtnLast.setEnabled(false);
|
||||
if (jbtnRefresh != null) jbtnRefresh.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnSortActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
try {
|
||||
Comparator c = JSort.showMessage(this, m_cc);
|
||||
if (c != null) {
|
||||
m_bd.sort(c);
|
||||
}
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nolistdata"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnFindActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
||||
try {
|
||||
FindInfo newFindInfo = JFind.showMessage(this, m_LastFindInfo);
|
||||
if (newFindInfo != null) {
|
||||
m_LastFindInfo = newFindInfo;
|
||||
|
||||
int index = m_bd.findNext(newFindInfo);
|
||||
if (index < 0) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.norecord"));
|
||||
msg.show(this);
|
||||
} else {
|
||||
m_bd.moveTo(index);
|
||||
}
|
||||
}
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nolistdata"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnRefreshActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
||||
m_bd.actionReloadCurrent(this);
|
||||
}
|
||||
|
||||
private void jbtnReloadActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
||||
try {
|
||||
m_bd.actionLoad();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.noreload"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnLastActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
||||
try {
|
||||
m_bd.moveLast();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnFirstActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
||||
try{
|
||||
m_bd.moveFirst();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnPrevActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
try {
|
||||
m_bd.movePrev();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void jbtnNextActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
try {
|
||||
m_bd.moveNext();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jbtnNew" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jbtnDelete" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jbtnSave" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jbtnNew" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jbtnDelete" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jbtnSave" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jbtnNew">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/editnew.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="tooltip.addnew" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[2, 2, 2, 2]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[60, 45]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnNewActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jbtnDelete">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/sale_delete.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="tooltip.delete" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[2, 2, 2, 2]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[60, 45]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnDeleteActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jbtnSave">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/filesave.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="tooltip.save" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[2, 2, 2, 2]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[60, 45]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnSaveActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,189 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import com.unicenta.data.user.BrowsableEditableData;
|
||||
import com.unicenta.data.user.StateListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JSaver extends JPanel implements StateListener {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected BrowsableEditableData m_bd;
|
||||
|
||||
/** Creates new form JSaver
|
||||
* @param bd */
|
||||
public JSaver(BrowsableEditableData bd) {
|
||||
|
||||
initComponents();
|
||||
|
||||
m_bd = bd;
|
||||
|
||||
// m_bd.addBrowseListener(this);
|
||||
m_bd.addStateListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iState
|
||||
*/
|
||||
@Override
|
||||
public void updateState(int iState) {
|
||||
switch (iState) {
|
||||
case BrowsableEditableData.ST_INSERT:
|
||||
jbtnNew.setEnabled(m_bd.canInsertData());
|
||||
jbtnDelete.setEnabled(false);
|
||||
jbtnSave.setEnabled(m_bd.canInsertData());
|
||||
break;
|
||||
case BrowsableEditableData.ST_DELETE:
|
||||
jbtnNew.setEnabled(m_bd.canInsertData());
|
||||
jbtnDelete.setEnabled(false);
|
||||
jbtnSave.setEnabled(m_bd.canDeleteData());
|
||||
break;
|
||||
case BrowsableEditableData.ST_NORECORD:
|
||||
jbtnNew.setEnabled(m_bd.canInsertData());
|
||||
jbtnDelete.setEnabled(false);
|
||||
jbtnSave.setEnabled(false);
|
||||
break;
|
||||
case BrowsableEditableData.ST_UPDATE:
|
||||
jbtnNew.setEnabled(m_bd.canInsertData());
|
||||
jbtnDelete.setEnabled(m_bd.canDeleteData());
|
||||
jbtnSave.setEnabled(m_bd.canUpdateData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jbtnNew = new javax.swing.JButton();
|
||||
jbtnDelete = new javax.swing.JButton();
|
||||
jbtnSave = new javax.swing.JButton();
|
||||
|
||||
jbtnNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/editnew.png"))); // NOI18N
|
||||
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N
|
||||
jbtnNew.setToolTipText(bundle.getString("tooltip.addnew")); // NOI18N
|
||||
jbtnNew.setFocusPainted(false);
|
||||
jbtnNew.setFocusable(false);
|
||||
jbtnNew.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnNew.setPreferredSize(new java.awt.Dimension(60, 45));
|
||||
jbtnNew.setRequestFocusEnabled(false);
|
||||
jbtnNew.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnNewActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jbtnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N
|
||||
jbtnDelete.setToolTipText(bundle.getString("tooltip.delete")); // NOI18N
|
||||
jbtnDelete.setFocusPainted(false);
|
||||
jbtnDelete.setFocusable(false);
|
||||
jbtnDelete.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnDelete.setPreferredSize(new java.awt.Dimension(60, 45));
|
||||
jbtnDelete.setRequestFocusEnabled(false);
|
||||
jbtnDelete.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnDeleteActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jbtnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N
|
||||
jbtnSave.setToolTipText(bundle.getString("tooltip.save")); // NOI18N
|
||||
jbtnSave.setFocusPainted(false);
|
||||
jbtnSave.setFocusable(false);
|
||||
jbtnSave.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
jbtnSave.setPreferredSize(new java.awt.Dimension(60, 45));
|
||||
jbtnSave.setRequestFocusEnabled(false);
|
||||
jbtnSave.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jbtnSaveActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
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(jbtnNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jbtnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jbtnNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jbtnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSaveActionPerformed
|
||||
try {
|
||||
m_bd.saveData();
|
||||
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nosave"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}//GEN-LAST:event_jbtnSaveActionPerformed
|
||||
|
||||
private void jbtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDeleteActionPerformed
|
||||
try {
|
||||
m_bd.actionDelete();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nodelete"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}//GEN-LAST:event_jbtnDeleteActionPerformed
|
||||
|
||||
private void jbtnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnNewActionPerformed
|
||||
try {
|
||||
m_bd.actionInsert();
|
||||
} catch (BasicException eD) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nonew"), eD);
|
||||
msg.show(this);
|
||||
}
|
||||
}//GEN-LAST:event_jbtnNewActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jbtnDelete;
|
||||
private javax.swing.JButton jbtnNew;
|
||||
private javax.swing.JButton jbtnSave;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="caption.sort" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="resizable" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-22,0,0,1,-116"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="m_jSort1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="m_jSort2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="m_jSort3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jSort1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jSort2" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="m_jSort3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.sortby" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="m_jSort1">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.andby" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="m_jSort2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="label.andby" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[150, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="m_jSort3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[200, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel2">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
|
||||
<Property name="alignment" type="int" value="2"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jcmdCancel">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/cancel.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.cancel" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jcmdOK">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/ok.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="data_messages.properties" key="button.OK" replaceFormat="LocalRes.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[65, 33]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 45]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,270 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Comparator;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.ComparatorCreator;
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class JSort extends JDialog {
|
||||
|
||||
private ComparatorCreator m_cc;
|
||||
private Comparator m_Comparator;
|
||||
|
||||
private JSort(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
private JSort(java.awt.Dialog parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
private Comparator init(ComparatorCreator cc) throws BasicException {
|
||||
|
||||
initComponents();
|
||||
|
||||
getRootPane().setDefaultButton(jcmdOK);
|
||||
|
||||
m_cc = cc;
|
||||
|
||||
String[] sHeaders = m_cc.getHeaders();
|
||||
|
||||
m_jSort1.removeAllItems();
|
||||
m_jSort1.addItem("");
|
||||
for (int i = 0; i < sHeaders.length; i++) {
|
||||
m_jSort1.addItem(sHeaders[i]);
|
||||
}
|
||||
m_jSort1.setSelectedItem(0);
|
||||
|
||||
m_jSort2.removeAllItems();
|
||||
m_jSort2.addItem("");
|
||||
for (int i = 0; i < sHeaders.length; i++) {
|
||||
m_jSort2.addItem(sHeaders[i]);
|
||||
}
|
||||
m_jSort2.setSelectedItem(0);
|
||||
|
||||
m_jSort3.removeAllItems();
|
||||
m_jSort3.addItem("");
|
||||
for (int i = 0; i < sHeaders.length; i++) {
|
||||
m_jSort3.addItem(sHeaders[i]);
|
||||
}
|
||||
m_jSort3.setSelectedItem(0);
|
||||
|
||||
m_Comparator = null;
|
||||
setVisible(true);
|
||||
return m_Comparator;
|
||||
}
|
||||
|
||||
private static Window getWindow(Component parent) {
|
||||
if (parent == null) {
|
||||
return new JFrame();
|
||||
} else if (parent instanceof Frame || parent instanceof Dialog) {
|
||||
return (Window)parent;
|
||||
} else {
|
||||
return getWindow(parent.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
* @param cc
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public static Comparator showMessage(Component parent, ComparatorCreator cc) throws BasicException {
|
||||
|
||||
Window window = getWindow(parent);
|
||||
|
||||
JSort myMsg;
|
||||
if (window instanceof Frame) {
|
||||
myMsg = new JSort((Frame) window, true);
|
||||
} else {
|
||||
myMsg = new JSort((Dialog) window, true);
|
||||
}
|
||||
return myMsg.init(cc);
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
m_jSort1 = new javax.swing.JComboBox();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
m_jSort2 = new javax.swing.JComboBox();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
m_jSort3 = new javax.swing.JComboBox();
|
||||
jPanel2 = new javax.swing.JPanel();
|
||||
jcmdCancel = new javax.swing.JButton();
|
||||
jcmdOK = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(LocalRes.getIntString("caption.sort")); // NOI18N
|
||||
setResizable(false);
|
||||
|
||||
jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel2.setText(LocalRes.getIntString("label.sortby")); // NOI18N
|
||||
jLabel2.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jSort1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jSort1.setPreferredSize(new java.awt.Dimension(200, 30));
|
||||
|
||||
jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel3.setText(LocalRes.getIntString("label.andby")); // NOI18N
|
||||
jLabel3.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jSort2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jSort2.setPreferredSize(new java.awt.Dimension(200, 30));
|
||||
|
||||
jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel4.setText(LocalRes.getIntString("label.andby")); // NOI18N
|
||||
jLabel4.setPreferredSize(new java.awt.Dimension(150, 30));
|
||||
|
||||
m_jSort3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jSort3.setPreferredSize(new java.awt.Dimension(200, 30));
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(m_jSort1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(m_jSort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(m_jSort3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jSort1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jSort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(m_jSort3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
);
|
||||
|
||||
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
|
||||
|
||||
jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N
|
||||
jcmdCancel.setText(LocalRes.getIntString("button.cancel")); // NOI18N
|
||||
jcmdCancel.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdCancel.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45));
|
||||
jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdCancel);
|
||||
|
||||
jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N
|
||||
jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N
|
||||
jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33));
|
||||
jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45));
|
||||
jcmdOK.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdOKActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel2.add(jcmdOK);
|
||||
|
||||
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
setSize(new java.awt.Dimension(396, 234));
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
|
||||
|
||||
dispose();
|
||||
|
||||
}//GEN-LAST:event_jcmdCancelActionPerformed
|
||||
|
||||
private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
|
||||
|
||||
int iSort1 = m_jSort1.getSelectedIndex();
|
||||
int iSort2 = m_jSort2.getSelectedIndex();
|
||||
int iSort3 = m_jSort3.getSelectedIndex();
|
||||
|
||||
if (iSort1 > 0 && iSort2 == 0 && iSort3 == 0) {
|
||||
m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1});
|
||||
dispose();
|
||||
} else if (iSort1 > 0 && iSort2 > 0 && iSort3 == 0) {
|
||||
m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1, iSort2 - 1});
|
||||
dispose();
|
||||
} else if (iSort1 > 0 && iSort2 > 0 && iSort3 > 0) {
|
||||
m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1, iSort2 - 1, iSort3 - 1});
|
||||
dispose();
|
||||
} else {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nosort"));
|
||||
msg.show(this);
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_jcmdOKActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JButton jcmdCancel;
|
||||
private javax.swing.JButton jcmdOK;
|
||||
private javax.swing.JComboBox m_jSort1;
|
||||
private javax.swing.JComboBox m_jSort2;
|
||||
private javax.swing.JComboBox m_jSort3;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.IRenderString;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class ListCellRendererBasic extends DefaultListCellRenderer {
|
||||
|
||||
private IRenderString m_renderer;
|
||||
|
||||
/** Creates a new instance of ListCellRendererBasic
|
||||
* @param renderer */
|
||||
public ListCellRendererBasic(IRenderString renderer) {
|
||||
m_renderer = renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus);
|
||||
|
||||
String s = m_renderer.getRenderString(value);
|
||||
setText((s == null || s.equals("")) ? " " : s); // Un espacio en caso de nulo para que no deja la celda chiquitita.
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.IKeyed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
* @param <K>
|
||||
*/
|
||||
public class ListKeyed<K extends IKeyed> extends ArrayList<K> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
public ListKeyed(List<K> list) {
|
||||
this.addAll(list);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public K get(Object key) {
|
||||
|
||||
for (K elem : this) {
|
||||
if ((key == null && elem.getKey() == null) || (key != null && key.equals(elem.getKey()))) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.QBFCompareEnum;
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.ComboBoxModel;
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class ListQBFModelNumber extends AbstractListModel implements ComboBoxModel {
|
||||
|
||||
private Object[] m_items;
|
||||
private Object m_sel;
|
||||
|
||||
/** Creates a new instance of ListQBFModelNumber
|
||||
* @param items */
|
||||
// public ListQBFModelNumber() {
|
||||
// private ListQBFModelNumber(Object... items) {
|
||||
public ListQBFModelNumber(Object... items) {
|
||||
m_items = items;
|
||||
m_sel = m_items[0];
|
||||
}
|
||||
|
||||
// m_items = new Object[] {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ListQBFModelNumber getMandatoryString() {
|
||||
return new ListQBFModelNumber(
|
||||
QBFCompareEnum.COMP_NONE,
|
||||
QBFCompareEnum.COMP_EQUALS,
|
||||
QBFCompareEnum.COMP_RE,
|
||||
QBFCompareEnum.COMP_DISTINCT,
|
||||
// QBFCompareEnum.COMP_GREATER,
|
||||
QBFCompareEnum.COMP_GREATER,
|
||||
QBFCompareEnum.COMP_LESS,
|
||||
// QBFCompareEnum.COMP_GREATEROREQUALS,
|
||||
QBFCompareEnum.COMP_GREATEROREQUALS,
|
||||
QBFCompareEnum.COMP_LESSOREQUALS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ListQBFModelNumber getMandatoryNumber() {
|
||||
return new ListQBFModelNumber(
|
||||
QBFCompareEnum.COMP_NONE,
|
||||
QBFCompareEnum.COMP_EQUALS,
|
||||
QBFCompareEnum.COMP_DISTINCT,
|
||||
QBFCompareEnum.COMP_GREATER,
|
||||
QBFCompareEnum.COMP_LESS,
|
||||
QBFCompareEnum.COMP_GREATEROREQUALS,
|
||||
QBFCompareEnum.COMP_LESSOREQUALS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ListQBFModelNumber getNonMandatoryString() {
|
||||
return new ListQBFModelNumber(
|
||||
QBFCompareEnum.COMP_NONE,
|
||||
QBFCompareEnum.COMP_EQUALS,
|
||||
QBFCompareEnum.COMP_RE,
|
||||
QBFCompareEnum.COMP_DISTINCT,
|
||||
QBFCompareEnum.COMP_GREATER,
|
||||
QBFCompareEnum.COMP_LESS,
|
||||
QBFCompareEnum.COMP_GREATEROREQUALS,
|
||||
QBFCompareEnum.COMP_LESSOREQUALS,
|
||||
QBFCompareEnum.COMP_ISNULL,
|
||||
// QBFCompareEnum.COMP_ISNOTNULL,
|
||||
// };
|
||||
// m_sel = m_items[0];
|
||||
QBFCompareEnum.COMP_ISNOTNULL
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static ListQBFModelNumber getNonMandatoryNumber() {
|
||||
return new ListQBFModelNumber(
|
||||
QBFCompareEnum.COMP_NONE,
|
||||
QBFCompareEnum.COMP_EQUALS,
|
||||
QBFCompareEnum.COMP_DISTINCT,
|
||||
QBFCompareEnum.COMP_GREATER,
|
||||
QBFCompareEnum.COMP_LESS,
|
||||
QBFCompareEnum.COMP_GREATEROREQUALS,
|
||||
QBFCompareEnum.COMP_LESSOREQUALS,
|
||||
QBFCompareEnum.COMP_ISNULL,
|
||||
QBFCompareEnum.COMP_ISNOTNULL
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
|
||||
return m_items[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return m_items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return m_sel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object anItem) {
|
||||
m_sel = anItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.data.loader.LocalRes;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class MessageInf {
|
||||
|
||||
// SIGNAL_WORD'S
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_DANGER = 0xFF000000; // Death or serious injury will occur
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_WARNING = 0xFE000000; // Death or serious injury may occur
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_CAUTION = 0xFD000000; // Minor or moderate injury may occur
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_NOTICE = 0xFC000000; // Damage to property may occur
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_IMPORTANT = 0xFA000000; // Operating or maintenance instructions or additional information
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int SGN_SUCCESS = 0xFB000000;
|
||||
|
||||
// ERROR_CLASS'ES
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static int CLS_GENERIC = 0x00000000;
|
||||
|
||||
// ERROR_CODE'S
|
||||
|
||||
// VARIABLES
|
||||
private int m_iMsgNumber; // = SIGNAL_WORD (0xFF000000) | ERROR_CLASS (0x00FF0000) | ERROR_CODE (0x0000FFFF)
|
||||
private String m_sHazard;
|
||||
private String m_sConsequences;
|
||||
private String m_sAvoiding;
|
||||
|
||||
// CAUSE
|
||||
private Object m_eCause;
|
||||
|
||||
/** Creates a new instance of MessageInf
|
||||
* @param iSignalWord
|
||||
* @param sHazard
|
||||
* @param e */
|
||||
public MessageInf(int iSignalWord, String sHazard, Object e) {
|
||||
// m_iMsgNumber = iSignalWord | CLS_GENERIC;
|
||||
m_iMsgNumber = iSignalWord;
|
||||
m_sHazard = sHazard;
|
||||
m_sConsequences = "";
|
||||
m_sAvoiding = "";
|
||||
m_eCause = e;
|
||||
}
|
||||
/** Creates a new instance of MessageInf
|
||||
* @param iSignalWord
|
||||
* @param sHazard */
|
||||
public MessageInf(int iSignalWord, String sHazard) {
|
||||
this (iSignalWord, sHazard, null);
|
||||
}
|
||||
|
||||
/** Creates a new instance of MessageInf
|
||||
* @param e */
|
||||
public MessageInf(Throwable e) {
|
||||
this(SGN_WARNING, e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
*/
|
||||
public void show(Component parent) {
|
||||
JMessageDialog.showMessage(parent, this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object getCause() {
|
||||
return m_eCause;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getSignalWord() {
|
||||
return m_iMsgNumber & 0xFF000000;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Icon getSignalWordIcon() {
|
||||
int iSignalWord = getSignalWord();
|
||||
if (iSignalWord == SGN_DANGER) {
|
||||
return UIManager.getIcon("OptionPane.errorIcon");
|
||||
} else if (iSignalWord == SGN_WARNING) {
|
||||
return UIManager.getIcon("OptionPane.warningIcon");
|
||||
} else if (iSignalWord == SGN_CAUTION) {
|
||||
return UIManager.getIcon("OptionPane.warningIcon");
|
||||
} else if (iSignalWord == SGN_NOTICE) {
|
||||
return UIManager.getIcon("OptionPane.informationIcon");
|
||||
} else if (iSignalWord == SGN_IMPORTANT) {
|
||||
return UIManager.getIcon("OptionPane.informationIcon");
|
||||
} else if (iSignalWord == SGN_SUCCESS) {
|
||||
return UIManager.getIcon("OptionPane.informationIcon");
|
||||
} else {
|
||||
return UIManager.getIcon("OptionPane.questionIcon");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getErrorCodeMsg() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int iSignalWord = getSignalWord();
|
||||
if (iSignalWord == SGN_DANGER) {
|
||||
sb.append("DNG_");
|
||||
} else if (iSignalWord == SGN_WARNING) {
|
||||
sb.append("WRN_");
|
||||
} else if (iSignalWord == SGN_CAUTION) {
|
||||
sb.append("CAU_");
|
||||
} else if (iSignalWord == SGN_NOTICE) {
|
||||
sb.append("NOT_");
|
||||
} else if (iSignalWord == SGN_IMPORTANT) {
|
||||
sb.append("IMP_");
|
||||
} else if (iSignalWord == SGN_SUCCESS) {
|
||||
sb.append("INF_");
|
||||
} else {
|
||||
sb.append("UNK_");
|
||||
}
|
||||
sb.append(toHex((m_iMsgNumber & 0x00FF0000) >> 16, 2));
|
||||
sb.append('_');
|
||||
sb.append(toHex(m_iMsgNumber & 0x0000FFFF, 4));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String toHex(int i, int iChars) {
|
||||
String s = Integer.toHexString(i);
|
||||
return s.length() >= iChars ? s : fillString(iChars - s.length()) + s;
|
||||
}
|
||||
|
||||
private String fillString(int iChars) {
|
||||
char[] aStr = new char[iChars];
|
||||
for (int i = 0; i < aStr.length; i++) {
|
||||
aStr[i] = '0';
|
||||
}
|
||||
return new String(aStr);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMessageMsg() {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int iSignalWord = getSignalWord();
|
||||
if (iSignalWord == SGN_DANGER) {
|
||||
sb.append(LocalRes.getIntString("sgn.danger"));
|
||||
} else if (iSignalWord == SGN_WARNING) {
|
||||
sb.append(LocalRes.getIntString("sgn.warning"));
|
||||
} else if (iSignalWord == SGN_CAUTION) {
|
||||
sb.append(LocalRes.getIntString("sgn.caution"));
|
||||
} else if (iSignalWord == SGN_NOTICE) {
|
||||
sb.append(LocalRes.getIntString("sgn.notice"));
|
||||
} else if (iSignalWord == SGN_IMPORTANT) {
|
||||
sb.append(LocalRes.getIntString("sgn.important"));
|
||||
} else if (iSignalWord == SGN_SUCCESS) {
|
||||
sb.append(LocalRes.getIntString("sgn.success"));
|
||||
} else {
|
||||
sb.append(LocalRes.getIntString("sgn.unknown"));
|
||||
}
|
||||
sb.append(m_sHazard);
|
||||
sb.append(m_sConsequences);
|
||||
sb.append(m_sAvoiding);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import javax.swing.Icon;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class NullIcon implements Icon {
|
||||
|
||||
private int m_iWidth;
|
||||
private int m_iHeight;
|
||||
|
||||
/** Creates a new instance of NullIcon
|
||||
* @param width
|
||||
* @param height */
|
||||
public NullIcon(int width, int height) {
|
||||
m_iWidth = width;
|
||||
m_iHeight = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return m_iHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return m_iWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.gui;
|
||||
|
||||
import com.unicenta.format.Formats;
|
||||
import java.awt.Component;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class TableRendererBasic extends DefaultTableCellRenderer {
|
||||
|
||||
private Formats[] m_aFormats;
|
||||
|
||||
/** Creates a new instance of TableRendererBasic
|
||||
* @param aFormats */
|
||||
public TableRendererBasic(Formats[] aFormats) {
|
||||
m_aFormats = aFormats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
|
||||
|
||||
JLabel aux = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);
|
||||
|
||||
aux.setText(m_aFormats[column].formatValue(value));
|
||||
aux.setHorizontalAlignment(m_aFormats[column].getAlignment());
|
||||
|
||||
return aux;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class BaseSentence implements SentenceList, SentenceFind, SentenceExec {
|
||||
|
||||
// Funciones de bajo nivel
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract DataResultSet openExec(Object params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract DataResultSet moreResults() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract void closeExec() throws BasicException;
|
||||
|
||||
// Funciones
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final int exec() throws BasicException {
|
||||
return exec((Object) null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final int exec(Object... params) throws BasicException {
|
||||
return exec((Object) params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final int exec(Object params) throws BasicException {
|
||||
DataResultSet SRS = openExec(params);
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noupdatecount"));
|
||||
}
|
||||
int iResult = SRS.updateCount();
|
||||
SRS.close();
|
||||
closeExec();
|
||||
return iResult;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final List list() throws BasicException {
|
||||
return list((Object) null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final List list(Object... params) throws BasicException {
|
||||
return list((Object) params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final List list(Object params) throws BasicException {
|
||||
// En caso de error o lanza un pepinazo en forma de DataException
|
||||
DataResultSet SRS = openExec(params);
|
||||
List aSO = fetchAll(SRS);
|
||||
SRS.close();
|
||||
closeExec();
|
||||
return aSO;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final List listPage(int offset, int length) throws BasicException {
|
||||
return listPage(null, offset, length);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final List listPage(Object params, int offset, int length) throws BasicException {
|
||||
// En caso de error o lanza un pepinazo en forma de DataException
|
||||
DataResultSet SRS = openExec(params);
|
||||
List aSO = fetchPage(SRS, offset, length);
|
||||
SRS.close();
|
||||
closeExec();
|
||||
return aSO;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final Object find() throws BasicException {
|
||||
return find((Object) null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final Object find(Object... params) throws BasicException {
|
||||
return find((Object) params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final Object find(Object params) throws BasicException {
|
||||
// En caso de error o lanza un pepinazo en forma de SQLException
|
||||
DataResultSet SRS = openExec(params);
|
||||
Object obj = fetchOne(SRS);
|
||||
SRS.close();
|
||||
closeExec();
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Utilidades
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SRS
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final List fetchAll(DataResultSet SRS) throws BasicException {
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
List aSO = new ArrayList();
|
||||
while (SRS.next()) {
|
||||
aSO.add(SRS.getCurrent());
|
||||
}
|
||||
return aSO;
|
||||
}
|
||||
|
||||
// Utilidades
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SRS
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final List fetchPage(DataResultSet SRS, int offset, int length) throws BasicException {
|
||||
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
if (offset < 0 || length < 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nonegativelimits"));
|
||||
}
|
||||
|
||||
// Skip los primeros que no me importan
|
||||
while (offset > 0 && SRS.next()) {
|
||||
offset--;
|
||||
}
|
||||
|
||||
// me traigo tantos como me han dicho
|
||||
List aSO = new ArrayList();
|
||||
if (offset == 0) {
|
||||
while (length > 0 && SRS.next()) {
|
||||
length--;
|
||||
aSO.add(SRS.getCurrent());
|
||||
}
|
||||
}
|
||||
return aSO;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SRS
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final Object fetchOne(DataResultSet SRS) throws BasicException {
|
||||
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
if (SRS.next()) {
|
||||
return SRS.getCurrent();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class BasicSentenceEnum implements SentenceEnum {
|
||||
|
||||
BaseSentence sent;
|
||||
DataResultSet SRS;
|
||||
|
||||
/** Creates a new instance of AbstractSentenceEnum
|
||||
* @param sent */
|
||||
public BasicSentenceEnum(BaseSentence sent) {
|
||||
this.sent = sent;
|
||||
this.SRS = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void load() throws BasicException {
|
||||
load(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void load(Object params) throws BasicException {
|
||||
SRS = sent.openExec(params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getCurrent() throws BasicException {
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
return SRS.getCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public boolean next() throws BasicException {
|
||||
if (SRS == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
if (SRS.next()) {
|
||||
return true;
|
||||
} else {
|
||||
SRS.close();
|
||||
SRS = null;
|
||||
sent.closeExec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class BatchSentence extends BaseSentence {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected Session m_s;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected HashMap<String, String> m_parameters;
|
||||
|
||||
/** Creates a new instance of BatchSentence
|
||||
* @param s */
|
||||
public BatchSentence(Session s) {
|
||||
m_s = s;
|
||||
m_parameters = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param replacement
|
||||
*/
|
||||
public void putParameter(String name, String replacement) {
|
||||
m_parameters.put(name, replacement);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
protected abstract Reader getReader() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ExceptionsResultSet implements DataResultSet {
|
||||
|
||||
List l;
|
||||
int m_iIndex;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param l
|
||||
*/
|
||||
public ExceptionsResultSet(List l) {
|
||||
this.l = l;
|
||||
m_iIndex = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Integer getInt(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public String getString(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Double getDouble(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Boolean getBoolean(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public java.util.Date getTimestamp(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
//public java.io.InputStream getBinaryStream(int columnIndex) throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public byte[] getBytes(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Object getObject(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
// public int getColumnCount() throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataField[] getDataField() throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Object getCurrent() throws BasicException {
|
||||
if (m_iIndex < 0 || m_iIndex >= l.size()) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.outofbounds"));
|
||||
} else {
|
||||
return l.get(m_iIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public boolean next() throws BasicException {
|
||||
return ++m_iIndex < l.size();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws BasicException {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int updateCount() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final void closeExec() throws BasicException {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final DataResultSet moreResults() throws BasicException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
|
||||
BufferedReader br = new BufferedReader(getReader());
|
||||
|
||||
String sLine;
|
||||
StringBuffer sSentence = new StringBuffer();
|
||||
List aExceptions = new ArrayList();
|
||||
|
||||
try {
|
||||
while ((sLine = br.readLine()) != null) {
|
||||
sLine = sLine.trim();
|
||||
if (!sLine.equals("") && !sLine.startsWith("--")) {
|
||||
// No es un comentario ni linea vacia
|
||||
if (sLine.endsWith(";")) {
|
||||
// ha terminado la sentencia
|
||||
sSentence.append(sLine.substring(0, sLine.length() - 1));
|
||||
|
||||
// File parameters
|
||||
Pattern pattern = Pattern.compile("\\$(\\w+)\\{([^}]*)\\}");
|
||||
Matcher matcher = pattern.matcher(sSentence.toString());
|
||||
List paramlist = new ArrayList();
|
||||
|
||||
// Replace all occurrences of pattern in input
|
||||
StringBuffer buf = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
if ("FILE".equals(matcher.group(1))) {
|
||||
paramlist.add(ImageUtils.getBytesFromResource(matcher.group(2)));
|
||||
matcher.appendReplacement(buf, "?");
|
||||
} else {
|
||||
String replacement = m_parameters.get(matcher.group(1));
|
||||
if (replacement == null) {
|
||||
matcher.appendReplacement(buf, Matcher.quoteReplacement(matcher.group(0)));
|
||||
} else {
|
||||
paramlist.add(replacement);
|
||||
matcher.appendReplacement(buf, "?");
|
||||
}
|
||||
}
|
||||
}
|
||||
matcher.appendTail(buf);
|
||||
|
||||
// La disparo
|
||||
try {
|
||||
BaseSentence sent;
|
||||
if (paramlist.isEmpty()) {
|
||||
sent = new StaticSentence(m_s, buf.toString());
|
||||
sent.exec();
|
||||
} else {
|
||||
sent = new PreparedSentence(m_s, buf.toString(), SerializerWriteBuilder.INSTANCE);
|
||||
sent.exec(new VarParams(paramlist));
|
||||
}
|
||||
} catch (BasicException eD) {
|
||||
aExceptions.add(eD);
|
||||
}
|
||||
sSentence = new StringBuffer();
|
||||
|
||||
} else {
|
||||
// la sentencia continua en la linea siguiente
|
||||
sSentence.append(sLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
br.close();
|
||||
|
||||
} catch (IOException eIO) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noreadfile"), eIO);
|
||||
}
|
||||
|
||||
if (sSentence.length() > 0) {
|
||||
// ha quedado una sentencia inacabada
|
||||
aExceptions.add(new BasicException(LocalRes.getIntString("exception.nofinishedfile")));
|
||||
}
|
||||
|
||||
return new ExceptionsResultSet(aExceptions);
|
||||
}
|
||||
|
||||
private static class VarParams implements SerializableWrite {
|
||||
|
||||
private List l;
|
||||
|
||||
public VarParams(List l) {
|
||||
this.l = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValues(DataWrite dp) throws BasicException {
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
Object v = l.get(i);
|
||||
if (v instanceof String) {
|
||||
dp.setString(i + 1, (String) v);
|
||||
} else if (v instanceof byte[]) {
|
||||
dp.setBytes(i + 1, (byte[]) l.get(i));
|
||||
} else {
|
||||
dp.setObject(i + 1, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class BatchSentenceResource extends BatchSentence {
|
||||
|
||||
private String m_sResScript;
|
||||
|
||||
/** Creates a new instance of BatchSentenceResource
|
||||
* @param s
|
||||
* @param resscript */
|
||||
public BatchSentenceResource(Session s, String resscript) {
|
||||
super(s);
|
||||
m_sResScript = resscript;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
protected Reader getReader() throws BasicException {
|
||||
|
||||
InputStream in = BatchSentenceResource.class.getResourceAsStream(m_sResScript);
|
||||
|
||||
if (in == null) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nosentencesfile"));
|
||||
} else {
|
||||
try {
|
||||
return new InputStreamReader(in, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nosentencesfile"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.io.Reader;
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class BatchSentenceScript extends BatchSentence {
|
||||
|
||||
private String m_sScript;
|
||||
|
||||
/** Creates a new instance of BatchSentenceScript
|
||||
* @param s
|
||||
* @param script */
|
||||
public BatchSentenceScript(Session s, String script) {
|
||||
super(s);
|
||||
m_sScript = script;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
protected Reader getReader() throws BasicException {
|
||||
|
||||
return new java.io.StringReader(m_sScript);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
|
||||
import com.unicenta.pos.forms.AppConfig;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class CompanyDetails {
|
||||
private String db_url;
|
||||
private String db_user;
|
||||
private String db_password;
|
||||
private File m_config;
|
||||
private Session session;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CompanyDetails() {
|
||||
|
||||
AppConfig config = new AppConfig(m_config);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
public void loadProperties(AppConfig config) {
|
||||
|
||||
db_url=(config.getProperty("db.url"));
|
||||
db_user=(config.getProperty("db_user"));
|
||||
db_password=(config.getProperty("db.password"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUser() {
|
||||
return db_user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface ComparatorCreator {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getHeaders();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public Comparator createComparator(int[] index);
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class ComparatorCreatorBasic implements ComparatorCreator {
|
||||
|
||||
private String[] m_sHeaders;
|
||||
private Datas[] m_aDatas;
|
||||
private int[] m_iAvailableIndexes;
|
||||
|
||||
/** Creates a new instance of ComparatorCreatorBasic
|
||||
* @param sHeaders
|
||||
* @param aDatas
|
||||
* @param iAvailableIndexes */
|
||||
public ComparatorCreatorBasic(String[] sHeaders, Datas[] aDatas, int[] iAvailableIndexes) {
|
||||
|
||||
m_sHeaders = sHeaders;
|
||||
m_aDatas = aDatas;
|
||||
m_iAvailableIndexes = iAvailableIndexes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sHeaders
|
||||
* @param aDatas
|
||||
*/
|
||||
public ComparatorCreatorBasic(String[] sHeaders, Datas[] aDatas) {
|
||||
m_sHeaders = sHeaders;
|
||||
m_aDatas = aDatas;
|
||||
m_iAvailableIndexes = new int[aDatas.length];
|
||||
for (int i = 0; i < aDatas.length; i++) {
|
||||
m_iAvailableIndexes[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getHeaders() {
|
||||
|
||||
String[] sTempHeaders = new String[m_iAvailableIndexes.length];
|
||||
|
||||
for (int i = 0; i < m_iAvailableIndexes.length; i++) {
|
||||
sTempHeaders[i] = m_sHeaders[m_iAvailableIndexes[i]];
|
||||
}
|
||||
return sTempHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aiOrderBy
|
||||
* @return
|
||||
*/
|
||||
public Comparator createComparator(int[] aiOrderBy) {
|
||||
return new ComparatorBasic(aiOrderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ComparatorBasic implements Comparator {
|
||||
|
||||
private int[] m_aiOrderBy;
|
||||
|
||||
/** Creates a new instance of ComparatorBasic
|
||||
* @param aiOrderBy */
|
||||
public ComparatorBasic(int[] aiOrderBy) {
|
||||
m_aiOrderBy = aiOrderBy;
|
||||
}
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (o1 == null) {
|
||||
if (o2 == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (o2 == null) {
|
||||
return +1;
|
||||
} else {
|
||||
// ninguno de los dos es nulo...
|
||||
Object[] ao1 = (Object[]) o1;
|
||||
Object[] ao2 = (Object[]) o2;
|
||||
for (int i = 0; i < m_aiOrderBy.length; i++) {
|
||||
int result = m_aDatas[m_iAvailableIndexes[m_aiOrderBy[i]]].compare(ao1[m_iAvailableIndexes[m_aiOrderBy[i]]], ao2[m_iAvailableIndexes[m_aiOrderBy[i]]]);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class DataField {
|
||||
|
||||
/** Creates a new instance of DataField */
|
||||
public DataField() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String Name;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public int Size;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public int Type;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public abstract class DataParams implements DataWrite {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected DataWrite dw;
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract void writeValues() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param iValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
dw.setInt(paramIndex, iValue);
|
||||
}
|
||||
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
dw.setString(paramIndex, sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param dValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
dw.setDouble(paramIndex, dValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param bValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
dw.setBoolean(paramIndex, bValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param dValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setTimestamp(int paramIndex, Date dValue) throws BasicException {
|
||||
dw.setTimestamp(paramIndex, dValue);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param value
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
dw.setBytes(paramIndex, value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param value
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
dw.setObject(paramIndex, value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DataWrite getDataWrite() {
|
||||
return dw;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dw
|
||||
*/
|
||||
public void setDataWrite(DataWrite dw) {
|
||||
this.dw = dw;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public interface DataRead {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Integer getInt(int columnIndex) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public String getString(int columnIndex) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Double getDouble(int columnIndex) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Boolean getBoolean(int columnIndex) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public java.util.Date getTimestamp(int columnIndex) throws BasicException;
|
||||
|
||||
//public java.io.InputStream getBinaryStream(int columnIndex) throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public byte[] getBytes(int columnIndex) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getObject(int columnIndex) throws BasicException ;
|
||||
|
||||
// public int getColumnCount() throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataField[] getDataField() throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface DataResultSet extends DataRead {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getCurrent() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public boolean next() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void close() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int updateCount() throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public interface DataWrite {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param iValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException;
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param sValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setString(int paramIndex, String sValue) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param dValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param bValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param dValue
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException;
|
||||
|
||||
//public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param value
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param paramIndex
|
||||
* @param value
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void setObject(int paramIndex, Object value) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Date;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class DataWriteUtils {
|
||||
|
||||
|
||||
/** Creates a new instance of DataWriteUtils */
|
||||
public DataWriteUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(Object obj) {
|
||||
if (obj == null) {
|
||||
return "NULL";
|
||||
} else if (obj instanceof Double) {
|
||||
return getSQLValue((Double) obj);
|
||||
} else if (obj instanceof Integer) {
|
||||
return getSQLValue((Integer) obj);
|
||||
} else if (obj instanceof Boolean) {
|
||||
return getSQLValue((Boolean) obj);
|
||||
} else if (obj instanceof String) {
|
||||
return getSQLValue((String) obj);
|
||||
} else if (obj instanceof Date) {
|
||||
return getSQLValue((Date) obj);
|
||||
} else {
|
||||
return getSQLValue(obj.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iValue
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(Integer iValue) {
|
||||
if (iValue == null) {
|
||||
return "NULL";
|
||||
} else {
|
||||
return iValue.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dValue
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(Double dValue) {
|
||||
if (dValue == null) {
|
||||
return "NULL";
|
||||
} else {
|
||||
return dValue.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bValue
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(Boolean bValue) {
|
||||
if (bValue == null) {
|
||||
return "NULL";
|
||||
} else {
|
||||
return bValue.booleanValue() ? "TRUE" : "FALSE";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sValue
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(String sValue) {
|
||||
if (sValue == null) {
|
||||
return "NULL";
|
||||
} else {
|
||||
return '\'' + getEscaped(sValue) + '\'';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dValue
|
||||
* @return
|
||||
*/
|
||||
public static String getSQLValue(Date dValue) {
|
||||
if (dValue == null) {
|
||||
return "NULL";
|
||||
} else {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = sdf.format(dValue);
|
||||
return "'"+date+"'";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sValue
|
||||
* @return
|
||||
*/
|
||||
public static String getEscaped(String sValue) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < sValue.length(); i++) {
|
||||
switch (sValue.charAt(i)) {
|
||||
case '\\':
|
||||
sb.append("\\\\");
|
||||
break;
|
||||
case '\'':
|
||||
sb.append("\\'");
|
||||
break;
|
||||
case '\n':
|
||||
sb.append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
sb.append("\\r");
|
||||
break;
|
||||
default:
|
||||
sb.append(sValue.charAt(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
/**
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class Datas {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas INT = new DatasINT();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas STRING = new DatasSTRING();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas DOUBLE = new DatasDOUBLE();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas BOOLEAN = new DatasBOOLEAN();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas TIMESTAMP = new DatasTIMESTAMP();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas BYTES = new DatasBYTES();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas IMAGE = new DatasIMAGE();
|
||||
//public final static Datas INPUTSTREAM = new DatasINPUTSTREAM();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas OBJECT = new DatasOBJECT();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas SERIALIZABLE = new DatasSERIALIZABLE();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static Datas NULL = new DatasNULL();
|
||||
|
||||
private static DateFormat tsf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
/**
|
||||
* Creates a new instance of Datas
|
||||
*/
|
||||
private Datas() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dr
|
||||
* @param i
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract Object getValue(DataRead dr, int i) throws BasicException;
|
||||
|
||||
/**
|
||||
* @param dw
|
||||
* @param i
|
||||
* @param value
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract void setValue(DataWrite dw, int i, Object value) throws BasicException;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public abstract Class getClassValue();
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
protected abstract String toStringAbstract(Object value);
|
||||
|
||||
/**
|
||||
* @param o1
|
||||
* @param o2
|
||||
* @return
|
||||
*/
|
||||
protected abstract int compareAbstract(Object o1, Object o2);
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public String toString(Object value) {
|
||||
if (value == null) {
|
||||
return "null";
|
||||
} else {
|
||||
return toStringAbstract(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param o1
|
||||
* @param o2
|
||||
* @return
|
||||
*/
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (o1 == null) {
|
||||
if (o2 == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (o2 == null) {
|
||||
return +1;
|
||||
} else {
|
||||
return compareAbstract(o1, o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasINT extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getInt(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setInt(i, (Integer) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Integer.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return ((Integer) value).toString();
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
return ((Integer) o1).compareTo((Integer) o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasSTRING extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getString(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setString(i, (String) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.String.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "\'" + DataWriteUtils.getEscaped((String) value) + "\'";
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
return ((String) o1).compareTo((String) o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasDOUBLE extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getDouble(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setDouble(i, (Double) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Double.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return ((Double) value).toString();
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
return ((Double) o1).compareTo((Double) o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasBOOLEAN extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getBoolean(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setBoolean(i, (Boolean) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Boolean.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return ((Boolean) value).toString();
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
return ((Boolean) o1).compareTo((Boolean) o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasTIMESTAMP extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getTimestamp(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setTimestamp(i, (java.util.Date) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.util.Date.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return tsf.format(value);
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
return ((java.util.Date) o1).compareTo((java.util.Date) o2);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasBYTES extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getBytes(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setBytes(i, (byte[]) value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return byte[].class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "0x" + ImageUtils.bytes2hex((byte[]) value);
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasIMAGE extends Datas {
|
||||
@Override
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return ImageUtils.readImage(dr.getBytes(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setBytes(i, ImageUtils.writeImage((java.awt.image.BufferedImage) value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getClassValue() {
|
||||
return java.awt.image.BufferedImage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "0x" + ImageUtils.bytes2hex(ImageUtils.writeImage((java.awt.image.BufferedImage) value));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
// private static final class DatasINPUTSTREAM extends Datas {
|
||||
// public Object getValue(DataRead dr, int i) throws DataException {
|
||||
// byte[] b = dr.getBytes(i);
|
||||
// return b == null ? null : new java.io.ByteArrayInputStream(b);
|
||||
// }
|
||||
// public void setValue(DataWrite dw, int i, Object value) throws DataException {
|
||||
// }
|
||||
// }
|
||||
private static final class DatasOBJECT extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return dr.getObject(i);
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setObject(i, value);
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Object.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "0x" + ImageUtils.bytes2hex(ImageUtils.writeSerializable(value));
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasSERIALIZABLE extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return ImageUtils.readSerializable(dr.getBytes(i));
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
dw.setBytes(i, ImageUtils.writeSerializable(value));
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Object.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "0x" + ImageUtils.bytes2hex(ImageUtils.writeSerializable(value));
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DatasNULL extends Datas {
|
||||
public Object getValue(DataRead dr, int i) throws BasicException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValue(DataWrite dw, int i, Object value) throws BasicException {
|
||||
// No asigno null, no asigno nada.
|
||||
}
|
||||
|
||||
public Class getClassValue() {
|
||||
return java.lang.Object.class;
|
||||
}
|
||||
|
||||
protected String toStringAbstract(Object value) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
protected int compareAbstract(Object o1, Object o2) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface IKeyGetter {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Object getKey(Object value);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
* Created on 27 de febrero de 2007, 22:08
|
||||
*
|
||||
*/
|
||||
public interface IKeyed {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object getKey();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface IRenderString {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public String getRenderString(Object value);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface ISQLBuilderStatic {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sw
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public String getSQL(SerializerWrite sw, Object params) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.io.*;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class ImageUtils {
|
||||
|
||||
private static char[] HEXCHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
/** Creates a new instance of ImageUtils */
|
||||
private ImageUtils() {
|
||||
}
|
||||
|
||||
private static byte[] readStream(InputStream in) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
byte[] resource = new byte[0];
|
||||
int n;
|
||||
|
||||
while ((n = in.read(buffer)) != -1) {
|
||||
byte[] b = new byte[resource.length + n];
|
||||
System.arraycopy(resource, 0, b, 0, resource.length);
|
||||
System.arraycopy(buffer, 0, b, resource.length, n);
|
||||
resource = b;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static byte[] getBytesFromResource(String file) {
|
||||
|
||||
InputStream in = ImageUtils.class.getResourceAsStream(file);
|
||||
|
||||
if (in == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return ImageUtils.readStream(in);
|
||||
} catch (IOException e) {
|
||||
return new byte[0];
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static BufferedImage readImageFromResource(String file) {
|
||||
return readImage(getBytesFromResource(file));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static BufferedImage readImage(String url) {
|
||||
try {
|
||||
return readImage(new URL(url));
|
||||
} catch (MalformedURLException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static BufferedImage readImage(URL url) {
|
||||
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
URLConnection urlConnection = url.openConnection();
|
||||
in = urlConnection.getInputStream();
|
||||
return readImage(readStream(in));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static BufferedImage readImage(byte[] b) {
|
||||
if (b == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return ImageIO.read(new ByteArrayInputStream(b));
|
||||
} catch(IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param img
|
||||
* @return
|
||||
*/
|
||||
public static byte[] writeImage(BufferedImage img) {
|
||||
if (img == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
ImageIO.write(img, "png", b);
|
||||
b.flush();
|
||||
b.close();
|
||||
return b.toByteArray();
|
||||
} catch(IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static Object readSerializable(byte[] b) {
|
||||
if (b == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b));
|
||||
Object obj = in.readObject();
|
||||
in.close();
|
||||
return obj;
|
||||
} catch (ClassNotFoundException eCNF) {
|
||||
//logger.error("Cannot create lists object", eCNF);
|
||||
return null;
|
||||
} catch (IOException eIO) {
|
||||
//logger.error("Cannot load lists file", eIO);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public static byte[] writeSerializable(Object o) {
|
||||
|
||||
if (o == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(b);
|
||||
out.writeObject(o);
|
||||
out.flush();
|
||||
out.close();
|
||||
return b.toByteArray();
|
||||
} catch (IOException eIO) {
|
||||
eIO.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
* @return
|
||||
*/
|
||||
public static Properties readProperties(byte b[]) {
|
||||
Properties prop = new Properties();
|
||||
try {
|
||||
if (b != null) {
|
||||
prop.loadFromXML(new ByteArrayInputStream(b));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param binput
|
||||
* @return
|
||||
*/
|
||||
public static String bytes2hex(byte[] binput) {
|
||||
|
||||
StringBuilder s = new StringBuilder(binput.length *2);
|
||||
for (int i = 0; i < binput.length; i++) {
|
||||
byte b = binput[i];
|
||||
s.append(HEXCHARS[(b & 0xF0) >> 4]);
|
||||
s.append(HEXCHARS[b & 0x0F]);
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class ImportSentence extends BaseSentence {
|
||||
|
||||
/** Creates a new instance of ImportSentence */
|
||||
public ImportSentence() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void closeExec() throws BasicException {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet moreResults() throws BasicException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class JDBCSentence extends BaseSentence {
|
||||
|
||||
// Conexion
|
||||
// protected Connection m_c;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected Session session;
|
||||
|
||||
/** Creates a new instance of BaseSentence
|
||||
* @param session */
|
||||
public JDBCSentence(Session session) {
|
||||
super();
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected static final class JDBCDataResultSet implements DataResultSet {
|
||||
|
||||
private ResultSet m_rs;
|
||||
private SerializerRead m_serread;
|
||||
// private int m_iColumnCount;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rs
|
||||
* @param serread
|
||||
*/
|
||||
public JDBCDataResultSet(ResultSet rs, SerializerRead serread) {
|
||||
m_rs = rs;
|
||||
m_serread = serread;
|
||||
// m_iColumnCount = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Integer getInt(int columnIndex) throws BasicException {
|
||||
try {
|
||||
int iValue = m_rs.getInt(columnIndex);
|
||||
return m_rs.wasNull() ? null : new Integer(iValue);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public String getString(int columnIndex) throws BasicException {
|
||||
try {
|
||||
return m_rs.getString(columnIndex);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Double getDouble(int columnIndex) throws BasicException {
|
||||
try {
|
||||
double dValue = m_rs.getDouble(columnIndex);
|
||||
return m_rs.wasNull() ? null : new Double(dValue);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Boolean getBoolean(int columnIndex) throws BasicException {
|
||||
try {
|
||||
boolean bValue = m_rs.getBoolean(columnIndex);
|
||||
return m_rs.wasNull() ? null : new Boolean(bValue);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public java.util.Date getTimestamp(int columnIndex) throws BasicException {
|
||||
try {
|
||||
java.sql.Timestamp ts = m_rs.getTimestamp(columnIndex);
|
||||
return ts == null ? null : new java.util.Date(ts.getTime());
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public byte[] getBytes(int columnIndex) throws BasicException {
|
||||
try {
|
||||
return m_rs.getBytes(columnIndex);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getObject(int columnIndex) throws BasicException {
|
||||
try {
|
||||
return m_rs.getObject(columnIndex);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataField[] getDataField() throws BasicException {
|
||||
try {
|
||||
ResultSetMetaData md = m_rs.getMetaData();
|
||||
DataField[] df = new DataField[md.getColumnCount()];
|
||||
for (int i = 0; i < df.length; i++) {
|
||||
df[i] = new DataField();
|
||||
df[i].Name = md.getColumnName(i + 1);
|
||||
df[i].Size = md.getColumnDisplaySize(i + 1);
|
||||
df[i].Type = md.getColumnType(i + 1);
|
||||
}
|
||||
return df;
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Object getCurrent() throws BasicException {
|
||||
return m_serread.readValues(this);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public boolean next() throws BasicException {
|
||||
try {
|
||||
return m_rs.next();
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws BasicException {
|
||||
try {
|
||||
m_rs.close();
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public int updateCount() throws BasicException {
|
||||
return -1; // es decir somos datos.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class KeyGetterBasic implements IKeyGetter {
|
||||
|
||||
private int [] m_aElems;
|
||||
|
||||
/** Creates a new instance of KeyGetterBasic
|
||||
* @param aElems */
|
||||
public KeyGetterBasic(int[] aElems) {
|
||||
m_aElems = aElems;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public Object getKey(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
} else {
|
||||
Object[] avalue = (Object []) value;
|
||||
Object[] akey = new Object[m_aElems.length];
|
||||
for (int i = 0; i < m_aElems.length; i++) {
|
||||
akey[i] = avalue[m_aElems[i]];
|
||||
}
|
||||
return akey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
* Created on 27 de febrero de 2007, 22:09
|
||||
*
|
||||
*/
|
||||
public class KeyGetterBuilder implements IKeyGetter {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static IKeyGetter INSTANCE = new KeyGetterBuilder();
|
||||
|
||||
/** Creates a new instance of KeyGetterBuilder */
|
||||
public KeyGetterBuilder() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getKey(Object value) {
|
||||
|
||||
return (value == null)
|
||||
? null
|
||||
: ((IKeyed) value).getKey();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class KeyGetterFirst implements IKeyGetter {
|
||||
|
||||
private final int [] m_aElems;
|
||||
|
||||
/** Creates a new instance of KeyGetterBasic
|
||||
* @param aElems */
|
||||
public KeyGetterFirst(int[] aElems) {
|
||||
m_aElems = aElems;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object getKey(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
} else {
|
||||
Object[] avalue = (Object []) value;
|
||||
return avalue[m_aElems[0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import com.unicenta.beans.LocaleResources;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class LocalRes {
|
||||
|
||||
// private static ResourceBundle m_Intl;
|
||||
private static LocaleResources m_resources;
|
||||
|
||||
static {
|
||||
m_resources = new LocaleResources();
|
||||
m_resources.addBundleName("data_messages");
|
||||
}
|
||||
|
||||
/** Creates a new instance of LocalRes */
|
||||
private LocalRes() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sKey
|
||||
* @return
|
||||
*/
|
||||
public static String getIntString(String sKey) {
|
||||
return m_resources.getString(sKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class MetaSentence extends JDBCSentence {
|
||||
|
||||
private String m_sSentence;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected SerializerRead m_SerRead = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected SerializerWrite m_SerWrite = null;
|
||||
|
||||
/** Creates a new instance of MetaDataSentence
|
||||
* @param s
|
||||
* @param sSentence
|
||||
* @param serwrite
|
||||
* @param serread */
|
||||
public MetaSentence(Session s, String sSentence, SerializerWrite serwrite, SerializerRead serread) {
|
||||
super(s);
|
||||
m_sSentence = sSentence;
|
||||
m_SerWrite = serwrite;
|
||||
m_SerRead = serread;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sSentence
|
||||
* @param serread
|
||||
*/
|
||||
public MetaSentence(Session s, String sSentence, SerializerRead serread) {
|
||||
this(s, sSentence, null, serread);
|
||||
}
|
||||
|
||||
private static class MetaParameter implements DataWrite {
|
||||
|
||||
private ArrayList m_aParams;
|
||||
|
||||
/** Creates a new instance of MetaParameter */
|
||||
public MetaParameter() {
|
||||
m_aParams = new ArrayList();
|
||||
}
|
||||
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, sValue);
|
||||
}
|
||||
public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException {
|
||||
// throw new DataException("Param type not allowed");
|
||||
// }
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
setString(paramIndex, (value == null) ? null : value.toString());
|
||||
}
|
||||
|
||||
public String getString(int index) {
|
||||
return (String) m_aParams.get(index);
|
||||
}
|
||||
|
||||
private void ensurePlace(int i) {
|
||||
m_aParams.ensureCapacity(i);
|
||||
while (i >= m_aParams.size()){
|
||||
m_aParams.add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
|
||||
closeExec();
|
||||
|
||||
try {
|
||||
DatabaseMetaData db = session.getConnection().getMetaData();
|
||||
|
||||
MetaParameter mp = new MetaParameter();
|
||||
if (params != null) {
|
||||
// si m_SerWrite fuera null deberiamos cascar
|
||||
m_SerWrite.writeValues(mp, params);
|
||||
}
|
||||
|
||||
// Catalogs Has Schemas Has Objects
|
||||
|
||||
// Lo generico de la base de datos
|
||||
if ("getCatalogs".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getCatalogs(), m_SerRead);
|
||||
} else if ("getSchemas".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getSchemas(), m_SerRead);
|
||||
} else if ("getTableTypes".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getTableTypes(), m_SerRead);
|
||||
} else if ("getTypeInfo".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getTypeInfo(), m_SerRead);
|
||||
|
||||
// Los objetos por catalogo, esquema
|
||||
|
||||
// Los tipos definidos por usuario
|
||||
} else if ("getUDTs".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getUDTs(mp.getString(0), mp.getString(1), null, null), m_SerRead);
|
||||
} else if ("getSuperTypes".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getSuperTypes(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
|
||||
// Los atributos
|
||||
} else if ("getAttributes".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getAttributes(mp.getString(0), mp.getString(1), null, null), m_SerRead);
|
||||
|
||||
// Las Tablas y sus objetos relacionados
|
||||
} else if ("getTables".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getTables(mp.getString(0), mp.getString(1), null, null), m_SerRead);
|
||||
} else if ("getSuperTables".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getSuperTables(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getTablePrivileges".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getTablePrivileges(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getBestRowIdentifier".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getBestRowIdentifier(mp.getString(0), mp.getString(1), mp.getString(2), 0, true), m_SerRead);
|
||||
} else if ("getPrimaryKeys".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getPrimaryKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getColumnPrivileges".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getColumnPrivileges(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead);
|
||||
} else if ("getColumns".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getColumns(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead);
|
||||
} else if ("getVersionColumns".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getVersionColumns(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getIndexInfo".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getIndexInfo(mp.getString(0), mp.getString(1), mp.getString(2), false, false), m_SerRead);
|
||||
} else if ("getExportedKeys".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getExportedKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getImportedKeys".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getImportedKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead);
|
||||
} else if ("getCrossReference".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getCrossReference(mp.getString(0), mp.getString(1), mp.getString(2), null, null, null), m_SerRead);
|
||||
|
||||
// Los procedimientos y sus objetos relacionados
|
||||
} else if ("getProcedures".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getProcedures(mp.getString(0), mp.getString(1), null), m_SerRead);
|
||||
} else if ("getProcedureColumns".equals(m_sSentence)) {
|
||||
return new JDBCDataResultSet(db.getProcedureColumns(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead);
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void closeExec() throws BasicException {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet moreResults() throws BasicException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.util.*;
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class NormalBuilder implements ISQLBuilderStatic {
|
||||
|
||||
public String sentence;
|
||||
|
||||
/** Creates a new instance of NormalBuilder
|
||||
* @param sSentence */
|
||||
public NormalBuilder(String sSentence) {
|
||||
sentence = sSentence;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param write
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public String getSQL(SerializerWrite write, Object params) throws BasicException {
|
||||
|
||||
NormalParameter normalParameter = new NormalParameter(sentence);
|
||||
if (write != null) {
|
||||
write.writeValues(normalParameter, params);
|
||||
}
|
||||
return normalParameter.getSentence();
|
||||
}
|
||||
private static class NormalParameter implements DataWrite {
|
||||
|
||||
private String m_sSentence;
|
||||
private ArrayList m_aParams; // of String
|
||||
|
||||
public NormalParameter(String sSentence) {
|
||||
m_sSentence = sSentence;
|
||||
m_aParams = new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(dValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(bValue));
|
||||
}
|
||||
@Override
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(iValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(sValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(dValue));
|
||||
}
|
||||
// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException{
|
||||
// throw new DataException("Param type not allowed");
|
||||
// }
|
||||
@Override
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.noparamtype"));
|
||||
}
|
||||
@Override
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
ensurePlace(paramIndex - 1);
|
||||
m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(value));
|
||||
}
|
||||
|
||||
private void ensurePlace(int i) {
|
||||
m_aParams.ensureCapacity(i);
|
||||
while (i >= m_aParams.size()){
|
||||
m_aParams.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSentence() {
|
||||
|
||||
StringBuilder sNewSentence = new StringBuilder();
|
||||
int iCount = 0;
|
||||
int iPos;
|
||||
int iLast = 0;
|
||||
while ((iPos = m_sSentence.indexOf('?', iLast)) > 0) {
|
||||
sNewSentence.append(m_sSentence.substring(iLast, iPos));
|
||||
if (iCount < m_aParams.size() && m_aParams.get(iCount) != null) {
|
||||
// el valor que viene
|
||||
sNewSentence.append(m_aParams.get(iCount));
|
||||
} else {
|
||||
// nulo
|
||||
sNewSentence.append(DataWriteUtils.getSQLValue((Object) null));
|
||||
}
|
||||
iCount++;
|
||||
iLast = iPos + 1;
|
||||
}
|
||||
sNewSentence.append(m_sSentence.substring(iLast));
|
||||
|
||||
return sNewSentence.toString(); // sustituida
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
@Slf4j
|
||||
public class PreparedSentence extends JDBCSentence {
|
||||
|
||||
|
||||
private String m_sentence;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected SerializerWrite m_SerWrite = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected SerializerRead m_SerRead = null;
|
||||
|
||||
// Estado
|
||||
private PreparedStatement m_Stmt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sentence
|
||||
* @param serwrite
|
||||
* @param serread
|
||||
*/
|
||||
public PreparedSentence(Session s, String sentence, SerializerWrite serwrite, SerializerRead serread) {
|
||||
super(s);
|
||||
m_sentence = sentence;
|
||||
m_SerWrite = serwrite;
|
||||
m_SerRead = serread;
|
||||
m_Stmt = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sentence
|
||||
* @param serwrite
|
||||
*/
|
||||
public PreparedSentence(Session s, String sentence, SerializerWrite serwrite) {
|
||||
this(s, sentence, serwrite, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sentence
|
||||
*/
|
||||
public PreparedSentence(Session s, String sentence) {
|
||||
this(s, sentence, null, null);
|
||||
}
|
||||
|
||||
private static final class PreparedSentencePars implements DataWrite {
|
||||
|
||||
private PreparedStatement m_ps;
|
||||
|
||||
/** Creates a new instance of SQLParameter */
|
||||
PreparedSentencePars(PreparedStatement ps) {
|
||||
m_ps = ps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
try {
|
||||
m_ps.setObject(paramIndex, iValue, Types.INTEGER);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
try {
|
||||
m_ps.setString(paramIndex, sValue);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
try {
|
||||
m_ps.setObject(paramIndex, dValue, Types.DOUBLE);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
try {
|
||||
if (bValue == null) {
|
||||
m_ps.setObject(paramIndex, null);
|
||||
} else {
|
||||
m_ps.setBoolean(paramIndex, bValue.booleanValue());
|
||||
}
|
||||
// m_ps.setObject(paramIndex, bValue, Types.BOOLEAN);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException {
|
||||
try {
|
||||
m_ps.setObject(paramIndex, dValue == null ? null : new Timestamp(dValue.getTime()), Types.TIMESTAMP);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException {
|
||||
// try {
|
||||
// m_ps.setBinaryStream(paramIndex, in, length);
|
||||
// } catch (SQLException eSQL) {
|
||||
// throw new DataException(eSQL);
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
try {
|
||||
m_ps.setBytes(paramIndex, value);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
try {
|
||||
m_ps.setObject(paramIndex, value);
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
// true -> un resultset
|
||||
// false -> un updatecount (si -1 entonces se acabo)
|
||||
|
||||
closeExec();
|
||||
|
||||
try {
|
||||
log.debug("Executing prepared SQL: {}", m_sentence);
|
||||
|
||||
m_Stmt = session.getConnection().prepareStatement(m_sentence);
|
||||
|
||||
if (m_SerWrite != null) {
|
||||
// si m_SerWrite fuera null deberiamos cascar.
|
||||
PreparedSentencePars preparedSentencePars = new PreparedSentencePars(m_Stmt);
|
||||
m_SerWrite.writeValues(preparedSentencePars, params);
|
||||
}
|
||||
|
||||
if (m_Stmt.execute()) {
|
||||
return new JDBCDataResultSet(m_Stmt.getResultSet(), m_SerRead);
|
||||
} else {
|
||||
int iUC = m_Stmt.getUpdateCount();
|
||||
if (iUC < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return new SentenceUpdateResultSet(iUC);
|
||||
}
|
||||
}
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final DataResultSet moreResults() throws BasicException {
|
||||
// true -> un resultset
|
||||
// false -> un updatecount (si -1 entonces se acabo)
|
||||
|
||||
try {
|
||||
if (m_Stmt.getMoreResults()){
|
||||
// tenemos resultset
|
||||
return new JDBCDataResultSet(m_Stmt.getResultSet(), m_SerRead);
|
||||
} else {
|
||||
// tenemos updatecount o si devuelve -1 ya no hay mas
|
||||
int iUC = m_Stmt.getUpdateCount();
|
||||
if (iUC < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return new SentenceUpdateResultSet(iUC);
|
||||
}
|
||||
}
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public final void closeExec() throws BasicException {
|
||||
|
||||
if (m_Stmt != null) {
|
||||
try {
|
||||
m_Stmt.close();
|
||||
} catch (SQLException eSQL) {
|
||||
throw new BasicException(eSQL);
|
||||
} finally {
|
||||
m_Stmt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class QBFBuilder implements ISQLBuilderStatic {
|
||||
|
||||
private final String m_sSentNullFilter; // la sentencia que se devuelve cuando el filtro es vacio
|
||||
private final String m_sSentBeginPart; // La sentencia que se devuelve es m_sSentBeginPart + ( filtro ) + m_sSentEndPart
|
||||
private final String m_sSentEndPart;
|
||||
|
||||
private final String[] m_asFindFields;
|
||||
|
||||
// /** Creates a new instance of QBFBuilder */
|
||||
// public QBFBuilder(TableDefinition tb, String[] asFindFields) {
|
||||
// StringBuilder sent = new StringBuilder();
|
||||
// sent.append("select ");
|
||||
// for (int i = 0; i < tb.getFields().length; i ++) {
|
||||
// if (i > 0) {
|
||||
// sent.append(", ");
|
||||
// }
|
||||
// sent.append(tb.getFields()[i]);
|
||||
// }
|
||||
// sent.append(" from ");
|
||||
// sent.append(tb.getTableName());
|
||||
// m_sSentNullFilter = sent.toString();
|
||||
// sent.append(" where ");
|
||||
// m_sSentBeginPart = sent.toString();
|
||||
// m_sSentEndPart = "";
|
||||
// m_asFindFields = asFindFields;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sSentence
|
||||
* @param asFindFields
|
||||
*/
|
||||
public QBFBuilder(String sSentence, String[] asFindFields) {
|
||||
int iPos = sSentence.indexOf("?(QBF_FILTER)");
|
||||
if (iPos < 0) {
|
||||
m_sSentBeginPart = sSentence;
|
||||
m_sSentEndPart = "";
|
||||
m_sSentNullFilter = sSentence;
|
||||
} else {
|
||||
m_sSentBeginPart = sSentence.substring(0, iPos);
|
||||
m_sSentEndPart = sSentence.substring(iPos + 13);
|
||||
m_sSentNullFilter = m_sSentBeginPart + "(1=1)" + m_sSentEndPart;
|
||||
}
|
||||
m_asFindFields = asFindFields;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sw
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public String getSQL(SerializerWrite sw, Object params) throws BasicException {
|
||||
|
||||
QBFParameter mydw = new QBFParameter(m_asFindFields);
|
||||
if (sw == null || params == null) {
|
||||
return m_sSentNullFilter;
|
||||
} else {
|
||||
sw.writeValues(mydw, params);
|
||||
String sFilter = mydw.getFilter();
|
||||
if (sFilter.length() == 0) {
|
||||
return m_sSentNullFilter; // no hay filtro
|
||||
} else {
|
||||
return m_sSentBeginPart + "(" + sFilter + ")" + m_sSentEndPart; // incluimos el filtro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class QBFParameter implements DataWrite {
|
||||
|
||||
private final String[] m_asFindFields;
|
||||
private final QBFCompareEnum[] m_aiCondFields;
|
||||
private final String[] m_aParams;
|
||||
|
||||
public QBFParameter(String[] asFindFields) {
|
||||
m_asFindFields = asFindFields;
|
||||
m_aiCondFields = new QBFCompareEnum[asFindFields.length];
|
||||
m_aParams = new String[asFindFields.length];
|
||||
|
||||
for( int i = 0; i < m_aParams.length; i++) {
|
||||
m_aParams[i] = DataWriteUtils.getSQLValue((Object) null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(dValue);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(bValue);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(iValue);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(sValue);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(dValue);
|
||||
}
|
||||
}
|
||||
// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException{
|
||||
// if ((paramIndex - 1) % 2 == 0) {
|
||||
// throw new DataException("Expected comparator for QBF");
|
||||
// } else {
|
||||
// throw new DataException("Param type not allowed");
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
} else {
|
||||
throw new BasicException("Param type not allowed");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
if ((paramIndex - 1) % 2 == 0) {
|
||||
if (value instanceof QBFCompareEnum) {
|
||||
m_aiCondFields[(paramIndex - 1) / 2] = (QBFCompareEnum) value;
|
||||
} else {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nocompare"));
|
||||
}
|
||||
} else {
|
||||
m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
// El retorno debe ser siempre una expresion valida puesto que no se donde sera insertada.
|
||||
|
||||
StringBuilder sFilter = new StringBuilder();
|
||||
|
||||
String sItem;
|
||||
for (int i = 0; i < m_asFindFields.length; i ++) {
|
||||
sItem = m_aiCondFields[i].getExpression(m_asFindFields[i], m_aParams[i]);
|
||||
if (sItem != null) {
|
||||
if (sFilter.length() > 0) {
|
||||
sFilter.append(" AND ");
|
||||
}
|
||||
sFilter.append(sItem);
|
||||
}
|
||||
}
|
||||
|
||||
return sFilter.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public abstract class QBFCompareEnum {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_NONE = new QBFCompareEnum(0, "qbf.none") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return null; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_ISNULL = new QBFCompareEnum(1, "qbf.null") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " IS NULL"; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_ISNOTNULL = new QBFCompareEnum(2, "qbf.notnull") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " IS NOT NULL"; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_RE = new QBFCompareEnum(3, "qbf.re") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " LIKE " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_EQUALS = new QBFCompareEnum(3, "qbf.equals") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " = " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_DISTINCT = new QBFCompareEnum(4, "qbf.distinct") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " <> " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_GREATER = new QBFCompareEnum(5, "qbf.greater") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " > " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_LESS = new QBFCompareEnum(6, "qbf.less") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " < " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_GREATEROREQUALS = new QBFCompareEnum(7, "qbf.greaterequals") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " >= " + sSQLValue; }
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final static QBFCompareEnum COMP_LESSOREQUALS = new QBFCompareEnum(8, "qbf.lessequals") {
|
||||
@Override
|
||||
public String getExpression(String sField, String sSQLValue) { return sField + " <= " + sSQLValue; }
|
||||
};
|
||||
// public final static QBFCompareEnum COMP_STARTSWITH = new QBFCompareEnum(9, "qbf.startswith") {
|
||||
// public String getExpression(String sField, String sSQLValue) { return sField + " LIKE " ... + sSQLValue; }
|
||||
// };
|
||||
// public final static int COMP_ENDSWITH = 12;
|
||||
// public final static int COMP_CONTAINS = 13;
|
||||
|
||||
private final int m_iValue;
|
||||
private final String m_sKey;
|
||||
|
||||
private QBFCompareEnum(int iValue, String sKey) {
|
||||
m_iValue = iValue;
|
||||
m_sKey = sKey;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getCompareInt() {
|
||||
return m_iValue;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return LocalRes.getIntString(m_sKey);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sField
|
||||
* @param sSQLValue
|
||||
* @return
|
||||
*/
|
||||
public abstract String getExpression(String sField, String sSQLValue);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.format.Formats;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class RenderStringBasic implements IRenderString {
|
||||
|
||||
private Formats[] m_aFormats;
|
||||
private int[] m_aiIndex;
|
||||
|
||||
/** Creates a new instance of StringnizerBasic
|
||||
* @param fmts
|
||||
* @param aiIndex */
|
||||
public RenderStringBasic(Formats[] fmts, int[] aiIndex) {
|
||||
m_aFormats = fmts;
|
||||
m_aiIndex = aiIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public String getRenderString(Object value) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
} else {
|
||||
Object [] avalue = (Object[]) value;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < m_aiIndex.length; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(" - ");
|
||||
}
|
||||
sb.append(m_aFormats[m_aiIndex[i]].formatValue(avalue[m_aiIndex[i]]));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SentenceEnum {
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void load() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void load(Object params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getCurrent() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public boolean next() throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SentenceExec {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int exec() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int exec(Object params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int exec(Object... params) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public abstract class SentenceExecAdapter implements SentenceExec {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int exec() throws BasicException {
|
||||
return exec((Object) null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int exec(Object... params) throws BasicException {
|
||||
return exec((Object) params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public abstract int exec(Object params) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
* Created on February 6, 2007, 4:06 PM
|
||||
*
|
||||
*/
|
||||
public abstract class SentenceExecTransaction implements SentenceExec {
|
||||
|
||||
private Session m_s;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
public SentenceExecTransaction(Session s) {
|
||||
m_s = s;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final int exec() throws BasicException {
|
||||
return exec((Object) null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final int exec(Object... params) throws BasicException {
|
||||
return exec((Object) params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public final int exec(final Object params) throws BasicException {
|
||||
|
||||
Transaction<Integer> t = new Transaction<Integer>(m_s) {
|
||||
public Integer transact() throws BasicException{
|
||||
return execInTransaction(params);
|
||||
}
|
||||
};
|
||||
|
||||
return t.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
protected abstract int execInTransaction(Object params) throws BasicException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SentenceFind {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object find() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object find(Object params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object find(Object... params) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SentenceList {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public List list() throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public List list(Object... params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public List list(Object params) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public List listPage(int offset, int length) throws BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @param offset
|
||||
* @param length
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public List listPage(Object params, int offset, int length) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class SentenceUpdateResultSet implements DataResultSet {
|
||||
|
||||
private int m_iUpdateCount;
|
||||
|
||||
/** Creates a new instance of UpdateResultSet
|
||||
* @param iUpdateCount */
|
||||
public SentenceUpdateResultSet(int iUpdateCount) {
|
||||
m_iUpdateCount = iUpdateCount;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Integer getInt(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public String getString(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Double getDouble(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Boolean getBoolean(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public java.util.Date getTimestamp(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
//public java.io.InputStream getBinaryStream(int columnIndex) throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public byte[] getBytes(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param columnIndex
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getObject(int columnIndex) throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
// public int getColumnCount() throws DataException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataField[] getDataField() throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object getCurrent() throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public boolean next() throws BasicException {
|
||||
throw new BasicException(LocalRes.getIntString("exception.nodataset"));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void close() throws BasicException {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public int updateCount() throws BasicException {
|
||||
return m_iUpdateCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SequenceForDerby extends BaseSentence {
|
||||
|
||||
private BaseSentence sent1;
|
||||
private BaseSentence sent2;
|
||||
|
||||
/** Creates a new instance of SequenceForMySQL
|
||||
* @param s
|
||||
* @param sSeqTable */
|
||||
public SequenceForDerby(Session s, String sSeqTable) {
|
||||
|
||||
sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = (SELECT ID FROM "+ sSeqTable +")+1 ");
|
||||
sent2 = new StaticSentence(s, "SELECT ID from PICKUP_NUMBER", null, SerializerReadInteger.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
// Funciones de bajo nivel
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
sent1.exec();
|
||||
return sent2.openExec(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public DataResultSet moreResults() throws BasicException {
|
||||
return sent2.moreResults();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void closeExec() throws BasicException {
|
||||
sent2.closeExec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SequenceForMySQL extends BaseSentence {
|
||||
|
||||
private BaseSentence sent1;
|
||||
private BaseSentence sent2;
|
||||
|
||||
/** Creates a new instance of SequenceForMySQL
|
||||
* @param s
|
||||
* @param sSeqTable */
|
||||
public SequenceForMySQL(Session s, String sSeqTable) {
|
||||
|
||||
sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = LAST_INSERT_ID(ID + 1)");
|
||||
sent2 = new StaticSentence(s, "SELECT LAST_INSERT_ID()", null, SerializerReadInteger.INSTANCE);
|
||||
}
|
||||
|
||||
// Funciones de bajo nivel
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
sent1.exec();
|
||||
return sent2.openExec(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet moreResults() throws BasicException {
|
||||
return sent2.moreResults();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void closeExec() throws BasicException {
|
||||
sent2.closeExec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
public class SequenceForSQLite extends BaseSentence {
|
||||
|
||||
private BaseSentence sent1;
|
||||
private BaseSentence sent2;
|
||||
|
||||
/** Creates a new instance of SequenceForMySQL
|
||||
* @param s
|
||||
* @param sSeqTable */
|
||||
public SequenceForSQLite(Session s, String sSeqTable) {
|
||||
|
||||
sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = last_insert_rowid()+1");
|
||||
sent2 = new StaticSentence(s, "SELECT last_insert_rowid()", null, SerializerReadInteger.INSTANCE);
|
||||
}
|
||||
|
||||
// Funciones de bajo nivel
|
||||
|
||||
/**
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet openExec(Object params) throws BasicException {
|
||||
sent1.exec();
|
||||
return sent2.openExec(null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public DataResultSet moreResults() throws BasicException {
|
||||
return sent2.moreResults();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void closeExec() throws BasicException {
|
||||
sent2.closeExec();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SerializableBuilder {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SerializableRead createNew();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SerializableRead {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void readValues(DataRead dr) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public interface SerializableWrite {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public interface SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadBasic implements SerializerRead {
|
||||
|
||||
private Datas[] m_classes;
|
||||
|
||||
/** Creates a new instance of SerializerReadBasic
|
||||
* @param classes */
|
||||
public SerializerReadBasic(Datas[] classes) {
|
||||
m_classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
|
||||
Object[] m_values = new Object[m_classes.length];
|
||||
for (int i = 0; i < m_classes.length; i++) {
|
||||
m_values[i] = m_classes[i].getValue(dr, i + 1);
|
||||
}
|
||||
return m_values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrian
|
||||
*/
|
||||
public class SerializerReadBuilder implements SerializerRead {
|
||||
|
||||
private SerializableBuilder m_sb;
|
||||
|
||||
/** Creates a new instance of SerializerReadBuilder
|
||||
* @param sb */
|
||||
public SerializerReadBuilder(SerializableBuilder sb) {
|
||||
m_sb = sb;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
SerializableRead sr = m_sb.createNew();
|
||||
sr.readValues(dr);
|
||||
return sr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian
|
||||
*/
|
||||
public class SerializerReadBytes implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadBytes();
|
||||
|
||||
/** Creates a new instance of SerializerReadBytes */
|
||||
private SerializerReadBytes() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.BYTES.getValue(dr,1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadClass implements SerializerRead {
|
||||
|
||||
private final Class m_clazz;
|
||||
|
||||
/** Creates a new instance of DefaultSerializerRead
|
||||
* @param clazz */
|
||||
public SerializerReadClass(Class clazz) {
|
||||
m_clazz = clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
try {
|
||||
SerializableRead sr = (SerializableRead) m_clazz.newInstance();
|
||||
sr.readValues(dr);
|
||||
return sr;
|
||||
// JG 16 May 12 use multicatch
|
||||
} catch (java.lang.InstantiationException | IllegalAccessException | ClassCastException eIns) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author James Bolongan
|
||||
*/
|
||||
|
||||
public class SerializerReadDate implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadDate();
|
||||
|
||||
/** Creates a new instance of SerializerReadImage */
|
||||
private SerializerReadDate() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.TIMESTAMP.getValue(dr, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadDouble implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadDouble();
|
||||
|
||||
/** Creates a new instance of SerializerReadInteger */
|
||||
public SerializerReadDouble() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.DOUBLE.getValue(dr,1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadImage implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadImage();
|
||||
|
||||
/** Creates a new instance of SerializerReadImage */
|
||||
private SerializerReadImage() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.IMAGE.getValue(dr,1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadInteger implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadInteger();
|
||||
|
||||
/** Creates a new instance of SerializerReadInteger */
|
||||
private SerializerReadInteger() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.INT.getValue(dr,1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadString implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadString();
|
||||
|
||||
/** Creates a new instance of SerializerReadImage */
|
||||
private SerializerReadString() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return Datas.STRING.getValue(dr,1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerReadUTF8 implements SerializerRead {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerRead INSTANCE = new SerializerReadUTF8();
|
||||
|
||||
/** Creates a new instance of SerializerReadImage */
|
||||
private SerializerReadUTF8() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dr
|
||||
* @return
|
||||
* @throws BasicException
|
||||
*/
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
try {
|
||||
return new String((byte[]) Datas.BYTES.getValue(dr,1), "UTF-8");
|
||||
} catch (java.io.UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
* @param <T>
|
||||
*/
|
||||
public interface SerializerWrite<T> {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, T obj) throws BasicException;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteBasic implements SerializerWrite<Object[]> {
|
||||
|
||||
private Datas[] m_classes;
|
||||
|
||||
/** Creates a new instance of SerializerWriteBasic
|
||||
* @param classes */
|
||||
public SerializerWriteBasic(Datas... classes) {
|
||||
m_classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void writeValues(DataWrite dp, Object[] obj) throws BasicException {
|
||||
|
||||
for (int i = 0; i < m_classes.length; i++) {
|
||||
m_classes[i].setValue(dp, i + 1, obj[i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteBasicComposed implements SerializerWrite<Object[]> {
|
||||
|
||||
private Datas[][] m_classes;
|
||||
|
||||
/** Creates a new instance of SerializerWriteComposed
|
||||
* @param classes */
|
||||
public SerializerWriteBasicComposed(Datas[]... classes) {
|
||||
m_classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, Object[] obj) throws BasicException {
|
||||
|
||||
int index = 0;
|
||||
for (int i = 0; i < m_classes.length; i++) {
|
||||
Object[] val = (Object[]) obj[i];
|
||||
for (int j = 0; j < m_classes[i].length; j++) {
|
||||
index++;
|
||||
m_classes[i][j].setValue(dp, index, val[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteBasicExt implements SerializerWrite<Object[]> {
|
||||
|
||||
private Datas[] m_classes;
|
||||
private int[] m_index;
|
||||
|
||||
/** Creates a new instance of SerializerWriteBasic
|
||||
* @param classes
|
||||
* @param index */
|
||||
public SerializerWriteBasicExt(Datas[] classes, int[] index) {
|
||||
m_classes = classes;
|
||||
m_index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void writeValues(DataWrite dp, Object[] obj) throws BasicException {
|
||||
|
||||
for (int i = 0; i < m_index.length; i++) {
|
||||
m_classes[m_index[i]].setValue(dp, i + 1, obj[m_index[i]]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteBuilder implements SerializerWrite<SerializableWrite> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerWrite INSTANCE = new SerializerWriteBuilder();
|
||||
|
||||
/** Creates a new instance of SerializerWriteBuilder */
|
||||
private SerializerWriteBuilder() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, SerializableWrite obj) throws BasicException {
|
||||
obj.writeValues(dp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteComposed implements SerializerWrite {
|
||||
|
||||
private List<SerializerWrite> serwrites = new ArrayList<SerializerWrite>();
|
||||
|
||||
/** Creates a new instance of SerializerWriteComposed */
|
||||
public SerializerWriteComposed() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sw
|
||||
*/
|
||||
public void add(SerializerWrite sw) {
|
||||
serwrites.add(sw);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, Object obj) throws BasicException {
|
||||
|
||||
Object[] a = (Object[]) obj;
|
||||
DataWriteComposed dpc = new DataWriteComposed(dp);
|
||||
|
||||
int i = 0;
|
||||
for (SerializerWrite sw : serwrites) {
|
||||
dpc.next();
|
||||
sw.writeValues(dpc, a[i++]);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DataWriteComposed implements DataWrite {
|
||||
|
||||
private DataWrite dp;
|
||||
private int offset = 0;
|
||||
private int max = 0;
|
||||
|
||||
public DataWriteComposed(DataWrite dp) {
|
||||
this.dp = dp;
|
||||
}
|
||||
|
||||
public void next() {
|
||||
offset = max;
|
||||
}
|
||||
|
||||
public void setInt(int paramIndex, Integer iValue) throws BasicException {
|
||||
dp.setInt(offset + paramIndex, iValue);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setString(int paramIndex, String sValue) throws BasicException {
|
||||
dp.setString(offset + paramIndex, sValue);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setDouble(int paramIndex, Double dValue) throws BasicException {
|
||||
dp.setDouble(offset + paramIndex, dValue);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setBoolean(int paramIndex, Boolean bValue) throws BasicException {
|
||||
dp.setBoolean(offset + paramIndex, bValue);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setTimestamp(int paramIndex, Date dValue) throws BasicException {
|
||||
dp.setTimestamp(offset + paramIndex, dValue);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setBytes(int paramIndex, byte[] value) throws BasicException {
|
||||
dp.setBytes(offset + paramIndex, value);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
|
||||
public void setObject(int paramIndex, Object value) throws BasicException {
|
||||
dp.setObject(offset + paramIndex, value);
|
||||
max = Math.max(max, offset + paramIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteInteger implements SerializerWrite<Integer> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerWrite INSTANCE = new SerializerWriteInteger();
|
||||
|
||||
/** Creates a new instance of SerializerWriteInteger */
|
||||
private SerializerWriteInteger() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, Integer obj) throws BasicException {
|
||||
Datas.INT.setValue(dp, 1, obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class SerializerWriteParams implements SerializerWrite<DataParams>{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerWrite INSTANCE = new SerializerWriteParams();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
@Override
|
||||
public void writeValues(DataWrite dp, DataParams obj) throws BasicException {
|
||||
obj.setDataWrite(dp);
|
||||
obj.writeValues();
|
||||
obj.setDataWrite(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JG uniCenta
|
||||
*/
|
||||
public class SerializerWriteString implements SerializerWrite<Object> {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final SerializerWrite INSTANCE = new SerializerWriteString();
|
||||
|
||||
/** Creates a new instance of SerializerWriteString */
|
||||
private SerializerWriteString() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dp
|
||||
* @param obj
|
||||
* @throws BasicException
|
||||
*/
|
||||
public void writeValues(DataWrite dp, Object obj) throws BasicException {
|
||||
if (obj instanceof Object[]){
|
||||
for (int i = 0 ; i < ((Object[]) obj).length ; i++) {
|
||||
Datas.STRING.setValue(dp, i+1, ((Object[]) obj)[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Datas.STRING.setValue(dp, 1, obj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright © 2009-2020 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
* Created on February 6, 2007, 4:06 PM
|
||||
*
|
||||
*/
|
||||
public final class Session {
|
||||
|
||||
private final String m_surl;
|
||||
private final String m_sappuser;
|
||||
private final String m_spassword;
|
||||
|
||||
private Connection m_c;
|
||||
private boolean m_bInTransaction;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final SessionDB DB;
|
||||
|
||||
/** Creates a new instance of Session
|
||||
* @param url
|
||||
* @param user
|
||||
* @param password
|
||||
* @throws java.sql.SQLException */
|
||||
public Session(String url, String user, String password) throws SQLException {
|
||||
m_surl = url;
|
||||
m_sappuser = user;
|
||||
m_spassword = password;
|
||||
|
||||
m_c = null;
|
||||
m_bInTransaction = false;
|
||||
|
||||
connect(); // no lazy connection
|
||||
|
||||
DB = getDiff();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void connect() throws SQLException {
|
||||
|
||||
// primero cerramos si no estabamos cerrados
|
||||
close();
|
||||
|
||||
// creamos una nueva conexion.
|
||||
m_c = (m_sappuser == null && m_spassword == null)
|
||||
? DriverManager.getConnection(m_surl)
|
||||
: DriverManager.getConnection(m_surl, m_sappuser, m_spassword);
|
||||
m_c.setAutoCommit(true);
|
||||
m_bInTransaction = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void close() {
|
||||
|
||||
if (m_c != null) {
|
||||
try {
|
||||
if (m_bInTransaction) {
|
||||
m_bInTransaction = false; // lo primero salimos del estado
|
||||
m_c.rollback();
|
||||
m_c.setAutoCommit(true);
|
||||
}
|
||||
m_c.close();
|
||||
} catch (SQLException e) {
|
||||
// me la como
|
||||
} finally {
|
||||
m_c = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
|
||||
if (!m_bInTransaction) {
|
||||
ensureConnection();
|
||||
}
|
||||
return m_c;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void begin() throws SQLException {
|
||||
|
||||
if (m_bInTransaction) {
|
||||
throw new SQLException("Already in transaction");
|
||||
} else {
|
||||
ensureConnection();
|
||||
m_c.setAutoCommit(false);
|
||||
m_bInTransaction = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void commit() throws SQLException {
|
||||
if (m_bInTransaction) {
|
||||
m_bInTransaction = false; // lo primero salimos del estado
|
||||
m_c.commit();
|
||||
m_c.setAutoCommit(true);
|
||||
} else {
|
||||
throw new SQLException("Transaction not started");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void rollback() throws SQLException {
|
||||
if (m_bInTransaction) {
|
||||
m_bInTransaction = false; // lo primero salimos del estado
|
||||
m_c.rollback();
|
||||
m_c.setAutoCommit(true);
|
||||
} else {
|
||||
throw new SQLException("Transaction not started");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isTransaction() {
|
||||
return m_bInTransaction;
|
||||
}
|
||||
|
||||
private void ensureConnection() throws SQLException {
|
||||
// solo se invoca si isTransaction == false
|
||||
|
||||
boolean bclosed;
|
||||
try {
|
||||
bclosed = m_c == null || m_c.isClosed();
|
||||
} catch (SQLException e) {
|
||||
bclosed = true;
|
||||
}
|
||||
|
||||
// reconnect if closed
|
||||
if (bclosed) {
|
||||
connect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public String getURL() throws SQLException {
|
||||
return getConnection().getMetaData().getURL();
|
||||
}
|
||||
|
||||
private SessionDB getDiff() throws SQLException {
|
||||
|
||||
String sdbmanager = getConnection().getMetaData().getDatabaseProductName();
|
||||
switch (sdbmanager) {
|
||||
case "SQLite":
|
||||
return new SessionDBSQLite();
|
||||
case "MariaDB":
|
||||
return new SessionDBMariaDB();
|
||||
case "HSQL Database Engine":
|
||||
return new SessionDBHSQLDB();
|
||||
case "MySQL":
|
||||
return new SessionDBMySQL();
|
||||
case "PostgreSQL":
|
||||
return new SessionDBPostgreSQL();
|
||||
case "Oracle":
|
||||
return new SessionDBOracle();
|
||||
case "Apache Derby":
|
||||
return new SessionDBDerby();
|
||||
default:
|
||||
return new SessionDBGeneric(sdbmanager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public interface SessionDB {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String TRUE();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String FALSE();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String INTEGER_NULL();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String CHAR_NULL();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
public SentenceFind getSequenceSentence(Session s, String sequence);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
public SentenceFind resetSequenceSentence(Session s, String sequence);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// 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.unicenta.data.loader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author adrianromero
|
||||
*/
|
||||
public class SessionDBDerby implements SessionDB {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String TRUE() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String FALSE() {
|
||||
return "0";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String INTEGER_NULL() {
|
||||
return "CAST(NULL AS INTEGER)";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String CHAR_NULL() {
|
||||
return "CAST(NULL AS CHAR)";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Derby";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SentenceFind getSequenceSentence(Session s, String sequence) {
|
||||
return new SequenceForDerby(s, sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param s
|
||||
* @param sequence
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public SentenceFind resetSequenceSentence(Session s, String sequence) {
|
||||
return new SequenceForDerby(s, sequence);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user