diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4e73779
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.idea/
+target/
+.vscode/
+*.iml
+nb-configuration.xml
+nbactions.xml
+*.log
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..054ec78
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,588 @@
+
+
+ 4.0.0
+
+ com.unicenta
+ unicentaopos
+ 5.0
+ jar
+
+ UTF-8
+ 11
+ 11
+
+
+
+
+ org.xerial
+ sqlite-jdbc
+ 3.7.2
+
+
+
+ org.openjfx
+ javafx-base
+ 11
+
+
+ org.openjfx
+ javafx-controls
+ 11
+
+
+ org.openjfx
+ javafx-fxml
+ 11
+
+
+ org.openjfx
+ javafx-graphics
+ 11
+
+
+ org.openjfx
+ javafx-media
+ 11
+
+
+ org.openjfx
+ javafx-swing
+ 11
+
+
+ org.openjfx
+ javafx-web
+ 11
+
+
+ org.mariadb.jdbc
+ mariadb-java-client
+ 2.7.0
+
+
+ org.projectlombok
+ lombok
+ 1.18.6
+ provided
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.2
+
+
+ org.jfree
+ jcommon
+ 1.0.24
+
+
+ org.jfree
+ jfreechart
+ 1.0.19
+
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.3
+
+
+ commons-digester
+ commons-digester
+ 2.1
+
+
+ com.lowagie
+ itext
+ 2.1.7
+
+
+ org.apache.poi
+ poi
+ 3.10.1
+
+
+ net.sf.barcode4j
+ barcode4j
+ 2.1
+
+
+ commons-codec
+ commons-codec
+ 1.10
+
+
+ org.apache.velocity
+ velocity
+ 1.7
+
+
+ oro
+ oro
+ 2.0.8
+
+
+ commons-collections
+ commons-collections
+ 3.2.2
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ org.beanshell
+ bsh
+ 2.0b4
+
+
+ org.bidib.jbidib.org.qbang.rxtx
+ rxtxcomm
+ 2.2
+
+
+ org.jpos
+ jpos
+ 2.0.10
+
+
+ org.slf4j
+ slf4j-nop
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
+
+ org.swinglabs.swingx
+ swingx-all
+ 1.6.5-1
+
+
+ axis
+ axis
+ 1.4
+
+
+ org.apache.axis
+ axis-jaxrpc
+ 1.4
+
+
+ javax.xml.soap
+ saaj-api
+ 1.3.5
+
+
+ axis
+ axis-wsdl4j
+ 1.5.1
+
+
+ commons-discovery
+ commons-discovery
+ 0.5
+
+
+
+ org.swinglabs
+ swing-layout
+ 1.0.3
+
+
+ net.sourceforge.javacsv
+ javacsv
+ 2.0
+
+
+ org.netbeans.external
+ AbsoluteLayout
+ RELEASE82
+
+
+ com.javapos
+ jpos
+ 1.13
+
+
+ mysql
+ mysql-connector-java
+ 5.1.39
+
+
+ org.apache.derby
+ derby
+ 10.14.2.0
+
+
+ xml-apis
+ xml-apis
+ 1.0.b2
+
+
+
+
+ org.apache.xmlgraphics
+ fop
+ 2.1
+
+
+ net.sf.jasperreports
+ jasperreports
+ 6.4.0
+
+
+ com.lowagie
+ itext
+
+
+
+
+ net.sf.jasperreports
+ jasperreports-fonts
+ 6.0.0
+
+
+ ar.com.fdvs
+ DynamicJasper-core-fonts
+ 2.0
+
+
+
+ org.eclipse.jdt.core.compiler
+ ecj
+ 4.6.1
+
+
+
+ joda-time
+ joda-time
+ 2.9.7
+
+
+
+
+ com.formdev
+ flatlaf-intellij-themes
+ 2.0.1
+
+
+
+ com.formdev
+ flatlaf
+ 1.6.5
+
+
+
+ com.formdev
+ flatlaf-swingx
+ 1.6.5
+
+
+ org.reflections
+ reflections
+ 0.9.12
+
+
+
+ de.sciss
+ weblaf
+ 1.2.9
+
+
+ org.slf4j
+ slf4j-nop
+
+
+ org.slf4j
+ slf4j-api
+
+
+ org.slf4j
+ slf4j-simple
+
+
+
+
+ com.unicenta
+ unicenta-plugins
+ 1.1
+
+
+ uk.co.pos_apps
+ openbravo
+ 1.0-SNAPSHOT
+
+
+ com.gluonhq
+ charm-glisten
+ 6.2.2
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.0
+
+
+ javax.persistence
+ persistence-api
+ 1.0.2
+
+
+ com.dalsemi.onewire
+ OneWireAPI
+ 0.1
+
+
+
+ org.usb4java
+ usb4java
+ 1.2.0
+
+
+ javax.usb
+ usb-api
+ 1.0.2
+
+
+ org.jdatepicker
+ jdatepicker
+ 1.3.4
+
+
+
+ com.sleepycat
+ je
+ 5.0.73
+
+
+ org.pushingpixels
+ trident
+ 1.4
+
+
+ org.pushingpixels
+ substance
+ 7.1.00
+
+
+
+ org.postgresql
+ postgresql
+ 9.4.1208
+
+
+ de.sciss
+ weblaf-ui
+ 2.1.3
+ jar
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.mockito
+ mockito-inline
+ 4.2.0
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 4.2.0
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 2.10
+
+
+ copy-dependencies
+ prepare-package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/lib
+ false
+ false
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ true
+ lib/
+ com.unicenta.pos.forms.StartPOS
+
+
+ unicenta-pos
+ ${project.version}
+ com.unicenta
+ unicenta.com
+
+
+
+
+
+ maven-resources-plugin
+ 2.7
+
+
+ copy-resources
+ validate
+
+ copy-resources
+
+
+ ${project.build.directory}
+
+
+ ${basedir}/target/lib/Windows
+ ${basedir}/src/other/Windows
+ false
+
+
+ ${basedir}/target/lib/Linux
+ ${basedir}/src/other/Linux
+ false
+
+
+ ${basedir}/target/lib/Mac_OS_X
+ ${basedir}/src/other/Mac_OS_X
+ false
+
+
+ ${basedir}/target/
+ ${basedir}/src/scripts
+ false
+
+
+ ${basedir}/target/Bonus
+ ${basedir}/src/other/Bonus
+ false
+
+
+ ${basedir}/target/Configs
+ ${basedir}/src/other/Configs
+ false
+
+
+ ${basedir}/target/Templates
+ ${basedir}/src/other/Templates
+ false
+
+
+ ${basedir}/target
+ ${basedir}/src/other/images
+ false
+
+
+ ${basedir}/target
+ ${basedir}/src/other/license
+ false
+
+
+ ${basedir}/target/reports/com
+ ${basedir}/src/main/resources/com
+ false
+
+
+ ${basedir}/target/locales
+ ${basedir}/src/main/resources
+ false
+
+ com/**
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+ true
+ true
+
+
+
+
+
+ org.apache.maven.wagon
+ wagon-ftp
+ 2.10
+
+
+ unicentaopos
+
+
+
+ charm-glisten
+ charm-glisten Repository
+ https://nexus.gluonhq.com/nexus/content/repositories/releases/
+ default
+
+
+ unicenta-repo
+ https://repo.unicenta.org/maven2/
+ default
+
+
+ central
+ https://repo1.maven.org/maven2/
+ default
+
+
+
+ netbeans
+ NetBeans
+ https://netbeans.apidesign.org/maven2/
+
+
+
+ flatlaf
+ flatlaf
+ https://dev.webswing.org/public/nexus/repository/webswing-3rd-parties//
+
+
+
+
+ unicenta-repo
+ ftp://repo.unicenta.org/
+ false
+
+
+ unicenta-opos
+
diff --git a/src/main/java/com/unicenta/basic/BasicException.java b/src/main/java/com/unicenta/basic/BasicException.java
new file mode 100644
index 0000000..fed648f
--- /dev/null
+++ b/src/main/java/com/unicenta/basic/BasicException.java
@@ -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 .
+
+package com.unicenta.basic;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class BasicException extends java.lang.Exception {
+
+ /**
+ * Creates a new instance of DataException without detail message.
+ */
+ public BasicException() {
+ }
+
+ /**
+ *
+ * @param msg
+ */
+ public BasicException(String msg) {
+ super(msg);
+ }
+
+ /**
+ *
+ * @param msg
+ * @param cause
+ */
+ public BasicException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+
+ /**
+ *
+ * @param cause
+ */
+ public BasicException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/main/java/com/unicenta/beans/DateUtils.java b/src/main/java/com/unicenta/beans/DateUtils.java
new file mode 100644
index 0000000..c412f5d
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/DateUtils.java
@@ -0,0 +1,121 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class DateUtils {
+
+ /** Creates a new instance of DateUtils */
+ private DateUtils() {
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static Date getToday() {
+ // el dia de hoy sin horas ni nada.
+ return getToday(new Date());
+ }
+
+ /**
+ *
+ * @param d
+ * @return
+ */
+ public static Date getToday(Date d) {
+ // el dia de hoy sin horas ni nada.
+ GregorianCalendar ddate = new GregorianCalendar();
+ ddate.setTime(d);
+ GregorianCalendar ddateday = new GregorianCalendar(ddate.get(GregorianCalendar.YEAR), ddate.get(GregorianCalendar.MONTH), ddate.get(GregorianCalendar.DAY_OF_MONTH));
+ return ddateday.getTime();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static Date getTodayMinutes() {
+ // el dia de hoy sin horas ni nada.
+ return getTodayMinutes(new Date());
+ }
+
+ /**
+ *
+ * @param d
+ * @return
+ */
+ public static Date getTodayMinutes(Date d) {
+ // el dia de hoy sin horas ni nada.
+ GregorianCalendar ddate = new GregorianCalendar();
+ ddate.setTime(d);
+ GregorianCalendar ddateday = new GregorianCalendar(ddate.get(GregorianCalendar.YEAR), ddate.get(GregorianCalendar.MONTH), ddate.get(GregorianCalendar.DAY_OF_MONTH)
+ , ddate.get(GregorianCalendar.HOUR_OF_DAY), ddate.get(GregorianCalendar.MINUTE));
+ return ddateday.getTime();
+ }
+
+ /**
+ *
+ * @param d
+ * @return
+ */
+ public static Date getTodayHours(Date d) {
+ // el dia ajustado a las horeas
+ Calendar ddate = Calendar.getInstance();
+ ddate.setTime(d);
+
+ Calendar dNow = Calendar.getInstance();
+ dNow.clear();
+ dNow.set(ddate.get(Calendar.YEAR), ddate.get(Calendar.MONTH), ddate.get(Calendar.DAY_OF_MONTH)
+ , ddate.get(Calendar.HOUR_OF_DAY), 0, 0);
+
+ return dNow.getTime();
+ }
+
+ /**
+ *
+ * @param day
+ * @param hour
+ * @return
+ */
+ public static Date getDate(Date day, Date hour) {
+
+ // Calculamos el dia actual con la hora escogida.
+ Calendar dDay = Calendar.getInstance();
+ dDay.setTime(day);
+ Calendar dHour = Calendar.getInstance();
+ dHour.setTime(hour);
+
+ Calendar dNow = Calendar.getInstance();
+ dNow.clear();
+ dNow.set(dDay.get(Calendar.YEAR), dDay.get(Calendar.MONTH), dDay.get(Calendar.DAY_OF_MONTH)
+ , dHour.get(Calendar.HOUR_OF_DAY), dHour.get(Calendar.MINUTE), dHour.get(Calendar.SECOND));
+
+ return dNow.getTime();
+ }
+
+}
diff --git a/src/main/java/com/unicenta/beans/JCalendarDialog.form b/src/main/java/com/unicenta/beans/JCalendarDialog.form
new file mode 100644
index 0000000..83063f6
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JCalendarDialog.form
@@ -0,0 +1,118 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JCalendarDialog.java b/src/main/java/com/unicenta/beans/JCalendarDialog.java
new file mode 100644
index 0000000..e170d87
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JCalendarDialog.java
@@ -0,0 +1,274 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.swing.*;
+import java.util.*;
+
+/**
+ *
+ * @author Adrian
+ */
+public class JCalendarDialog extends javax.swing.JDialog {
+
+ // private static ResourceBundle m_Intl;
+ private static LocaleResources m_resources;
+
+ private Date m_date;
+ private JCalendarPanel myCalendar = null;
+ private JTimePanel myTime = null;
+
+ /** Creates new form JCalendarDialog
+ * @param parent
+ * @param modal */
+ public JCalendarDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ } else {
+ }
+ }
+ /** Creates new form JCalendarDialog
+ * @param parent
+ * @param modal */
+ public JCalendarDialog(java.awt.Dialog parent, boolean modal) {
+ super(parent, modal);
+
+ if (m_resources != null) {
+ } else {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+ }
+
+ 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 date
+ * @return
+ */
+ public static Date showCalendarTimeHours(Component parent, Date date) {
+ return internalCalendarTime(parent, date == null ? DateUtils.getToday() : date, true);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param date
+ * @return
+ */
+ public static Date showCalendarTime(Component parent, Date date) {
+ return internalCalendarTime(parent, date == null ? DateUtils.getTodayMinutes() : date, true);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param date
+ * @return
+ */
+ public static Date showCalendar(Component parent, Date date) {
+ return internalCalendarTime(parent, date == null ? DateUtils.getTodayMinutes() : date, false);
+ }
+
+ private static Date internalCalendarTime(Component parent, Date date, boolean bTimePanel) {
+
+ Window window = getWindow(parent);
+
+ JCalendarDialog myMsg;
+ if (window instanceof Frame) {
+ myMsg = new JCalendarDialog((Frame) window, true);
+ } else {
+ myMsg = new JCalendarDialog((Dialog) window, true);
+ }
+
+ myMsg.initComponents();
+
+ Date d = date;
+ int dialogwidth = 400;
+
+ myMsg.myCalendar = new JCalendarPanel(d);
+ myMsg.myCalendar.addPropertyChangeListener("Date", new JPanelCalendarChange(myMsg));
+ myMsg.jPanelGrid.add(myMsg.myCalendar);
+
+ if (bTimePanel) {
+ myMsg.myTime = new JTimePanel(d);
+ myMsg.myTime.addPropertyChangeListener("Date", new JPanelTimeChange(myMsg));
+ myMsg.jPanelGrid.add(myMsg.myTime);
+ dialogwidth += 400;
+ }
+
+ myMsg.getRootPane().setDefaultButton(myMsg.jcmdOK);
+
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ myMsg.setBounds((screenSize.width - dialogwidth) / 2, (screenSize.height - 359) / 2, dialogwidth, 359);
+
+ //myMsg.show();
+ myMsg.m_date = null;
+ myMsg.setVisible(true);
+ return myMsg.m_date;
+ }
+
+ private static class JPanelTimeChange implements PropertyChangeListener {
+ private final JCalendarDialog m_me;
+ public JPanelTimeChange(JCalendarDialog me) {
+ m_me = me;
+ }
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ m_me.myCalendar.setDate(m_me.myTime.getDate());
+ }
+ }
+
+ private static class JPanelCalendarChange implements PropertyChangeListener {
+ private final JCalendarDialog m_me;
+ public JPanelCalendarChange(JCalendarDialog me) {
+ m_me = me;
+ }
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ m_me.myTime.setDate(m_me.myCalendar.getDate());
+ }
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jcmdOK = new javax.swing.JButton();
+ jcmdCancel = new javax.swing.JButton();
+ jPanel2 = new javax.swing.JPanel();
+ jPanelGrid = new javax.swing.JPanel();
+
+ setTitle(m_resources.getString("title.calendar")); // NOI18N
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ closeWindow(evt);
+ }
+ });
+
+ jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
+
+ 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(m_resources.getString("button.ok")); // NOI18N
+ jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdOK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdOKActionPerformed(evt);
+ }
+ });
+ jPanel1.add(jcmdOK);
+
+ 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(m_resources.getString("button.cancel")); // NOI18N
+ jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdCancelActionPerformed(evt);
+ }
+ });
+ jPanel1.add(jcmdCancel);
+
+ getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jPanelGrid.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
+ jPanelGrid.setLayout(new java.awt.GridLayout(1, 0, 5, 0));
+ jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
+ }// //GEN-END:initComponents
+
+ private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
+
+ GregorianCalendar dateresult;
+
+ GregorianCalendar date1 = new GregorianCalendar();
+ date1.setTime(myCalendar.getDate());
+
+ if (myTime == null) {
+ dateresult = new GregorianCalendar(
+ date1.get(GregorianCalendar.YEAR),
+ date1.get(GregorianCalendar.MONTH),
+ date1.get(GregorianCalendar.DAY_OF_MONTH));
+
+ } else {
+ GregorianCalendar date2 = new GregorianCalendar();
+ date2.setTime(myTime.getDate());
+ dateresult = new GregorianCalendar(
+ date1.get(GregorianCalendar.YEAR),
+ date1.get(GregorianCalendar.MONTH),
+ date1.get(GregorianCalendar.DAY_OF_MONTH),
+ date2.get(GregorianCalendar.HOUR_OF_DAY),
+ date2.get(GregorianCalendar.MINUTE));
+ }
+
+ m_date = dateresult.getTime();
+
+ setVisible(false);
+ dispose();
+ }//GEN-LAST:event_jcmdOKActionPerformed
+
+ private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
+
+ setVisible(false);
+ dispose();
+ }//GEN-LAST:event_jcmdCancelActionPerformed
+
+ private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow
+
+ setVisible(false);
+ dispose();
+ }//GEN-LAST:event_closeWindow
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanelGrid;
+ private javax.swing.JButton jcmdCancel;
+ private javax.swing.JButton jcmdOK;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JCalendarPanel.form b/src/main/java/com/unicenta/beans/JCalendarPanel.form
new file mode 100644
index 0000000..9aceef4
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JCalendarPanel.form
@@ -0,0 +1,134 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JCalendarPanel.java b/src/main/java/com/unicenta/beans/JCalendarPanel.java
new file mode 100644
index 0000000..e8bb895
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JCalendarPanel.java
@@ -0,0 +1,376 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.border.LineBorder;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class JCalendarPanel extends javax.swing.JPanel {
+
+ // private static ResourceBundle m_Intl;
+ private static LocaleResources m_resources;
+
+ private static GregorianCalendar m_CalendarHelper = new GregorianCalendar(); // solo de ayuda
+
+ private Date m_date;
+ private JButtonDate[] m_ListDates;
+ private JLabel[] m_jDays;
+
+ private JButtonDate m_jCurrent;
+ private JButtonDate m_jBtnMonthInc;
+ private JButtonDate m_jBtnMonthDec;
+ private JButtonDate m_jBtnYearInc;
+ private JButtonDate m_jBtnYearDec;
+ private JButtonDate m_jBtnToday;
+
+ private DateFormat fmtMonthYear = new SimpleDateFormat("MMMMM yyyy");
+
+ /** Creates new form JCalendarPanel2 */
+ public JCalendarPanel() {
+ this(new Date());
+ }
+
+ /**
+ *
+ * @param dDate
+ */
+ public JCalendarPanel(Date dDate) {
+
+ super();
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+
+ initComponents();
+ initComponents2();
+
+// m_CalendarHelper = new GregorianCalendar();
+// m_CalendarHelper.setTime(dDate);
+ m_date = dDate;
+
+ // pintamos
+ renderMonth();
+ renderDay();
+ }
+
+ /**
+ *
+ * @param dNewDate
+ */
+ public void setDate(Date dNewDate) {
+
+ // cambiamos la fecha
+ Date dOldDate = m_date;
+ m_date = dNewDate;
+
+ // pintamos
+ renderMonth();
+ renderDay();
+
+ // decimos al mundo que ha cambiado la propiedad fecha
+ firePropertyChange("Date", dOldDate, dNewDate);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Date getDate() {
+ return m_date;
+ }
+
+ public void setEnabled(boolean bValue) {
+
+ super.setEnabled(bValue);
+
+ // pintamos
+ renderMonth();
+ renderDay();
+ }
+
+ private void renderMonth() {
+
+// GregorianCalendar oCalRender = new GregorianCalendar();
+// oCalRender.setTime(m_CalendarHelper.getTime());
+
+ for (int j = 0; j < 7; j++) {
+ m_jDays[j].setEnabled(isEnabled());
+ }
+
+ // Borramos todos los dias
+ for(int i = 0; i < 42; i++) {
+ JButtonDate jAux = m_ListDates[i];
+ jAux.DateInf = null;
+ jAux.setEnabled(false);
+ jAux.setText(null);
+ jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground"));
+ jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.background"));
+ jAux.setBorder(null);
+ }
+
+ if (m_date == null) {
+ m_jLblMonth.setEnabled(isEnabled());
+ m_jLblMonth.setText(null);
+ } else {
+ m_CalendarHelper.setTime(m_date);
+
+ m_jLblMonth.setEnabled(isEnabled());
+ m_jLblMonth.setText(fmtMonthYear.format(m_CalendarHelper.getTime()));
+
+ int iCurrentMonth = m_CalendarHelper.get(Calendar.MONTH);
+ m_CalendarHelper.set(Calendar.DAY_OF_MONTH, 1);
+
+ while(m_CalendarHelper.get(Calendar.MONTH) == iCurrentMonth) {
+
+ JButtonDate jAux = getLabelByDate(m_CalendarHelper.getTime());
+ jAux.DateInf = m_CalendarHelper.getTime();
+ jAux.setEnabled(isEnabled());
+ jAux.setText(String.valueOf(m_CalendarHelper.get(Calendar.DAY_OF_MONTH)));
+
+ m_CalendarHelper.add(Calendar.DATE, 1);
+ }
+ }
+
+ m_jCurrent = null;
+ }
+
+ private void renderDay() {
+
+ m_jBtnToday.setEnabled(isEnabled());
+
+ if (m_date == null) {
+ m_jBtnMonthDec.setEnabled(false);
+ m_jBtnMonthInc.setEnabled(isEnabled());
+ m_jBtnYearDec.setEnabled(isEnabled());
+ m_jBtnYearInc.setEnabled(isEnabled());
+ } else {
+ m_CalendarHelper.setTime(m_date);
+
+ m_CalendarHelper.add(Calendar.MONTH, -1);
+ m_jBtnMonthDec.DateInf = m_CalendarHelper.getTime();
+ m_jBtnMonthDec.setEnabled(isEnabled());
+ m_CalendarHelper.add(Calendar.MONTH, 2);
+ m_jBtnMonthInc.DateInf = m_CalendarHelper.getTime();
+ m_jBtnMonthInc.setEnabled(isEnabled());
+
+ m_CalendarHelper.setTime(m_date);
+ m_CalendarHelper.add(Calendar.YEAR, -1);
+ m_jBtnYearDec.DateInf = m_CalendarHelper.getTime();
+ m_jBtnYearDec.setEnabled(isEnabled());
+ m_CalendarHelper.add(Calendar.YEAR, 2);
+ m_jBtnYearInc.DateInf = m_CalendarHelper.getTime();
+ m_jBtnYearInc.setEnabled(isEnabled());
+
+ if(m_jCurrent != null) {
+ m_jCurrent.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground"));
+ m_jCurrent.setBackground((Color)UIManager.getDefaults().get("TextPane.background"));
+ m_jCurrent.setBorder(null);
+ }
+
+ JButtonDate jAux = getLabelByDate(m_date);
+ jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.selectionBackground"));
+ jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.selectionForeground"));
+ jAux.setBorder(new LineBorder((Color)UIManager.getDefaults().get("TitledBorder.titleColor")));
+ m_jCurrent = jAux;
+ }
+ }
+
+ private JButtonDate getLabelByDate(Date d) {
+
+ GregorianCalendar oCalRender = new GregorianCalendar();
+ oCalRender.setTime(d);
+ int iDayOfMonth = oCalRender.get(Calendar.DAY_OF_MONTH);
+
+ oCalRender.set(Calendar.DAY_OF_MONTH, 1);
+
+ int iCol = oCalRender.get(Calendar.DAY_OF_WEEK) - oCalRender.getFirstDayOfWeek();
+ if (iCol < 0) {
+ iCol += 7;
+ }
+ return m_ListDates[iCol + iDayOfMonth - 1];
+ }
+
+ private class DateClick implements ActionListener {
+
+ public void actionPerformed(ActionEvent e) {
+ JButtonDate oLbl = (JButtonDate)e.getSource();
+ if(oLbl.DateInf != null) {
+ setDate(oLbl.DateInf);
+ }
+ }
+ }
+
+ private static class JButtonDate extends JButton {
+
+ public Date DateInf;
+
+ public JButtonDate(ActionListener datehandler) {
+ super();
+ initComponent();
+ addActionListener(datehandler);
+ }
+ public JButtonDate(String sText, ActionListener datehandler) {
+ super(sText);
+ initComponent();
+ addActionListener(datehandler);
+ }
+ public JButtonDate(Icon icon, ActionListener datehandler) {
+ super(icon);
+ initComponent();
+ addActionListener(datehandler);
+ }
+
+ private void initComponent() {
+ DateInf = null;
+ setRequestFocusEnabled(false);
+ setFocusPainted(false);
+ setFocusable(false);
+ }
+ }
+
+ private void initComponents2() {
+
+ ActionListener dateclick = new DateClick();
+
+ m_jBtnYearDec = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png")), dateclick);
+ m_jBtnMonthDec = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick);
+ m_jBtnToday = new JButtonDate(m_resources.getString("button.Today"), dateclick);
+ m_jBtnMonthInc = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick);
+ m_jBtnYearInc = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png")), dateclick);
+
+ m_jBtnToday.DateInf = new Date();
+ m_jActions.add(m_jBtnYearDec);
+ m_jActions.add(m_jBtnMonthDec);
+ m_jActions.add(m_jBtnToday);
+ m_jActions.add(m_jBtnMonthInc);
+ m_jActions.add(m_jBtnYearInc);
+
+ m_ListDates = new JButtonDate[42];
+ for(int i = 0; i < 42; i++) {
+ JButtonDate jAux = new JButtonDate(dateclick);
+ // jAux.setFont(new Font("Dialog", 1, 24));
+ jAux.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ jAux.setText(null);
+ jAux.setOpaque(true);
+ jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground"));
+ jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.background"));
+ jAux.setBorder(null);
+ m_ListDates[i] = jAux;
+ m_jDates.add(jAux);
+ }
+
+ m_jDays = new JLabel[7];
+ for(int iHead = 0; iHead < 7; iHead++) {
+ JLabel JAuxHeader = new JLabel();
+ //JAuxHeader.setFont(new Font("Dialog", 1, 24));
+ JAuxHeader.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
+ m_jDays[iHead] = JAuxHeader;
+ m_jWeekDays.add(JAuxHeader);
+ }
+
+ DateFormat fmtWeekDay = new SimpleDateFormat("E");
+ Calendar oCalRender = new GregorianCalendar();
+ int iCol;
+ for (int j = 0; j < 7; j++) {
+ oCalRender.add(Calendar.DATE, 1);
+ iCol = oCalRender.get(Calendar.DAY_OF_WEEK) - oCalRender.getFirstDayOfWeek();
+ if (iCol < 0) {
+ iCol += 7;
+ }
+ m_jDays[iCol].setText(fmtWeekDay.format(oCalRender.getTime()));
+ }
+ }
+
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ m_jMonth = new javax.swing.JPanel();
+ m_jWeekDays = new javax.swing.JPanel();
+ m_jDates = new javax.swing.JPanel();
+ jPanel2 = new javax.swing.JPanel();
+ m_jLblMonth = new javax.swing.JLabel();
+ jPanel3 = new javax.swing.JPanel();
+ m_jActions = new javax.swing.JPanel();
+
+ setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
+ setLayout(new java.awt.BorderLayout());
+
+ jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+ jPanel1.setLayout(new java.awt.BorderLayout());
+
+ m_jMonth.setLayout(new java.awt.BorderLayout());
+
+ m_jWeekDays.setLayout(new java.awt.GridLayout(1, 7));
+ m_jMonth.add(m_jWeekDays, java.awt.BorderLayout.NORTH);
+
+ m_jDates.setBackground(javax.swing.UIManager.getDefaults().getColor("TextPane.background"));
+ m_jDates.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
+ m_jDates.setLayout(new java.awt.GridLayout(6, 7));
+ m_jMonth.add(m_jDates, java.awt.BorderLayout.CENTER);
+
+ jPanel1.add(m_jMonth, java.awt.BorderLayout.CENTER);
+
+ m_jLblMonth.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
+ jPanel2.add(m_jLblMonth);
+
+ jPanel1.add(jPanel2, java.awt.BorderLayout.NORTH);
+
+ add(jPanel1, java.awt.BorderLayout.CENTER);
+
+ jPanel3.setLayout(new java.awt.BorderLayout());
+
+ m_jActions.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
+ m_jActions.setLayout(new java.awt.GridLayout(0, 1, 0, 5));
+ jPanel3.add(m_jActions, java.awt.BorderLayout.NORTH);
+
+ add(jPanel3, java.awt.BorderLayout.LINE_END);
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel m_jActions;
+ private javax.swing.JPanel m_jDates;
+ private javax.swing.JLabel m_jLblMonth;
+ private javax.swing.JPanel m_jMonth;
+ private javax.swing.JPanel m_jWeekDays;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JClockPanel.form b/src/main/java/com/unicenta/beans/JClockPanel.form
new file mode 100644
index 0000000..5c32496
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JClockPanel.form
@@ -0,0 +1,22 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JClockPanel.java b/src/main/java/com/unicenta/beans/JClockPanel.java
new file mode 100644
index 0000000..8924fa4
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JClockPanel.java
@@ -0,0 +1,252 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.Color;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class JClockPanel extends javax.swing.JPanel {
+
+ private static Calendar m_calendar = new GregorianCalendar(); // solo de ayuda...
+
+ private Date m_date;
+ private boolean m_bSeconds;
+ private long m_lPeriod;
+
+ /** Creates new form JClockPanel */
+ public JClockPanel() {
+ this(true);
+ }
+
+ /**
+ *
+ * @param bSeconds
+ */
+ public JClockPanel(boolean bSeconds) {
+
+ initComponents();
+
+ m_bSeconds = bSeconds;
+ m_date = null;
+ m_lPeriod = 0L;
+ }
+
+ /**
+ *
+ * @param bValue
+ */
+ public void setSecondsVisible(boolean bValue) {
+ m_bSeconds = bValue;
+ repaint();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isSecondsVisible() {
+ return m_bSeconds;
+ }
+
+ /**
+ *
+ * @param period
+ */
+ public void setPeriod(long period) {
+ if (period >= 0L) {
+ m_lPeriod = period;
+ repaint();
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public long getPeriod() {
+ return m_lPeriod;
+ }
+
+ /**
+ *
+ * @param dDate
+ */
+ public void setTime(Date dDate){
+ m_date = dDate;
+ repaint();
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Date getTime() {
+ return m_date;
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+
+ super.paintComponent(g);
+
+ int width = getWidth();
+ int height = getHeight();
+
+ double dhour = 0.0;
+ double dminute = 0.0;
+ double dsecond = 0.0;
+
+ // Calculo los atributos de la hora que voy a pintar
+ if (m_date != null) {
+ m_calendar.setTime(m_date);
+ dhour = (double) m_calendar.get(Calendar.HOUR_OF_DAY);
+ dminute = (double) m_calendar.get(Calendar.MINUTE);
+ dsecond = (double) m_calendar.get(Calendar.SECOND);
+ }
+
+ Graphics2D g2 = (Graphics2D) g;
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+
+ // guardo los valores iniciales
+ Paint oldPainter = g2.getPaint();
+ AffineTransform oldt = g2.getTransform();
+
+ // pinto el fondo
+// g2.setPaint(new GradientPaint(0, 0, Color.WHITE, width, 0, Color.LIGHT_GRAY));
+// g2.fill(g2.getClip());
+
+ // Calculo el centro y el tamano del reloj
+ int icenterx = width / 2;
+ int icentery = height / 2;
+ int iradius = Math.min(icenterx, icentery);
+
+ // Centro las coordenadas y ajusto la transformacion del tamano del reloj
+ g2.transform(AffineTransform.getTranslateInstance(icenterx, icentery));
+ g2.transform(AffineTransform.getScaleInstance(iradius / 1100.0 , iradius / 1100.0));
+ AffineTransform mytrans = g2.getTransform();
+
+ // Pinto la esfera del reloj;
+ g2.setPaint(this.isEnabled()
+ ? new GradientPaint(-1200, -1200, Color.BLUE, 1200, 1200, Color.CYAN)
+ : new GradientPaint(-1200, -1200, Color.GRAY, 1200, 1200, Color.LIGHT_GRAY));
+ g2.fillOval(-1000, -1000, 2000, 2000);
+ g2.setPaint(this.isEnabled()
+ ? new GradientPaint(-1200, -1200, Color.CYAN, 1200, 1200, Color.BLUE)
+ : new GradientPaint(-1200, -1200, Color.LIGHT_GRAY, 1200, 1200, Color.GRAY));
+ g2.fillOval(-900, -900, 1800, 1800);
+ g2.setColor(Color.BLACK);
+ g2.drawOval(-1000, -1000, 2000, 2000);
+
+ // Pinto las marcas pequenas, los minutos
+ for (int i = 0; i < 60; i++) {
+ g2.setColor(Color.WHITE);
+ g2.fillRect(900, -5 , 50, 10);
+ g2.transform(AffineTransform.getRotateInstance(Math.PI / 30.0));
+ }
+
+ // Pinto las marcas grandes, las horas.
+ g2.setTransform(mytrans);
+ for (int i = 0; i < 12; i++) {
+ g2.setColor(Color.WHITE);
+ g2.fillRect(800, -15 , 150, 30);
+ // g2.setColor(Color.BLACK);
+ // g2.drawRect(800, -15 , 150, 30);
+ g2.transform(AffineTransform.getRotateInstance(Math.PI / 6.0));
+ }
+
+ if (m_date != null) {
+ // Aguja de las horas
+ g2.setTransform(mytrans);
+ g2.transform(AffineTransform.getRotateInstance((dhour + dminute / 60.0) * Math.PI / 6.0)); // Poner hora
+
+ if (m_lPeriod > 0L) { // pintamos la marca del periodo...
+ // dibujo un arco con el periodo seleccionado...
+ int iArc = (int) (m_lPeriod / 120000L);
+ g2.setColor(new Color(255, 255, 255, 100));
+ g2.fillArc(-1000, -1000, 2000, 2000, 90 - iArc, iArc);
+ g2.setColor(Color.DARK_GRAY);
+ g2.drawArc(-1000, -1000, 2000, 2000, 90 - iArc, iArc);
+ } else {
+ // la aguja de las horas
+ g2.setColor(Color.WHITE);
+ g2.fillPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -600, 0}, 4);
+ g2.setColor(Color.DARK_GRAY);
+ g2.drawPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -600, 0}, 4);
+
+ // Aguja de los minutos
+ g2.setTransform(mytrans);
+ g2.transform(AffineTransform.getRotateInstance((dminute) * Math.PI / 30.0)); // Poner minutos
+ g2.setColor(Color.WHITE);
+ g2.fillPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -900, 0}, 4);
+ g2.setColor(Color.DARK_GRAY);
+ g2.drawPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -900, 0}, 4);
+
+ // Aguja de los segundos
+ if (m_bSeconds) {
+ g2.setTransform(mytrans);
+ g2.transform(AffineTransform.getRotateInstance(dsecond * Math.PI / 30.0)); // Poner segundos
+ g2.setColor(Color.YELLOW);
+ g2.fillPolygon(new int[]{-15, 0, 15}, new int[]{200, -900, 200}, 3);
+ g2.setColor(Color.DARK_GRAY);
+ g2.drawPolygon(new int[]{-15, 0, 15}, new int[]{200, -900, 200}, 3);
+
+ g2.setTransform(mytrans);
+ g2.setColor(Color.YELLOW);
+ g2.fillOval(-25, -25, 50, 50);
+ g2.setColor(Color.DARK_GRAY);
+ g2.drawOval(-25, -25, 50, 50);
+ }
+ }
+ }
+
+ // Pinto el tornillo central
+ g2.setColor(Color.WHITE);
+ g2.fillOval(-10, -10, 20, 20);
+ g2.setColor(Color.BLACK);
+ g2.drawOval(-10, -10, 20, 20);
+
+ // restauro los valores iniciales
+ g2.setTransform(oldt);
+ g2.setPaint(oldPainter);
+ }
+
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JFlowPanel.java b/src/main/java/com/unicenta/beans/JFlowPanel.java
new file mode 100644
index 0000000..c47a7f1
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JFlowPanel.java
@@ -0,0 +1,214 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.Component;
+import java.awt.ComponentOrientation;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import javax.swing.JPanel;
+import javax.swing.JViewport;
+import javax.swing.Scrollable;
+import javax.swing.SwingConstants;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class JFlowPanel extends JPanel implements Scrollable {
+
+ private int hgap = 5;
+ private int vgap = 5;
+
+ /**
+ *
+ */
+ public JFlowPanel() {
+ this(5, 5);
+ }
+
+ /**
+ *
+ * @param hgap
+ * @param vgap
+ */
+ public JFlowPanel(int hgap, int vgap) {
+ this.hgap = hgap;
+ this.vgap = vgap;
+ }
+
+ /**
+ *
+ * @param iValue
+ */
+ public void setHorizontalGap(int iValue) {
+ hgap = iValue;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public int getHorizontalGap() {
+ return hgap;
+ }
+
+ /**
+ *
+ * @param iValue
+ */
+ public void setVerticalGap(int iValue) {
+ vgap = iValue;
+ }
+
+ /**
+ *
+ * @param iValue
+ * @return
+ */
+ public int getVerticalGap(int iValue) {
+ return vgap;
+ }
+
+ private Dimension calculateFlowLayout(boolean bDoChilds) {
+ Dimension dim = new Dimension(0, hgap);
+
+ int maxWidth;
+ if (getParent() != null && getParent() instanceof JViewport) {
+ JViewport viewport = (JViewport) getParent();
+ maxWidth = viewport.getExtentSize().width;
+ } else if (getParent() != null){
+ maxWidth = getParent().getWidth();
+ } else {
+ maxWidth = getWidth();
+ }
+
+ synchronized (getTreeLock()) {
+ int compCount = getComponentCount();
+ int maxRowWidth = 0;
+ int maxRowHeight = 0;
+ int x = 0;
+
+ for (int i = 0 ; i < compCount ; i++) {
+ Component m = getComponent(i);
+ if (m.isVisible()) {
+ Dimension d = m.getPreferredSize();
+ if (x == 0 || (x + hgap + d.width + hgap) <= maxWidth) {
+ // continuamos con esta linea
+ x += hgap;
+ if (bDoChilds) {
+ m.setBounds(getPosition(x, maxWidth - d.width), dim.height, d.width, d.height);
+ }
+ x += d.width;
+ if (d.height > maxRowHeight) {
+ maxRowHeight = d.height;
+ }
+ } else {
+ // nueva linea
+ dim.height += maxRowHeight + vgap;
+ if (bDoChilds) {
+ m.setBounds(getPosition(hgap, maxWidth - d.width), dim.height, d.width, d.height);
+ }
+ if (x > maxRowWidth) {
+ maxRowWidth = x;
+ }
+ x = hgap + d.width;
+ maxRowHeight = d.height;
+ }
+ }
+ }
+
+ // calculamos la ultima linea.
+ dim.height += maxRowHeight + vgap;
+ if (x > maxRowWidth) {
+ maxRowWidth = x;
+ }
+ dim.width = maxRowWidth;
+ }
+ return dim;
+ }
+
+ private int getPosition(int x, int width) {
+ if (getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) {
+ return width - x ;
+ } else {
+ return x;
+ }
+ }
+
+ public Dimension getPreferredSize() {
+ return calculateFlowLayout(false);
+ }
+ public Dimension getMinimumSize() {
+ return calculateFlowLayout(false);
+ }
+ public Dimension getMaximumSize() {
+ return calculateFlowLayout(false);
+ }
+ public Dimension getPreferredScrollableViewportSize() {
+ return calculateFlowLayout(false);
+ }
+
+ public void doLayout() {
+ calculateFlowLayout(true);
+ }
+
+ public boolean getScrollableTracksViewportHeight() {
+ return (getParent().getHeight() > getPreferredSize().height);
+ }
+
+ public boolean getScrollableTracksViewportWidth() {
+ return (getParent().getWidth() > getPreferredSize().width);
+ }
+
+ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
+ if (getComponentCount() == 0) {
+ return orientation == SwingConstants.HORIZONTAL ? hgap : vgap;
+ } else {
+ return orientation == SwingConstants.HORIZONTAL
+ ? getComponent(0).getWidth() + hgap
+ : getComponent(0).getHeight() + vgap;
+ }
+ }
+
+ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
+ if (getComponentCount() == 0) {
+ return orientation == SwingConstants.HORIZONTAL ? hgap : vgap;
+ } else {
+ if (orientation == SwingConstants.HORIZONTAL) {
+ int hunit = getComponent(0).getWidth() + hgap;
+ return (visibleRect.width / hunit) * hunit;
+ } else {
+ int vunit = getComponent(0).getHeight() + vgap;
+ return (visibleRect.width / vunit) * vunit;
+ }
+ }
+ }
+
+ public void setEnabled(boolean value) {
+ synchronized (getTreeLock()) {
+ int compCount = getComponentCount();
+ for (int i = 0 ; i < compCount ; i++) {
+ getComponent(i).setEnabled(value);
+ }
+ }
+ super.setEnabled(value);
+ }
+}
diff --git a/src/main/java/com/unicenta/beans/JGuestsPop.form b/src/main/java/com/unicenta/beans/JGuestsPop.form
new file mode 100644
index 0000000..6aadfdc
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JGuestsPop.form
@@ -0,0 +1,175 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JGuestsPop.java b/src/main/java/com/unicenta/beans/JGuestsPop.java
new file mode 100644
index 0000000..5b4bfb0
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JGuestsPop.java
@@ -0,0 +1,226 @@
+// uniCenta oPOS - Touch Friendly Point Of Sale
+// Copyright (c) 2009-2018 uniCenta - joint with Jacinto Rodriguez
+// 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 .
+
+package com.unicenta.beans;
+
+import com.unicenta.basic.BasicException;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Jun 2018
+ * @author Jack Gerrard uniCenta
+ */
+@Slf4j
+public class JGuestsPop extends javax.swing.JDialog {
+
+ private static LocaleResources m_resources;
+
+ private Integer m_value;
+
+ /** Creates new form JDinerPop
+ * @param parent
+ * @param modal */
+ public JGuestsPop(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ /** Creates new form JDinerPop
+ * @param parent
+ * @param modal */
+ public JGuestsPop(java.awt.Dialog parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ private void init() {
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+
+ initComponents();
+ getRootPane().setDefaultButton(jcmdOK);
+
+ m_jnumber.addEditorKeys(m_jKeys);
+ m_jnumber.reset();
+ m_jnumber.setValueInteger(1);
+ m_jnumber.activate();
+// m_jnumber.setVisible(false);
+
+ m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
+
+ m_value = null;
+ }
+
+ private void setTitle(String title, String message, Icon icon) {
+ setTitle(title);
+ m_lblMessage.setText(message);
+ m_lblMessage.setIcon(icon);
+ }
+
+ public static Integer showEditNumber(Component parent, String title) {
+ return showEditNumber(parent, title, null, null);
+ }
+ public static Integer showEditNumber(Component parent, String title, String message) {
+ return showEditNumber(parent, title, message, null);
+ }
+ public static Integer showEditNumber(Component parent, String title, String message, Icon icon) {
+
+ Window window = SwingUtilities.windowForComponent(parent);
+
+ JGuestsPop myMsg;
+ if (window instanceof Frame) {
+ myMsg = new JGuestsPop((Frame) window, true);
+ } else {
+ myMsg = new JGuestsPop((Dialog) window, true);
+ }
+
+ myMsg.setTitle(title, message, icon);
+ myMsg.setVisible(true);
+ return myMsg.m_value;
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel2 = new javax.swing.JPanel();
+ jPanelGrid = new javax.swing.JPanel();
+ jPanel3 = new javax.swing.JPanel();
+ m_jKeys = new com.unicenta.editor.JEditorKeys();
+ jPanel4 = new javax.swing.JPanel();
+ jPanel1 = new javax.swing.JPanel();
+ m_jnumber = new com.unicenta.editor.JEditorDoublePositive();
+ jcmdOK = new javax.swing.JButton();
+ m_jPanelTitle = new javax.swing.JPanel();
+ m_lblMessage = new javax.swing.JLabel();
+
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ formWindowClosing(evt);
+ }
+ });
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));
+ jPanel3.add(m_jKeys);
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel4.setLayout(new java.awt.BorderLayout());
+
+ jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+
+ m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jnumber.setPreferredSize(new java.awt.Dimension(130, 30));
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(m_jnumber, 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()
+ .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(20, Short.MAX_VALUE))
+ );
+
+ jPanel4.add(jPanel1, java.awt.BorderLayout.LINE_START);
+
+ 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.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45));
+ jcmdOK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdOKActionPerformed(evt);
+ }
+ });
+ jPanel4.add(jcmdOK, java.awt.BorderLayout.CENTER);
+
+ jPanel3.add(jPanel4);
+
+ jPanelGrid.add(jPanel3);
+
+ jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
+
+ m_jPanelTitle.setLayout(new java.awt.BorderLayout());
+
+ m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH);
+
+ setSize(new java.awt.Dimension(328, 409));
+ setLocationRelativeTo(null);
+ }// //GEN-END:initComponents
+
+ private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
+
+ try {
+ m_value = m_jnumber.getValueInteger();
+ } catch (BasicException ex) {
+ log.error(ex.getMessage());
+ }
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_jcmdOKActionPerformed
+
+ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_formWindowClosing
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanelGrid;
+ private javax.swing.JButton jcmdOK;
+ private com.unicenta.editor.JEditorKeys m_jKeys;
+ private javax.swing.JPanel m_jPanelTitle;
+ private com.unicenta.editor.JEditorDoublePositive m_jnumber;
+ private javax.swing.JLabel m_lblMessage;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JNumberDialog.form b/src/main/java/com/unicenta/beans/JNumberDialog.form
new file mode 100644
index 0000000..9169f94
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberDialog.form
@@ -0,0 +1,241 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JNumberDialog.java b/src/main/java/com/unicenta/beans/JNumberDialog.java
new file mode 100644
index 0000000..25246e0
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberDialog.java
@@ -0,0 +1,300 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.Component;
+import java.awt.Dialog;
+import java.awt.Frame;
+import java.awt.Window;
+import javax.swing.Icon;
+import javax.swing.SwingUtilities;
+
+/**
+ *
+ * @author adrian
+ */
+public class JNumberDialog extends javax.swing.JDialog {
+
+ private static LocaleResources m_resources;
+
+ private Double m_value;
+
+ /** Creates new form JNumberDialog
+ * @param parent
+ * @param modal */
+ public JNumberDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ /** Creates new form JNumberDialog
+ * @param parent
+ * @param modal */
+ public JNumberDialog(java.awt.Dialog parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ public JNumberDialog() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ private void init() {
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+
+ initComponents();
+ getRootPane().setDefaultButton(jcmdOK);
+
+ m_jnumber.addEditorKeys(m_jKeys);
+ m_jnumber.reset();
+ m_jnumber.setDoubleValue(0.0);
+ m_jnumber.activate();
+
+ m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
+
+ m_value = null;
+ }
+
+ private void setTitle(String title, String message, Icon icon) {
+ setTitle(title);
+ m_lblMessage.setText(message);
+ m_lblMessage.setIcon(icon);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param title
+ * @return
+ */
+ public static Double showEditNumber(Component parent, String title) {
+ return showEditNumber(parent, title, null, null);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param title
+ * @param message
+ * @return
+ */
+ public static Double showEditNumber(Component parent, String title, String message) {
+ return showEditNumber(parent, title, message, null);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param title
+ * @param message
+ * @param icon
+ * @return
+ */
+ public static Double showEditNumber(Component parent, String title, String message, Icon icon) {
+
+ Window window = SwingUtilities.windowForComponent(parent);
+
+ JNumberDialog myMsg;
+ if (window instanceof Frame) {
+ myMsg = new JNumberDialog((Frame) window, true);
+ } else {
+ myMsg = new JNumberDialog((Dialog) window, true);
+ }
+
+ myMsg.setTitle(title, message, icon);
+ myMsg.setVisible(true);
+ return myMsg.m_value;
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jcmdCancel = new javax.swing.JButton();
+ jcmdOK = new javax.swing.JButton();
+ jPanel2 = new javax.swing.JPanel();
+ jPanelGrid = new javax.swing.JPanel();
+ jPanel3 = new javax.swing.JPanel();
+ m_jKeys = new com.unicenta.editor.JEditorKeys();
+ jPanel4 = new javax.swing.JPanel();
+ m_jnumber = new com.unicenta.editor.JEditorDoublePositive();
+ m_jPanelTitle = new javax.swing.JPanel();
+ m_lblMessage = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(310, 410));
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ formWindowClosing(evt);
+ }
+ });
+
+ jPanel1.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(m_resources.getString("button.cancel")); // NOI18N
+ jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdCancelActionPerformed(evt);
+ }
+ });
+ jPanel1.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(m_resources.getString("button.ok")); // NOI18N
+ jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdOK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdOKActionPerformed(evt);
+ }
+ });
+ jPanel1.add(jcmdOK);
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jPanelGrid.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ jPanelGrid.setPreferredSize(new java.awt.Dimension(300, 320));
+
+ jPanel3.setPreferredSize(new java.awt.Dimension(300, 350));
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));
+
+ m_jKeys.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jKeys.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_jKeysActionPerformed(evt);
+ }
+ });
+ jPanel3.add(m_jKeys);
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel4.setMinimumSize(new java.awt.Dimension(110, 30));
+ jPanel4.setPreferredSize(new java.awt.Dimension(142, 30));
+ jPanel4.setLayout(new java.awt.BorderLayout());
+
+ m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jnumber.setMinimumSize(new java.awt.Dimension(100, 20));
+ m_jnumber.setPreferredSize(new java.awt.Dimension(132, 20));
+ jPanel4.add(m_jnumber, java.awt.BorderLayout.PAGE_START);
+
+ jPanel3.add(jPanel4);
+
+ javax.swing.GroupLayout jPanelGridLayout = new javax.swing.GroupLayout(jPanelGrid);
+ jPanelGrid.setLayout(jPanelGridLayout);
+ jPanelGridLayout.setHorizontalGroup(
+ jPanelGridLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanelGridLayout.createSequentialGroup()
+ .addGap(16, 16, 16)
+ .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ );
+ jPanelGridLayout.setVerticalGroup(
+ jPanelGridLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanelGridLayout.createSequentialGroup()
+ .addGap(5, 5, 5)
+ .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE)
+ .addGap(0, 0, 0))
+ );
+
+ jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER);
+
+ m_jPanelTitle.setLayout(new java.awt.BorderLayout());
+
+ m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_lblMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)));
+ m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(m_jPanelTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(m_jPanelTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ );
+
+ setSize(new java.awt.Dimension(358, 479));
+ setLocationRelativeTo(null);
+ }// //GEN-END:initComponents
+
+ private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
+
+
+ m_value = m_jnumber.getDoubleValue();
+ setVisible(false);
+ dispose();
+
+
+ }//GEN-LAST:event_jcmdOKActionPerformed
+
+ private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_jcmdCancelActionPerformed
+
+ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_formWindowClosing
+
+ private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed
+
+ }//GEN-LAST:event_m_jKeysActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanelGrid;
+ private javax.swing.JButton jcmdCancel;
+ private javax.swing.JButton jcmdOK;
+ private com.unicenta.editor.JEditorKeys m_jKeys;
+ private javax.swing.JPanel m_jPanelTitle;
+ private com.unicenta.editor.JEditorDoublePositive m_jnumber;
+ private javax.swing.JLabel m_lblMessage;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JNumberEvent.java b/src/main/java/com/unicenta/beans/JNumberEvent.java
new file mode 100644
index 0000000..12458a3
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberEvent.java
@@ -0,0 +1,51 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.util.EventObject;
+
+/**
+ *
+ * @author adrianromero
+ * @version
+ */
+public class JNumberEvent extends EventObject {
+
+ private char m_cKey;
+
+ /**
+ *
+ * @param source
+ * @param cKey
+ */
+ public JNumberEvent(Object source, char cKey) {
+ super(source);
+ m_cKey = cKey;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public char getKey() {
+ return m_cKey;
+ }
+
+}
diff --git a/src/main/java/com/unicenta/beans/JNumberEventListener.java b/src/main/java/com/unicenta/beans/JNumberEventListener.java
new file mode 100644
index 0000000..268e064
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberEventListener.java
@@ -0,0 +1,35 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.util.EventListener;
+/**
+ *
+ * @author adrian romero
+ * @version
+ */
+public interface JNumberEventListener extends EventListener {
+
+ /**
+ *
+ * @param e
+ */
+ public void keyPerformed(JNumberEvent e);
+}
diff --git a/src/main/java/com/unicenta/beans/JNumberKeys.form b/src/main/java/com/unicenta/beans/JNumberKeys.form
new file mode 100644
index 0000000..4259836
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberKeys.form
@@ -0,0 +1,452 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JNumberKeys.java b/src/main/java/com/unicenta/beans/JNumberKeys.java
new file mode 100644
index 0000000..83c5645
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberKeys.java
@@ -0,0 +1,501 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.ComponentOrientation;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class JNumberKeys extends javax.swing.JPanel {
+
+ private Vector m_Listeners = new Vector();
+
+ private boolean minusenabled = true;
+ private boolean equalsenabled = true;
+
+ /** Creates new form JNumberKeys */
+ public JNumberKeys() {
+ initComponents ();
+
+ m_jKey0.addActionListener(new MyKeyNumberListener('0'));
+ m_jKey1.addActionListener(new MyKeyNumberListener('1'));
+ m_jKey2.addActionListener(new MyKeyNumberListener('2'));
+ m_jKey3.addActionListener(new MyKeyNumberListener('3'));
+ m_jKey4.addActionListener(new MyKeyNumberListener('4'));
+ m_jKey5.addActionListener(new MyKeyNumberListener('5'));
+ m_jKey6.addActionListener(new MyKeyNumberListener('6'));
+ m_jKey7.addActionListener(new MyKeyNumberListener('7'));
+ m_jKey8.addActionListener(new MyKeyNumberListener('8'));
+ m_jKey9.addActionListener(new MyKeyNumberListener('9'));
+ m_jKeyDot.addActionListener(new MyKeyNumberListener('.'));
+ m_jMultiply.addActionListener(new MyKeyNumberListener('*'));
+ m_jCE.addActionListener(new MyKeyNumberListener('\u007f'));
+ m_jPlus.addActionListener(new MyKeyNumberListener('+'));
+ m_jMinus.addActionListener(new MyKeyNumberListener('-'));
+ m_jEquals.addActionListener(new MyKeyNumberListener('='));
+ }
+
+ /**
+ *
+ * @param value
+ */
+ public void setNumbersOnly(boolean value) {
+ m_jEquals.setVisible(value);
+ m_jMinus.setVisible(value);
+ m_jPlus.setVisible(value);
+ m_jMultiply.setVisible(value);
+ }
+
+ @Override
+ public void setEnabled(boolean b) {
+ super.setEnabled(b);
+
+ m_jKey0.setEnabled(b);
+ m_jKey1.setEnabled(b);
+ m_jKey2.setEnabled(b);
+ m_jKey3.setEnabled(b);
+ m_jKey4.setEnabled(b);
+ m_jKey5.setEnabled(b);
+ m_jKey6.setEnabled(b);
+ m_jKey7.setEnabled(b);
+ m_jKey8.setEnabled(b);
+ m_jKey9.setEnabled(b);
+ m_jKeyDot.setEnabled(b);
+ m_jMultiply.setEnabled(b);
+ m_jCE.setEnabled(b);
+ m_jPlus.setEnabled(b);
+ m_jMinus.setEnabled(minusenabled && b);
+ m_jEquals.setEnabled(equalsenabled && b);
+ }
+
+ @Override
+ public void setComponentOrientation(ComponentOrientation o) {
+ // Nothing to change
+ }
+
+ /**
+ *
+ * @param b
+ */
+ public void setMinusEnabled(boolean b) {
+ minusenabled = b;
+ m_jMinus.setEnabled(minusenabled && isEnabled());
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isMinusEnabled() {
+ return minusenabled;
+ }
+
+ /**
+ *
+ * @param b
+ */
+ public void setEqualsEnabled(boolean b) {
+ equalsenabled = b;
+ m_jEquals.setEnabled(equalsenabled && isEnabled());
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isEqualsEnabled() {
+ return equalsenabled;
+ }
+
+ /**
+ *
+ * @param enabled
+ */
+ public void dotIs00(boolean enabled) {
+ if (enabled) {
+ m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass()
+ .getResource("/com/unicenta/images/btn00.png")));
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isNumbersOnly() {
+ return m_jEquals.isVisible();
+ }
+
+ /**
+ *
+ * @param listener
+ */
+ public void addJNumberEventListener(JNumberEventListener listener) {
+ m_Listeners.add(listener);
+ }
+
+ /**
+ *
+ * @param listener
+ */
+ public void removeJNumberEventListener(JNumberEventListener listener) {
+ m_Listeners.remove(listener);
+ }
+
+ private class MyKeyNumberListener implements java.awt.event.ActionListener {
+
+ private final char m_cCad;
+
+ public MyKeyNumberListener(char cCad){
+ m_cCad = cCad;
+ }
+ @Override
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+
+ JNumberEvent oEv = new JNumberEvent(JNumberKeys.this, m_cCad);
+ JNumberEventListener oListener;
+
+ for (Enumeration e = m_Listeners.elements(); e.hasMoreElements();) {
+ oListener = (JNumberEventListener) e.nextElement();
+ oListener.keyPerformed(oEv);
+ }
+ }
+ }
+
+ /** 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 FormEditor.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ m_jCE = new javax.swing.JButton();
+ m_jMultiply = new javax.swing.JButton();
+ m_jMinus = new javax.swing.JButton();
+ m_jPlus = new javax.swing.JButton();
+ m_jKey9 = new javax.swing.JButton();
+ m_jKey8 = new javax.swing.JButton();
+ m_jKey7 = new javax.swing.JButton();
+ m_jKey4 = new javax.swing.JButton();
+ m_jKey5 = new javax.swing.JButton();
+ m_jKey6 = new javax.swing.JButton();
+ m_jKey3 = new javax.swing.JButton();
+ m_jKey2 = new javax.swing.JButton();
+ m_jKey1 = new javax.swing.JButton();
+ m_jKey0 = new javax.swing.JButton();
+ m_jKeyDot = new javax.swing.JButton();
+ m_jEquals = new javax.swing.JButton();
+
+ setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ setMinimumSize(new java.awt.Dimension(193, 200));
+ setPreferredSize(new java.awt.Dimension(193, 200));
+ setLayout(new java.awt.GridBagLayout());
+
+ m_jCE.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnce.png"))); // NOI18N
+ m_jCE.setFocusPainted(false);
+ m_jCE.setFocusable(false);
+ m_jCE.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jCE.setMaximumSize(new java.awt.Dimension(66, 36));
+ m_jCE.setMinimumSize(new java.awt.Dimension(66, 36));
+ m_jCE.setPreferredSize(new java.awt.Dimension(66, 36));
+ m_jCE.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
+ add(m_jCE, gridBagConstraints);
+
+ m_jMultiply.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnmult.png"))); // NOI18N
+ m_jMultiply.setFocusPainted(false);
+ m_jMultiply.setFocusable(false);
+ m_jMultiply.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jMultiply.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jMultiply.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jMultiply.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jMultiply.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
+ add(m_jMultiply, gridBagConstraints);
+
+ m_jMinus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnminus.png"))); // NOI18N
+ m_jMinus.setFocusPainted(false);
+ m_jMinus.setFocusable(false);
+ m_jMinus.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jMinus.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jMinus.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jMinus.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jMinus.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
+ add(m_jMinus, gridBagConstraints);
+
+ m_jPlus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnplus.png"))); // NOI18N
+ m_jPlus.setFocusPainted(false);
+ m_jPlus.setFocusable(false);
+ m_jPlus.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jPlus.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jPlus.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.gridheight = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
+ add(m_jPlus, gridBagConstraints);
+
+ m_jKey9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn9.png"))); // NOI18N
+ m_jKey9.setFocusPainted(false);
+ m_jKey9.setFocusable(false);
+ m_jKey9.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey9.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey9.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey9.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey9.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey9, gridBagConstraints);
+
+ m_jKey8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn8.png"))); // NOI18N
+ m_jKey8.setFocusPainted(false);
+ m_jKey8.setFocusable(false);
+ m_jKey8.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey8.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey8.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey8.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey8.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey8, gridBagConstraints);
+
+ m_jKey7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn7.png"))); // NOI18N
+ m_jKey7.setFocusPainted(false);
+ m_jKey7.setFocusable(false);
+ m_jKey7.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey7.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey7.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey7.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey7.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey7, gridBagConstraints);
+
+ m_jKey4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn4.png"))); // NOI18N
+ m_jKey4.setFocusPainted(false);
+ m_jKey4.setFocusable(false);
+ m_jKey4.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey4.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey4.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey4.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey4.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey4, gridBagConstraints);
+
+ m_jKey5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn5.png"))); // NOI18N
+ m_jKey5.setFocusPainted(false);
+ m_jKey5.setFocusable(false);
+ m_jKey5.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey5.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey5.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey5.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey5.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey5, gridBagConstraints);
+
+ m_jKey6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn6.png"))); // NOI18N
+ m_jKey6.setFocusPainted(false);
+ m_jKey6.setFocusable(false);
+ m_jKey6.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey6.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey6.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey6.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey6.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey6, gridBagConstraints);
+
+ m_jKey3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn3.png"))); // NOI18N
+ m_jKey3.setFocusPainted(false);
+ m_jKey3.setFocusable(false);
+ m_jKey3.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey3.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey3.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey3.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey3.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey3, gridBagConstraints);
+
+ m_jKey2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2.png"))); // NOI18N
+ m_jKey2.setFocusPainted(false);
+ m_jKey2.setFocusable(false);
+ m_jKey2.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey2.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey2.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey2.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey2.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey2, gridBagConstraints);
+
+ m_jKey1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N
+ m_jKey1.setFocusPainted(false);
+ m_jKey1.setFocusable(false);
+ m_jKey1.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey1.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey1.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey1.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey1.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(m_jKey1, gridBagConstraints);
+
+ m_jKey0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn0.png"))); // NOI18N
+ m_jKey0.setFocusPainted(false);
+ m_jKey0.setFocusable(false);
+ m_jKey0.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKey0.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKey0.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKey0.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKey0.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.gridwidth = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
+ add(m_jKey0, gridBagConstraints);
+
+ m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btndot.png"))); // NOI18N
+ m_jKeyDot.setFocusPainted(false);
+ m_jKeyDot.setFocusable(false);
+ m_jKeyDot.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jKeyDot.setMaximumSize(new java.awt.Dimension(42, 36));
+ m_jKeyDot.setMinimumSize(new java.awt.Dimension(42, 36));
+ m_jKeyDot.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jKeyDot.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0);
+ add(m_jKeyDot, gridBagConstraints);
+
+ m_jEquals.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnequals.png"))); // NOI18N
+ m_jEquals.setFocusPainted(false);
+ m_jEquals.setFocusable(false);
+ m_jEquals.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ m_jEquals.setPreferredSize(new java.awt.Dimension(42, 36));
+ m_jEquals.setRequestFocusEnabled(false);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 3;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.gridheight = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
+ add(m_jEquals, gridBagConstraints);
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton m_jCE;
+ private javax.swing.JButton m_jEquals;
+ private javax.swing.JButton m_jKey0;
+ private javax.swing.JButton m_jKey1;
+ private javax.swing.JButton m_jKey2;
+ private javax.swing.JButton m_jKey3;
+ private javax.swing.JButton m_jKey4;
+ private javax.swing.JButton m_jKey5;
+ private javax.swing.JButton m_jKey6;
+ private javax.swing.JButton m_jKey7;
+ private javax.swing.JButton m_jKey8;
+ private javax.swing.JButton m_jKey9;
+ private javax.swing.JButton m_jKeyDot;
+ private javax.swing.JButton m_jMinus;
+ private javax.swing.JButton m_jMultiply;
+ private javax.swing.JButton m_jPlus;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JNumberPop.form b/src/main/java/com/unicenta/beans/JNumberPop.form
new file mode 100644
index 0000000..d8b98d9
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberPop.form
@@ -0,0 +1,175 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JNumberPop.java b/src/main/java/com/unicenta/beans/JNumberPop.java
new file mode 100644
index 0000000..c51224f
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JNumberPop.java
@@ -0,0 +1,237 @@
+// uniCenta oPOS - Touch Friendly Point Of Sale
+// Copyright (c) 2009-2018 uniCenta - joint with Jacinto Rodriguez
+// 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 .
+
+package com.unicenta.beans;
+
+import com.unicenta.basic.BasicException;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * Dec 2017
+ * @author Jack Gerarrd uniCenta
+ */
+@Slf4j
+public class JNumberPop extends javax.swing.JDialog {
+
+ private static LocaleResources m_resources;
+
+ private Integer m_value;
+
+ /** Creates new form JNumberDialog
+ * @param parent
+ * @param modal */
+ public JNumberPop(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ /** Creates new form JNumberDialog
+ * @param parent
+ * @param modal */
+ public JNumberPop(java.awt.Dialog parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ private void init() {
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+
+ initComponents();
+ getRootPane().setDefaultButton(jcmdOK);
+
+ m_jnumber.addEditorKeys(m_jKeys);
+ m_jnumber.reset();
+ m_jnumber.setValueInteger(1);
+ m_jnumber.activate();
+ m_jnumber.setVisible(false);
+
+ m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
+
+ m_value = null;
+ }
+
+ private void setTitle(String title, String message, Icon icon) {
+ setTitle(title);
+ m_lblMessage.setText(message);
+ m_lblMessage.setIcon(icon);
+ }
+
+ public static Integer showEditNumber(Component parent, String title) {
+ return showEditNumber(parent, title, null, null);
+ }
+ public static Integer showEditNumber(Component parent, String title, String message) {
+ return showEditNumber(parent, title, message, null);
+ }
+ public static Integer showEditNumber(Component parent, String title, String message, Icon icon) {
+
+ Window window = SwingUtilities.windowForComponent(parent);
+
+ JNumberPop myMsg;
+ if (window instanceof Frame) {
+ myMsg = new JNumberPop((Frame) window, true);
+ } else {
+ myMsg = new JNumberPop((Dialog) window, true);
+ }
+
+ myMsg.setTitle(title, message, icon);
+ myMsg.setVisible(true);
+ return myMsg.m_value;
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel2 = new javax.swing.JPanel();
+ jPanelGrid = new javax.swing.JPanel();
+ jPanel3 = new javax.swing.JPanel();
+ m_jKeys = new com.unicenta.editor.JEditorKeys();
+ jPanel4 = new javax.swing.JPanel();
+ jPanel1 = new javax.swing.JPanel();
+ m_jnumber = new com.unicenta.editor.JEditorDoublePositive();
+ jcmdOK = new javax.swing.JButton();
+ m_jPanelTitle = new javax.swing.JPanel();
+ m_lblMessage = new javax.swing.JLabel();
+
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ formWindowClosing(evt);
+ }
+ });
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));
+
+ m_jKeys.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_jKeysActionPerformed(evt);
+ }
+ });
+ jPanel3.add(m_jKeys);
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel4.setLayout(new java.awt.BorderLayout());
+
+ jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+
+ m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(95, 95, 95))
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(20, Short.MAX_VALUE))
+ );
+
+ jPanel4.add(jPanel1, java.awt.BorderLayout.LINE_START);
+
+ 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.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45));
+ jcmdOK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdOKActionPerformed(evt);
+ }
+ });
+ jPanel4.add(jcmdOK, java.awt.BorderLayout.CENTER);
+
+ jPanel3.add(jPanel4);
+
+ jPanelGrid.add(jPanel3);
+
+ jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
+
+ m_jPanelTitle.setLayout(new java.awt.BorderLayout());
+
+ m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH);
+
+ setSize(new java.awt.Dimension(328, 409));
+ setLocationRelativeTo(null);
+ }// //GEN-END:initComponents
+
+ private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
+
+
+ try {
+ m_value = m_jnumber.getValueInteger();
+ } catch (BasicException ex) {
+ log.error(ex.getMessage());
+ }
+ setVisible(false);
+ dispose();
+
+
+ }//GEN-LAST:event_jcmdOKActionPerformed
+
+ private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_formWindowClosing
+
+ private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed
+
+ }//GEN-LAST:event_m_jKeysActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanelGrid;
+ private javax.swing.JButton jcmdOK;
+ private com.unicenta.editor.JEditorKeys m_jKeys;
+ private javax.swing.JPanel m_jPanelTitle;
+ private com.unicenta.editor.JEditorDoublePositive m_jnumber;
+ private javax.swing.JLabel m_lblMessage;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JPasswordDialog.form b/src/main/java/com/unicenta/beans/JPasswordDialog.form
new file mode 100644
index 0000000..6a3e437
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JPasswordDialog.form
@@ -0,0 +1,204 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JPasswordDialog.java b/src/main/java/com/unicenta/beans/JPasswordDialog.java
new file mode 100644
index 0000000..4ca0d60
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JPasswordDialog.java
@@ -0,0 +1,266 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.*;
+import javax.swing.*;
+
+public class JPasswordDialog extends javax.swing.JDialog {
+
+ private static LocaleResources m_resources;
+
+ private String m_sPassword;
+
+ /** Creates new form JPasswordDialog
+ * @param parent
+ * @param modal */
+ public JPasswordDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+ /** Creates new form JPasswordDialog
+ * @param parent
+ * @param modal */
+ public JPasswordDialog(java.awt.Dialog parent, boolean modal) {
+ super(parent, modal);
+ init();
+ }
+
+ private void init() {
+
+ if (m_resources == null) {
+ m_resources = new LocaleResources();
+ m_resources.addBundleName("beans_messages");
+ }
+
+ initComponents();
+ getRootPane().setDefaultButton(jcmdOK);
+
+ m_jpassword.addEditorKeys(m_jKeys);
+ m_jpassword.reset();
+ m_jpassword.activate();
+
+ m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder());
+
+ m_sPassword = null;
+ }
+
+ private void setTitle(String title, String message, Icon icon) {
+ setTitle(title);
+ m_lblMessage.setText(message);
+ m_lblMessage.setIcon(icon);
+ }
+
+ 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 title
+ * @return
+ */
+ public static String showEditPassword(Component parent, String title) {
+ return showEditPassword(parent, title, null, null);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param title
+ * @param message
+ * @return
+ */
+ public static String showEditPassword(Component parent, String title, String message) {
+ return showEditPassword(parent, title, message, null);
+ }
+
+ /**
+ *
+ * @param parent
+ * @param title
+ * @param message
+ * @param icon
+ * @return
+ */
+ public static String showEditPassword(Component parent, String title, String message, Icon icon) {
+
+ Window window = getWindow(parent);
+
+ JPasswordDialog myMsg;
+ if (window instanceof Frame) {
+ myMsg = new JPasswordDialog((Frame) window, true);
+ } else {
+ myMsg = new JPasswordDialog((Dialog) window, true);
+ }
+
+ myMsg.setTitle(title, message, icon);
+ myMsg.setVisible(true);
+ return myMsg.m_sPassword;
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jcmdCancel = new javax.swing.JButton();
+ jcmdOK = new javax.swing.JButton();
+ jPanel2 = new javax.swing.JPanel();
+ jPanelGrid = new javax.swing.JPanel();
+ jPanel3 = new javax.swing.JPanel();
+ m_jKeys = new com.unicenta.editor.JEditorKeys();
+ jPanel4 = new javax.swing.JPanel();
+ m_jpassword = new com.unicenta.editor.JEditorPassword();
+ m_jPanelTitle = new javax.swing.JPanel();
+ m_lblMessage = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(320, 450));
+ setResizable(false);
+ addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent evt) {
+ closeWindow(evt);
+ }
+ });
+
+ jPanel1.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.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdCancel.setPreferredSize(new java.awt.Dimension(80, 45));
+ jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdCancelActionPerformed(evt);
+ }
+ });
+ jPanel1.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.setMargin(new java.awt.Insets(8, 16, 8, 16));
+ jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45));
+ jcmdOK.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jcmdOKActionPerformed(evt);
+ }
+ });
+ jPanel1.add(jcmdOK);
+
+ getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel2.setPreferredSize(new java.awt.Dimension(320, 390));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jPanelGrid.setPreferredSize(new java.awt.Dimension(310, 380));
+
+ jPanel3.setPreferredSize(new java.awt.Dimension(300, 350));
+ jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS));
+
+ m_jKeys.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ m_jKeysActionPerformed(evt);
+ }
+ });
+ jPanel3.add(m_jKeys);
+
+ jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ jPanel4.setPreferredSize(new java.awt.Dimension(120, 30));
+ jPanel4.setLayout(new java.awt.BorderLayout());
+
+ m_jpassword.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ m_jpassword.setPreferredSize(new java.awt.Dimension(110, 30));
+ jPanel4.add(m_jpassword, java.awt.BorderLayout.CENTER);
+
+ jPanel3.add(jPanel4);
+
+ jPanelGrid.add(jPanel3);
+
+ jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
+
+ m_jPanelTitle.setLayout(new java.awt.BorderLayout());
+
+ m_lblMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)));
+ m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER);
+
+ getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH);
+
+ setSize(new java.awt.Dimension(308, 489));
+ setLocationRelativeTo(null);
+ }// //GEN-END:initComponents
+
+ private void jNumberKeys21KeyPerformed(com.unicenta.beans.JNumberEvent evt) {//GEN-FIRST:event_jNumberKeys21KeyPerformed
+
+ }//GEN-LAST:event_jNumberKeys21KeyPerformed
+
+ private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
+
+ m_sPassword = m_jpassword.getPassword();
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_jcmdOKActionPerformed
+
+ private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_jcmdCancelActionPerformed
+
+ private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow
+
+ setVisible(false);
+ dispose();
+
+ }//GEN-LAST:event_closeWindow
+
+ private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed
+ }//GEN-LAST:event_m_jKeysActionPerformed
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanelGrid;
+ private javax.swing.JButton jcmdCancel;
+ private javax.swing.JButton jcmdOK;
+ private com.unicenta.editor.JEditorKeys m_jKeys;
+ private javax.swing.JPanel m_jPanelTitle;
+ private com.unicenta.editor.JEditorPassword m_jpassword;
+ private javax.swing.JLabel m_lblMessage;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/JTimePanel.form b/src/main/java/com/unicenta/beans/JTimePanel.form
new file mode 100644
index 0000000..8257d83
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JTimePanel.form
@@ -0,0 +1,92 @@
+
+
+
diff --git a/src/main/java/com/unicenta/beans/JTimePanel.java b/src/main/java/com/unicenta/beans/JTimePanel.java
new file mode 100644
index 0000000..d03776c
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/JTimePanel.java
@@ -0,0 +1,387 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class JTimePanel extends javax.swing.JPanel {
+
+ /**
+ *
+ */
+ public final static int BUTTONS_ALL = 3;
+
+ /**
+ *
+ */
+ public final static int BUTTONS_HOUR = 1;
+
+ /**
+ *
+ */
+ public final static int BUTTONS_MINUTE = 2;
+
+ private DateFormat fmtTime = DateFormat.getTimeInstance(DateFormat.SHORT);
+
+ private JClockPanel m_jclock;
+ private Date m_dMinDate;
+ private Date m_dMaxDate;
+
+ private JButtonDate m_jbtnplushour = null;
+ private JButtonDate m_jbtnminushour = null;
+ private JButtonDate m_jbtnplusfifteen = null;
+ private JButtonDate m_jbtnminusfifteen = null;
+ private JButtonDate m_jbtnplusminute = null;
+ private JButtonDate m_jbtnminusminute = null;
+
+ /** Creates new form JTimePanel */
+ public JTimePanel() {
+ this(null, BUTTONS_ALL);
+ }
+
+ /**
+ *
+ * @param dDate
+ */
+ public JTimePanel(Date dDate) {
+ this(dDate, BUTTONS_ALL);
+ }
+
+ /**
+ *
+ * @param dDate
+ * @param iButtons
+ */
+ public JTimePanel(Date dDate, int iButtons) {
+ super();
+
+ initComponents();
+
+ m_jclock = new JClockPanel(false);
+ jPanel2.add(m_jclock, BorderLayout.CENTER);
+
+
+ GregorianCalendar c;
+ DateFormat f = new SimpleDateFormat("H:mm");
+
+ ActionListener dateclick = new DateClick();
+
+ if ((iButtons & BUTTONS_HOUR) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 1, 0);
+ m_jbtnplushour = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png")), dateclick);
+ m_jactions.add(m_jbtnplushour);
+ }
+
+ if ((iButtons & BUTTONS_MINUTE) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 0, 15);
+ m_jbtnplusfifteen = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick);
+ m_jactions.add(m_jbtnplusfifteen);
+ }
+
+ if ((iButtons & BUTTONS_MINUTE) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 0, 1);
+ m_jbtnplusminute = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick);
+ m_jactions.add(m_jbtnplusminute);
+ }
+// c = new GregorianCalendar(1900, 0, 0, 0, 0);
+// m_jbtnmidnight = new JButtonDate(f.format(c.getTime()), dateclick);
+// m_jactions.add(m_jbtnmidnight);
+
+ if ((iButtons & BUTTONS_MINUTE) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 0, 1);
+ m_jbtnminusminute = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick);
+ m_jactions.add(m_jbtnminusminute);
+ }
+
+ if ((iButtons & BUTTONS_MINUTE) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 0, 15);
+ m_jbtnminusfifteen = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick);
+ m_jactions.add(m_jbtnminusfifteen);
+ }
+
+ if ((iButtons & BUTTONS_HOUR) > 0) {
+ c = new GregorianCalendar(1900, 0, 0, 1, 0);
+ m_jbtnminushour = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png")), dateclick);
+ m_jactions.add(m_jbtnminushour);
+ }
+
+ m_dMinDate = null;
+ m_dMaxDate = null;
+ m_jclock.setTime(dDate);
+ renderTime();
+ }
+
+ /**
+ *
+ */
+ public void setDateMidNight() {
+ setDate(new GregorianCalendar(1900, 0, 0, 0, 0).getTime());
+ }
+
+ /**
+ *
+ * @param dNewDate
+ */
+ public void setDate(Date dNewDate) {
+
+ Date dOldDate = m_jclock.getTime();
+ if (((dNewDate == null && dOldDate != null) || (dNewDate != null && !dNewDate.equals(dOldDate)))
+ && checkDates(dNewDate)) {
+ m_jclock.setTime(dNewDate);
+ renderTime();
+ firePropertyChange("Date", dOldDate, dNewDate); // decimos al mundo que ha cambiado la propiedad fecha
+ }
+ }
+
+ private boolean checkDates(Date dDate) {
+ return dDate == null || (m_dMaxDate == null || m_dMaxDate.compareTo(dDate) > 0) && (m_dMinDate == null || m_dMinDate.compareTo(dDate) <= 0);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Date getDate() {
+ return m_jclock.getTime();
+ }
+
+ /**
+ *
+ * @param dMinDate
+ * @param dMaxDate
+ */
+ public void setCheckDates(Date dMinDate, Date dMaxDate) {
+
+ m_dMinDate = dMinDate;
+ m_dMaxDate = dMaxDate;
+ setDate(null);
+ renderTime(); // este quiza sobra.
+ }
+
+ @Override
+ public void setEnabled(boolean bValue) {
+
+ super.setEnabled(bValue);
+ renderTime();
+ }
+
+ /**
+ *
+ * @param period
+ */
+ public void setPeriod(long period) {
+ m_jclock.setPeriod(period);
+ renderTime();
+ }
+
+ private void renderTime() {
+
+ Date dDate = m_jclock.getTime();
+ if (dDate == null) {
+ if (m_jbtnplushour != null) {
+ m_jbtnplushour.setEnabled(false);
+ }
+ if (m_jbtnminushour != null) {
+ m_jbtnminushour.setEnabled(false);
+ }
+ if (m_jbtnplusfifteen != null) {
+ m_jbtnplusfifteen.setEnabled(false);
+ }
+ if (m_jbtnminusfifteen != null) {
+ m_jbtnminusfifteen.setEnabled(false);
+ }
+ if (m_jbtnplusminute != null) {
+ m_jbtnplusminute.setEnabled(false);
+ }
+ if (m_jbtnminusminute != null) {
+ m_jbtnminusminute.setEnabled(false);
+ }
+ m_jlblTime.setText(" ");
+ m_jlblSeparator.setVisible(false);
+ m_jlblTime2.setVisible(false);
+ m_jtime.revalidate();
+ } else {
+ GregorianCalendar oCalRender = new GregorianCalendar();
+ oCalRender.setTime(dDate);
+ // int iDay = oCalRender.get(Calendar.DAY_OF_MONTH);
+
+ oCalRender.add(Calendar.HOUR_OF_DAY, 1);
+ if (m_jbtnplushour != null) {
+ m_jbtnplushour.DateInf = oCalRender.getTime();
+ m_jbtnplushour.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+ oCalRender.add(Calendar.HOUR_OF_DAY, -2);
+ if (m_jbtnminushour != null) {
+ m_jbtnminushour.DateInf = oCalRender.getTime();
+ m_jbtnminushour.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+
+ oCalRender.setTime(dDate);
+
+ oCalRender.add(Calendar.MINUTE, 15);
+ if (m_jbtnplusfifteen != null) {
+ m_jbtnplusfifteen.DateInf = oCalRender.getTime();
+ m_jbtnplusfifteen.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+ oCalRender.add(Calendar.MINUTE, -30);
+ if (m_jbtnminusfifteen != null) {
+ m_jbtnminusfifteen.DateInf = oCalRender.getTime();
+ m_jbtnminusfifteen.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+ oCalRender.setTime(dDate);
+
+ oCalRender.add(Calendar.MINUTE, 1);
+ if (m_jbtnplusminute != null) {
+ m_jbtnplusminute.DateInf = oCalRender.getTime();
+ m_jbtnplusminute.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+ oCalRender.add(Calendar.MINUTE, -2);
+ if (m_jbtnminusminute != null) {
+ m_jbtnminusminute.DateInf = oCalRender.getTime();
+ m_jbtnminusminute.setEnabled(isEnabled() && checkDates(oCalRender.getTime()));
+ }
+
+ if (m_jclock.getPeriod() > 0L) {
+ // damos el periodo
+ m_jlblTime.setText(fmtTime.format(dDate));
+ m_jlblTime2.setText(fmtTime.format(new Date(dDate.getTime() + m_jclock.getPeriod())));
+ m_jlblSeparator.setVisible(true);
+ m_jlblTime2.setVisible(true);
+ m_jtime.revalidate();
+ } else {
+ // es una hora normal
+ m_jlblTime.setText(fmtTime.format(dDate));
+ m_jlblSeparator.setVisible(false);
+ m_jlblTime2.setVisible(false);
+ m_jtime.revalidate();
+ }
+ }
+
+ m_jclock.setEnabled(isEnabled());
+ }
+
+ private class DateClick implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JButtonDate oLbl = (JButtonDate)e.getSource();
+ if(oLbl.DateInf != null) {
+ setDate(oLbl.DateInf);
+ }
+ }
+ }
+
+ private static class JButtonDate extends JButton {
+
+ public Date DateInf;
+
+ public JButtonDate(ActionListener datehandler) {
+ super();
+ initComponent();
+ addActionListener(datehandler);
+ }
+
+ public JButtonDate(String sText, ActionListener datehandler) {
+ super(sText);
+ initComponent();
+ addActionListener(datehandler);
+ }
+
+ public JButtonDate(String sText, Icon ico, ActionListener datehandler) {
+ super(sText, ico);
+ initComponent();
+ addActionListener(datehandler);
+ }
+
+ private void initComponent() {
+ DateInf = null;
+ setRequestFocusEnabled(false);
+ setFocusPainted(false);
+ setFocusable(false);
+ }
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ m_jactions = new javax.swing.JPanel();
+ jPanel2 = new javax.swing.JPanel();
+ m_jtime = new javax.swing.JPanel();
+ m_jlblTime = new javax.swing.JLabel();
+ m_jlblSeparator = new javax.swing.JLabel();
+ m_jlblTime2 = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ jPanel1.setLayout(new java.awt.BorderLayout());
+
+ m_jactions.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5));
+ m_jactions.setLayout(new java.awt.GridLayout(0, 1, 0, 5));
+ jPanel1.add(m_jactions, java.awt.BorderLayout.NORTH);
+
+ add(jPanel1, java.awt.BorderLayout.LINE_END);
+
+ jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+ jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ m_jtime.add(m_jlblTime);
+
+ m_jlblSeparator.setText(" - ");
+ m_jtime.add(m_jlblSeparator);
+ m_jtime.add(m_jlblTime2);
+
+ jPanel2.add(m_jtime, java.awt.BorderLayout.NORTH);
+
+ add(jPanel2, java.awt.BorderLayout.CENTER);
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel m_jactions;
+ private javax.swing.JLabel m_jlblSeparator;
+ private javax.swing.JLabel m_jlblTime;
+ private javax.swing.JLabel m_jlblTime2;
+ private javax.swing.JPanel m_jtime;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/beans/LocaleResources.java b/src/main/java/com/unicenta/beans/LocaleResources.java
new file mode 100644
index 0000000..71bb28d
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/LocaleResources.java
@@ -0,0 +1,127 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ *
+ * @author adrian
+ */
+public class LocaleResources {
+
+ private List m_resources;
+ private ClassLoader m_localeloader;
+
+ /** Creates a new instance of LocaleResources */
+ public LocaleResources() {
+// m_resources = new LinkedList();
+ m_resources = new LinkedList<>();
+
+ File fuserdir = new File(System.getProperty("user.dir"));
+ File fresources = new File(fuserdir, "locales");
+ try {
+ m_localeloader = URLClassLoader.newInstance(
+ new URL[] { fresources.toURI().toURL() },
+ Thread.currentThread().getContextClassLoader());
+ } catch (MalformedURLException e) {
+ m_localeloader = Thread.currentThread().getContextClassLoader();
+ }
+ }
+
+ public ResourceBundle getBundle(String bundlename) {
+ return ResourceBundle.getBundle(bundlename, Locale.getDefault(), m_localeloader);
+ }
+
+ /**
+ *
+ * @param bundlename
+ */
+
+ public void addBundleName(String bundlename) {
+// m_resources.add(getBundle(bundlename));
+ m_resources.add(ResourceBundle.getBundle(bundlename));
+ }
+
+ /**
+ *
+ * @param sKey
+ * @return
+ */
+ public String getString(String sKey) {
+
+ if (sKey == null) {
+ return null;
+ } else {
+ for (ResourceBundle r : m_resources) {
+ try {
+ return r.getString(sKey);
+ } catch (MissingResourceException e) {
+ // Next
+ }
+ }
+
+ // MissingResourceException in all ResourceBundle
+ return "** " + sKey + " **";
+ }
+ }
+
+ /**
+ *
+ * @param sKey
+ * @param sValues
+ * @return
+ */
+ public String getString(String sKey, Object ... sValues) {
+
+ if (sKey == null) {
+ return null;
+ } else {
+ for (ResourceBundle r : m_resources) {
+ try {
+ return MessageFormat.format(r.getString(sKey), sValues);
+ } catch (MissingResourceException e) {
+ // Next
+ }
+ }
+
+ // MissingResourceException in all ResourceBundle
+ StringBuilder sreturn = new StringBuilder();
+ sreturn.append("** ");
+ sreturn.append(sKey);
+ for (Object value : sValues) {
+ sreturn.append(" < ");
+ sreturn.append(value.toString());
+ }
+ sreturn.append("** ");
+
+ return sreturn.toString();
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/beans/RoundedBorder.java b/src/main/java/com/unicenta/beans/RoundedBorder.java
new file mode 100644
index 0000000..92560b4
--- /dev/null
+++ b/src/main/java/com/unicenta/beans/RoundedBorder.java
@@ -0,0 +1,268 @@
+// 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 .
+
+package com.unicenta.beans;
+
+import java.awt.*;
+import javax.swing.border.AbstractBorder;
+import javax.swing.border.Border;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class RoundedBorder extends AbstractBorder {
+
+ private static Border blackLine;
+ private static Border grayLine;
+ private static Border gradientBorder;
+
+ /**
+ *
+ */
+ protected Color colorBorder;
+
+ /**
+ *
+ */
+ protected Color colorgradient;
+
+ /**
+ *
+ */
+ protected int roundedRadius;
+
+ /**
+ *
+ */
+ protected float thickness;
+
+ /**
+ *
+ */
+ protected boolean filled;
+
+ private float ftop;
+ private float fbottom;
+ private float ftopinset;
+ private float fbottominset;
+
+ /**
+ *
+ * @return
+ */
+ public static Border createBlackLineBorder() {
+ if (blackLine == null) {
+ blackLine = new RoundedBorder(Color.BLACK);
+ }
+ return blackLine;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static Border createGrayLineBorder() {
+ if (grayLine == null) {
+ grayLine = new RoundedBorder(Color.GRAY);
+ }
+ return grayLine;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static Border createGradientBorder() {
+ if (gradientBorder == null) {
+ gradientBorder = new RoundedBorder(Color.GRAY, 0f, 8, false, false);
+ }
+ return gradientBorder;
+ }
+
+ /**
+ *
+ * @param colorBorder
+ */
+ public RoundedBorder(Color colorBorder) {
+ this(colorBorder, Color.WHITE, 1f, 0, true, true);
+ }
+
+ /**
+ *
+ * @param colorBorder
+ * @param thickness
+ */
+ public RoundedBorder(Color colorBorder, float thickness) {
+ this(colorBorder, Color.WHITE, thickness, 0, true, true);
+ }
+
+ /**
+ *
+ * @param colorBorder
+ * @param thickness
+ * @param roundedRadius
+ */
+ public RoundedBorder(Color colorBorder, float thickness, int roundedRadius) {
+ this(colorBorder, Color.WHITE, thickness, roundedRadius, true, true);
+ }
+
+ /**
+ *
+ * @param colorBorder
+ * @param thickness
+ * @param roundedRadius
+ * @param btopborder
+ * @param bbottomborder
+ */
+ public RoundedBorder(Color colorBorder, float thickness, int roundedRadius, boolean btopborder, boolean bbottomborder) {
+ this(colorBorder, Color.WHITE, thickness, roundedRadius, btopborder, bbottomborder);
+ }
+
+ /**
+ *
+ * @param colorBorder
+ * @param colorgradient
+ * @param thickness
+ * @param roundedRadius
+ * @param btopborder
+ * @param bbottomborder
+ */
+ public RoundedBorder(Color colorBorder, Color colorgradient, float thickness, int roundedRadius, boolean btopborder, boolean bbottomborder) {
+
+ this.colorBorder = colorBorder;
+ this.colorgradient = colorgradient;
+ this.thickness = thickness;
+ this.roundedRadius = roundedRadius;
+ this.filled = true;
+
+ ftop = btopborder ? 0f : thickness + roundedRadius;
+ fbottom = bbottomborder ? 0f : thickness + roundedRadius;
+ ftopinset = btopborder ? 0f : thickness; // para los bordes a derecha e izquierda
+ fbottominset = bbottomborder ? 0f : thickness; // para los bordes a derecha e izquierda
+ }
+
+ @Override
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+
+ Graphics2D g2d = (Graphics2D) g;
+
+ Object oldAntialias = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
+ Stroke oldStroke = g2d.getStroke();
+ Paint oldColor = g2d.getPaint();
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+
+ float imedium = thickness;
+
+ if (filled) {
+ if (c.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) {
+ g2d.setPaint(new GradientPaint(0, 0, c.getBackground(), width, 0, colorgradient));
+ } else {
+ g2d.setPaint(new GradientPaint(0, 0, colorgradient, width, 0, c.getBackground()));
+ }
+ g2d.fillRoundRect(
+ (int) (x + thickness),
+ (int) (y + thickness - ftop),
+ (int) (width - thickness - thickness),
+ (int) (height - thickness - thickness + ftop + fbottom),
+ (int) (roundedRadius * 2 - imedium),
+ (int) (roundedRadius * 2 - imedium));
+ }
+
+ if (thickness > 0f) {
+ g2d.setStroke(new BasicStroke(thickness));
+ g2d.setPaint(colorBorder);
+ g2d.drawRoundRect(
+ (int) (x),
+ (int) (y - ftop),
+ (int) (width- thickness),
+ (int) (height - thickness + ftop + fbottom),
+ roundedRadius * 2,
+ roundedRadius * 2);
+ }
+
+ g2d.setPaint(oldColor);
+ g2d.setStroke(oldStroke);
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialias);
+ }
+
+ @Override
+ public Insets getBorderInsets(Component c) {
+
+// // Los bordes estan arriba y abajo
+// return new Insets(
+// (int)(0.5 + thickness + roundedRadius - ftop),
+// (int)(0.5 + thickness),
+// (int)(0.5 + thickness + roundedRadius - fbottom),
+// (int)(0.5 + thickness));
+
+ // Los bordes estan a derecha y a izquierda
+ return new Insets(
+ (int)(0.5 + thickness - ftopinset),
+ (int)(0.5 + thickness + roundedRadius),
+ (int)(0.5 + thickness - fbottominset),
+ (int)(0.5 + thickness + roundedRadius));
+ }
+
+ @Override
+ public Insets getBorderInsets(Component c, Insets insets) {
+
+// insets.top = (int)(0.5 + thickness + roundedRadius - ftop);
+// insets.left =(int)(0.5 + thickness);
+// insets.bottom = (int)(0.5 + thickness + roundedRadius - fbottom);
+// insets.right = (int)(0.5 + thickness);
+
+ insets.top = (int)(0.5 + thickness - ftopinset);
+ insets.left =(int)(0.5 + thickness + roundedRadius);
+ insets.bottom = (int)(0.5 + thickness - fbottominset);
+ insets.right = (int)(0.5 + thickness + roundedRadius);
+
+ return insets;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Color getLineColor() {
+ return colorBorder;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public float getThickness() {
+ return thickness;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public boolean isFilled() {
+ return filled;
+ }
+
+ @Override
+ public boolean isBorderOpaque() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java b/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java
new file mode 100644
index 0000000..c24a661
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java
@@ -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 .
+
+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);
+ }
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/CompoundIcon.java b/src/main/java/com/unicenta/data/gui/CompoundIcon.java
new file mode 100644
index 0000000..b69f1e6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/CompoundIcon.java
@@ -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 .
+
+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);
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/FindInfo.java b/src/main/java/com/unicenta/data/gui/FindInfo.java
new file mode 100644
index 0000000..4d63f09
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/FindInfo.java
@@ -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 .
+
+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;
+ }
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JCounter.form b/src/main/java/com/unicenta/data/gui/JCounter.form
new file mode 100644
index 0000000..e3aa037
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JCounter.form
@@ -0,0 +1,60 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JCounter.java b/src/main/java/com/unicenta/data/gui/JCounter.java
new file mode 100644
index 0000000..06e25cf
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JCounter.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JFind.form b/src/main/java/com/unicenta/data/gui/JFind.form
new file mode 100644
index 0000000..ed48e25
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JFind.form
@@ -0,0 +1,232 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JFind.java b/src/main/java/com/unicenta/data/gui/JFind.java
new file mode 100644
index 0000000..e10c4f6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JFind.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JImageEditor.form b/src/main/java/com/unicenta/data/gui/JImageEditor.form
new file mode 100644
index 0000000..d423fbf
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageEditor.form
@@ -0,0 +1,184 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JImageEditor.java b/src/main/java/com/unicenta/data/gui/JImageEditor.java
new file mode 100644
index 0000000..2bac7e7
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageEditor.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form
new file mode 100644
index 0000000..c5e4fcd
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form
@@ -0,0 +1,131 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java
new file mode 100644
index 0000000..77a17f7
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form
new file mode 100644
index 0000000..c5e4fcd
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form
@@ -0,0 +1,131 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java
new file mode 100644
index 0000000..c0029ef
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JLabelDirty.java b/src/main/java/com/unicenta/data/gui/JLabelDirty.java
new file mode 100644
index 0000000..5f5af25
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JLabelDirty.java
@@ -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 .
+
+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);
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/unicenta/data/gui/JListData.form b/src/main/java/com/unicenta/data/gui/JListData.form
new file mode 100644
index 0000000..41b5032
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JListData.form
@@ -0,0 +1,117 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JListData.java b/src/main/java/com/unicenta/data/gui/JListData.java
new file mode 100644
index 0000000..f9f5de0
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JListData.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JListNavigator.form b/src/main/java/com/unicenta/data/gui/JListNavigator.form
new file mode 100644
index 0000000..c80ac1e
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JListNavigator.form
@@ -0,0 +1,54 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JListNavigator.java b/src/main/java/com/unicenta/data/gui/JListNavigator.java
new file mode 100644
index 0000000..10822dc
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JListNavigator.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JMessageDialog.form b/src/main/java/com/unicenta/data/gui/JMessageDialog.form
new file mode 100644
index 0000000..1c4d13d
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JMessageDialog.form
@@ -0,0 +1,180 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JMessageDialog.java b/src/main/java/com/unicenta/data/gui/JMessageDialog.java
new file mode 100644
index 0000000..2b2fbe6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JMessageDialog.java
@@ -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 .
+
+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("" + 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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JNavigator.form b/src/main/java/com/unicenta/data/gui/JNavigator.form
new file mode 100644
index 0000000..e30e205
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JNavigator.form
@@ -0,0 +1,22 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JNavigator.java b/src/main/java/com/unicenta/data/gui/JNavigator.java
new file mode 100644
index 0000000..8251719
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JNavigator.java
@@ -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 .
+
+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);
+ }
+ }
+
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
+ }// //GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JSaver.form b/src/main/java/com/unicenta/data/gui/JSaver.form
new file mode 100644
index 0000000..5dc9645
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JSaver.form
@@ -0,0 +1,106 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JSaver.java b/src/main/java/com/unicenta/data/gui/JSaver.java
new file mode 100644
index 0000000..95daaaa
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JSaver.java
@@ -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 .
+
+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.
+ */
+ // //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)
+ );
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/JSort.form b/src/main/java/com/unicenta/data/gui/JSort.form
new file mode 100644
index 0000000..98593ac
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JSort.form
@@ -0,0 +1,221 @@
+
+
+
diff --git a/src/main/java/com/unicenta/data/gui/JSort.java b/src/main/java/com/unicenta/data/gui/JSort.java
new file mode 100644
index 0000000..dc3456a
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/JSort.java
@@ -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 .
+
+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.
+ */
+ // //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);
+ }// //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
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java b/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java
new file mode 100644
index 0000000..8b591bc
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java
@@ -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 .
+
+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;
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/ListKeyed.java b/src/main/java/com/unicenta/data/gui/ListKeyed.java
new file mode 100644
index 0000000..b0e412f
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/ListKeyed.java
@@ -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 .
+
+package com.unicenta.data.gui;
+
+import com.unicenta.data.loader.IKeyed;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author adrianromero
+ * @param
+ */
+public class ListKeyed extends ArrayList {
+
+ /**
+ *
+ * @param list
+ */
+ public ListKeyed(List 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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java b/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java
new file mode 100644
index 0000000..ae3f2b4
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java
@@ -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 .
+
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/gui/MessageInf.java b/src/main/java/com/unicenta/data/gui/MessageInf.java
new file mode 100644
index 0000000..11b4db6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/MessageInf.java
@@ -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 .
+
+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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/gui/NullIcon.java b/src/main/java/com/unicenta/data/gui/NullIcon.java
new file mode 100644
index 0000000..1599c9d
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/NullIcon.java
@@ -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 .
+
+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) {
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/gui/TableRendererBasic.java b/src/main/java/com/unicenta/data/gui/TableRendererBasic.java
new file mode 100644
index 0000000..925180f
--- /dev/null
+++ b/src/main/java/com/unicenta/data/gui/TableRendererBasic.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/BaseSentence.java b/src/main/java/com/unicenta/data/loader/BaseSentence.java
new file mode 100644
index 0000000..1993f2e
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/BaseSentence.java
@@ -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 .
+
+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;
+ }
+ }
+
+ }
diff --git a/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java b/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java
new file mode 100644
index 0000000..4e18085
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java
@@ -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 .
+
+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;
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/BatchSentence.java b/src/main/java/com/unicenta/data/loader/BatchSentence.java
new file mode 100644
index 0000000..8eb9d7f
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/BatchSentence.java
@@ -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 .
+
+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 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);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java b/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java
new file mode 100644
index 0000000..0027584
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java
@@ -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 .
+
+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);
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java b/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java
new file mode 100644
index 0000000..b0ea0e2
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java
@@ -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 .
+
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/CompanyDetails.java b/src/main/java/com/unicenta/data/loader/CompanyDetails.java
new file mode 100644
index 0000000..71c0ce0
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/CompanyDetails.java
@@ -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 .
+
+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;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/unicenta/data/loader/ComparatorCreator.java b/src/main/java/com/unicenta/data/loader/ComparatorCreator.java
new file mode 100644
index 0000000..b760a10
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/ComparatorCreator.java
@@ -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 .
+
+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);
+}
diff --git a/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java b/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java
new file mode 100644
index 0000000..e179cb4
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java
@@ -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 .
+
+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;
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataField.java b/src/main/java/com/unicenta/data/loader/DataField.java
new file mode 100644
index 0000000..ddf1ce8
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataField.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataParams.java b/src/main/java/com/unicenta/data/loader/DataParams.java
new file mode 100644
index 0000000..68f33e8
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataParams.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataRead.java b/src/main/java/com/unicenta/data/loader/DataRead.java
new file mode 100644
index 0000000..a80fa96
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataRead.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataResultSet.java b/src/main/java/com/unicenta/data/loader/DataResultSet.java
new file mode 100644
index 0000000..cca22f3
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataResultSet.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataWrite.java b/src/main/java/com/unicenta/data/loader/DataWrite.java
new file mode 100644
index 0000000..606d6bb
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataWrite.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/DataWriteUtils.java b/src/main/java/com/unicenta/data/loader/DataWriteUtils.java
new file mode 100644
index 0000000..faaa098
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/DataWriteUtils.java
@@ -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 .
+
+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();
+ }
+ }
diff --git a/src/main/java/com/unicenta/data/loader/Datas.java b/src/main/java/com/unicenta/data/loader/Datas.java
new file mode 100644
index 0000000..81db461
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/Datas.java
@@ -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 .
+
+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();
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/IKeyGetter.java b/src/main/java/com/unicenta/data/loader/IKeyGetter.java
new file mode 100644
index 0000000..f24cc1b
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/IKeyGetter.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public interface IKeyGetter {
+
+ /**
+ *
+ * @param value
+ * @return
+ */
+ public Object getKey(Object value);
+}
diff --git a/src/main/java/com/unicenta/data/loader/IKeyed.java b/src/main/java/com/unicenta/data/loader/IKeyed.java
new file mode 100644
index 0000000..b7f7431
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/IKeyed.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+/**
+ *
+ * @author adrianromero
+ * Created on 27 de febrero de 2007, 22:08
+ *
+ */
+public interface IKeyed {
+
+ /**
+ *
+ * @return
+ */
+ public Object getKey();
+}
diff --git a/src/main/java/com/unicenta/data/loader/IRenderString.java b/src/main/java/com/unicenta/data/loader/IRenderString.java
new file mode 100644
index 0000000..f656c8f
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/IRenderString.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public interface IRenderString {
+
+ /**
+ *
+ * @param value
+ * @return
+ */
+ public String getRenderString(Object value);
+}
diff --git a/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java b/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java
new file mode 100644
index 0000000..6d17064
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/ImageUtils.java b/src/main/java/com/unicenta/data/loader/ImageUtils.java
new file mode 100644
index 0000000..ab9cbef
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/ImageUtils.java
@@ -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 .
+
+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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/ImportSentence.java b/src/main/java/com/unicenta/data/loader/ImportSentence.java
new file mode 100644
index 0000000..0c96b4f
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/ImportSentence.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/JDBCSentence.java b/src/main/java/com/unicenta/data/loader/JDBCSentence.java
new file mode 100644
index 0000000..f399909
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/JDBCSentence.java
@@ -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 .
+
+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.
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java b/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java
new file mode 100644
index 0000000..3f63b95
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java
@@ -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 .
+
+
+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;
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java b/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java
new file mode 100644
index 0000000..b0c78fe
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java
@@ -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 .
+
+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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java b/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java
new file mode 100644
index 0000000..444c98c
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java
@@ -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 .
+
+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]];
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/LocalRes.java b/src/main/java/com/unicenta/data/loader/LocalRes.java
new file mode 100644
index 0000000..5d8fa67
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/LocalRes.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/MetaSentence.java b/src/main/java/com/unicenta/data/loader/MetaSentence.java
new file mode 100644
index 0000000..20b3abd
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/MetaSentence.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/NormalBuilder.java b/src/main/java/com/unicenta/data/loader/NormalBuilder.java
new file mode 100644
index 0000000..9c1dbc4
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/NormalBuilder.java
@@ -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 .
+
+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
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/PreparedSentence.java b/src/main/java/com/unicenta/data/loader/PreparedSentence.java
new file mode 100644
index 0000000..4d870c1
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/PreparedSentence.java
@@ -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 .
+
+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;
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/QBFBuilder.java b/src/main/java/com/unicenta/data/loader/QBFBuilder.java
new file mode 100644
index 0000000..621b18b
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/QBFBuilder.java
@@ -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 .
+
+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();
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java b/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java
new file mode 100644
index 0000000..34cd421
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java
@@ -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 .
+
+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);
+}
diff --git a/src/main/java/com/unicenta/data/loader/RenderStringBasic.java b/src/main/java/com/unicenta/data/loader/RenderStringBasic.java
new file mode 100644
index 0000000..3e905d8
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/RenderStringBasic.java
@@ -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 .
+
+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();
+ }
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceEnum.java b/src/main/java/com/unicenta/data/loader/SentenceEnum.java
new file mode 100644
index 0000000..158c898
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceEnum.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceExec.java b/src/main/java/com/unicenta/data/loader/SentenceExec.java
new file mode 100644
index 0000000..c12f57b
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceExec.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java b/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java
new file mode 100644
index 0000000..4443b0b
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java b/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java
new file mode 100644
index 0000000..dfc164c
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java
@@ -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 .
+
+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 t = new Transaction(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;
+}
+
diff --git a/src/main/java/com/unicenta/data/loader/SentenceFind.java b/src/main/java/com/unicenta/data/loader/SentenceFind.java
new file mode 100644
index 0000000..c18e880
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceFind.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceList.java b/src/main/java/com/unicenta/data/loader/SentenceList.java
new file mode 100644
index 0000000..edd7ab0
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceList.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java b/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java
new file mode 100644
index 0000000..8d4847b
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SequenceForDerby.java b/src/main/java/com/unicenta/data/loader/SequenceForDerby.java
new file mode 100644
index 0000000..719f1c7
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SequenceForDerby.java
@@ -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 .
+
+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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java b/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java
new file mode 100644
index 0000000..b6d2092
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java
@@ -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 .
+
+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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java b/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java
new file mode 100644
index 0000000..30202e6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java
@@ -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();
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializableBuilder.java b/src/main/java/com/unicenta/data/loader/SerializableBuilder.java
new file mode 100644
index 0000000..a3e8003
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializableBuilder.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public interface SerializableBuilder {
+
+ /**
+ *
+ * @return
+ */
+ public SerializableRead createNew();
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializableRead.java b/src/main/java/com/unicenta/data/loader/SerializableRead.java
new file mode 100644
index 0000000..2a5e706
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializableRead.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializableWrite.java b/src/main/java/com/unicenta/data/loader/SerializableWrite.java
new file mode 100644
index 0000000..05c45cb
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializableWrite.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerRead.java b/src/main/java/com/unicenta/data/loader/SerializerRead.java
new file mode 100644
index 0000000..5a981f6
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerRead.java
@@ -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 .
+
+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;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java b/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java
new file mode 100644
index 0000000..ecabb83
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java
@@ -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 .
+
+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;
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java b/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java
new file mode 100644
index 0000000..c403ca5
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java
@@ -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 .
+
+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;
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java b/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java
new file mode 100644
index 0000000..9ea2561
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadClass.java b/src/main/java/com/unicenta/data/loader/SerializerReadClass.java
new file mode 100644
index 0000000..13e64ef
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadClass.java
@@ -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 .
+
+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;
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadDate.java b/src/main/java/com/unicenta/data/loader/SerializerReadDate.java
new file mode 100644
index 0000000..eafada8
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadDate.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java b/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java
new file mode 100644
index 0000000..359961a
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadImage.java b/src/main/java/com/unicenta/data/loader/SerializerReadImage.java
new file mode 100644
index 0000000..9b01377
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadImage.java
@@ -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 .
+
+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);
+ }
+
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java b/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java
new file mode 100644
index 0000000..ad990aa
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadString.java b/src/main/java/com/unicenta/data/loader/SerializerReadString.java
new file mode 100644
index 0000000..2730d82
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadString.java
@@ -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 .
+
+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);
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java b/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java
new file mode 100644
index 0000000..3c18f82
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java
@@ -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 .
+
+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;
+ }
+ }
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerWrite.java b/src/main/java/com/unicenta/data/loader/SerializerWrite.java
new file mode 100644
index 0000000..7e1f21e
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerWrite.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+import com.unicenta.basic.BasicException;
+
+/**
+ *
+ * @author JG uniCenta
+ * @param
+ */
+public interface SerializerWrite {
+
+ /**
+ *
+ * @param dp
+ * @param obj
+ * @throws BasicException
+ */
+ public void writeValues(DataWrite dp, T obj) throws BasicException;
+}
diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java b/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java
new file mode 100644
index 0000000..8a36fd3
--- /dev/null
+++ b/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java
@@ -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 .
+
+package com.unicenta.data.loader;
+
+import com.unicenta.basic.BasicException;
+
+/**
+ *
+ * @author JG uniCenta
+ */
+public class SerializerWriteBasic implements SerializerWrite