From a2d88048b9749afc0202f1da7978bc17578c384c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginb=C3=BChl?= Date: Sat, 3 Dec 2016 13:11:47 +0100 Subject: [PATCH 01/23] Update CHANGELOG.md --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3ae044e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Change Log + +## [3.92.0](https://github.com/lugipfupf/tokuPOS/releases/tag/3.92.0https://github.com/lugipfupf/tokuPOS/compare/3.91.3...3.92.0) (2016-12-03) +[Full Changelog](https://github.com/lugipfupf/tokuPOS/compare/3.91.3...3.92.0) + +- Ability to sync product ids with barcode text field +- Copy values when creating a new product +- Minor ui adjustments +- Improved german translation and swiss localization + +## [3.91.3](https://github.com/lugipfupf/tokuPOS/releases/tag/3.91.3) (2015-12-19) + +**Initial Release** + +Initial release was forked off [unicentaPos](https://sourceforge.net/projects/unicentaopos/) 3.91.3. Unfortunately no commit log is available since source was only accessible through zip. From 93d660c2be800e841eb098e37ec5df6feb6d1f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginb=C3=BChl?= Date: Sat, 3 Dec 2016 13:12:10 +0100 Subject: [PATCH 02/23] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ae044e..998391e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [3.92.0](https://github.com/lugipfupf/tokuPOS/releases/tag/3.92.0https://github.com/lugipfupf/tokuPOS/compare/3.91.3...3.92.0) (2016-12-03) +## [3.92.0](https://github.com/lugipfupf/tokuPOS/releases/tag/3.92.0) (2016-12-03) [Full Changelog](https://github.com/lugipfupf/tokuPOS/compare/3.91.3...3.92.0) - Ability to sync product ids with barcode text field From 390ed666ab11913437cc3485b18b66f4987c0fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sun, 4 Dec 2016 15:12:30 +0100 Subject: [PATCH 03/23] renamed readme --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..52c850f --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +tokuPOS +========= +This is just a basic readme. More might come eventually. + +About +----- +tokuPOS is an open source POS system based on OpenbravoPOS, which has been forked many times. This version has been forked off UnicentaPOS 3.91.3. +It incorporates some changes and additions as requested by a small fashion retail shop in Switzerland: + +- Swiss coins and bills +- some minor hard coded ui adjustments +- ability to sync product reference and barcode +- corrected and improved translations + +Who can use it? +--------------- +Anyone, it's open source. + +Installation +------------ +So far, no installer build will be provided. Just clone this repository and build it using Netbeans. + +I need something done +--------------------- +I'm doing this just for myself during my spare time. If you need something done, you have three choices: + +- Do it yourself and file a pull request. +- Fork this repository and be your own master. +- Ask someone else \ No newline at end of file From 449166c313e2284ec14849bffaafd8cb13de6890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Thu, 1 Dec 2016 14:01:05 +0100 Subject: [PATCH 04/23] pmt37: csv import basic setup --- .../pos/imports/CustomerImportPanel.java | 14 ++++++ .../pos/imports/ProductsImportPanel.java | 44 +++++++++++++++++++ .../com/openbravo/pos/templates/Menu.Root.txt | 2 + .../pos/templates/Role.Administrator.xml | 2 + .../openbravo/pos/templates/Role.Manager.xml | 2 + src/main/resources/pos_messages.properties | 2 + 6 files changed, 66 insertions(+) create mode 100644 src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java create mode 100644 src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java diff --git a/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java new file mode 100644 index 0000000..d748847 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.openbravo.pos.imports; + +/** + * + * @author highway + */ +public class CustomerImportPanel { + +} diff --git a/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java b/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java new file mode 100644 index 0000000..3283703 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.openbravo.pos.imports; + +import com.openbravo.data.user.EditorRecord; +import com.openbravo.data.user.ListProvider; +import com.openbravo.data.user.SaveProvider; +import com.openbravo.pos.panels.JPanelTable; + +/** + * + * @author highway + */ +public class ProductsImportPanel extends JPanelTable { + + @Override + protected void init() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public EditorRecord getEditor() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ListProvider getListProvider() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public SaveProvider getSaveProvider() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getTitle() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt b/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt index 99fd161..4431cac 100755 --- a/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt +++ b/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt @@ -131,6 +131,8 @@ group = menu.addGroup("Menu.Backoffice"); submenu = group.addSubmenu("/com/openbravo/images/utilities.png", "Menu.Tools", "com.openbravo.pos.imports.JPanelCSV"); submenu.addTitle("Menu.Import"); submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVImport", "com.openbravo.pos.imports.JPanelCSVImport"); + submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVProductsImport", "com.openbravo.pos.imports.ProductsImportPanel"); + submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVCustomerImport", "com.openbravo.pos.imports.CustomerImportPanel"); submenu.addPanel("/com/openbravo/images/database.png", "Menu.CSVReset", "com.openbravo.pos.imports.JPanelCSVCleardb"); submenu.addTitle("Menu.Import.Reports"); submenu.addPanel("/com/openbravo/images/reports.png", "Menu.UpdatedPrices", "/com/openbravo/reports/updatedprices.bs"); diff --git a/src/main/resources/com/openbravo/pos/templates/Role.Administrator.xml b/src/main/resources/com/openbravo/pos/templates/Role.Administrator.xml index 15a6202..17e6693 100755 --- a/src/main/resources/com/openbravo/pos/templates/Role.Administrator.xml +++ b/src/main/resources/com/openbravo/pos/templates/Role.Administrator.xml @@ -144,6 +144,8 @@ + + diff --git a/src/main/resources/com/openbravo/pos/templates/Role.Manager.xml b/src/main/resources/com/openbravo/pos/templates/Role.Manager.xml index 279a64e..93d705b 100755 --- a/src/main/resources/com/openbravo/pos/templates/Role.Manager.xml +++ b/src/main/resources/com/openbravo/pos/templates/Role.Manager.xml @@ -145,6 +145,8 @@ + + diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index 38fb584..2590b77 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -57,7 +57,9 @@ Menu.Auxiliar=Auxiliary products Menu.Backoffice=Administration Menu.BarcodeSheet=Labels: Barcode Menu.Breaks=Breaks +Menu.CSVCustomerImport=Import Customers Menu.CSVImport=Import CSV File +Menu.CSVProductsImport=Import Products Menu.CSVReset=Clear Import Database Log Menu.CashFlow=Cash-Flow Menu.CashRegisterLog=Transaction Log From 5d033b43b20702d7208125f75409ff6218d53e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Thu, 1 Dec 2016 19:18:28 +0100 Subject: [PATCH 05/23] pmt37: created file chooser ui --- .../pos/imports/CustomerImportPanel.java | 14 ---- .../pos/imports/CustomersImportPanel.java | 45 +++++++++++++ .../pos/imports/JFileChooserPanel.form | 67 +++++++++++++++++++ .../pos/imports/JFileChooserPanel.java | 58 ++++++++++++++++ .../com/openbravo/pos/imports/JPanelCSV.form | 28 -------- .../com/openbravo/pos/imports/JPanelCSV.java | 42 ------------ .../com/openbravo/pos/templates/Menu.Root.txt | 2 +- 7 files changed, 171 insertions(+), 85 deletions(-) delete mode 100644 src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java create mode 100644 src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java create mode 100755 src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form create mode 100755 src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java delete mode 100755 src/main/java/com/openbravo/pos/imports/JPanelCSV.form delete mode 100755 src/main/java/com/openbravo/pos/imports/JPanelCSV.java diff --git a/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java deleted file mode 100644 index d748847..0000000 --- a/src/main/java/com/openbravo/pos/imports/CustomerImportPanel.java +++ /dev/null @@ -1,14 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package com.openbravo.pos.imports; - -/** - * - * @author highway - */ -public class CustomerImportPanel { - -} diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java new file mode 100644 index 0000000..5fa463d --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -0,0 +1,45 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.openbravo.pos.imports; + +import com.openbravo.data.user.EditorRecord; +import com.openbravo.data.user.ListProvider; +import com.openbravo.data.user.SaveProvider; +import com.openbravo.pos.panels.JPanelTable; + +/** + * + * @author highway + */ +public class CustomersImportPanel extends JPanelTable { + private JFileChooserPanel jFileChooser; + + @Override + protected void init() { + this.jFileChooser = new JFileChooserPanel(); + } + + @Override + public EditorRecord getEditor() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public ListProvider getListProvider() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public SaveProvider getSaveProvider() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getTitle() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form new file mode 100755 index 0000000..1bf8f83 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form @@ -0,0 +1,67 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java new file mode 100755 index 0000000..1615e95 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java @@ -0,0 +1,58 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.openbravo.pos.imports; + +import com.openbravo.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class JFileChooserPanel extends javax.swing.JPanel { + + /** + * + */ + public JFileChooserPanel() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + lblFile = new javax.swing.JLabel(); + txtFile = new javax.swing.JTextField(); + btnFile = new javax.swing.JButton(); + + setLayout(null); + + lblFile.setText(AppLocal.getIntString("label.csvfile")); // NOI18N + lblFile.setPreferredSize(new java.awt.Dimension(80, 36)); + add(lblFile); + lblFile.setBounds(0, 0, 80, 36); + + txtFile.setLocation(new java.awt.Point(80, 0)); + txtFile.setPreferredSize(new java.awt.Dimension(14, 30)); + add(txtFile); + txtFile.setBounds(80, 0, 480, 36); + + btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N + btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); + add(btnFile); + btnFile.setBounds(560, 0, 64, 36); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnFile; + private javax.swing.JLabel lblFile; + private javax.swing.JTextField txtFile; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSV.form b/src/main/java/com/openbravo/pos/imports/JPanelCSV.form deleted file mode 100755 index 86321ea..0000000 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSV.form +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSV.java b/src/main/java/com/openbravo/pos/imports/JPanelCSV.java deleted file mode 100755 index e46ca6b..0000000 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSV.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.openbravo.pos.imports; - -/** - * - * @author JG uniCenta - */ -public class JPanelCSV extends javax.swing.JPanel { - - /** - * - */ - public JPanelCSV() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) - ); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables -} diff --git a/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt b/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt index 4431cac..e36eb1f 100755 --- a/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt +++ b/src/main/resources/com/openbravo/pos/templates/Menu.Root.txt @@ -132,7 +132,7 @@ group = menu.addGroup("Menu.Backoffice"); submenu.addTitle("Menu.Import"); submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVImport", "com.openbravo.pos.imports.JPanelCSVImport"); submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVProductsImport", "com.openbravo.pos.imports.ProductsImportPanel"); - submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVCustomerImport", "com.openbravo.pos.imports.CustomerImportPanel"); + submenu.addPanel("/com/openbravo/images/import.png", "Menu.CSVCustomerImport", "com.openbravo.pos.imports.CustomersImportPanel"); submenu.addPanel("/com/openbravo/images/database.png", "Menu.CSVReset", "com.openbravo.pos.imports.JPanelCSVCleardb"); submenu.addTitle("Menu.Import.Reports"); submenu.addPanel("/com/openbravo/images/reports.png", "Menu.UpdatedPrices", "/com/openbravo/reports/updatedprices.bs"); From 958a06900e6d2d6fc453bf17baa8276569accb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Fri, 2 Dec 2016 07:50:24 +0100 Subject: [PATCH 06/23] pmt37: added correct license header to recently created files --- .../pos/imports/CustomersImportPanel.java | 21 ++++++++++++------- .../pos/imports/JFileChooserPanel.java | 20 ++++++++++++------ .../pos/imports/ProductsImportPanel.java | 21 ++++++++++++------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 5fa463d..16c0b33 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.openbravo.pos.imports; @@ -10,10 +21,6 @@ import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.panels.JPanelTable; -/** - * - * @author highway - */ public class CustomersImportPanel extends JPanelTable { private JFileChooserPanel jFileChooser; diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java index 1615e95..935c14f 100755 --- a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java +++ b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java @@ -1,15 +1,23 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.openbravo.pos.imports; import com.openbravo.pos.forms.AppLocal; -/** - * - * @author JG uniCenta - */ public class JFileChooserPanel extends javax.swing.JPanel { /** diff --git a/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java b/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java index 3283703..12877fa 100644 --- a/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/ProductsImportPanel.java @@ -1,7 +1,18 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.openbravo.pos.imports; @@ -10,10 +21,6 @@ import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.panels.JPanelTable; -/** - * - * @author highway - */ public class ProductsImportPanel extends JPanelTable { @Override From 5756e1ea97cc0b4af7d21159547d115806c21a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Fri, 2 Dec 2016 13:43:52 +0100 Subject: [PATCH 07/23] stop menu from being set to invisible by default --- src/main/java/com/openbravo/pos/forms/JPrincipalApp.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/openbravo/pos/forms/JPrincipalApp.java b/src/main/java/com/openbravo/pos/forms/JPrincipalApp.java index a91f1e6..3ddad60 100755 --- a/src/main/java/com/openbravo/pos/forms/JPrincipalApp.java +++ b/src/main/java/com/openbravo/pos/forms/JPrincipalApp.java @@ -500,8 +500,6 @@ public void showTask(String sTaskClass) { m_jLastView = m_jMyView; setMenuVisible(getBounds().width > 800); -// JG Added 10 Nov 12 - setMenuVisible(false); showView(sTaskClass); String sTitle = m_jMyView.getTitle(); From 0c3aa59dc7f1ce75411af727054aaa55f462f2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Fri, 2 Dec 2016 13:44:53 +0100 Subject: [PATCH 08/23] pmt37: first visible ui elements, nothing doing anything useful yet --- .../pos/imports/CustomersImportPanel.java | 32 +------ .../pos/imports/JFileChooserPanel.form | 26 +----- .../pos/imports/JFileChooserPanel.java | 8 +- .../openbravo/pos/panels/JPanelImporter.form | 28 ++++++ .../openbravo/pos/panels/JPanelImporter.java | 91 +++++++++++++++++++ src/main/resources/pos_messages.properties | 2 + 6 files changed, 132 insertions(+), 55 deletions(-) create mode 100644 src/main/java/com/openbravo/pos/panels/JPanelImporter.form create mode 100644 src/main/java/com/openbravo/pos/panels/JPanelImporter.java diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 16c0b33..d1abc86 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,37 +16,15 @@ */ package com.openbravo.pos.imports; -import com.openbravo.data.user.EditorRecord; -import com.openbravo.data.user.ListProvider; -import com.openbravo.data.user.SaveProvider; -import com.openbravo.pos.panels.JPanelTable; +import com.openbravo.pos.panels.JPanelImporter; +import com.unicenta.pozapps.forms.AppLocal; -public class CustomersImportPanel extends JPanelTable { - private JFileChooserPanel jFileChooser; - - @Override - protected void init() { - this.jFileChooser = new JFileChooserPanel(); - } - - @Override - public EditorRecord getEditor() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public ListProvider getListProvider() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public SaveProvider getSaveProvider() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } +public class CustomersImportPanel extends JPanelImporter { @Override public String getTitle() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + return AppLocal.getIntString("Menu.Import.Customers"); } + } diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form index 1bf8f83..d9cc652 100755 --- a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form +++ b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form @@ -11,11 +11,11 @@ - + - - + + @@ -27,26 +27,13 @@ - - - - - - - - - + - - - - - @@ -57,11 +44,6 @@ - - - - - diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java index 935c14f..9fc5d53 100755 --- a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java +++ b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java @@ -40,22 +40,18 @@ private void initComponents() { txtFile = new javax.swing.JTextField(); btnFile = new javax.swing.JButton(); - setLayout(null); + setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); lblFile.setText(AppLocal.getIntString("label.csvfile")); // NOI18N lblFile.setPreferredSize(new java.awt.Dimension(80, 36)); add(lblFile); - lblFile.setBounds(0, 0, 80, 36); - txtFile.setLocation(new java.awt.Point(80, 0)); - txtFile.setPreferredSize(new java.awt.Dimension(14, 30)); + txtFile.setPreferredSize(new java.awt.Dimension(400, 30)); add(txtFile); - txtFile.setBounds(80, 0, 480, 36); btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); add(btnFile); - btnFile.setBounds(560, 0, 64, 36); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.form b/src/main/java/com/openbravo/pos/panels/JPanelImporter.form new file mode 100644 index 0000000..fdcf264 --- /dev/null +++ b/src/main/java/com/openbravo/pos/panels/JPanelImporter.form @@ -0,0 +1,28 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelImporter.java new file mode 100644 index 0000000..1a14676 --- /dev/null +++ b/src/main/java/com/openbravo/pos/panels/JPanelImporter.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.panels; + +import com.openbravo.basic.BasicException; +import com.openbravo.pos.forms.AppView; +import com.openbravo.pos.forms.BeanFactoryApp; +import com.openbravo.pos.forms.BeanFactoryException; +import com.openbravo.pos.forms.JPanelView; +import com.openbravo.pos.imports.JFileChooserPanel; +import javax.swing.JComponent; + +/** + * + * @author Beat Luginbühl + */ +public abstract class JPanelImporter extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { + protected AppView appView; + protected JFileChooserPanel fileChooserPanel; + + /** + * Creates new form JPanelImporter + */ + public JPanelImporter() { + initComponents(); + } + + @Override + public void init(AppView app) throws BeanFactoryException { + this.appView = app; + this.fileChooserPanel = new JFileChooserPanel(); + } + + @Override + public void activate() throws BasicException { + this.fileChooserPanel.applyComponentOrientation(getComponentOrientation()); + this.container.add(this.fileChooserPanel, java.awt.BorderLayout.NORTH); + this.fileChooserPanel.setVisible(true); + } + + @Override + public boolean deactivate() { + return true; + } + + @Override + public JComponent getComponent() { + return this; + } + + @Override + public Object getBean() { + return this; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + container = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout()); + + container.setLayout(new java.awt.BorderLayout()); + add(container, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel container; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index 2590b77..aa50d21 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -97,6 +97,8 @@ Menu.ExtendedCashRegisterLog=Transaction Log: Extended Menu.ExtendedSales=Extended Sales Menu.Floors=Floors Menu.Import=CSV Import +Menu.Import.Customers=Import Customers +Menu.Import.Products=Import Products Menu.Import.Reports=CSV Import Reports Menu.InvalidData=Invalid or duplicate data found Menu.Inventory=Inventory From 3bb5beba456b78738e001490118641da7c9d8378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sun, 4 Dec 2016 18:09:35 +0100 Subject: [PATCH 09/23] pmt37: add more ui elements --- .../pos/imports/CustomersImportPanel.java | 8 + .../pos/imports/JFileChooserPanel.form | 49 -- .../pos/imports/JFileChooserPanel.java | 62 -- .../pos/imports/JPanelCSVFileChooser.form | 127 ++++ .../pos/imports/JPanelCSVFileChooser.java | 112 ++++ .../pos/imports/JPanelCustomers.form | 560 ++++++++++++++++++ .../pos/imports/JPanelCustomers.java | 333 +++++++++++ .../openbravo/pos/panels/JPanelImporter.form | 14 +- .../openbravo/pos/panels/JPanelImporter.java | 18 +- src/main/resources/pos_messages.properties | 3 + 10 files changed, 1169 insertions(+), 117 deletions(-) delete mode 100755 src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form delete mode 100755 src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java create mode 100755 src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form create mode 100755 src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java create mode 100644 src/main/java/com/openbravo/pos/imports/JPanelCustomers.form create mode 100644 src/main/java/com/openbravo/pos/imports/JPanelCustomers.java diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index d1abc86..afeb8e0 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,6 +16,8 @@ */ package com.openbravo.pos.imports; +import com.openbravo.pos.forms.AppView; +import com.openbravo.pos.forms.BeanFactoryException; import com.openbravo.pos.panels.JPanelImporter; import com.unicenta.pozapps.forms.AppLocal; @@ -26,5 +28,11 @@ public String getTitle() { return AppLocal.getIntString("Menu.Import.Customers"); } + @Override + public void init(AppView app) throws BeanFactoryException { + super.init(app); + + this.fieldConfigurator = new JPanelCustomers(); + } } diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form deleted file mode 100755 index d9cc652..0000000 --- a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.form +++ /dev/null @@ -1,49 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java b/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java deleted file mode 100755 index 9fc5d53..0000000 --- a/src/main/java/com/openbravo/pos/imports/JFileChooserPanel.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2016 Beat Luginbühl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.openbravo.pos.imports; - -import com.openbravo.pos.forms.AppLocal; - -public class JFileChooserPanel extends javax.swing.JPanel { - - /** - * - */ - public JFileChooserPanel() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - lblFile = new javax.swing.JLabel(); - txtFile = new javax.swing.JTextField(); - btnFile = new javax.swing.JButton(); - - setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); - - lblFile.setText(AppLocal.getIntString("label.csvfile")); // NOI18N - lblFile.setPreferredSize(new java.awt.Dimension(80, 36)); - add(lblFile); - - txtFile.setPreferredSize(new java.awt.Dimension(400, 30)); - add(txtFile); - - btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N - btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); - add(btnFile); - }// //GEN-END:initComponents - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btnFile; - private javax.swing.JLabel lblFile; - private javax.swing.JTextField txtFile; - // End of variables declaration//GEN-END:variables -} diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form new file mode 100755 index 0000000..07742d7 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form @@ -0,0 +1,127 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java new file mode 100755 index 0000000..49be4de --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.imports; + +import com.openbravo.pos.forms.AppLocal; + +public class JPanelCSVFileChooser extends javax.swing.JPanel { + + /** + * + */ + public JPanelCSVFileChooser() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + lblFile = new javax.swing.JLabel(); + txtFile = new javax.swing.JTextField(); + btnFile = new javax.swing.JButton(); + btnRead = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + lblConfig = new javax.swing.JLabel(); + lblDelim = new javax.swing.JLabel(); + txtDelim = new javax.swing.JTextField(); + lblQuote = new javax.swing.JLabel(); + txtQuote = new javax.swing.JTextField(); + + setMaximumSize(new java.awt.Dimension(186, 84)); + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING)); + + lblFile.setText(AppLocal.getIntString("label.csvfile")); // NOI18N + lblFile.setPreferredSize(new java.awt.Dimension(80, 16)); + lblFile.setRequestFocusEnabled(false); + jPanel1.add(lblFile); + + txtFile.setPreferredSize(new java.awt.Dimension(400, 30)); + jPanel1.add(txtFile); + + btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N + btnFile.setToolTipText(AppLocal.getIntString("label.csvfile")); // NOI18N + btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); + jPanel1.add(btnFile); + + btnRead.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N + btnRead.setToolTipText(AppLocal.getIntString("label.csvread")); // NOI18N + btnRead.setPreferredSize(new java.awt.Dimension(64, 32)); + jPanel1.add(btnRead); + + add(jPanel1); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING)); + + lblConfig.setText(AppLocal.getIntString("label.options")); // NOI18N + lblConfig.setPreferredSize(new java.awt.Dimension(80, 16)); + jPanel2.add(lblConfig); + + lblDelim.setText(AppLocal.getIntString("label.csvdelimit")); // NOI18N + jPanel2.add(lblDelim); + + txtDelim.setText(","); + txtDelim.setPreferredSize(new java.awt.Dimension(32, 28)); + jPanel2.add(txtDelim); + + lblQuote.setText(AppLocal.getIntString("label.csvquote")); // NOI18N + jPanel2.add(lblQuote); + + txtQuote.setText("\""); + txtQuote.setPreferredSize(new java.awt.Dimension(32, 28)); + jPanel2.add(txtQuote); + + add(jPanel2); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnFile; + private javax.swing.JButton btnRead; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JLabel lblConfig; + private javax.swing.JLabel lblDelim; + private javax.swing.JLabel lblFile; + private javax.swing.JLabel lblQuote; + private javax.swing.JTextField txtDelim; + private javax.swing.JTextField txtFile; + private javax.swing.JTextField txtQuote; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form new file mode 100644 index 0000000..c6f82bd --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form @@ -0,0 +1,560 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java new file mode 100644 index 0000000..a469e93 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java @@ -0,0 +1,333 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.imports; + +import com.openbravo.pos.forms.AppLocal; + +/** + * + * @author Beat Luginbühl + */ +public class JPanelCustomers extends javax.swing.JPanel { + + /** + * Creates new form JPanelCustomers + */ + public JPanelCustomers() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jLabel1 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox<>(); + jLabel2 = new javax.swing.JLabel(); + jComboBox2 = new javax.swing.JComboBox<>(); + jLabel3 = new javax.swing.JLabel(); + jComboBox3 = new javax.swing.JComboBox<>(); + jLabel4 = new javax.swing.JLabel(); + jComboBox4 = new javax.swing.JComboBox<>(); + jLabel5 = new javax.swing.JLabel(); + jComboBox5 = new javax.swing.JComboBox<>(); + jLabel6 = new javax.swing.JLabel(); + jComboBox6 = new javax.swing.JComboBox<>(); + jLabel7 = new javax.swing.JLabel(); + jComboBox7 = new javax.swing.JComboBox<>(); + jLabel8 = new javax.swing.JLabel(); + jComboBox8 = new javax.swing.JComboBox<>(); + jLabel9 = new javax.swing.JLabel(); + jComboBox9 = new javax.swing.JComboBox<>(); + jLabel11 = new javax.swing.JLabel(); + jComboBox10 = new javax.swing.JComboBox<>(); + jLabel10 = new javax.swing.JLabel(); + jComboBox11 = new javax.swing.JComboBox<>(); + jLabel12 = new javax.swing.JLabel(); + jComboBox12 = new javax.swing.JComboBox<>(); + jLabel13 = new javax.swing.JLabel(); + jComboBox13 = new javax.swing.JComboBox<>(); + jLabel14 = new javax.swing.JLabel(); + jComboBox14 = new javax.swing.JComboBox<>(); + jLabel15 = new javax.swing.JLabel(); + jComboBox15 = new javax.swing.JComboBox<>(); + jLabel16 = new javax.swing.JLabel(); + jComboBox16 = new javax.swing.JComboBox<>(); + jLabel17 = new javax.swing.JLabel(); + jComboBox18 = new javax.swing.JComboBox<>(); + jLabel18 = new javax.swing.JLabel(); + jComboBox17 = new javax.swing.JComboBox<>(); + jLabel19 = new javax.swing.JLabel(); + jComboBox19 = new javax.swing.JComboBox<>(); + jLabel20 = new javax.swing.JLabel(); + jComboBox20 = new javax.swing.JComboBox<>(); + + setLayout(new java.awt.GridBagLayout()); + + jLabel1.setText(AppLocal.getIntString("label.taxid")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + gridBagConstraints.weightx = 0.05; + add(jLabel1, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.weightx = 0.05; + add(jComboBox1, gridBagConstraints); + + jLabel2.setText(AppLocal.getIntString("label.searchkey")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + gridBagConstraints.weightx = 0.05; + add(jLabel2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.weightx = 0.05; + add(jComboBox2, gridBagConstraints); + + jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel3, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 1; + add(jComboBox3, gridBagConstraints); + + jLabel4.setText(AppLocal.getIntString("label.card")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel4, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 1; + add(jComboBox4, gridBagConstraints); + + jLabel5.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel5, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + add(jComboBox5, gridBagConstraints); + + jLabel6.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel6, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + add(jComboBox6, gridBagConstraints); + + jLabel7.setText(AppLocal.getIntString("label.firstname")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 3; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel7, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 3; + add(jComboBox7, gridBagConstraints); + + jLabel8.setText(AppLocal.getIntString("label.firstname")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 3; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel8, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 3; + add(jComboBox8, gridBagConstraints); + + jLabel9.setText(AppLocal.getIntString("label.email")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 4; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel9, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 4; + add(jComboBox9, gridBagConstraints); + + jLabel11.setText(AppLocal.getIntString("label.phone")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 4; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel11, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 4; + add(jComboBox10, gridBagConstraints); + + jLabel10.setText(AppLocal.getIntString("label.phone2")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 5; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel10, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 5; + add(jComboBox11, gridBagConstraints); + + jLabel12.setText(AppLocal.getIntString("label.fax")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 5; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel12, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 5; + add(jComboBox12, gridBagConstraints); + + jLabel13.setText(AppLocal.getIntString("label.address")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 6; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel13, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 6; + add(jComboBox13, gridBagConstraints); + + jLabel14.setText(AppLocal.getIntString("label.address2")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 6; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel14, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 6; + add(jComboBox14, gridBagConstraints); + + jLabel15.setText(AppLocal.getIntString("label.city")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 7; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel15, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 7; + add(jComboBox15, gridBagConstraints); + + jLabel16.setText(AppLocal.getIntString("label.region")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 7; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel16, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 7; + add(jComboBox16, gridBagConstraints); + + jLabel17.setText(AppLocal.getIntString("label.postal")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 8; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel17, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 8; + add(jComboBox18, gridBagConstraints); + + jLabel18.setText(AppLocal.getIntString("label.country")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 8; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel18, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 8; + add(jComboBox17, gridBagConstraints); + + jLabel19.setText(AppLocal.getIntString("label.notes")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 9; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel19, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 9; + add(jComboBox19, gridBagConstraints); + + jLabel20.setText(AppLocal.getIntString("label.visible")); // NOI18N + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 9; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; + add(jLabel20, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 9; + add(jComboBox20, gridBagConstraints); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jComboBox1; + private javax.swing.JComboBox jComboBox10; + private javax.swing.JComboBox jComboBox11; + private javax.swing.JComboBox jComboBox12; + private javax.swing.JComboBox jComboBox13; + private javax.swing.JComboBox jComboBox14; + private javax.swing.JComboBox jComboBox15; + private javax.swing.JComboBox jComboBox16; + private javax.swing.JComboBox jComboBox17; + private javax.swing.JComboBox jComboBox18; + private javax.swing.JComboBox jComboBox19; + private javax.swing.JComboBox jComboBox2; + private javax.swing.JComboBox jComboBox20; + private javax.swing.JComboBox jComboBox3; + private javax.swing.JComboBox jComboBox4; + private javax.swing.JComboBox jComboBox5; + private javax.swing.JComboBox jComboBox6; + private javax.swing.JComboBox jComboBox7; + private javax.swing.JComboBox jComboBox8; + private javax.swing.JComboBox jComboBox9; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.form b/src/main/java/com/openbravo/pos/panels/JPanelImporter.form index fdcf264..aac46ad 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelImporter.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelImporter.form @@ -1,6 +1,6 @@ -
+ @@ -11,6 +11,7 @@ + @@ -23,6 +24,17 @@ + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelImporter.java index 1a14676..44d7120 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelImporter.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelImporter.java @@ -21,8 +21,9 @@ import com.openbravo.pos.forms.BeanFactoryApp; import com.openbravo.pos.forms.BeanFactoryException; import com.openbravo.pos.forms.JPanelView; -import com.openbravo.pos.imports.JFileChooserPanel; +import com.openbravo.pos.imports.JPanelCSVFileChooser; import javax.swing.JComponent; +import javax.swing.JPanel; /** * @@ -30,7 +31,9 @@ */ public abstract class JPanelImporter extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { protected AppView appView; - protected JFileChooserPanel fileChooserPanel; + protected JPanelCSVFileChooser fileChooserPanel; + + protected JPanel fieldConfigurator; /** * Creates new form JPanelImporter @@ -42,14 +45,15 @@ public JPanelImporter() { @Override public void init(AppView app) throws BeanFactoryException { this.appView = app; - this.fileChooserPanel = new JFileChooserPanel(); + this.fileChooserPanel = new JPanelCSVFileChooser(); } @Override public void activate() throws BasicException { this.fileChooserPanel.applyComponentOrientation(getComponentOrientation()); - this.container.add(this.fileChooserPanel, java.awt.BorderLayout.NORTH); - this.fileChooserPanel.setVisible(true); + this.fieldConfigurator.applyComponentOrientation(getComponentOrientation()); + this.toolbar.add(this.fileChooserPanel); + this.container.add(this.fieldConfigurator, java.awt.BorderLayout.CENTER); } @Override @@ -77,15 +81,19 @@ public Object getBean() { private void initComponents() { container = new javax.swing.JPanel(); + toolbar = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); container.setLayout(new java.awt.BorderLayout()); + container.add(toolbar, java.awt.BorderLayout.NORTH); + add(container, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel container; + private javax.swing.JPanel toolbar; // End of variables declaration//GEN-END:variables } diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index aa50d21..0cfb0f8 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -295,6 +295,7 @@ label.csvfile=File label.csvimpostbtn=Import CSV label.csvmissing=Missing Data label.csvnewproducts=New Products +label.csvquote=Quote label.csvpriceupdated=Prices Updated label.csvread=Read Header label.csvrecordsfound=Records Found @@ -380,6 +381,7 @@ label.notes=Notes label.noticketstoclose=No Bills to Close label.nullcategory=(No Category) label.order=Order +label.options=Options label.passwordnew=New Password label.passwordold=Old Password label.passwordrepeat=Repeat Password @@ -690,3 +692,4 @@ label.barcodetype=Barcode label.prodbarcodetype=Barcode Type = label.copyref=Use as barcode +label.Options=jLabel1 From cd46fa4682ed608c68dfc46a1da2baf4ed812eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Tue, 6 Dec 2016 21:58:51 +0100 Subject: [PATCH 10/23] pmt37: import ui almost finished --- .../pos/imports/JPanelCSVFileChooser.form | 239 +++-- .../pos/imports/JPanelCSVFileChooser.java | 32 +- .../pos/imports/JPanelCustomers.form | 926 ++++++++---------- .../pos/imports/JPanelCustomers.java | 504 +++++----- src/main/resources/pos_messages.properties | 1 + 5 files changed, 775 insertions(+), 927 deletions(-) diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form index 07742d7..dfb2168 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form @@ -16,111 +16,154 @@ - + - - - + - + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java index 49be4de..4c541d9 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java @@ -36,20 +36,26 @@ public JPanelCSVFileChooser() { // //GEN-BEGIN:initComponents private void initComponents() { + jPanel3 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); lblFile = new javax.swing.JLabel(); txtFile = new javax.swing.JTextField(); btnFile = new javax.swing.JButton(); btnRead = new javax.swing.JButton(); + jButton1 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); lblConfig = new javax.swing.JLabel(); lblDelim = new javax.swing.JLabel(); txtDelim = new javax.swing.JTextField(); lblQuote = new javax.swing.JLabel(); txtQuote = new javax.swing.JTextField(); + lblRecordsFound = new javax.swing.JLabel(); + txtRecordsFound = new javax.swing.JTextField(); setMaximumSize(new java.awt.Dimension(186, 84)); - setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); + setLayout(new java.awt.BorderLayout()); + + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.PAGE_AXIS)); jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING)); @@ -71,7 +77,12 @@ private void initComponents() { btnRead.setPreferredSize(new java.awt.Dimension(64, 32)); jPanel1.add(btnRead); - add(jPanel1); + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/import.png"))); // NOI18N + jButton1.setToolTipText(AppLocal.getIntString("label.csvimpostbct")); // NOI18N + jButton1.setPreferredSize(new java.awt.Dimension(64, 32)); + jPanel1.add(jButton1); + + jPanel3.add(jPanel1); jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEADING)); @@ -93,20 +104,35 @@ private void initComponents() { txtQuote.setPreferredSize(new java.awt.Dimension(32, 28)); jPanel2.add(txtQuote); - add(jPanel2); + lblRecordsFound.setText(AppLocal.getIntString("label.csvrecordsfound")); // NOI18N + jPanel2.add(lblRecordsFound); + + txtRecordsFound.setEditable(false); + txtRecordsFound.setBackground(new java.awt.Color(204, 204, 204)); + txtRecordsFound.setToolTipText(""); + txtRecordsFound.setPreferredSize(new java.awt.Dimension(60, 28)); + jPanel2.add(txtRecordsFound); + + jPanel3.add(jPanel2); + + add(jPanel3, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; + private javax.swing.JButton jButton1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; private javax.swing.JLabel lblConfig; private javax.swing.JLabel lblDelim; private javax.swing.JLabel lblFile; private javax.swing.JLabel lblQuote; + private javax.swing.JLabel lblRecordsFound; private javax.swing.JTextField txtDelim; private javax.swing.JTextField txtFile; private javax.swing.JTextField txtQuote; + private javax.swing.JTextField txtRecordsFound; // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form index c6f82bd..aa494d3 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form @@ -11,550 +11,392 @@ - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java index a469e93..b062ff6 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java @@ -41,293 +41,229 @@ public JPanelCustomers() { private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; - jLabel1 = new javax.swing.JLabel(); - jComboBox1 = new javax.swing.JComboBox<>(); - jLabel2 = new javax.swing.JLabel(); - jComboBox2 = new javax.swing.JComboBox<>(); - jLabel3 = new javax.swing.JLabel(); - jComboBox3 = new javax.swing.JComboBox<>(); - jLabel4 = new javax.swing.JLabel(); - jComboBox4 = new javax.swing.JComboBox<>(); - jLabel5 = new javax.swing.JLabel(); - jComboBox5 = new javax.swing.JComboBox<>(); - jLabel6 = new javax.swing.JLabel(); - jComboBox6 = new javax.swing.JComboBox<>(); - jLabel7 = new javax.swing.JLabel(); - jComboBox7 = new javax.swing.JComboBox<>(); - jLabel8 = new javax.swing.JLabel(); - jComboBox8 = new javax.swing.JComboBox<>(); - jLabel9 = new javax.swing.JLabel(); - jComboBox9 = new javax.swing.JComboBox<>(); - jLabel11 = new javax.swing.JLabel(); - jComboBox10 = new javax.swing.JComboBox<>(); - jLabel10 = new javax.swing.JLabel(); - jComboBox11 = new javax.swing.JComboBox<>(); - jLabel12 = new javax.swing.JLabel(); - jComboBox12 = new javax.swing.JComboBox<>(); - jLabel13 = new javax.swing.JLabel(); - jComboBox13 = new javax.swing.JComboBox<>(); - jLabel14 = new javax.swing.JLabel(); - jComboBox14 = new javax.swing.JComboBox<>(); - jLabel15 = new javax.swing.JLabel(); - jComboBox15 = new javax.swing.JComboBox<>(); - jLabel16 = new javax.swing.JLabel(); - jComboBox16 = new javax.swing.JComboBox<>(); - jLabel17 = new javax.swing.JLabel(); - jComboBox18 = new javax.swing.JComboBox<>(); - jLabel18 = new javax.swing.JLabel(); - jComboBox17 = new javax.swing.JComboBox<>(); - jLabel19 = new javax.swing.JLabel(); - jComboBox19 = new javax.swing.JComboBox<>(); - jLabel20 = new javax.swing.JLabel(); - jComboBox20 = new javax.swing.JComboBox<>(); - - setLayout(new java.awt.GridBagLayout()); - - jLabel1.setText(AppLocal.getIntString("label.taxid")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - gridBagConstraints.weightx = 0.05; - add(jLabel1, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.weightx = 0.05; - add(jComboBox1, gridBagConstraints); - - jLabel2.setText(AppLocal.getIntString("label.searchkey")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 0; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - gridBagConstraints.weightx = 0.05; - add(jLabel2, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 0; - gridBagConstraints.weightx = 0.05; - add(jComboBox2, gridBagConstraints); - - jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 1; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel3, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 1; - add(jComboBox3, gridBagConstraints); - - jLabel4.setText(AppLocal.getIntString("label.card")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 1; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel4, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 1; - add(jComboBox4, gridBagConstraints); - - jLabel5.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 2; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel5, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 2; - add(jComboBox5, gridBagConstraints); - - jLabel6.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 2; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel6, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 2; - add(jComboBox6, gridBagConstraints); - - jLabel7.setText(AppLocal.getIntString("label.firstname")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 3; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel7, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 3; - add(jComboBox7, gridBagConstraints); - - jLabel8.setText(AppLocal.getIntString("label.firstname")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 3; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel8, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 3; - add(jComboBox8, gridBagConstraints); - - jLabel9.setText(AppLocal.getIntString("label.email")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 4; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel9, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 4; - add(jComboBox9, gridBagConstraints); - - jLabel11.setText(AppLocal.getIntString("label.phone")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 4; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel11, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 4; - add(jComboBox10, gridBagConstraints); - - jLabel10.setText(AppLocal.getIntString("label.phone2")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 5; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel10, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 5; - add(jComboBox11, gridBagConstraints); - - jLabel12.setText(AppLocal.getIntString("label.fax")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 5; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel12, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 5; - add(jComboBox12, gridBagConstraints); - - jLabel13.setText(AppLocal.getIntString("label.address")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 6; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel13, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 6; - add(jComboBox13, gridBagConstraints); - - jLabel14.setText(AppLocal.getIntString("label.address2")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 6; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel14, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 6; - add(jComboBox14, gridBagConstraints); - - jLabel15.setText(AppLocal.getIntString("label.city")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 7; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel15, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 7; - add(jComboBox15, gridBagConstraints); - - jLabel16.setText(AppLocal.getIntString("label.region")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 7; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel16, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 7; - add(jComboBox16, gridBagConstraints); - - jLabel17.setText(AppLocal.getIntString("label.postal")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 8; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel17, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 8; - add(jComboBox18, gridBagConstraints); - - jLabel18.setText(AppLocal.getIntString("label.country")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 8; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel18, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 8; - add(jComboBox17, gridBagConstraints); - - jLabel19.setText(AppLocal.getIntString("label.notes")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 9; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel19, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 9; - add(jComboBox19, gridBagConstraints); - - jLabel20.setText(AppLocal.getIntString("label.visible")); // NOI18N - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 9; - gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; - add(jLabel20, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 9; - add(jComboBox20, gridBagConstraints); + pnlFields = new javax.swing.JPanel(); + lblCard = new javax.swing.JLabel(); + cmbCard = new javax.swing.JComboBox<>(); + chkCardGenerate = new javax.swing.JCheckBox(); + lblDummy = new javax.swing.JLabel(); + lblAccountId = new javax.swing.JLabel(); + cmbAccountId = new javax.swing.JComboBox<>(); + lblSearchKey = new javax.swing.JLabel(); + cmdSearchKey = new javax.swing.JComboBox<>(); + lblFirstName = new javax.swing.JLabel(); + cmbFirstName = new javax.swing.JComboBox<>(); + lblTaxCat = new javax.swing.JLabel(); + cmbTaxCat = new javax.swing.JComboBox<>(); + lblLastName = new javax.swing.JLabel(); + cmbLastName = new javax.swing.JComboBox<>(); + lblCreditLimit = new javax.swing.JLabel(); + cmbCreditLimit = new javax.swing.JComboBox<>(); + lblEmail = new javax.swing.JLabel(); + cmbEmail = new javax.swing.JComboBox<>(); + lblPhone1 = new javax.swing.JLabel(); + cmdPhone1 = new javax.swing.JComboBox<>(); + lblPhone2 = new javax.swing.JLabel(); + cmbPhone2 = new javax.swing.JComboBox<>(); + lblFax = new javax.swing.JLabel(); + cmdFax = new javax.swing.JComboBox<>(); + lblAddress1 = new javax.swing.JLabel(); + cmbAddress1 = new javax.swing.JComboBox<>(); + lblAddress2 = new javax.swing.JLabel(); + cmbAddress2 = new javax.swing.JComboBox<>(); + lblCity = new javax.swing.JLabel(); + cmbCity = new javax.swing.JComboBox<>(); + lblRegion = new javax.swing.JLabel(); + cmbRegion = new javax.swing.JComboBox<>(); + lblZip = new javax.swing.JLabel(); + cmbZip = new javax.swing.JComboBox<>(); + lblCountry = new javax.swing.JLabel(); + cmbCountry = new javax.swing.JComboBox<>(); + lblNotes = new javax.swing.JLabel(); + cmbNotes = new javax.swing.JComboBox<>(); + lblVisible = new javax.swing.JLabel(); + cmbVisible = new javax.swing.JComboBox<>(); + pnlData = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + tblData = new javax.swing.JTable(); + + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); + + pnlFields.setLayout(new java.awt.GridLayout(0, 4, 10, 0)); + + lblCard.setText(AppLocal.getIntString("label.card")); // NOI18N + pnlFields.add(lblCard); + + cmbCard.setEnabled(false); + pnlFields.add(cmbCard); + + chkCardGenerate.setSelected(true); + chkCardGenerate.setText(AppLocal.getIntString("label.generate")); // NOI18N + chkCardGenerate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + chkCardGenerateActionPerformed(evt); + } + }); + pnlFields.add(chkCardGenerate); + pnlFields.add(lblDummy); + + lblAccountId.setText(AppLocal.getIntString("label.taxid")); // NOI18N + pnlFields.add(lblAccountId); + + pnlFields.add(cmbAccountId); + + lblSearchKey.setText(AppLocal.getIntString("label.searchkey")); // NOI18N + pnlFields.add(lblSearchKey); + + pnlFields.add(cmdSearchKey); + + lblFirstName.setText(AppLocal.getIntString("label.firstname")); // NOI18N + pnlFields.add(lblFirstName); + + pnlFields.add(cmbFirstName); + + lblTaxCat.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N + pnlFields.add(lblTaxCat); + + pnlFields.add(cmbTaxCat); + + lblLastName.setText(AppLocal.getIntString("label.lastname")); // NOI18N + pnlFields.add(lblLastName); + + pnlFields.add(cmbLastName); + + lblCreditLimit.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + pnlFields.add(lblCreditLimit); + + pnlFields.add(cmbCreditLimit); + + lblEmail.setText(AppLocal.getIntString("label.email")); // NOI18N + pnlFields.add(lblEmail); + + pnlFields.add(cmbEmail); + + lblPhone1.setText(AppLocal.getIntString("label.phone")); // NOI18N + pnlFields.add(lblPhone1); + + pnlFields.add(cmdPhone1); + + lblPhone2.setText(AppLocal.getIntString("label.phone2")); // NOI18N + pnlFields.add(lblPhone2); + + pnlFields.add(cmbPhone2); + + lblFax.setText(AppLocal.getIntString("label.fax")); // NOI18N + pnlFields.add(lblFax); + + pnlFields.add(cmdFax); + + lblAddress1.setText(AppLocal.getIntString("label.address")); // NOI18N + pnlFields.add(lblAddress1); + + pnlFields.add(cmbAddress1); + + lblAddress2.setText(AppLocal.getIntString("label.address2")); // NOI18N + pnlFields.add(lblAddress2); + + pnlFields.add(cmbAddress2); + + lblCity.setText(AppLocal.getIntString("label.city")); // NOI18N + pnlFields.add(lblCity); + + pnlFields.add(cmbCity); + + lblRegion.setText(AppLocal.getIntString("label.region")); // NOI18N + pnlFields.add(lblRegion); + + pnlFields.add(cmbRegion); + + lblZip.setText(AppLocal.getIntString("label.postal")); // NOI18N + pnlFields.add(lblZip); + + pnlFields.add(cmbZip); + + lblCountry.setText(AppLocal.getIntString("label.country")); // NOI18N + pnlFields.add(lblCountry); + + pnlFields.add(cmbCountry); + + lblNotes.setText(AppLocal.getIntString("label.notes")); // NOI18N + pnlFields.add(lblNotes); + + pnlFields.add(cmbNotes); + + lblVisible.setText(AppLocal.getIntString("label.visible")); // NOI18N + pnlFields.add(lblVisible); + + pnlFields.add(cmbVisible); + + add(pnlFields); + + pnlData.setLayout(new java.awt.BorderLayout()); + + tblData.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + jScrollPane1.setViewportView(tblData); + + pnlData.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + add(pnlData); }// //GEN-END:initComponents + private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCardGenerateActionPerformed + cmbCard.setEnabled(!chkCardGenerate.isSelected()); + }//GEN-LAST:event_chkCardGenerateActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JComboBox jComboBox1; - private javax.swing.JComboBox jComboBox10; - private javax.swing.JComboBox jComboBox11; - private javax.swing.JComboBox jComboBox12; - private javax.swing.JComboBox jComboBox13; - private javax.swing.JComboBox jComboBox14; - private javax.swing.JComboBox jComboBox15; - private javax.swing.JComboBox jComboBox16; - private javax.swing.JComboBox jComboBox17; - private javax.swing.JComboBox jComboBox18; - private javax.swing.JComboBox jComboBox19; - private javax.swing.JComboBox jComboBox2; - private javax.swing.JComboBox jComboBox20; - private javax.swing.JComboBox jComboBox3; - private javax.swing.JComboBox jComboBox4; - private javax.swing.JComboBox jComboBox5; - private javax.swing.JComboBox jComboBox6; - private javax.swing.JComboBox jComboBox7; - private javax.swing.JComboBox jComboBox8; - private javax.swing.JComboBox jComboBox9; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel10; - private javax.swing.JLabel jLabel11; - private javax.swing.JLabel jLabel12; - private javax.swing.JLabel jLabel13; - private javax.swing.JLabel jLabel14; - private javax.swing.JLabel jLabel15; - private javax.swing.JLabel jLabel16; - private javax.swing.JLabel jLabel17; - private javax.swing.JLabel jLabel18; - private javax.swing.JLabel jLabel19; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel20; - private javax.swing.JLabel jLabel3; - private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; - private javax.swing.JLabel jLabel9; + private javax.swing.JCheckBox chkCardGenerate; + private javax.swing.JComboBox cmbAccountId; + private javax.swing.JComboBox cmbAddress1; + private javax.swing.JComboBox cmbAddress2; + private javax.swing.JComboBox cmbCard; + private javax.swing.JComboBox cmbCity; + private javax.swing.JComboBox cmbCountry; + private javax.swing.JComboBox cmbCreditLimit; + private javax.swing.JComboBox cmbEmail; + private javax.swing.JComboBox cmbFirstName; + private javax.swing.JComboBox cmbLastName; + private javax.swing.JComboBox cmbNotes; + private javax.swing.JComboBox cmbPhone2; + private javax.swing.JComboBox cmbRegion; + private javax.swing.JComboBox cmbTaxCat; + private javax.swing.JComboBox cmbVisible; + private javax.swing.JComboBox cmbZip; + private javax.swing.JComboBox cmdFax; + private javax.swing.JComboBox cmdPhone1; + private javax.swing.JComboBox cmdSearchKey; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lblAccountId; + private javax.swing.JLabel lblAddress1; + private javax.swing.JLabel lblAddress2; + private javax.swing.JLabel lblCard; + private javax.swing.JLabel lblCity; + private javax.swing.JLabel lblCountry; + private javax.swing.JLabel lblCreditLimit; + private javax.swing.JLabel lblDummy; + private javax.swing.JLabel lblEmail; + private javax.swing.JLabel lblFax; + private javax.swing.JLabel lblFirstName; + private javax.swing.JLabel lblLastName; + private javax.swing.JLabel lblNotes; + private javax.swing.JLabel lblPhone1; + private javax.swing.JLabel lblPhone2; + private javax.swing.JLabel lblRegion; + private javax.swing.JLabel lblSearchKey; + private javax.swing.JLabel lblTaxCat; + private javax.swing.JLabel lblVisible; + private javax.swing.JLabel lblZip; + private javax.swing.JPanel pnlData; + private javax.swing.JPanel pnlFields; + private javax.swing.JTable tblData; // End of variables declaration//GEN-END:variables } diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index 0cfb0f8..6be31c7 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -343,6 +343,7 @@ label.fontsizelarge=Large Text label.fontsizesmall=Font Size: small label.fontweight=Bold Text label.general=General +label.generate=Generate label.grossprofit=Gross Profit label.image=Image label.inputamount=Input box above keypad From d0b87086ac6493bc8882a9ca158e92d5b548e170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sat, 10 Dec 2016 15:01:57 +0100 Subject: [PATCH 11/23] pmt37: refactored class model --- .../com/openbravo/data/gui/Populator.java | 25 +++++ .../pos/imports/CustomersImportPanel.java | 30 +++--- ...stomers.form => JPanelCustomerFields.form} | 2 +- ...stomers.java => JPanelCustomerFields.java} | 14 ++- .../JPanelCSVFileChooser.form | 3 + .../JPanelCSVFileChooser.java | 18 +++- .../pos/panels/JPanelCsvImporter.java | 42 ++++++++ .../openbravo/pos/panels/JPanelImporter.form | 40 -------- .../openbravo/pos/panels/JPanelImporter.java | 99 ------------------- .../com/openbravo/pos/panels/JPanelTable.form | 6 ++ .../com/openbravo/pos/panels/JPanelTable.java | 4 +- 11 files changed, 123 insertions(+), 160 deletions(-) create mode 100644 src/main/java/com/openbravo/data/gui/Populator.java rename src/main/java/com/openbravo/pos/imports/{JPanelCustomers.form => JPanelCustomerFields.form} (99%) rename src/main/java/com/openbravo/pos/imports/{JPanelCustomers.java => JPanelCustomerFields.java} (96%) rename src/main/java/com/openbravo/pos/{imports => panels}/JPanelCSVFileChooser.form (97%) rename src/main/java/com/openbravo/pos/{imports => panels}/JPanelCSVFileChooser.java (89%) create mode 100644 src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java delete mode 100644 src/main/java/com/openbravo/pos/panels/JPanelImporter.form delete mode 100644 src/main/java/com/openbravo/pos/panels/JPanelImporter.java diff --git a/src/main/java/com/openbravo/data/gui/Populator.java b/src/main/java/com/openbravo/data/gui/Populator.java new file mode 100644 index 0000000..134eef7 --- /dev/null +++ b/src/main/java/com/openbravo/data/gui/Populator.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.data.gui; + +/** + * + * @author Beat Luginbühl + */ +public interface Populator { + public int populate(); +} diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index afeb8e0..5bcfe8b 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,23 +16,29 @@ */ package com.openbravo.pos.imports; -import com.openbravo.pos.forms.AppView; -import com.openbravo.pos.forms.BeanFactoryException; -import com.openbravo.pos.panels.JPanelImporter; +import com.openbravo.data.user.EditorRecord; +import com.openbravo.pos.panels.JPanelCsvImporter; import com.unicenta.pozapps.forms.AppLocal; -public class CustomersImportPanel extends JPanelImporter { +public class CustomersImportPanel extends JPanelCsvImporter { + JPanelCustomerFields fieldConfigurator; + + @Override + protected void init() { + super.init(); + + this.fieldConfigurator = new JPanelCustomerFields(); + this.fieldConfigurator.setComponentOrientation(getComponentOrientation()); + this.container.add(this.fieldConfigurator); + } @Override - public String getTitle() { - return AppLocal.getIntString("Menu.Import.Customers"); + public EditorRecord getEditor() { + return null; } - + @Override - public void init(AppView app) throws BeanFactoryException { - super.init(app); - - this.fieldConfigurator = new JPanelCustomers(); + public String getTitle() { + return AppLocal.getIntString("Menu.CSVCustomerImport"); } - } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form similarity index 99% rename from src/main/java/com/openbravo/pos/imports/JPanelCustomers.form rename to src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form index aa494d3..44d30cf 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.form +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form @@ -1,6 +1,6 @@ -
+ diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java similarity index 96% rename from src/main/java/com/openbravo/pos/imports/JPanelCustomers.java rename to src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java index b062ff6..3757d6a 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomers.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java @@ -16,20 +16,27 @@ */ package com.openbravo.pos.imports; +import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; +import javax.swing.JPanel; /** * * @author Beat Luginbühl */ -public class JPanelCustomers extends javax.swing.JPanel { +public class JPanelCustomerFields extends JPanel implements Populator { /** * Creates new form JPanelCustomers */ - public JPanelCustomers() { + public JPanelCustomerFields() { initComponents(); } + + @Override + public int populate() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } /** * This method is called from within the constructor to initialize the form. @@ -39,7 +46,6 @@ public JPanelCustomers() { @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { - java.awt.GridBagConstraints gridBagConstraints; pnlFields = new javax.swing.JPanel(); lblCard = new javax.swing.JLabel(); @@ -266,4 +272,6 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JPanel pnlFields; private javax.swing.JTable tblData; // End of variables declaration//GEN-END:variables + + } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form similarity index 97% rename from src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form rename to src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form index dfb2168..4e61792 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form @@ -81,6 +81,9 @@ + + + diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java similarity index 89% rename from src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java rename to src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index 4c541d9..de19fe3 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -14,17 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.openbravo.pos.imports; +package com.openbravo.pos.panels; import com.openbravo.pos.forms.AppLocal; public class JPanelCSVFileChooser extends javax.swing.JPanel { - + private final JPanelCsvImporter csvImporter; + /** * */ - public JPanelCSVFileChooser() { + public JPanelCSVFileChooser(JPanelCsvImporter importer) { initComponents(); + + this.csvImporter = importer; } /** @@ -75,6 +78,11 @@ private void initComponents() { btnRead.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N btnRead.setToolTipText(AppLocal.getIntString("label.csvread")); // NOI18N btnRead.setPreferredSize(new java.awt.Dimension(64, 32)); + btnRead.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnReadActionPerformed(evt); + } + }); jPanel1.add(btnRead); jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/import.png"))); // NOI18N @@ -118,6 +126,10 @@ private void initComponents() { add(jPanel3, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents + private void btnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_btnReadActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java new file mode 100644 index 0000000..176db41 --- /dev/null +++ b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.panels; + +/** + * + * @author Beat Luginbühl + */ +public abstract class JPanelCsvImporter extends JPanelTable2 { + protected JPanelCSVFileChooser fileChooserPanel; + + @Override + protected void init() { + startNavigation(); + } + + @Override + protected void startNavigation() { + this.fileChooserPanel = new JPanelCSVFileChooser(this); + this.fileChooserPanel.setComponentOrientation(getComponentOrientation()); + this.toolbar.add(this.fileChooserPanel); + } + + @Override + public boolean deactivate() { + return true; + } +} diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.form b/src/main/java/com/openbravo/pos/panels/JPanelImporter.form deleted file mode 100644 index aac46ad..0000000 --- a/src/main/java/com/openbravo/pos/panels/JPanelImporter.form +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/openbravo/pos/panels/JPanelImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelImporter.java deleted file mode 100644 index 44d7120..0000000 --- a/src/main/java/com/openbravo/pos/panels/JPanelImporter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2016 Beat Luginbühl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.openbravo.pos.panels; - -import com.openbravo.basic.BasicException; -import com.openbravo.pos.forms.AppView; -import com.openbravo.pos.forms.BeanFactoryApp; -import com.openbravo.pos.forms.BeanFactoryException; -import com.openbravo.pos.forms.JPanelView; -import com.openbravo.pos.imports.JPanelCSVFileChooser; -import javax.swing.JComponent; -import javax.swing.JPanel; - -/** - * - * @author Beat Luginbühl - */ -public abstract class JPanelImporter extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { - protected AppView appView; - protected JPanelCSVFileChooser fileChooserPanel; - - protected JPanel fieldConfigurator; - - /** - * Creates new form JPanelImporter - */ - public JPanelImporter() { - initComponents(); - } - - @Override - public void init(AppView app) throws BeanFactoryException { - this.appView = app; - this.fileChooserPanel = new JPanelCSVFileChooser(); - } - - @Override - public void activate() throws BasicException { - this.fileChooserPanel.applyComponentOrientation(getComponentOrientation()); - this.fieldConfigurator.applyComponentOrientation(getComponentOrientation()); - this.toolbar.add(this.fileChooserPanel); - this.container.add(this.fieldConfigurator, java.awt.BorderLayout.CENTER); - } - - @Override - public boolean deactivate() { - return true; - } - - @Override - public JComponent getComponent() { - return this; - } - - @Override - public Object getBean() { - return this; - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - container = new javax.swing.JPanel(); - toolbar = new javax.swing.JPanel(); - - setLayout(new java.awt.BorderLayout()); - - container.setLayout(new java.awt.BorderLayout()); - container.add(toolbar, java.awt.BorderLayout.NORTH); - - add(container, java.awt.BorderLayout.CENTER); - }// //GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel container; - private javax.swing.JPanel toolbar; - // End of variables declaration//GEN-END:variables -} diff --git a/src/main/java/com/openbravo/pos/panels/JPanelTable.form b/src/main/java/com/openbravo/pos/panels/JPanelTable.form index f2727ff..acb29b9 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelTable.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelTable.form @@ -28,6 +28,9 @@ + + + @@ -37,6 +40,9 @@ + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelTable.java b/src/main/java/com/openbravo/pos/panels/JPanelTable.java index 03cceda..377a9fe 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelTable.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelTable.java @@ -268,8 +268,8 @@ private void initComponents() { // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel container; - private javax.swing.JPanel toolbar; + protected javax.swing.JPanel container; + protected javax.swing.JPanel toolbar; // End of variables declaration//GEN-END:variables } From 7f26229d5db3e80d92f0986ae130f897b0d6a5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sun, 11 Dec 2016 17:10:50 +0100 Subject: [PATCH 12/23] pmt37: file choosing logic --- .../pos/panels/JPanelCSVFileChooser.form | 3 ++ .../pos/panels/JPanelCSVFileChooser.java | 53 ++++++++++++++++--- .../pos/panels/JPanelCsvImporter.java | 14 +++++ src/main/resources/pos_messages.properties | 2 + 4 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form index 4e61792..9eb20ae 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form @@ -68,6 +68,9 @@ + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index de19fe3..e629762 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -17,23 +17,41 @@ package com.openbravo.pos.panels; import com.openbravo.pos.forms.AppLocal; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; public class JPanelCSVFileChooser extends javax.swing.JPanel { + + private static final String FILE_FILTER_DESCRIPTION = "CSV Files *.csv"; + private static final String FILE_FILTER = "csv"; + private final JPanelCsvImporter csvImporter; - + private JFileChooser fileChooser; + private File csvFile; + /** * */ public JPanelCSVFileChooser(JPanelCsvImporter importer) { - initComponents(); - this.csvImporter = importer; + + initComponents(); + + FileNameExtensionFilter filter = new FileNameExtensionFilter(FILE_FILTER_DESCRIPTION, FILE_FILTER); + + this.fileChooser = new JFileChooser(); + this.fileChooser.setFileFilter(filter); + this.fileChooser.setMultiSelectionEnabled(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. + * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The + * content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -73,6 +91,11 @@ private void initComponents() { btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N btnFile.setToolTipText(AppLocal.getIntString("label.csvfile")); // NOI18N btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); + btnFile.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFileActionPerformed(evt); + } + }); jPanel1.add(btnFile); btnRead.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N @@ -127,9 +150,25 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }// //GEN-END:initComponents private void btnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadActionPerformed - // TODO add your handling code here: + if (this.txtFile.getText().length() > 0) { + try { + this.csvImporter.readCsvMetaData(new File(this.txtFile.getText())); + } catch (FileNotFoundException ex) { + Logger.getLogger(JPanelCSVFileChooser.class.getName()).log( + Level.WARNING, "{0}: {1}", new Object[]{ex.getMessage(), this.txtFile.getText()} + ); + JOptionPane.showMessageDialog(this, ex.getMessage(), + AppLocal.getIntString("label.error.filenotfound.title"), JOptionPane.ERROR_MESSAGE); + } + } }//GEN-LAST:event_btnReadActionPerformed + private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed + if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + this.txtFile.setText(fileChooser.getSelectedFile().getAbsolutePath()); + } + }//GEN-LAST:event_btnFileActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java index 176db41..38d8d48 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java @@ -16,6 +16,10 @@ */ package com.openbravo.pos.panels; +import com.unicenta.pozapps.forms.AppLocal; +import java.io.File; +import java.io.FileNotFoundException; + /** * * @author Beat Luginbühl @@ -25,6 +29,10 @@ public abstract class JPanelCsvImporter extends JPanelTable2 { @Override protected void init() { + } + + @Override + public void activate() { startNavigation(); } @@ -39,4 +47,10 @@ protected void startNavigation() { public boolean deactivate() { return true; } + + public void readCsvMetaData(File csvFile) throws FileNotFoundException { + if ( ! csvFile.exists()) { + throw new FileNotFoundException(AppLocal.getIntString("label.error.filenotfound.message")); + } + } } diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index 6be31c7..f77f668 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -331,6 +331,8 @@ label.epm.enddate=End Date label.epm.notes=Notes label.epm.startdate=Start Date label.epm.visible=Visible +label.error.filenotfound.title=File not found +label.error.filenotfound.message=The specified path and file cannot be found. label.fax=Fax label.firstname=First Name label.floorid=ID From 381c8c688074678ee72f9532e871713dfc29e248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 12 Dec 2016 17:54:59 +0100 Subject: [PATCH 13/23] pmt37: csv header logic --- .../com/openbravo/data/gui/Populator.java | 4 +- .../pos/imports/CustomersImportPanel.java | 4 -- .../pos/imports/JPanelCSVImport.form | 3 +- .../pos/imports/JPanelCSVImport.java | 3 +- .../pos/imports/JPanelCustomerFields.form | 20 ++++++ .../pos/imports/JPanelCustomerFields.java | 71 ++++++++++++++++--- .../pos/panels/JPanelCSVFileChooser.form | 14 +++- .../pos/panels/JPanelCSVFileChooser.java | 45 ++++++++++-- .../pos/panels/JPanelCsvImporter.java | 34 ++++++++- .../pos/panels/JPanelPopulatable.java | 28 ++++++++ 10 files changed, 198 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java diff --git a/src/main/java/com/openbravo/data/gui/Populator.java b/src/main/java/com/openbravo/data/gui/Populator.java index 134eef7..1e0e73a 100644 --- a/src/main/java/com/openbravo/data/gui/Populator.java +++ b/src/main/java/com/openbravo/data/gui/Populator.java @@ -16,10 +16,12 @@ */ package com.openbravo.data.gui; +import java.util.List; + /** * * @author Beat Luginbühl */ public interface Populator { - public int populate(); + public void populate(List data); } diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 5bcfe8b..7d21c27 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -21,12 +21,8 @@ import com.unicenta.pozapps.forms.AppLocal; public class CustomersImportPanel extends JPanelCsvImporter { - JPanelCustomerFields fieldConfigurator; - @Override protected void init() { - super.init(); - this.fieldConfigurator = new JPanelCustomerFields(); this.fieldConfigurator.setComponentOrientation(getComponentOrientation()); this.container.add(this.fieldConfigurator); diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.form b/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.form index a2478ef..0cf31cd 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.form +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.form @@ -84,7 +84,7 @@ - + @@ -290,7 +290,6 @@ - diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.java b/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.java index d89950a..35e67c1 100755 --- a/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCSVImport.java @@ -799,7 +799,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jComboReference.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N jComboReference.setEnabled(false); jComboReference.setMinimumSize(new java.awt.Dimension(32, 25)); - jComboReference.setOpaque(false); jComboReference.setPreferredSize(new java.awt.Dimension(275, 30)); jComboReference.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { @@ -1304,7 +1303,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(41, Short.MAX_VALUE)) ); }// //GEN-END:initComponents diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form index 44d30cf..20d82be 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form @@ -39,6 +39,7 @@ + @@ -69,6 +70,8 @@ + + @@ -86,6 +89,7 @@ + @@ -103,6 +107,7 @@ + @@ -120,6 +125,7 @@ + @@ -137,6 +143,7 @@ + @@ -154,6 +161,7 @@ + @@ -171,6 +179,7 @@ + @@ -188,6 +197,7 @@ + @@ -205,6 +215,7 @@ + @@ -222,6 +233,7 @@ + @@ -239,6 +251,7 @@ + @@ -256,6 +269,7 @@ + @@ -273,6 +287,7 @@ + @@ -290,6 +305,7 @@ + @@ -307,6 +323,7 @@ + @@ -324,6 +341,7 @@ + @@ -341,6 +359,7 @@ + @@ -358,6 +377,7 @@ + diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java index 3757d6a..57f6d7c 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java @@ -16,32 +16,64 @@ */ package com.openbravo.pos.imports; -import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; -import javax.swing.JPanel; +import com.openbravo.pos.panels.JPanelPopulatable; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JComboBox; /** * * @author Beat Luginbühl */ -public class JPanelCustomerFields extends JPanel implements Populator { +public class JPanelCustomerFields extends JPanelPopulatable { + + private ArrayList combos = new ArrayList<>(); /** * Creates new form JPanelCustomers */ public JPanelCustomerFields() { initComponents(); + + combos.add(cmbCard); + combos.add(cmbAccountId); + combos.add(cmdSearchKey); + combos.add(cmbFirstName); + combos.add(cmbTaxCat); + combos.add(cmbLastName); + combos.add(cmbCreditLimit); + combos.add(cmbEmail); + combos.add(cmdPhone1); + combos.add(cmbPhone2); + combos.add(cmdFax); + combos.add(cmbAddress1); + combos.add(cmbAddress2); + combos.add(cmbCity); + combos.add(cmbRegion); + combos.add(cmbZip); + combos.add(cmbCountry); + combos.add(cmbNotes); + combos.add(cmbVisible); } - + @Override - public int populate() { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public void populate(List data) { + for (JComboBox box : combos) { + box.addItem(""); + for (String header : data) { + box.addItem(header); + } + + if (data.contains(box.getName())) { + box.setSelectedItem(box.getName()); + } + } } /** - * 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. + * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The + * content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -100,6 +132,7 @@ private void initComponents() { pnlFields.add(lblCard); cmbCard.setEnabled(false); + cmbCard.setName("card"); // NOI18N pnlFields.add(cmbCard); chkCardGenerate.setSelected(true); @@ -115,91 +148,110 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblAccountId.setText(AppLocal.getIntString("label.taxid")); // NOI18N pnlFields.add(lblAccountId); + cmbAccountId.setToolTipText(""); + cmbAccountId.setName("id"); // NOI18N pnlFields.add(cmbAccountId); lblSearchKey.setText(AppLocal.getIntString("label.searchkey")); // NOI18N pnlFields.add(lblSearchKey); + cmdSearchKey.setName("search_key"); // NOI18N pnlFields.add(cmdSearchKey); lblFirstName.setText(AppLocal.getIntString("label.firstname")); // NOI18N pnlFields.add(lblFirstName); + cmbFirstName.setName("first_name"); // NOI18N pnlFields.add(cmbFirstName); lblTaxCat.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N pnlFields.add(lblTaxCat); + cmbTaxCat.setName("taxcat"); // NOI18N pnlFields.add(cmbTaxCat); lblLastName.setText(AppLocal.getIntString("label.lastname")); // NOI18N pnlFields.add(lblLastName); + cmbLastName.setName("last_name"); // NOI18N pnlFields.add(cmbLastName); lblCreditLimit.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N pnlFields.add(lblCreditLimit); + cmbCreditLimit.setName("credit_limit"); // NOI18N pnlFields.add(cmbCreditLimit); lblEmail.setText(AppLocal.getIntString("label.email")); // NOI18N pnlFields.add(lblEmail); + cmbEmail.setName("email"); // NOI18N pnlFields.add(cmbEmail); lblPhone1.setText(AppLocal.getIntString("label.phone")); // NOI18N pnlFields.add(lblPhone1); + cmdPhone1.setName("telephone"); // NOI18N pnlFields.add(cmdPhone1); lblPhone2.setText(AppLocal.getIntString("label.phone2")); // NOI18N pnlFields.add(lblPhone2); + cmbPhone2.setName("mobile"); // NOI18N pnlFields.add(cmbPhone2); lblFax.setText(AppLocal.getIntString("label.fax")); // NOI18N pnlFields.add(lblFax); + cmdFax.setName("fax"); // NOI18N pnlFields.add(cmdFax); lblAddress1.setText(AppLocal.getIntString("label.address")); // NOI18N pnlFields.add(lblAddress1); + cmbAddress1.setName("address"); // NOI18N pnlFields.add(cmbAddress1); lblAddress2.setText(AppLocal.getIntString("label.address2")); // NOI18N pnlFields.add(lblAddress2); + cmbAddress2.setName("address2"); // NOI18N pnlFields.add(cmbAddress2); lblCity.setText(AppLocal.getIntString("label.city")); // NOI18N pnlFields.add(lblCity); + cmbCity.setName("city"); // NOI18N pnlFields.add(cmbCity); lblRegion.setText(AppLocal.getIntString("label.region")); // NOI18N pnlFields.add(lblRegion); + cmbRegion.setName("state"); // NOI18N pnlFields.add(cmbRegion); lblZip.setText(AppLocal.getIntString("label.postal")); // NOI18N pnlFields.add(lblZip); + cmbZip.setName("zip"); // NOI18N pnlFields.add(cmbZip); lblCountry.setText(AppLocal.getIntString("label.country")); // NOI18N pnlFields.add(lblCountry); + cmbCountry.setName("country"); // NOI18N pnlFields.add(cmbCountry); lblNotes.setText(AppLocal.getIntString("label.notes")); // NOI18N pnlFields.add(lblNotes); + cmbNotes.setName("comments"); // NOI18N pnlFields.add(cmbNotes); lblVisible.setText(AppLocal.getIntString("label.visible")); // NOI18N pnlFields.add(lblVisible); + cmbVisible.setName("visible"); // NOI18N pnlFields.add(cmbVisible); add(pnlFields); @@ -273,5 +325,4 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JTable tblData; // End of variables declaration//GEN-END:variables - } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form index 9eb20ae..c62cd98 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form @@ -128,11 +128,16 @@ - + + + + + + @@ -143,11 +148,16 @@ - + + + + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index e629762..d416c5d 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -19,16 +19,19 @@ import com.openbravo.pos.forms.AppLocal; import java.io.File; import java.io.FileNotFoundException; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; -public class JPanelCSVFileChooser extends javax.swing.JPanel { +public class JPanelCSVFileChooser extends JPanelPopulatable { private static final String FILE_FILTER_DESCRIPTION = "CSV Files *.csv"; private static final String FILE_FILTER = "csv"; + private static final char CSV_DEFAULT_DELIMITER = ','; + private static final char CSV_DEFAULT_QUOTE = '"'; private final JPanelCsvImporter csvImporter; private JFileChooser fileChooser; @@ -124,15 +127,25 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblDelim.setText(AppLocal.getIntString("label.csvdelimit")); // NOI18N jPanel2.add(lblDelim); - txtDelim.setText(","); + txtDelim.setText(String.valueOf(CSV_DEFAULT_DELIMITER)); txtDelim.setPreferredSize(new java.awt.Dimension(32, 28)); + txtDelim.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + txtDelimKeyTypedHandler(evt); + } + }); jPanel2.add(txtDelim); lblQuote.setText(AppLocal.getIntString("label.csvquote")); // NOI18N jPanel2.add(lblQuote); - txtQuote.setText("\""); + txtQuote.setText(String.valueOf(CSV_DEFAULT_QUOTE)); txtQuote.setPreferredSize(new java.awt.Dimension(32, 28)); + txtQuote.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + txtQuoteKeyTypedHandler(evt); + } + }); jPanel2.add(txtQuote); lblRecordsFound.setText(AppLocal.getIntString("label.csvrecordsfound")); // NOI18N @@ -152,7 +165,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void btnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadActionPerformed if (this.txtFile.getText().length() > 0) { try { - this.csvImporter.readCsvMetaData(new File(this.txtFile.getText())); + if (this.txtDelim.getText().length() < 1) { + this.txtDelim.setText(String.valueOf(CSV_DEFAULT_DELIMITER)); + } + if (this.txtQuote.getText().length() < 1) { + this.txtQuote.setText(String.valueOf(CSV_DEFAULT_QUOTE)); + } + + this.csvImporter.readCsvMetaData(this.txtFile.getText(), this.txtDelim.getText().charAt(0), this.txtQuote.getText().charAt(0)); } catch (FileNotFoundException ex) { Logger.getLogger(JPanelCSVFileChooser.class.getName()).log( Level.WARNING, "{0}: {1}", new Object[]{ex.getMessage(), this.txtFile.getText()} @@ -169,6 +189,18 @@ private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST } }//GEN-LAST:event_btnFileActionPerformed + private void txtDelimKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDelimKeyTypedHandler + if (txtDelim.getText().length() > 0) { + evt.consume(); + } + }//GEN-LAST:event_txtDelimKeyTypedHandler + + private void txtQuoteKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtQuoteKeyTypedHandler + if (txtQuote.getText().length() > 0) { + evt.consume(); + } + }//GEN-LAST:event_txtQuoteKeyTypedHandler + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; @@ -186,4 +218,9 @@ private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST private javax.swing.JTextField txtQuote; private javax.swing.JTextField txtRecordsFound; // End of variables declaration//GEN-END:variables + + @Override + public void populate(List data) { + this.txtRecordsFound.setText(data.get(0).toString()); + } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java index 38d8d48..0cfec8b 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java @@ -16,9 +16,17 @@ */ package com.openbravo.pos.panels; +import com.csvreader.CsvReader; +import com.openbravo.pos.customers.DataLogicCustomers; +import com.openbravo.pos.imports.JPanelCustomerFields; import com.unicenta.pozapps.forms.AppLocal; import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -26,6 +34,7 @@ */ public abstract class JPanelCsvImporter extends JPanelTable2 { protected JPanelCSVFileChooser fileChooserPanel; + protected JPanelPopulatable fieldConfigurator; @Override protected void init() { @@ -48,9 +57,28 @@ public boolean deactivate() { return true; } - public void readCsvMetaData(File csvFile) throws FileNotFoundException { - if ( ! csvFile.exists()) { - throw new FileNotFoundException(AppLocal.getIntString("label.error.filenotfound.message")); + public void readCsvMetaData(String csvFileName, char delimiter, char quote) throws FileNotFoundException { + CsvReader csvReader = new CsvReader(csvFileName); + csvReader.setDelimiter(delimiter); + csvReader.setTextQualifier(quote); + + try { + csvReader.readHeaders(); + String[] headers = csvReader.getHeaders(); + + int recordCount = 0; + while (csvReader.skipRecord()) { + recordCount++; + } + ArrayList recordCountList = new ArrayList<>(); + ArrayList headerList = new ArrayList<>(); + recordCountList.add(String.valueOf(recordCount)); + headerList.addAll(Arrays.asList(headers)); + + this.fileChooserPanel.populate(recordCountList); + this.fieldConfigurator.populate(headerList); + } catch (IOException ex) { + Logger.getLogger(JPanelCsvImporter.class.getName()).log(Level.SEVERE, null, ex); } } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java new file mode 100644 index 0000000..3a845b1 --- /dev/null +++ b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.panels; + +import com.openbravo.data.gui.Populator; +import javax.swing.JPanel; + +/** + * + * @author Beat Luginbühl + */ +public abstract class JPanelPopulatable extends JPanel implements Populator { + +} From fea26b06e80b6dee15b854b3f19a6f3072c33a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Tue, 13 Dec 2016 22:57:23 +0100 Subject: [PATCH 14/23] pmt37: replace weird calls with handy lambdas --- pom.xml | 4 +-- .../com/openbravo/data/gui/Populator.java | 7 ++--- .../pos/imports/JPanelCustomerFields.java | 30 ++++++++++++------- .../pos/panels/JPanelCSVFileChooser.java | 17 +++++++---- .../pos/panels/JPanelCsvImporter.java | 8 ++--- .../pos/panels/JPanelPopulatable.java | 21 +++++++++++-- 6 files changed, 59 insertions(+), 28 deletions(-) diff --git a/pom.xml b/pom.xml index 49428a1..6fcf5cd 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,8 @@ jar UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/src/main/java/com/openbravo/data/gui/Populator.java b/src/main/java/com/openbravo/data/gui/Populator.java index 1e0e73a..5f5dfe1 100644 --- a/src/main/java/com/openbravo/data/gui/Populator.java +++ b/src/main/java/com/openbravo/data/gui/Populator.java @@ -16,12 +16,11 @@ */ package com.openbravo.data.gui; -import java.util.List; - /** * * @author Beat Luginbühl */ -public interface Populator { - public void populate(List data); +@FunctionalInterface +public interface Populator { + public void populate(T data); } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java index 57f6d7c..e93ff20 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java @@ -16,10 +16,10 @@ */ package com.openbravo.pos.imports; +import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; import java.util.ArrayList; -import java.util.List; import javax.swing.JComboBox; /** @@ -58,17 +58,27 @@ public JPanelCustomerFields() { } @Override - public void populate(List data) { - for (JComboBox box : combos) { - box.addItem(""); - for (String header : data) { - box.addItem(header); - } - - if (data.contains(box.getName())) { - box.setSelectedItem(box.getName()); + public Populator> getPopulator() { + return headerList -> { + for (JComboBox box : this.combos) { + box.addItem(""); + for (String header : headerList) { + box.addItem(header); + } + + if (headerList.contains(box.getName())) { + box.setSelectedItem(box.getName()); + } } + }; + } + + @Override + public boolean deactivate() { + for (JComboBox box : this.combos) { + box.removeAllItems(); } + return true; } /** diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index d416c5d..3f10ae1 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -16,10 +16,9 @@ */ package com.openbravo.pos.panels; +import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; -import java.io.File; import java.io.FileNotFoundException; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; @@ -34,8 +33,7 @@ public class JPanelCSVFileChooser extends JPanelPopulatable { private static final char CSV_DEFAULT_QUOTE = '"'; private final JPanelCsvImporter csvImporter; - private JFileChooser fileChooser; - private File csvFile; + private final JFileChooser fileChooser; /** * @@ -220,7 +218,14 @@ private void txtQuoteKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:e // End of variables declaration//GEN-END:variables @Override - public void populate(List data) { - this.txtRecordsFound.setText(data.get(0).toString()); + public Populator getPopulator() { + return recordCount -> this.txtRecordsFound.setText(String.valueOf(recordCount)); + } + + @Override + public boolean deactivate() { + this.txtFile.setText(""); + this.txtRecordsFound.setText(""); + return true; } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java index 0cfec8b..755f6f9 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java @@ -54,6 +54,8 @@ protected void startNavigation() { @Override public boolean deactivate() { + this.fieldConfigurator.deactivate(); + this.fileChooserPanel.deactivate(); return true; } @@ -70,13 +72,11 @@ public void readCsvMetaData(String csvFileName, char delimiter, char quote) thro while (csvReader.skipRecord()) { recordCount++; } - ArrayList recordCountList = new ArrayList<>(); ArrayList headerList = new ArrayList<>(); - recordCountList.add(String.valueOf(recordCount)); headerList.addAll(Arrays.asList(headers)); - this.fileChooserPanel.populate(recordCountList); - this.fieldConfigurator.populate(headerList); + this.fileChooserPanel.getPopulator().populate(recordCount); + this.fieldConfigurator.getPopulator().populate(headerList); } catch (IOException ex) { Logger.getLogger(JPanelCsvImporter.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java index 3a845b1..dc44bba 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java @@ -16,13 +16,30 @@ */ package com.openbravo.pos.panels; +import com.openbravo.basic.BasicException; import com.openbravo.data.gui.Populator; +import com.openbravo.pos.forms.JPanelView; +import javax.swing.JComponent; import javax.swing.JPanel; /** * * @author Beat Luginbühl */ -public abstract class JPanelPopulatable extends JPanel implements Populator { - +public abstract class JPanelPopulatable extends JPanel implements JPanelView { + public abstract Populator getPopulator(); + + @Override + public String getTitle() { + return ""; + } + + @Override + public void activate() throws BasicException { + } + + @Override + public JComponent getComponent() { + return this; + } } From 082f519d78b0caab01fe90dd5982438f4fec4936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sun, 18 Dec 2016 22:42:26 +0100 Subject: [PATCH 15/23] pmt37: prepare for final feature implementation --- .../JPanelCustomerFields.form | 33 -------- .../JPanelCustomerFields.java | 24 +----- .../pos/customers/JPanelCustomerList.form | 46 +++++++++++ .../pos/customers/JPanelCustomerList.java | 79 +++++++++++++++++++ .../pos/imports/CustomersImportPanel.java | 7 +- .../pos/panels/JPanelCsvImporter.java | 7 +- 6 files changed, 137 insertions(+), 59 deletions(-) rename src/main/java/com/openbravo/pos/{imports => customers}/JPanelCustomerFields.form (92%) rename src/main/java/com/openbravo/pos/{imports => customers}/JPanelCustomerFields.java (94%) create mode 100644 src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form create mode 100644 src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form similarity index 92% rename from src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form rename to src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form index 20d82be..b69352d 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.form +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form @@ -385,38 +385,5 @@ - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java similarity index 94% rename from src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java rename to src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java index e93ff20..c414437 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.openbravo.pos.imports; +package com.openbravo.pos.customers; import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; @@ -130,9 +130,6 @@ private void initComponents() { cmbNotes = new javax.swing.JComboBox<>(); lblVisible = new javax.swing.JLabel(); cmbVisible = new javax.swing.JComboBox<>(); - pnlData = new javax.swing.JPanel(); - jScrollPane1 = new javax.swing.JScrollPane(); - tblData = new javax.swing.JTable(); setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.PAGE_AXIS)); @@ -265,22 +262,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { pnlFields.add(cmbVisible); add(pnlFields); - - pnlData.setLayout(new java.awt.BorderLayout()); - - tblData.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - - }, - new String [] { - - } - )); - jScrollPane1.setViewportView(tblData); - - pnlData.add(jScrollPane1, java.awt.BorderLayout.CENTER); - - add(pnlData); }// //GEN-END:initComponents private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkCardGenerateActionPerformed @@ -309,7 +290,6 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JComboBox cmdFax; private javax.swing.JComboBox cmdPhone1; private javax.swing.JComboBox cmdSearchKey; - private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel lblAccountId; private javax.swing.JLabel lblAddress1; private javax.swing.JLabel lblAddress2; @@ -330,9 +310,7 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JLabel lblTaxCat; private javax.swing.JLabel lblVisible; private javax.swing.JLabel lblZip; - private javax.swing.JPanel pnlData; private javax.swing.JPanel pnlFields; - private javax.swing.JTable tblData; // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form new file mode 100644 index 0000000..f1d496a --- /dev/null +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form @@ -0,0 +1,46 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java new file mode 100644 index 0000000..597036b --- /dev/null +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.customers; + +import com.openbravo.data.gui.Populator; +import com.openbravo.pos.panels.JPanelPopulatable; +import java.util.ArrayList; + +/** + * + * @author Beat Luginbühl + */ +public class JPanelCustomerList extends JPanelPopulatable { + + /** + * Creates new form JPanelItemList + */ + public JPanelCustomerList() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The + * content of this method is always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + tblData = new javax.swing.JTable(); + + setLayout(new java.awt.BorderLayout()); + + tblData.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + jScrollPane1.setViewportView(tblData); + + add(jScrollPane1, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + @Override + public Populator> getPopulator() { + return (ArrayList customerList) -> { + System.out.println("POPULATING LIST"); + }; + } + + @Override + public boolean deactivate() { + return true; + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable tblData; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 7d21c27..6f04c66 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,7 +16,9 @@ */ package com.openbravo.pos.imports; +import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.data.user.EditorRecord; +import com.openbravo.pos.customers.JPanelCustomerList; import com.openbravo.pos.panels.JPanelCsvImporter; import com.unicenta.pozapps.forms.AppLocal; @@ -25,7 +27,10 @@ public class CustomersImportPanel extends JPanelCsvImporter { protected void init() { this.fieldConfigurator = new JPanelCustomerFields(); this.fieldConfigurator.setComponentOrientation(getComponentOrientation()); - this.container.add(this.fieldConfigurator); + this.itemList = new JPanelCustomerList(); + this.itemList.setComponentOrientation(getComponentOrientation()); + this.container.add(this.fieldConfigurator, java.awt.BorderLayout.CENTER); + this.container.add(this.itemList, java.awt.BorderLayout.SOUTH); } @Override diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java index 755f6f9..33edea2 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java @@ -17,8 +17,9 @@ package com.openbravo.pos.panels; import com.csvreader.CsvReader; +import com.openbravo.pos.customers.CustomerInfoExt; import com.openbravo.pos.customers.DataLogicCustomers; -import com.openbravo.pos.imports.JPanelCustomerFields; +import com.openbravo.pos.customers.JPanelCustomerFields; import com.unicenta.pozapps.forms.AppLocal; import java.io.File; import java.io.FileNotFoundException; @@ -35,6 +36,7 @@ public abstract class JPanelCsvImporter extends JPanelTable2 { protected JPanelCSVFileChooser fileChooserPanel; protected JPanelPopulatable fieldConfigurator; + protected JPanelPopulatable itemList; @Override protected void init() { @@ -50,12 +52,13 @@ protected void startNavigation() { this.fileChooserPanel = new JPanelCSVFileChooser(this); this.fileChooserPanel.setComponentOrientation(getComponentOrientation()); this.toolbar.add(this.fileChooserPanel); - } + } @Override public boolean deactivate() { this.fieldConfigurator.deactivate(); this.fileChooserPanel.deactivate(); + this.itemList.deactivate(); return true; } From f1b115fce89c5dfa6147816d7ff5abe81a7ae1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Tue, 20 Dec 2016 22:47:24 +0100 Subject: [PATCH 16/23] pmt37: add tablemodel --- .../pos/customers/JPanelCustomerList.form | 5 +- .../pos/customers/JPanelCustomerList.java | 114 ++++++++++++++++-- .../pos/imports/CustomersImportPanel.java | 1 - .../pos/imports/ImportException.java | 27 +++++ .../JPanelCsvImporter.java | 27 +++-- .../pos/panels/JPanelCSVFileChooser.form | 7 +- .../pos/panels/JPanelCSVFileChooser.java | 31 ++++- 7 files changed, 186 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/openbravo/pos/imports/ImportException.java rename src/main/java/com/openbravo/pos/{panels => imports}/JPanelCsvImporter.java (77%) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form index f1d496a..a5688c8 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.form @@ -11,6 +11,7 @@ + @@ -29,8 +30,8 @@ - -
+ + diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index 597036b..7aeb811 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -18,13 +18,22 @@ import com.openbravo.data.gui.Populator; import com.openbravo.pos.panels.JPanelPopulatable; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.table.AbstractTableModel; /** * * @author Beat Luginbühl */ public class JPanelCustomerList extends JPanelPopulatable { + private final CustomerListModel model = new CustomerListModel(); /** * Creates new form JPanelItemList @@ -46,14 +55,7 @@ private void initComponents() { setLayout(new java.awt.BorderLayout()); - tblData.setModel(new javax.swing.table.DefaultTableModel( - new Object [][] { - - }, - new String [] { - - } - )); + tblData.setModel(model); jScrollPane1.setViewportView(tblData); add(jScrollPane1, java.awt.BorderLayout.CENTER); @@ -62,7 +64,22 @@ private void initComponents() { @Override public Populator> getPopulator() { return (ArrayList customerList) -> { - System.out.println("POPULATING LIST"); + CustomerInfoExt cust1 = new CustomerInfoExt(null); + CustomerInfoExt cust2 = new CustomerInfoExt("1234"); + cust1.setFirstname("Yasmine"); + cust1.setLastname("Willi"); + cust2.setCard("blah"); + cust2.setFirstname("Beat"); + cust2.setLastname("Luginbühl"); + + CustomerListItem item1 = new CustomerListItem(cust1, cust1.getId() != null); + CustomerListItem item2= new CustomerListItem(cust2, cust2.getId() != null); + + ArrayList items = new ArrayList<>(); + items.add(item1); + items.add(item2); + + this.model.setData(items); }; } @@ -76,4 +93,83 @@ public boolean deactivate() { private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable tblData; // End of variables declaration//GEN-END:variables + + private class CustomerListModel extends AbstractTableModel { + private ArrayList customerList = new ArrayList<>(); + private final HashMap colNames = new HashMap<>(); + private final HashMap colTypes = new HashMap<>(); + + public CustomerListModel() { + colNames.put(0, "Card"); + colNames.put(1, "Firstname"); + colNames.put(2, "Lastname"); + + colTypes.put(0, String.class); + colTypes.put(1, String.class); + colTypes.put(2, String.class); + } + + public void setData(ArrayList customers) { + this.customerList = customers; + + fireTableDataChanged(); + } + + @Override + public String getColumnName(int column) { + return this.colNames.get(column); + } + + @Override + public Class getColumnClass(int col) { + return this.colTypes.get(col); + } + + @Override + public int getRowCount() { + return customerList.size(); + } + + @Override + public int getColumnCount() { + return colNames.size(); + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + MethodHandles.Lookup lookup = MethodHandles.lookup(); + try { + // probably pretty inefficient... + MethodHandle mh = lookup.findVirtual(CustomerInfoExt.class, "get" + colNames.get(columnIndex), MethodType.methodType(this.colTypes.get(columnIndex))); + return mh.invoke(this.customerList.get(rowIndex).getCustomer()); + } catch (NoSuchFieldException ex) { + Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + } catch (Throwable ex) { + Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + } + + return null; + } + + } + + private class CustomerListItem { + private CustomerInfoExt customer; + private boolean isExisting = false; + + public CustomerListItem(CustomerInfoExt customerInfoExt, boolean isExisting) { + this.customer = customerInfoExt; + this.isExisting = isExisting; + } + + public CustomerInfoExt getCustomer() { + return customer; + } + + public boolean isIsExisting() { + return isExisting; + } + } } diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 6f04c66..5eafd03 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -19,7 +19,6 @@ import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.data.user.EditorRecord; import com.openbravo.pos.customers.JPanelCustomerList; -import com.openbravo.pos.panels.JPanelCsvImporter; import com.unicenta.pozapps.forms.AppLocal; public class CustomersImportPanel extends JPanelCsvImporter { diff --git a/src/main/java/com/openbravo/pos/imports/ImportException.java b/src/main/java/com/openbravo/pos/imports/ImportException.java new file mode 100644 index 0000000..6ee0bb9 --- /dev/null +++ b/src/main/java/com/openbravo/pos/imports/ImportException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 Beat Luginbühl + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.openbravo.pos.imports; + +/** + * + * @author Beat Luginbühl + */ +public class ImportException extends RuntimeException { + public ImportException(String message) { + super(message); + } +} diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java similarity index 77% rename from src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java rename to src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java index 33edea2..e00acae 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java @@ -14,12 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package com.openbravo.pos.panels; +package com.openbravo.pos.imports; import com.csvreader.CsvReader; import com.openbravo.pos.customers.CustomerInfoExt; import com.openbravo.pos.customers.DataLogicCustomers; import com.openbravo.pos.customers.JPanelCustomerFields; +import com.openbravo.pos.panels.JPanelCSVFileChooser; +import com.openbravo.pos.panels.JPanelPopulatable; +import com.openbravo.pos.panels.JPanelTable2; import com.unicenta.pozapps.forms.AppLocal; import java.io.File; import java.io.FileNotFoundException; @@ -38,6 +41,8 @@ public abstract class JPanelCsvImporter extends JPanelTable2 { protected JPanelPopulatable fieldConfigurator; protected JPanelPopulatable itemList; + private CsvReader csvReader; + @Override protected void init() { } @@ -63,16 +68,16 @@ public boolean deactivate() { } public void readCsvMetaData(String csvFileName, char delimiter, char quote) throws FileNotFoundException { - CsvReader csvReader = new CsvReader(csvFileName); - csvReader.setDelimiter(delimiter); - csvReader.setTextQualifier(quote); + this.csvReader = new CsvReader(csvFileName); + this.csvReader.setDelimiter(delimiter); + this.csvReader.setTextQualifier(quote); try { - csvReader.readHeaders(); - String[] headers = csvReader.getHeaders(); + this.csvReader.readHeaders(); + String[] headers = this.csvReader.getHeaders(); int recordCount = 0; - while (csvReader.skipRecord()) { + while (this.csvReader.skipRecord()) { recordCount++; } ArrayList headerList = new ArrayList<>(); @@ -84,4 +89,12 @@ public void readCsvMetaData(String csvFileName, char delimiter, char quote) thro Logger.getLogger(JPanelCsvImporter.class.getName()).log(Level.SEVERE, null, ex); } } + + public void readCsvData() throws FileNotFoundException { + if (this.csvReader == null) { + throw new ImportException("No csv etadata present"); + } + + this.itemList.getPopulator().populate(new ArrayList()); + } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form index c62cd98..9668072 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form @@ -80,6 +80,7 @@ + @@ -88,7 +89,7 @@ - + @@ -96,10 +97,14 @@ + + + + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index 3f10ae1..cafc4c9 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -16,6 +16,7 @@ */ package com.openbravo.pos.panels; +import com.openbravo.pos.imports.JPanelCsvImporter; import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; import java.io.FileNotFoundException; @@ -64,7 +65,7 @@ private void initComponents() { txtFile = new javax.swing.JTextField(); btnFile = new javax.swing.JButton(); btnRead = new javax.swing.JButton(); - jButton1 = new javax.swing.JButton(); + btnReadData = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); lblConfig = new javax.swing.JLabel(); lblDelim = new javax.swing.JLabel(); @@ -101,6 +102,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { btnRead.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N btnRead.setToolTipText(AppLocal.getIntString("label.csvread")); // NOI18N + btnRead.setEnabled(false); btnRead.setPreferredSize(new java.awt.Dimension(64, 32)); btnRead.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -109,10 +111,16 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jPanel1.add(btnRead); - jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/import.png"))); // NOI18N - jButton1.setToolTipText(AppLocal.getIntString("label.csvimpostbct")); // NOI18N - jButton1.setPreferredSize(new java.awt.Dimension(64, 32)); - jPanel1.add(jButton1); + btnReadData.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/import.png"))); // NOI18N + btnReadData.setToolTipText(AppLocal.getIntString("label.csvimpostbct")); // NOI18N + btnReadData.setEnabled(false); + btnReadData.setPreferredSize(new java.awt.Dimension(64, 32)); + btnReadData.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnReadDataActionPerformed(evt); + } + }); + jPanel1.add(btnReadData); jPanel3.add(jPanel1); @@ -178,12 +186,15 @@ private void btnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST JOptionPane.showMessageDialog(this, ex.getMessage(), AppLocal.getIntString("label.error.filenotfound.title"), JOptionPane.ERROR_MESSAGE); } + + this.btnReadData.setEnabled(true); } }//GEN-LAST:event_btnReadActionPerformed private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { this.txtFile.setText(fileChooser.getSelectedFile().getAbsolutePath()); + this.btnRead.setEnabled(true); } }//GEN-LAST:event_btnFileActionPerformed @@ -199,10 +210,18 @@ private void txtQuoteKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:e } }//GEN-LAST:event_txtQuoteKeyTypedHandler + private void btnReadDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadDataActionPerformed + try { + this.csvImporter.readCsvData(); + } catch (FileNotFoundException ex) { + Logger.getLogger(JPanelCSVFileChooser.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_btnReadDataActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; - private javax.swing.JButton jButton1; + private javax.swing.JButton btnReadData; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; From 2290752cb9b3eb8528d3db49ce57f877a6901190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Sun, 5 Feb 2017 19:16:24 +0100 Subject: [PATCH 17/23] pmt37: complete csv reading --- .../pos/customers/JPanelCustomerFields.form | 6 +- .../pos/customers/JPanelCustomerFields.java | 65 +++++--- .../pos/customers/JPanelCustomerList.java | 139 ++++++++++++------ .../pos/imports/JPanelCsvImporter.java | 61 ++++++-- .../pos/panels/JPanelCSVFileChooser.java | 2 +- .../pos/panels/JPanelPopulatable.java | 9 ++ src/main/resources/pos_messages.properties | 2 + 7 files changed, 209 insertions(+), 75 deletions(-) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form index b69352d..aaa01a5 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.form @@ -84,7 +84,7 @@ - + @@ -192,7 +192,7 @@ - + @@ -228,7 +228,7 @@ - + diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java index c414437..99fdf63 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java @@ -20,6 +20,7 @@ import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; import java.util.ArrayList; +import java.util.HashMap; import javax.swing.JComboBox; /** @@ -27,6 +28,8 @@ * @author Beat Luginbühl */ public class JPanelCustomerFields extends JPanelPopulatable { + + public static String CARD_GENERATE = "GENERATE"; private ArrayList combos = new ArrayList<>(); @@ -38,15 +41,15 @@ public JPanelCustomerFields() { combos.add(cmbCard); combos.add(cmbAccountId); - combos.add(cmdSearchKey); + combos.add(cmbSearchKey); combos.add(cmbFirstName); combos.add(cmbTaxCat); combos.add(cmbLastName); combos.add(cmbCreditLimit); combos.add(cmbEmail); - combos.add(cmdPhone1); + combos.add(cmbPhone1); combos.add(cmbPhone2); - combos.add(cmdFax); + combos.add(cmbFax); combos.add(cmbAddress1); combos.add(cmbAddress2); combos.add(cmbCity); @@ -56,7 +59,33 @@ public JPanelCustomerFields() { combos.add(cmbNotes); combos.add(cmbVisible); } - + + @Override + public HashMap getConfig() { + HashMap config = new HashMap<>(); + + config.put("card", chkCardGenerate.isSelected() ? CARD_GENERATE : (String) cmbCard.getSelectedItem()); + config.put("taxid", (String) cmbTaxCat.getSelectedItem()); + config.put("notes", (String) cmbNotes.getSelectedItem()); + config.put("visible", (String) cmbVisible.getSelectedItem()); + config.put("firstname", (String) cmbFirstName.getSelectedItem()); + config.put("lastname", (String) cmbLastName.getSelectedItem()); + config.put("email", (String) cmbEmail.getSelectedItem()); + config.put("phone", (String) cmbPhone1.getSelectedItem()); + config.put("phone2", (String) cmbPhone2.getSelectedItem()); + config.put("fax", (String) cmbFax.getSelectedItem()); + config.put("address", (String) cmbAddress1.getSelectedItem()); + config.put("address2", (String) cmbAddress2.getSelectedItem()); + config.put("postal", (String) cmbZip.getSelectedItem()); + config.put("city", (String) cmbCity.getSelectedItem()); + config.put("region", (String) cmbRegion.getSelectedItem()); + config.put("country", (String) cmbCountry.getSelectedItem()); + config.put("searchkey", (String) cmbSearchKey.getSelectedItem()); + config.put("taxid", (String) cmbTaxCat.getSelectedItem()); + + return config; + } + @Override public Populator> getPopulator() { return headerList -> { @@ -75,9 +104,9 @@ public Populator> getPopulator() { @Override public boolean deactivate() { - for (JComboBox box : this.combos) { + this.combos.stream().forEach((box) -> { box.removeAllItems(); - } + }); return true; } @@ -97,7 +126,7 @@ private void initComponents() { lblAccountId = new javax.swing.JLabel(); cmbAccountId = new javax.swing.JComboBox<>(); lblSearchKey = new javax.swing.JLabel(); - cmdSearchKey = new javax.swing.JComboBox<>(); + cmbSearchKey = new javax.swing.JComboBox<>(); lblFirstName = new javax.swing.JLabel(); cmbFirstName = new javax.swing.JComboBox<>(); lblTaxCat = new javax.swing.JLabel(); @@ -109,11 +138,11 @@ private void initComponents() { lblEmail = new javax.swing.JLabel(); cmbEmail = new javax.swing.JComboBox<>(); lblPhone1 = new javax.swing.JLabel(); - cmdPhone1 = new javax.swing.JComboBox<>(); + cmbPhone1 = new javax.swing.JComboBox<>(); lblPhone2 = new javax.swing.JLabel(); cmbPhone2 = new javax.swing.JComboBox<>(); lblFax = new javax.swing.JLabel(); - cmdFax = new javax.swing.JComboBox<>(); + cmbFax = new javax.swing.JComboBox<>(); lblAddress1 = new javax.swing.JLabel(); cmbAddress1 = new javax.swing.JComboBox<>(); lblAddress2 = new javax.swing.JLabel(); @@ -162,8 +191,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblSearchKey.setText(AppLocal.getIntString("label.searchkey")); // NOI18N pnlFields.add(lblSearchKey); - cmdSearchKey.setName("search_key"); // NOI18N - pnlFields.add(cmdSearchKey); + cmbSearchKey.setName("search_key"); // NOI18N + pnlFields.add(cmbSearchKey); lblFirstName.setText(AppLocal.getIntString("label.firstname")); // NOI18N pnlFields.add(lblFirstName); @@ -198,8 +227,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblPhone1.setText(AppLocal.getIntString("label.phone")); // NOI18N pnlFields.add(lblPhone1); - cmdPhone1.setName("telephone"); // NOI18N - pnlFields.add(cmdPhone1); + cmbPhone1.setName("telephone"); // NOI18N + pnlFields.add(cmbPhone1); lblPhone2.setText(AppLocal.getIntString("label.phone2")); // NOI18N pnlFields.add(lblPhone2); @@ -210,8 +239,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { lblFax.setText(AppLocal.getIntString("label.fax")); // NOI18N pnlFields.add(lblFax); - cmdFax.setName("fax"); // NOI18N - pnlFields.add(cmdFax); + cmbFax.setName("fax"); // NOI18N + pnlFields.add(cmbFax); lblAddress1.setText(AppLocal.getIntString("label.address")); // NOI18N pnlFields.add(lblAddress1); @@ -279,17 +308,17 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JComboBox cmbCountry; private javax.swing.JComboBox cmbCreditLimit; private javax.swing.JComboBox cmbEmail; + private javax.swing.JComboBox cmbFax; private javax.swing.JComboBox cmbFirstName; private javax.swing.JComboBox cmbLastName; private javax.swing.JComboBox cmbNotes; + private javax.swing.JComboBox cmbPhone1; private javax.swing.JComboBox cmbPhone2; private javax.swing.JComboBox cmbRegion; + private javax.swing.JComboBox cmbSearchKey; private javax.swing.JComboBox cmbTaxCat; private javax.swing.JComboBox cmbVisible; private javax.swing.JComboBox cmbZip; - private javax.swing.JComboBox cmdFax; - private javax.swing.JComboBox cmdPhone1; - private javax.swing.JComboBox cmdSearchKey; private javax.swing.JLabel lblAccountId; private javax.swing.JLabel lblAddress1; private javax.swing.JLabel lblAddress2; diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index 7aeb811..de72ea8 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -17,15 +17,11 @@ package com.openbravo.pos.customers; import com.openbravo.data.gui.Populator; +import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; +import com.openbravo.pos.util.StringUtils; import java.util.ArrayList; import java.util.HashMap; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.table.AbstractTableModel; /** @@ -34,6 +30,7 @@ */ public class JPanelCustomerList extends JPanelPopulatable { private final CustomerListModel model = new CustomerListModel(); + private HashMap config; /** * Creates new form JPanelItemList @@ -62,30 +59,54 @@ private void initComponents() { }// //GEN-END:initComponents @Override - public Populator> getPopulator() { - return (ArrayList customerList) -> { - CustomerInfoExt cust1 = new CustomerInfoExt(null); - CustomerInfoExt cust2 = new CustomerInfoExt("1234"); - cust1.setFirstname("Yasmine"); - cust1.setLastname("Willi"); - cust2.setCard("blah"); - cust2.setFirstname("Beat"); - cust2.setLastname("Luginbühl"); - - CustomerListItem item1 = new CustomerListItem(cust1, cust1.getId() != null); - CustomerListItem item2= new CustomerListItem(cust2, cust2.getId() != null); - - ArrayList items = new ArrayList<>(); - items.add(item1); - items.add(item2); - - this.model.setData(items); + public Populator>> getPopulator() { + return (ArrayList> data) -> { + if (this.config == null) { + throw new IllegalStateException("No config has been set. Don't know how to treat data."); + } + + ArrayList customers = new ArrayList<>(); + + data.forEach((HashMap record) -> { + CustomerInfoExt cust = new CustomerInfoExt(null); + + String card = this.config.get("card").equals("GENERATE") ? StringUtils.getCardNumber() : record.get(this.config.get("card")); + cust.setCard(card); + cust.setFirstname(record.get(this.config.get("firstname"))); + cust.setLastname(record.get(this.config.get("lastname"))); + cust.setTaxid(record.get(this.config.get("lastname"))); + cust.setNotes(record.get(this.config.get("lastname"))); + cust.setVisible(Boolean.parseBoolean(record.get(this.config.get("lastname")))); + cust.setEmail(record.get(this.config.get("email"))); + cust.setPhone(record.get(this.config.get("phone"))); + cust.setPhone2(record.get(this.config.get("phone2"))); + cust.setFax(record.get(this.config.get("fax"))); + cust.setAddress(record.get(this.config.get("address"))); + cust.setAddress2(record.get(this.config.get("address2"))); + cust.setPostal(record.get(this.config.get("postal"))); + cust.setCity(record.get(this.config.get("city"))); + cust.setCountry(record.get(this.config.get("country"))); + cust.setSearchkey(record.get(this.config.get("name"))); + cust.setRegion(record.get(this.config.get("region"))); + + boolean isExisting = false; + boolean doImport = !isExisting; + + customers.add(new CustomerListItem(cust, isExisting, doImport)); + }); + + this.model.setData(customers); }; } + @Override + public void setConfig(HashMap config) { + this.config = config; + } + @Override public boolean deactivate() { - return true; + return this.model.clearData(); } @@ -100,13 +121,23 @@ private class CustomerListModel extends AbstractTableModel { private final HashMap colTypes = new HashMap<>(); public CustomerListModel() { - colNames.put(0, "Card"); - colNames.put(1, "Firstname"); - colNames.put(2, "Lastname"); + colNames.put(0, AppLocal.getIntString("label.import")); + colNames.put(1, AppLocal.getIntString("label.new")); + colNames.put(2, AppLocal.getIntString("label.card")); + colNames.put(3, AppLocal.getIntString("label.firstname")); + colNames.put(4, AppLocal.getIntString("label.lastname")); + colNames.put(5, AppLocal.getIntString("label.address")); + colNames.put(6, AppLocal.getIntString("label.city")); + colNames.put(7, AppLocal.getIntString("label.email")); - colTypes.put(0, String.class); - colTypes.put(1, String.class); + colTypes.put(0, Boolean.class); + colTypes.put(1, Boolean.class); colTypes.put(2, String.class); + colTypes.put(3, String.class); + colTypes.put(4, String.class); + colTypes.put(5, String.class); + colTypes.put(6, String.class); + colTypes.put(7, String.class); } public void setData(ArrayList customers) { @@ -137,31 +168,47 @@ public int getColumnCount() { @Override public Object getValueAt(int rowIndex, int columnIndex) { - MethodHandles.Lookup lookup = MethodHandles.lookup(); - try { - // probably pretty inefficient... - MethodHandle mh = lookup.findVirtual(CustomerInfoExt.class, "get" + colNames.get(columnIndex), MethodType.methodType(this.colTypes.get(columnIndex))); - return mh.invoke(this.customerList.get(rowIndex).getCustomer()); - } catch (NoSuchFieldException ex) { - Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); - } catch (Throwable ex) { - Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + CustomerListItem customer = this.customerList.get(rowIndex); + + switch (columnIndex) { + case 0: + return customer.getDoImport(); + case 1: + return customer.isIsExisting(); + case 2: + return customer.getCustomer().getCard(); + case 3: + return customer.getCustomer().getFirstname(); + case 4: + return customer.getCustomer().getLastname(); + case 5: + return customer.getCustomer().getAddress(); + case 6: + return customer.getCustomer().getCity(); + case 7: + return customer.getCustomer().getEmail(); } return null; } + public boolean clearData() { + this.customerList.clear(); + fireTableDataChanged(); + return this.getRowCount() == 0; + } + } private class CustomerListItem { private CustomerInfoExt customer; private boolean isExisting = false; + private boolean doImport = true; - public CustomerListItem(CustomerInfoExt customerInfoExt, boolean isExisting) { + public CustomerListItem(CustomerInfoExt customerInfoExt, boolean isExisting, boolean doImport) { this.customer = customerInfoExt; this.isExisting = isExisting; + this.doImport = doImport; } public CustomerInfoExt getCustomer() { @@ -171,5 +218,13 @@ public CustomerInfoExt getCustomer() { public boolean isIsExisting() { return isExisting; } + + public void setDoImport(boolean doIt) { + this.doImport = doIt; + } + + public boolean getDoImport() { + return this.doImport; + } } } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java index e00acae..e526a3f 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java @@ -17,18 +17,15 @@ package com.openbravo.pos.imports; import com.csvreader.CsvReader; -import com.openbravo.pos.customers.CustomerInfoExt; -import com.openbravo.pos.customers.DataLogicCustomers; -import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.pos.panels.JPanelCSVFileChooser; import com.openbravo.pos.panels.JPanelPopulatable; import com.openbravo.pos.panels.JPanelTable2; -import com.unicenta.pozapps.forms.AppLocal; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -42,6 +39,10 @@ public abstract class JPanelCsvImporter extends JPanelTable2 { protected JPanelPopulatable itemList; private CsvReader csvReader; + private String csvFileName; + private char csvDelimiter; + private char csvQuote; + private String[] csvHeaders; @Override protected void init() { @@ -68,9 +69,11 @@ public boolean deactivate() { } public void readCsvMetaData(String csvFileName, char delimiter, char quote) throws FileNotFoundException { - this.csvReader = new CsvReader(csvFileName); - this.csvReader.setDelimiter(delimiter); - this.csvReader.setTextQualifier(quote); + this.csvFileName = csvFileName; + this.csvDelimiter = delimiter; + this.csvQuote = quote; + + initCsvReader(); try { this.csvReader.readHeaders(); @@ -85,16 +88,52 @@ public void readCsvMetaData(String csvFileName, char delimiter, char quote) thro this.fileChooserPanel.getPopulator().populate(recordCount); this.fieldConfigurator.getPopulator().populate(headerList); + + this.csvReader.close(); } catch (IOException ex) { Logger.getLogger(JPanelCsvImporter.class.getName()).log(Level.SEVERE, null, ex); } } public void readCsvData() throws FileNotFoundException { - if (this.csvReader == null) { - throw new ImportException("No csv etadata present"); + initCsvReader(); + + ArrayList> data = new ArrayList<>(); + + try { + this.csvReader.readHeaders(); + while (this.csvReader.readRecord()) { + data.add(this.readCsvLine()); + } + } catch (IOException ex) { + Logger.getLogger(JPanelCsvImporter.class.getName()).log(Level.SEVERE, null, ex); + } + + this.itemList.setConfig(this.fieldConfigurator.getConfig()); + this.itemList.getPopulator().populate(data); + } + + private void initCsvReader() throws FileNotFoundException { + if (this.csvFileName == null) { + throw new ImportException("No csv metadata present"); + } + + this.csvReader = new CsvReader(this.csvFileName, this.csvDelimiter, Charset.forName("UTF-8")); + this.csvReader.setTextQualifier(this.csvQuote); + } + + private HashMap readCsvLine() throws IOException { + HashMap data = new HashMap<>(); + + if (this.csvHeaders == null) { + this.csvHeaders = this.csvReader.getHeaders(); + } + String[] values = this.csvReader.getValues(); + + for (int i = 0; i < csvHeaders.length; i++) { + data.put(csvHeaders[i], values[i]); } - this.itemList.getPopulator().populate(new ArrayList()); + return data; } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index cafc4c9..c8e2546 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -50,7 +50,7 @@ public JPanelCSVFileChooser(JPanelCsvImporter importer) { this.fileChooser.setFileFilter(filter); this.fileChooser.setMultiSelectionEnabled(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. diff --git a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java index dc44bba..3155999 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java @@ -19,6 +19,7 @@ import com.openbravo.basic.BasicException; import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.JPanelView; +import java.util.HashMap; import javax.swing.JComponent; import javax.swing.JPanel; @@ -28,6 +29,14 @@ */ public abstract class JPanelPopulatable extends JPanel implements JPanelView { public abstract Populator getPopulator(); + + public HashMap getConfig() { + throw new UnsupportedOperationException("This optional method has to be overriden in order to use it"); + } + + public void setConfig(HashMap config) { + throw new UnsupportedOperationException("This optional method has to be overriden in order to use it"); + } @Override public String getTitle() { diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index f77f668..0883f39 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -348,6 +348,7 @@ label.general=General label.generate=Generate label.grossprofit=Gross Profit label.image=Image +label.import=Import label.inputamount=Input box above keypad label.integer=Integer label.item=Item @@ -379,6 +380,7 @@ label.money=Total label.mooringcreatebtn=Create Ticket label.mooringscreatefor=Create ticket for label.name=Name +label.new=New label.nocashsales=No Sale - Drawer Openings label.notes=Notes label.noticketstoclose=No Bills to Close From 01cc6dfbf61c8189486e09e03dc9bc7daa24b1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 6 Feb 2017 21:02:54 +0100 Subject: [PATCH 18/23] pmt36: make Import checkbox editable --- .../pos/customers/JPanelCustomerList.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index de72ea8..59087b1 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -197,6 +197,21 @@ public boolean clearData() { fireTableDataChanged(); return this.getRowCount() == 0; } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return true; + } + + return false; + } + + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + this.customerList.get(rowIndex).setDoImport((Boolean) aValue); + } + } From eea9fb4854a92043bc469d9ac2e97f385e76a1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 6 Feb 2017 21:35:15 +0100 Subject: [PATCH 19/23] pmt37: refactor ui logic --- .../pos/customers/JPanelCustomerList.java | 4 +- .../pos/panels/JPanelCSVFileChooser.form | 28 ++++-- .../pos/panels/JPanelCSVFileChooser.java | 98 +++++++++++-------- src/main/resources/pos_messages.properties | 3 +- 4 files changed, 82 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index 59087b1..9240d16 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -122,7 +122,7 @@ private class CustomerListModel extends AbstractTableModel { public CustomerListModel() { colNames.put(0, AppLocal.getIntString("label.import")); - colNames.put(1, AppLocal.getIntString("label.new")); + colNames.put(1, AppLocal.getIntString("label.entry_exists")); colNames.put(2, AppLocal.getIntString("label.card")); colNames.put(3, AppLocal.getIntString("label.firstname")); colNames.put(4, AppLocal.getIntString("label.lastname")); @@ -211,8 +211,6 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { public void setValueAt(Object aValue, int rowIndex, int columnIndex) { this.customerList.get(rowIndex).setDoImport((Boolean) aValue); } - - } private class CustomerListItem { diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form index 9668072..413e8cf 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.form @@ -55,6 +55,9 @@ + + + @@ -64,8 +67,11 @@ + + + - + @@ -78,32 +84,38 @@ - + + + + - + - + - + - + + + + - + - + diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index c8e2546..b28a80f 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -22,6 +22,7 @@ import java.io.FileNotFoundException; import java.util.logging.Level; import java.util.logging.Logger; +import javafx.scene.input.KeyCode; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; @@ -65,7 +66,7 @@ private void initComponents() { txtFile = new javax.swing.JTextField(); btnFile = new javax.swing.JButton(); btnRead = new javax.swing.JButton(); - btnReadData = new javax.swing.JButton(); + btnSave = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); lblConfig = new javax.swing.JLabel(); lblDelim = new javax.swing.JLabel(); @@ -88,11 +89,17 @@ private void initComponents() { jPanel1.add(lblFile); txtFile.setPreferredSize(new java.awt.Dimension(400, 30)); + txtFile.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtFileActionPerformed(evt); + } + }); jPanel1.add(txtFile); btnFile.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/fileopen.png"))); // NOI18N btnFile.setToolTipText(AppLocal.getIntString("label.csvfile")); // NOI18N - btnFile.setPreferredSize(new java.awt.Dimension(64, 32)); + btnFile.setMargin(new java.awt.Insets(8, 2, 8, 2)); + btnFile.setPreferredSize(new java.awt.Dimension(52, 40)); btnFile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFileActionPerformed(evt); @@ -101,9 +108,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jPanel1.add(btnFile); btnRead.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N - btnRead.setToolTipText(AppLocal.getIntString("label.csvread")); // NOI18N + btnRead.setToolTipText(AppLocal.getIntString("label.csv")); // NOI18N btnRead.setEnabled(false); - btnRead.setPreferredSize(new java.awt.Dimension(64, 32)); + btnRead.setMargin(new java.awt.Insets(8, 2, 8, 2)); + btnRead.setPreferredSize(new java.awt.Dimension(52, 40)); btnRead.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnReadActionPerformed(evt); @@ -111,16 +119,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); jPanel1.add(btnRead); - btnReadData.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/import.png"))); // NOI18N - btnReadData.setToolTipText(AppLocal.getIntString("label.csvimpostbct")); // NOI18N - btnReadData.setEnabled(false); - btnReadData.setPreferredSize(new java.awt.Dimension(64, 32)); - btnReadData.addActionListener(new java.awt.event.ActionListener() { + btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/filesave.png"))); // NOI18N + btnSave.setToolTipText(AppLocal.getIntString("Button.Save")); // NOI18N + btnSave.setEnabled(false); + btnSave.setMargin(new java.awt.Insets(8, 2, 8, 2)); + btnSave.setPreferredSize(new java.awt.Dimension(52, 40)); + btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - btnReadDataActionPerformed(evt); + btnSaveActionPerformed(evt); } }); - jPanel1.add(btnReadData); + jPanel1.add(btnSave); jPanel3.add(jPanel1); @@ -169,33 +178,20 @@ public void keyTyped(java.awt.event.KeyEvent evt) { }// //GEN-END:initComponents private void btnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadActionPerformed - if (this.txtFile.getText().length() > 0) { - try { - if (this.txtDelim.getText().length() < 1) { - this.txtDelim.setText(String.valueOf(CSV_DEFAULT_DELIMITER)); - } - if (this.txtQuote.getText().length() < 1) { - this.txtQuote.setText(String.valueOf(CSV_DEFAULT_QUOTE)); - } - - this.csvImporter.readCsvMetaData(this.txtFile.getText(), this.txtDelim.getText().charAt(0), this.txtQuote.getText().charAt(0)); - } catch (FileNotFoundException ex) { - Logger.getLogger(JPanelCSVFileChooser.class.getName()).log( - Level.WARNING, "{0}: {1}", new Object[]{ex.getMessage(), this.txtFile.getText()} - ); - JOptionPane.showMessageDialog(this, ex.getMessage(), - AppLocal.getIntString("label.error.filenotfound.title"), JOptionPane.ERROR_MESSAGE); - } - - this.btnReadData.setEnabled(true); + try { + this.csvImporter.readCsvData(); + this.btnSave.setEnabled(true); + } catch (FileNotFoundException ex) { + Logger.getLogger(JPanelCSVFileChooser.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_btnReadActionPerformed private void btnFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFileActionPerformed if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { this.txtFile.setText(fileChooser.getSelectedFile().getAbsolutePath()); - this.btnRead.setEnabled(true); } + + this.readCsvMetaData(); }//GEN-LAST:event_btnFileActionPerformed private void txtDelimKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDelimKeyTypedHandler @@ -210,18 +206,18 @@ private void txtQuoteKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:e } }//GEN-LAST:event_txtQuoteKeyTypedHandler - private void btnReadDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReadDataActionPerformed - try { - this.csvImporter.readCsvData(); - } catch (FileNotFoundException ex) { - Logger.getLogger(JPanelCSVFileChooser.class.getName()).log(Level.SEVERE, null, ex); - } - }//GEN-LAST:event_btnReadDataActionPerformed + private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed + + }//GEN-LAST:event_btnSaveActionPerformed + + private void txtFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFileActionPerformed + this.readCsvMetaData(); + }//GEN-LAST:event_txtFileActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnFile; private javax.swing.JButton btnRead; - private javax.swing.JButton btnReadData; + private javax.swing.JButton btnSave; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; @@ -247,4 +243,28 @@ public boolean deactivate() { this.txtRecordsFound.setText(""); return true; } + + private void readCsvMetaData() { + if (this.txtFile.getText().length() > 0) { + try { + if (this.txtDelim.getText().length() < 1) { + this.txtDelim.setText(String.valueOf(CSV_DEFAULT_DELIMITER)); + } + if (this.txtQuote.getText().length() < 1) { + this.txtQuote.setText(String.valueOf(CSV_DEFAULT_QUOTE)); + } + + this.csvImporter.readCsvMetaData(this.txtFile.getText(), this.txtDelim.getText().charAt(0), this.txtQuote.getText().charAt(0)); + } catch (FileNotFoundException ex) { + Logger.getLogger(JPanelCSVFileChooser.class.getName()).log( + Level.WARNING, "{0}: {1}", new Object[]{ex.getMessage(), this.txtFile.getText()} + ); + JOptionPane.showMessageDialog(this, ex.getMessage(), + AppLocal.getIntString("label.error.filenotfound.title"), JOptionPane.ERROR_MESSAGE); + } + + this.btnRead.setEnabled(true); + this.btnSave.setEnabled(false); + } + } } diff --git a/src/main/resources/pos_messages.properties b/src/main/resources/pos_messages.properties index 0883f39..ed44d36 100755 --- a/src/main/resources/pos_messages.properties +++ b/src/main/resources/pos_messages.properties @@ -297,7 +297,7 @@ label.csvmissing=Missing Data label.csvnewproducts=New Products label.csvquote=Quote label.csvpriceupdated=Prices Updated -label.csvread=Read Header +label.csv=Read Records label.csvrecordsfound=Records Found label.csvresetimport=Reset Import Data label.csvsellingintax=Sell Price includes Tax? @@ -325,6 +325,7 @@ label.dutyname=Tax Name label.dutyrate=Rate label.editline=Edit Line label.email=email +label.entry_exists=Entry exists label.epm.employee=Employee label.epm.employee.id=Employee ID label.epm.enddate=End Date From 29af12c588ab50c5dc6775af25737ea54a533820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 6 Feb 2017 21:56:49 +0100 Subject: [PATCH 20/23] pmt37: remove unnecessary exception --- .../pos/customers/JPanelCustomerFields.java | 5 +++++ .../openbravo/pos/customers/JPanelCustomerList.java | 9 +++++++++ .../openbravo/pos/panels/JPanelCSVFileChooser.java | 13 +++++++++++-- .../com/openbravo/pos/panels/JPanelPopulatable.java | 8 ++------ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java index 99fdf63..ca39695 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java @@ -109,6 +109,8 @@ public boolean deactivate() { }); return true; } + + /** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The @@ -342,4 +344,7 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G private javax.swing.JPanel pnlFields; // End of variables declaration//GEN-END:variables + @Override + public void setConfig(HashMap config) { + } } diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index 9240d16..e724e28 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -16,10 +16,13 @@ */ package com.openbravo.pos.customers; +import com.openbravo.basic.BasicException; import com.openbravo.data.gui.Populator; +import com.openbravo.data.user.EditorRecord; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; import com.openbravo.pos.util.StringUtils; +import java.awt.Component; import java.util.ArrayList; import java.util.HashMap; import javax.swing.table.AbstractTableModel; @@ -58,6 +61,7 @@ private void initComponents() { add(jScrollPane1, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents + @Override public Populator>> getPopulator() { return (ArrayList> data) -> { @@ -98,6 +102,11 @@ public Populator>> getPopulator() { this.model.setData(customers); }; } + + @Override + public HashMap getConfig() { + return null; + } @Override public void setConfig(HashMap config) { diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index b28a80f..43ceb3a 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -16,13 +16,13 @@ */ package com.openbravo.pos.panels; -import com.openbravo.pos.imports.JPanelCsvImporter; import com.openbravo.data.gui.Populator; import com.openbravo.pos.forms.AppLocal; +import com.openbravo.pos.imports.JPanelCsvImporter; import java.io.FileNotFoundException; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; -import javafx.scene.input.KeyCode; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; @@ -267,4 +267,13 @@ private void readCsvMetaData() { this.btnSave.setEnabled(false); } } + + @Override + public HashMap getConfig() { + return null; + } + + @Override + public void setConfig(HashMap config) { + } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java index 3155999..bfc9eb3 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java @@ -30,13 +30,9 @@ public abstract class JPanelPopulatable extends JPanel implements JPanelView { public abstract Populator getPopulator(); - public HashMap getConfig() { - throw new UnsupportedOperationException("This optional method has to be overriden in order to use it"); - } + public abstract HashMap getConfig(); - public void setConfig(HashMap config) { - throw new UnsupportedOperationException("This optional method has to be overriden in order to use it"); - } + public abstract void setConfig(HashMap config); @Override public String getTitle() { From 27e54568371f853b463729f1f8d96a98b0d5a0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 6 Feb 2017 23:40:01 +0100 Subject: [PATCH 21/23] pmt37: save logic working --- .../pos/customers/JPanelCustomerFields.java | 6 ++ .../pos/customers/JPanelCustomerList.java | 83 +++++++++++++++++-- .../pos/imports/CustomersImportPanel.java | 16 ++++ .../pos/imports/JPanelCsvImporter.java | 4 + .../pos/panels/JPanelCSVFileChooser.java | 7 +- .../pos/panels/JPanelPopulatable.java | 4 + 6 files changed, 111 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java index ca39695..a051705 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerFields.java @@ -17,6 +17,7 @@ package com.openbravo.pos.customers; import com.openbravo.data.gui.Populator; +import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; import java.util.ArrayList; @@ -82,6 +83,7 @@ public HashMap getConfig() { config.put("country", (String) cmbCountry.getSelectedItem()); config.put("searchkey", (String) cmbSearchKey.getSelectedItem()); config.put("taxid", (String) cmbTaxCat.getSelectedItem()); + config.put("maxdept", (String) cmbCreditLimit.getSelectedItem()); return config; } @@ -347,4 +349,8 @@ private void chkCardGenerateActionPerformed(java.awt.event.ActionEvent evt) {//G @Override public void setConfig(HashMap config) { } + + @Override + public void saveData(SaveProvider spr) { + } } diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index e724e28..bbdf96a 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -18,13 +18,17 @@ import com.openbravo.basic.BasicException; import com.openbravo.data.gui.Populator; -import com.openbravo.data.user.EditorRecord; +import com.openbravo.data.loader.TableDefinition; +import com.openbravo.data.user.SaveProvider; +import com.openbravo.format.Formats; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.panels.JPanelPopulatable; import com.openbravo.pos.util.StringUtils; -import java.awt.Component; import java.util.ArrayList; import java.util.HashMap; +import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.table.AbstractTableModel; /** @@ -75,12 +79,15 @@ public Populator>> getPopulator() { CustomerInfoExt cust = new CustomerInfoExt(null); String card = this.config.get("card").equals("GENERATE") ? StringUtils.getCardNumber() : record.get(this.config.get("card")); + cust.setCard(card); + cust.setSearchkey(card); cust.setFirstname(record.get(this.config.get("firstname"))); cust.setLastname(record.get(this.config.get("lastname"))); - cust.setTaxid(record.get(this.config.get("lastname"))); - cust.setNotes(record.get(this.config.get("lastname"))); - cust.setVisible(Boolean.parseBoolean(record.get(this.config.get("lastname")))); + cust.setName(record.get(this.config.get("firstname")) + " " + record.get(this.config.get("lastname"))); + cust.setTaxid(record.get(this.config.get("taxid"))); + cust.setNotes(record.get(this.config.get("notes"))); + cust.setVisible(true); cust.setEmail(record.get(this.config.get("email"))); cust.setPhone(record.get(this.config.get("phone"))); cust.setPhone2(record.get(this.config.get("phone2"))); @@ -90,9 +97,18 @@ public Populator>> getPopulator() { cust.setPostal(record.get(this.config.get("postal"))); cust.setCity(record.get(this.config.get("city"))); cust.setCountry(record.get(this.config.get("country"))); - cust.setSearchkey(record.get(this.config.get("name"))); cust.setRegion(record.get(this.config.get("region"))); + Double maxDept = 0d; + if (record.get(this.config.get("maxdept")) != null && record.get(this.config.get("maxdept")).length() > 0) { + try { + maxDept = Double.valueOf(record.get(this.config.get("maxdept"))); + } catch (NumberFormatException ex) { + Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + } + } + cust.setMaxdebt(maxDept); + boolean isExisting = false; boolean doImport = !isExisting; @@ -118,7 +134,54 @@ public boolean deactivate() { return this.model.clearData(); } + @Override + public void saveData(SaveProvider spr) { + this.model.getData().forEach((CustomerListItem item) -> { + Object[] customer = new Object[24]; + try { + if (item.doImport) { + CustomerInfoExt custInfoExt = item.getCustomer(); + + customer[0] = custInfoExt.getId() == null ? UUID.randomUUID().toString() : custInfoExt.getId(); + customer[1] = custInfoExt.getTaxid(); + customer[2] = custInfoExt.getSearchkey(); + customer[3] = custInfoExt.getName(); + customer[4] = custInfoExt.getNotes(); + customer[5] = custInfoExt.isVisible(); + customer[6] = custInfoExt.getCard(); + customer[7] = custInfoExt.getMaxdebt(); + customer[8] = null; + customer[9] = null; + + customer[10] = custInfoExt.getFirstname(); + customer[11] = custInfoExt.getLastname(); + customer[12] = custInfoExt.getEmail(); + customer[13] = custInfoExt.getPhone(); + customer[14] = custInfoExt.getPhone2(); + customer[15] = custInfoExt.getFax(); + + customer[16] = custInfoExt.getAddress(); + customer[17] = custInfoExt.getAddress2(); + customer[18] = custInfoExt.getPostal(); + customer[19] = custInfoExt.getCity(); + customer[20] = custInfoExt.getRegion(); + customer[21] = custInfoExt.getCountry(); + customer[22] = null; + customer[23] = null; + + if (item.isExisting()) { + spr.updateData(customer); + } else { + spr.insertData(customer); + } + } + } catch (BasicException ex) { + Logger.getLogger(JPanelCustomerList.class.getName()).log(Level.SEVERE, null, ex); + } + }); + } + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable tblData; @@ -154,6 +217,10 @@ public void setData(ArrayList customers) { fireTableDataChanged(); } + + public ArrayList getData() { + return this.customerList; + } @Override public String getColumnName(int column) { @@ -183,7 +250,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { case 0: return customer.getDoImport(); case 1: - return customer.isIsExisting(); + return customer.isExisting(); case 2: return customer.getCustomer().getCard(); case 3: @@ -237,7 +304,7 @@ public CustomerInfoExt getCustomer() { return customer; } - public boolean isIsExisting() { + public boolean isExisting() { return isExisting; } diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 5eafd03..6a6a67c 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,14 +16,25 @@ */ package com.openbravo.pos.imports; +import com.openbravo.basic.BasicException; +import com.openbravo.data.loader.SentenceExec; import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.data.user.EditorRecord; +import com.openbravo.data.user.SaveProvider; +import com.openbravo.pos.customers.DataLogicCustomers; import com.openbravo.pos.customers.JPanelCustomerList; import com.unicenta.pozapps.forms.AppLocal; +import java.util.logging.Level; +import java.util.logging.Logger; public class CustomersImportPanel extends JPanelCsvImporter { @Override protected void init() { + DataLogicCustomers dlCustomers = (DataLogicCustomers) app.getBean("com.openbravo.pos.customers.DataLogicCustomers"); + this.tableDef = dlCustomers.getTableCustomers(); + + this.spr = new SaveProvider(this.tableDef, new int[]{0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}); + this.fieldConfigurator = new JPanelCustomerFields(); this.fieldConfigurator.setComponentOrientation(getComponentOrientation()); this.itemList = new JPanelCustomerList(); @@ -41,4 +52,9 @@ public EditorRecord getEditor() { public String getTitle() { return AppLocal.getIntString("Menu.CSVCustomerImport"); } + + @Override + public void saveData() { + this.itemList.saveData(this.spr); + } } diff --git a/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java index e526a3f..6771706 100644 --- a/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java +++ b/src/main/java/com/openbravo/pos/imports/JPanelCsvImporter.java @@ -17,6 +17,7 @@ package com.openbravo.pos.imports; import com.csvreader.CsvReader; +import com.openbravo.data.loader.TableDefinition; import com.openbravo.pos.panels.JPanelCSVFileChooser; import com.openbravo.pos.panels.JPanelPopulatable; import com.openbravo.pos.panels.JPanelTable2; @@ -34,6 +35,7 @@ * @author Beat Luginbühl */ public abstract class JPanelCsvImporter extends JPanelTable2 { + protected TableDefinition tableDef; protected JPanelCSVFileChooser fileChooserPanel; protected JPanelPopulatable fieldConfigurator; protected JPanelPopulatable itemList; @@ -44,6 +46,8 @@ public abstract class JPanelCsvImporter extends JPanelTable2 { private char csvQuote; private String[] csvHeaders; + public abstract void saveData(); + @Override protected void init() { } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java index 43ceb3a..6f8b2c2 100755 --- a/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelCSVFileChooser.java @@ -17,6 +17,7 @@ package com.openbravo.pos.panels; import com.openbravo.data.gui.Populator; +import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.imports.JPanelCsvImporter; import java.io.FileNotFoundException; @@ -207,7 +208,7 @@ private void txtQuoteKeyTypedHandler(java.awt.event.KeyEvent evt) {//GEN-FIRST:e }//GEN-LAST:event_txtQuoteKeyTypedHandler private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed - + this.csvImporter.saveData(); }//GEN-LAST:event_btnSaveActionPerformed private void txtFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFileActionPerformed @@ -276,4 +277,8 @@ public HashMap getConfig() { @Override public void setConfig(HashMap config) { } + + @Override + public void saveData(SaveProvider spr) { + } } diff --git a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java index bfc9eb3..54e9ea2 100644 --- a/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java +++ b/src/main/java/com/openbravo/pos/panels/JPanelPopulatable.java @@ -18,6 +18,7 @@ import com.openbravo.basic.BasicException; import com.openbravo.data.gui.Populator; +import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.forms.JPanelView; import java.util.HashMap; import javax.swing.JComponent; @@ -34,6 +35,8 @@ public abstract class JPanelPopulatable extends JPanel implements JPanelView { public abstract void setConfig(HashMap config); + public abstract void saveData(SaveProvider spr); + @Override public String getTitle() { return ""; @@ -47,4 +50,5 @@ public void activate() throws BasicException { public JComponent getComponent() { return this; } + } From e0cb1bbe22e269ee5c6bdfae604b5c4cb8c835aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Mon, 6 Feb 2017 23:44:48 +0100 Subject: [PATCH 22/23] pmt37: prefix card number with c character for consistency --- .../java/com/openbravo/pos/customers/JPanelCustomerList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java index bbdf96a..e8dca2d 100644 --- a/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java +++ b/src/main/java/com/openbravo/pos/customers/JPanelCustomerList.java @@ -78,7 +78,7 @@ public Populator>> getPopulator() { data.forEach((HashMap record) -> { CustomerInfoExt cust = new CustomerInfoExt(null); - String card = this.config.get("card").equals("GENERATE") ? StringUtils.getCardNumber() : record.get(this.config.get("card")); + String card = this.config.get("card").equals("GENERATE") ? "c" + StringUtils.getCardNumber() : record.get(this.config.get("card")); cust.setCard(card); cust.setSearchkey(card); From 218dc22a5dfa84253886b8af10f8a47fb179e879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20Luginbu=CC=88hl?= Date: Wed, 15 Feb 2017 18:57:40 +0100 Subject: [PATCH 23/23] pmt37: prepare for preliminary release of import feature --- .../pos/customers/DataLogicCustomers.java | 80 +++++++++++++------ .../pos/imports/CustomersImportPanel.java | 6 +- 2 files changed, 55 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java b/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java index 4285b48..26a5a4e 100755 --- a/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java +++ b/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java @@ -24,6 +24,7 @@ import com.openbravo.format.Formats; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.forms.BeanFactoryDataSingle; +import com.openbravo.pos.forms.DataLogicSales; /** * @author JG uniCenta @@ -48,6 +49,36 @@ public class DataLogicCustomers extends BeanFactoryDataSingle { Datas.BOOLEAN, Datas.STRING}; + private static final String[] fields = new String[] + { + "ID", + "TAXID", + "SEARCHKEY", + "NAME", + "NOTES", + "VISIBLE", + "CARD", + "MAXDEBT", + "CURDATE", + "CURDEBT", + "FIRSTNAME", + "LASTNAME", + "EMAIL", + "PHONE", + "PHONE2", + "FAX", + "ADDRESS", + "ADDRESS2", + "POSTAL", + "CITY", + "REGION", + "COUNTRY", + "TAXCATEGORY", + "IMAGE" + }; + + private static String baseSentence; + /** * * @param s @@ -58,31 +89,7 @@ public void init(Session s){ this.s = s; tcustomers = new TableDefinition(s , "CUSTOMERS" - , new String[] { - "ID", - "TAXID", - "SEARCHKEY", - "NAME", - "NOTES", - "VISIBLE", - "CARD", - "MAXDEBT", - "CURDATE", - "CURDEBT", - "FIRSTNAME", - "LASTNAME", - "EMAIL", - "PHONE", - "PHONE2", - "FAX", - "ADDRESS", - "ADDRESS2", - "POSTAL", - "CITY", - "REGION", - "COUNTRY", - "TAXCATEGORY", - "IMAGE" } + , fields , new String[] { "ID", AppLocal.getIntString("label.taxid"), @@ -160,6 +167,14 @@ public void init(Session s){ Formats.NULL } , new int[] {0} ); + + StringBuilder sqlBuilder = new StringBuilder("SELECT "); + for (int i = 0; i < fields.length; i++) { + sqlBuilder.append(fields[i]); + sqlBuilder.append(", "); + } + sqlBuilder.append(" FROM CUSTOMERS"); + this.baseSentence = sqlBuilder.toString(); } // JG 20 Sept 12 extended for Postal - CustomerList list @@ -299,5 +314,18 @@ public int execInTransaction(Object params) throws BasicException { */ public final TableDefinition getTableCustomers() { return tcustomers; - } + } + + public CustomerInfoExt findCustomersBy(String field, Object value) { + + StringBuilder sqlBuilder = new StringBuilder(this.baseSentence); + sqlBuilder.append(" WHERE "); + sqlBuilder.append(field); + sqlBuilder.append(" = ?"); + + PreparedSentence sentence = new PreparedSentence(this.s, sqlBuilder.toString()); + + // will be implemented for next release + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 6a6a67c..7d81edd 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,16 +16,12 @@ */ package com.openbravo.pos.imports; -import com.openbravo.basic.BasicException; -import com.openbravo.data.loader.SentenceExec; -import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.data.user.EditorRecord; import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.customers.DataLogicCustomers; +import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.pos.customers.JPanelCustomerList; import com.unicenta.pozapps.forms.AppLocal; -import java.util.logging.Level; -import java.util.logging.Logger; public class CustomersImportPanel extends JPanelCsvImporter { @Override