5.0 Source Code

Committing 5.0 Source Code
This commit is contained in:
2023-04-06 18:58:04 +01:00
parent 0f3ede77fa
commit 0282345603
1680 changed files with 241310 additions and 0 deletions
@@ -0,0 +1,400 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>
package com.unicenta.pos.forms;
import lombok.extern.slf4j.Slf4j;
import java.io.*;
import java.util.Locale;
import java.util.Properties;
/**
* Creation and Editing of stored settings
*
* @author JG uniCenta
*/
@Slf4j
public class AppConfig implements AppProperties {
private static AppConfig m_instance = null;
private Properties properties;
private File configfile;
/**
* Set configuration array
*
* @param args array strings
*/
public AppConfig(String[] args) {
if (args.length == 0) {
init(getDefaultConfig());
} else {
init(new File(args[0]));
}
}
/**
* unicenta resources file
*
* @param configfile resource file
*/
public AppConfig(File configfile) {
init(configfile);
this.configfile = configfile;
properties = new Properties();
load();
//log.debug("Reading configuration file: {}", configfile.getAbsolutePath());
}
private void init(File configfile) {
this.configfile = configfile;
properties = new Properties();
//log.debug("Reading configuration file: {}", configfile.getAbsolutePath());
}
private File getDefaultConfig() {
return new File(new File(System.getProperty("user.home"))
, AppLocal.APP_ID + ".properties");
}
/**
* Get key pair value from properties resource
*
* @param sKey key pair value
* @return key pair from .properties filename
*/
@Override
public String getProperty(String sKey) {
return properties.getProperty(sKey);
}
/**
* @return Machine name
*/
@Override
public String getHost() {
return getProperty("machine.hostname");
}
/**
* @return .properties filename
*/
@Override
public File getConfigFile() {
return configfile;
}
public String getTicketHeaderLine1() {
return getProperty("tkt.header1");
}
public String getTicketHeaderLine2() {
return getProperty("tkt.header2");
}
public String getTicketHeaderLine3() {
return getProperty("tkt.header3");
}
public String getTicketHeaderLine4() {
return getProperty("tkt.header4");
}
public String getTicketHeaderLine5() {
return getProperty("tkt.header5");
}
public String getTicketHeaderLine6() {
return getProperty("tkt.header6");
}
public String getTicketFooterLine1() {
return getProperty("tkt.footer1");
}
public String getTicketFooterLine2() {
return getProperty("tkt.footer2");
}
public String getTicketFooterLine3() {
return getProperty("tkt.footer3");
}
public String getTicketFooterLine4() {
return getProperty("tkt.footer4");
}
public String getTicketFooterLine5() {
return getProperty("tkt.footer5");
}
public String getTicketFooterLine6() {
return getProperty("tkt.footer6");
}
/**
* Update .properties resource key pair values
*
* @param sKey key pair left side
* @param sValue key pair right side value
*/
public void setProperty(String sKey, String sValue) {
if (sValue == null) {
properties.remove(sKey);
} else {
properties.setProperty(sKey, sValue);
}
}
/**
* Local machine identity
*
* @return Machine name from OS
*/
private String getLocalHostName() {
try {
return java.net.InetAddress.getLocalHost().getHostName();
} catch (java.net.UnknownHostException eUH) {
return "localhost";
}
}
public static AppConfig getInstance() {
if (m_instance == null) {
m_instance = new AppConfig(new File(System.getProperty("user.home")
, AppLocal.APP_ID + ".properties"));
}
return m_instance;
}
public Boolean getBoolean(String sKey) {
return Boolean.valueOf(properties.getProperty(sKey));
}
public void setBoolean(String sKey, Boolean sValue) {
if (sValue == null) {
properties.remove(sKey);
} else if (sValue) {
properties.setProperty(sKey, "true");
} else {
properties.setProperty(sKey, "false");
}
}
/**
* @return Delete .properties filename
*/
public boolean delete() {
loadDefault();
return configfile.delete();
}
/**
* Get instance settings
*/
public void load() {
loadDefault();
try {
InputStream in = new FileInputStream(configfile);
if (in != null) {
properties.load(in);
in.close();
}
} catch (IOException e) {
loadDefault();
}
}
private void refreshProperties() {
try {
InputStream in = new FileInputStream(configfile);
if (in != null) {
properties.load(in);
in.close();
}
} catch (IOException e) {
loadDefault();
}
}
/**
* @return 0 or 00 number keypad boolean true/false
*/
public Boolean isPriceWith00() {
String prop = getProperty("pricewith00");
if (prop == null) {
return false;
} else {
return prop.equals("true");
}
}
public void saveWithExistingProperties() throws IOException {
refreshProperties();
OutputStream out = new FileOutputStream(configfile);
if (out != null) {
properties.store(out, AppLocal.APP_NAME + ". Configuration file.");
out.close();
}
}
/**
* Save values to properties file
*
* @throws java.io.IOException explicit on OS
*/
public void save() throws IOException {
OutputStream out = new FileOutputStream(configfile);
if (out != null) {
properties.store(out, AppLocal.APP_NAME + ". Configuration file.");
out.close();
}
}
private void loadDefault() {
properties = new Properties();
String dirname = System.getProperty("dirname.path");
dirname = dirname == null ? "./" : dirname;
setDatabaseProperties(properties, dirname);
setPrinterProperties(properties);
setLocalProperties(properties);
setPaymentProperties(properties);
setDeviceProperties(properties);
setTableProperties(properties);
}
private void setTableProperties(Properties properties){
properties.setProperty("table.showcustomerdetails", "true");
properties.setProperty("table.customercolour", "#58B000");
properties.setProperty("table.showwaiterdetails", "true");
properties.setProperty("table.waitercolour", "#258FB0");
properties.setProperty("table.tablecolour", "#D62E52");
properties.setProperty("till.amountattop", "true");
properties.setProperty("till.hideinfo", "true");
}
private void setDeviceProperties(Properties properties) {
properties.setProperty("machine.display", "screen");
properties.setProperty("machine.scale", "Not defined");
properties.setProperty("machine.screenmode", "fullscreen");
properties.setProperty("machine.ticketsbag", "standard");
properties.setProperty("machine.scanner", "Not defined");
properties.setProperty("machine.iButton", "false");
properties.setProperty("machine.iButtonResponse", "5");
properties.setProperty("machine.uniqueinstance", "true");
properties.setProperty("machine.hostname", getLocalHostName());
properties.setProperty("swing.defaultlaf", System.getProperty("swing.defaultlaf","javax.swing.plaf.metal.MetalLookAndFeel"));
}
private void setPaymentProperties(Properties properties) {
properties.setProperty("payment.gateway", "external");
properties.setProperty("payment.magcardreader", "Not defined");
properties.setProperty("payment.testmode", "true");
properties.setProperty("payment.commerceid", "");
properties.setProperty("payment.commercepassword", "password");
}
private void setLocalProperties(Properties properties) {
Locale l = Locale.getDefault();
properties.setProperty("user.language", l.getLanguage());
properties.setProperty("user.country", l.getCountry());
properties.setProperty("user.variant", l.getVariant());
}
private void setPrinterProperties(Properties properties) {
// Receipt printer paper set to 72mmx200mm
properties.setProperty("paper.receipt.x", "10");
properties.setProperty("paper.receipt.y", "10");
properties.setProperty("paper.receipt.width", "190");
properties.setProperty("paper.receipt.height", "546");
properties.setProperty("paper.receipt.mediasizename", "A4");
// Normal printer paper for A4
properties.setProperty("paper.standard.x", "72");
properties.setProperty("paper.standard.y", "72");
properties.setProperty("paper.standard.width", "451");
properties.setProperty("paper.standard.height", "698");
properties.setProperty("paper.standard.mediasizename", "A4");
properties.setProperty("tkt.header1", "uniCenta oPOS");
properties.setProperty("tkt.header2", "Touch Friendly Point Of Sale");
properties.setProperty("tkt.header3", "Copyright (c) 2009-2018 uniCenta");
properties.setProperty("tkt.header4", "Change header text in Configuration");
properties.setProperty("tkt.footer1", "Change footer text in Configuration");
properties.setProperty("tkt.footer2", "Thank you for your custom");
properties.setProperty("tkt.footer3", "Please Call Again");
properties.setProperty("machine.printer", "screen");
properties.setProperty("machine.printer.2", "Not defined");
properties.setProperty("machine.printer.3", "Not defined");
properties.setProperty("machine.printer.4", "Not defined");
properties.setProperty("machine.printer.5", "Not defined");
properties.setProperty("machine.printer.6", "Not defined");
properties.setProperty("machine.printername", "(Default)");
properties.setProperty("screen.receipt.columns", "42");
}
private void setDatabaseProperties(Properties properties, String dirname) {
properties.setProperty("db.multi", "false");
properties.setProperty("override.check", "false");
properties.setProperty("override.pin", "");
// Default database
properties.setProperty("db.driverlib", new File(new File(dirname), "derby-10.14.2.0.jar").getAbsolutePath());
properties.setProperty("db.engine", "Derby");
properties.setProperty("db.driver", "org.apache.derby.jdbc.EmbeddedDriver");
properties.setProperty("db.name", "Main DB");
properties.setProperty("db.URL", "jdbc:derby:" + System.getProperty("user.home")+"/.unicenta/");
properties.setProperty("db.schema", "unicentaopos-database;create=true");
properties.setProperty("db.options", "");
properties.setProperty("db.user", "");
properties.setProperty("db.password", "");
// secondary DB
properties.setProperty("db1.name", "");
properties.setProperty("db1.URL", "jdbc:mysql://localhost:3306/");
properties.setProperty("db1.schema", "unicentaopos");
properties.setProperty("db1.options", "?zeroDateTimeBehavior=convertToNull");
properties.setProperty("db1.user", "");
properties.setProperty("db1.password", "");
}
}
@@ -0,0 +1,65 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>
package com.unicenta.pos.forms;
import com.unicenta.beans.LocaleResources;
/**
* @author Jack Gerrard
* @author adrianromero
*/
public class AppLocal {
public static final String APP_NAME = "uniCenta oPOS";
public static final String APP_ID = "unicentaopos";
public static final String APP_VERSION = "5.0";
private static final LocaleResources m_resources;
static {
m_resources = new LocaleResources();
m_resources.addBundleName("pos_messages");
m_resources.addBundleName("erp_messages");
}
/** Creates a new instance of AppLocal */
private AppLocal() {
}
/**
*
* @param sKey local values
* @return string values
*/
public static String getIntString(String sKey) {
return m_resources.getString(sKey);
}
/**
*
* @param sKey local values
* @param sValues string values
* @return string values
*/
public static String getIntString(String sKey, Object ... sValues) {
return m_resources.getString(sKey, sValues);
}
}
@@ -0,0 +1,48 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.io.File;
/**
*
* @author adrianromero
*/
public interface AppProperties {
/**
* Gets the configuration properties settings
* @return config file
*/
public File getConfigFile();
/**
* Gets the Host machine name
* @return host name
*/
public String getHost();
/**
* Read the property from the key pair
* @param sKey key pair value
* @return key pair property
*/
public String getProperty(String sKey);
}
@@ -0,0 +1,304 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.data.loader.LocalRes;
import com.unicenta.pos.ticket.UserInfo;
import com.unicenta.pos.util.Hashcypher;
import lombok.extern.slf4j.Slf4j;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.swing.*;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
/**
* @author adrianromero
*/
@Slf4j
public class AppUser {
private static SAXParser m_sp = null;
private static HashMap<String, String> m_oldclasses; // This is for backwards compatibility purposes
private final String m_sId;
private final String m_sName;
private final String m_sCard;
private String m_sPassword;
private final String m_sRole;
private final Icon m_Icon;
private Set<String> m_apermissions;
static {
initOldClasses();
}
/**
* Creates a new instance of AppUser
*
* @param id
* @param name
* @param card
* @param password
* @param icon
* @param role
*/
public AppUser(String id, String name, String password, String card, String role, Icon icon) {
m_sId = id;
m_sName = name;
m_sPassword = password;
m_sCard = card;
m_sRole = role;
m_Icon = icon;
m_apermissions = null;
}
/**
* Gets the User's button icon
*/
public Icon getIcon() {
return m_Icon;
}
/**
* Get the user's ID
*/
public String getId() {
return m_sId;
}
/**
* Get the User's Name
*/
public String getName() {
return m_sName;
}
/**
* Set the User's Password
*/
public void setPassword(String sValue) {
m_sPassword = sValue;
}
/**
* Get the User's Password
*/
public String getPassword() {
return m_sPassword;
}
/**
* Get the User's Role
*/
public String getRole() {
return m_sRole;
}
/**
* Get the User's Card
*/
public String getCard() {
return m_sCard;
}
/**
* Validate User's Password
*
* @return
*/
public boolean authenticate() {
return m_sPassword == null || m_sPassword.equals("") || m_sPassword.startsWith("empty:");
}
/**
* Eval User's Password
*
* @param sPwd
* @return
*/
public boolean authenticate(String sPwd) {
return Hashcypher.authenticate(sPwd, m_sPassword);
}
/**
* Load User's Permissions
*
* @param dlSystem
*/
public void fillPermissions(DataLogicSystem dlSystem) {
// JG 16 May use diamond inference
m_apermissions = new HashSet<>();
// Y lo que todos tienen permisos
m_apermissions.add("com.unicenta.pos.forms.JPanelMenu");
m_apermissions.add("Menu.Exit");
String sRolePermisions = dlSystem.findRolePermissions(m_sRole);
if (sRolePermisions != null) {
try {
if (m_sp == null) {
SAXParserFactory spf = SAXParserFactory.newInstance();
m_sp = spf.newSAXParser();
}
m_sp.parse(new InputSource(new StringReader(sRolePermisions)), new ConfigurationHandler());
} catch (ParserConfigurationException ePC) {
log.error(LocalRes.getIntString("exception.parserconfig"), ePC);
} catch (SAXException eSAX) {
log.error(LocalRes.getIntString("exception.xmlfile"), eSAX);
} catch (IOException eIO) {
log.error(LocalRes.getIntString("exception.iofile"), eIO);
}
}
}
/**
* Validate User's Permissions
*
* @param classname
* @return
*/
public boolean hasPermission(String classname) {
return (m_apermissions == null) ? false : m_apermissions.contains(classname);
}
/**
* Get User's ID/Name
*
* @return
*/
public UserInfo getUserInfo() {
return new UserInfo(m_sId, m_sName);
}
private static String mapNewClass(String classname) {
String newclass = m_oldclasses.get(classname);
return newclass == null
? classname
: newclass;
}
private static void initOldClasses() {
// JG 16 May use diamond inference
m_oldclasses = new HashMap<>();
// update permissions from 0.0.24 to 2.20
m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketSales", "com.unicenta.pos.sales.JPanelTicketSales");
m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketEdits", "com.unicenta.pos.sales.JPanelTicketEdits");
m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPayments", "com.unicenta.pos.panels.JPanelPayments");
m_oldclasses.put("net.adrianromero.tpv.panels.JPanelCloseMoney", "com.unicenta.pos.panels.JPanelCloseMoney");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedPos", "/com/unicenta/reports/closedpos.bs");
m_oldclasses.put("Menu.StockManagement", "com.unicenta.pos.forms.MenuStockManagement");
m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsPanel", "com.unicenta.pos.inventory.ProductsPanel");
m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsWarehousePanel", "com.unicenta.pos.inventory.ProductsWarehousePanel");
m_oldclasses.put("net.adrianromero.tpv.inventory.CategoriesPanel", "com.unicenta.pos.inventory.CategoriesPanel");
m_oldclasses.put("net.adrianromero.tpv.panels.JPanelTax", "com.unicenta.pos.inventory.TaxPanel");
m_oldclasses.put("net.adrianromero.tpv.inventory.StockDiaryPanel", "com.unicenta.pos.inventory.StockDiaryPanel");
m_oldclasses.put("net.adrianromero.tpv.inventory.StockManagement", "com.unicenta.pos.inventory.StockManagement");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportProducts", "/com/unicenta/reports/products.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportCatalog", "/com/unicenta/reports/productscatalog.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory", "/com/unicenta/reports/inventory.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory2", "/com/unicenta/reports/inventoryb.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryBroken", "/com/unicenta/reports/inventorybroken.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryDiff", "/com/unicenta/reports/inventorydiff.bs");
m_oldclasses.put("Menu.SalesManagement", "com.unicenta.pos.forms.MenuSalesManagement");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportUserSales", "/com/unicenta/reports/usersales.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedProducts", "/com/unicenta/reports/closedproducts.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JReportTaxes", "/com/unicenta/reports/taxes.bs");
m_oldclasses.put("net.adrianromero.tpv.reports.JChartSales", "/com/unicenta/reports/chartsales.bs");
m_oldclasses.put("Menu.Maintenance", "com.unicenta.pos.forms.MenuMaintenance");
m_oldclasses.put("net.adrianromero.tpv.admin.PeoplePanel", "com.unicenta.pos.admin.PeoplePanel");
m_oldclasses.put("net.adrianromero.tpv.admin.RolesPanel", "com.unicenta.pos.admin.RolesPanel");
m_oldclasses.put("net.adrianromero.tpv.admin.ResourcesPanel", "com.unicenta.pos.admin.ResourcesPanel");
m_oldclasses.put("net.adrianromero.tpv.inventory.LocationsPanel", "com.unicenta.pos.inventory.LocationsPanel");
m_oldclasses.put("net.adrianromero.tpv.mant.JPanelFloors", "com.unicenta.pos.mant.JPanelFloors");
m_oldclasses.put("net.adrianromero.tpv.mant.JPanelPlaces", "com.unicenta.pos.mant.JPanelPlaces");
m_oldclasses.put("com.unicenta.possync.ProductsSync", "com.unicenta.possync.ProductsSyncCreate");
m_oldclasses.put("com.unicenta.possync.OrdersSync", "com.unicenta.possync.OrdersSyncCreate");
m_oldclasses.put("Menu.ChangePassword", "Menu.ChangePassword");
m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPrinter", "com.unicenta.pos.panels.JPanelPrinter");
m_oldclasses.put("net.adrianromero.tpv.config.JPanelConfiguration", "com.unicenta.pos.config.JPanelConfiguration");
// update permissions from 2.00 to 2.20
m_oldclasses.put("com.unicenta.pos.reports.JReportCustomers", "/com/unicenta/reports/customers.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportCustomersB", "/com/unicenta/reports/customersb.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportClosedPos", "/com/unicenta/reports/closedpos.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportClosedProducts", "/com/unicenta/reports/closedproducts.bs");
m_oldclasses.put("com.unicenta.pos.reports.JChartSales", "/com/unicenta/reports/chartsales.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportInventory", "/com/unicenta/reports/inventory.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportInventory2", "/com/unicenta/reports/inventoryb.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryBroken", "/com/unicenta/reports/inventorybroken.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryDiff", "/com/unicenta/reports/inventorydiff.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportPeople", "/com/unicenta/reports/people.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportTaxes", "/com/unicenta/reports/taxes.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportUserSales", "/com/unicenta/reports/usersales.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportProducts", "/com/unicenta/reports/products.bs");
m_oldclasses.put("com.unicenta.pos.reports.JReportCatalog", "/com/unicenta/reports/productscatalog.bs");
// update permissions from 2.10 to 2.20
m_oldclasses.put("com.unicenta.pos.panels.JPanelTax", "com.unicenta.pos.inventory.TaxPanel");
}
private class ConfigurationHandler extends DefaultHandler {
@Override
public void startDocument() throws SAXException {
}
@Override
public void endDocument() throws SAXException {
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if ("class".equals(qName)) {
m_apermissions.add(mapNewClass(attributes.getValue("name")));
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
}
}
}
@@ -0,0 +1,52 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public interface AppUserView {
/**
*
*/
public static final String ACTION_TASKNAME = "taskname";
// Acciones de la aplicacion
/**
*
* @return
*/
public AppUser getUser(); // Usuario logado
/**
*
* @param sTaskClass
*/
public void showTask(String sTaskClass);
/**
*
* @param sTaskClass
*/
public void executeTask(String sTaskClass);
}
@@ -0,0 +1,74 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.data.loader.Session;
import com.unicenta.pos.printer.DeviceTicket;
import com.unicenta.pos.scale.DeviceScale;
import com.unicenta.pos.scanpal2.DeviceScanner;
import java.util.Date;
/**
*
* @author adrianromero
*/
public interface AppView {
public DeviceScale getDeviceScale();
public DeviceTicket getDeviceTicket();
public DeviceScanner getDeviceScanner();
public Session getSession();
public AppProperties getProperties();
/**
*
* @param beanfactory
* @return
* @throws BeanFactoryException
*/
public Object getBean(String beanfactory) throws BeanFactoryException;
/**
*
* @param value
* @param iSeq
* @param dStart
* @param dEnd
*/
public void setActiveCash(String value, int iSeq, Date dStart, Date dEnd);
public String getActiveCashIndex();
public int getActiveCashSequence();
public Date getActiveCashDateStart();
public Date getActiveCashDateEnd();
public void setClosedCash(String value, int iSeq, Date dStart, Date dEnd);
public String getClosedCashIndex();
public int getClosedCashSequence();
public Date getClosedCashDateStart();
public Date getClosedCashDateEnd();
public String getInventoryLocation();
public void waitCursorBegin();
public void waitCursorEnd();
public AppUserView getAppUserView();
}
@@ -0,0 +1,145 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.Session;
import com.unicenta.pos.util.AltEncrypter;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
/**
*
* @author adrianromero
*/
public class AppViewConnection {
/** Creates a new instance of AppViewConnection */
private AppViewConnection() {
}
/**
*
* @param props
* @return
* @throws BasicException
*/
public static Session createSession(AppProperties props) throws BasicException {
try {
String dbURL=null;
String sDBUser=null;
String sDBPassword=null;
String sUserPath = System.getProperty("user.home");
String filePath = sUserPath + "\\open.db";
if (isJavaWebStart()) {
Class.forName(props.getProperty("db.driver"), true, Thread.currentThread().getContextClassLoader());
} else {
URL[] urls = {new File(props.getProperty("db.driverlib")).toURI().toURL()};
ClassLoader cloader = new URLClassLoader(urls);
String driver = props.getProperty("db.driver");
DriverWrapper driverWrapper = new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance());
DriverManager.registerDriver(driverWrapper);
}
if("true".equals(props.getProperty("db.multi"))) {
if (!Files.exists(Paths.get(filePath))) {
ImageIcon icon = new ImageIcon("/com/unicenta/images/unicentaopos.png");
Object[] dbs = {
"0 - " + props.getProperty("db.name"),
"1 - " + props.getProperty("db1.name")};
Object s = (Object)JOptionPane.showInputDialog(
null, AppLocal.getIntString("message.databasechoose"),
"Selection", JOptionPane.OK_OPTION,
icon, dbs, props.getProperty("db.name"));
if (s.toString().startsWith("1")) {
sDBUser = props.getProperty("db1.user");
sDBPassword = props.getProperty("db1.password");
if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) {
AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser);
sDBPassword = cypher.decrypt(sDBPassword.substring(6));
}
dbURL = props.getProperty("db1.URL") +
props.getProperty("db1.schema") +
props.getProperty("db1.options");
} else {
sDBUser = props.getProperty("db.user");
sDBPassword = props.getProperty("db.password");
if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) {
AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser);
sDBPassword = cypher.decrypt(sDBPassword.substring(6));
}
dbURL = props.getProperty("db.URL") +
props.getProperty("db.schema") +
props.getProperty("db.options");
}
} else {
sDBUser = props.getProperty("db.user");
sDBPassword = props.getProperty("db.password");
if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) {
AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser);
sDBPassword = cypher.decrypt(sDBPassword.substring(6));
}
dbURL = props.getProperty("db.URL") +
props.getProperty("db.schema") +
props.getProperty("db.options");
}
} else {
sDBUser = props.getProperty("db.user");
sDBPassword = props.getProperty("db.password");
if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) {
AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser);
sDBPassword = cypher.decrypt(sDBPassword.substring(6));
}
dbURL = props.getProperty("db.URL") +
props.getProperty("db.schema") +
props.getProperty("db.options");
}
return new Session(dbURL, sDBUser,sDBPassword);
} catch (InstantiationException | IllegalAccessException | MalformedURLException | ClassNotFoundException e) {
throw new BasicException(AppLocal.getIntString("message.databasedrivererror"), e);
} catch (SQLException eSQL) {
throw new BasicException(AppLocal.getIntString("message.databaseconnectionerror"), eSQL);
}
}
private static boolean isJavaWebStart() {
try {
Class.forName("javax.jnlp.ServiceManager");
return true;
} catch (ClassNotFoundException ue) {
return false;
}
}
}
@@ -0,0 +1,33 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public interface BeanFactory {
/**
*
* @return
*/
public Object getBean();
}
@@ -0,0 +1,35 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public interface BeanFactoryApp extends BeanFactory {
/**
*
* @param app
* @throws BeanFactoryException
*/
public void init(AppView app) throws BeanFactoryException;
}
@@ -0,0 +1,56 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public abstract class BeanFactoryCache implements BeanFactoryApp {
private Object bean = null;
/**
*
* @param app
* @return
* @throws BeanFactoryException
*/
public abstract Object constructBean(AppView app) throws BeanFactoryException;
/**
*
* @param app
* @throws BeanFactoryException
*/
@Override
public void init(AppView app) throws BeanFactoryException {
bean = constructBean(app);
}
/**
*
* @return
*/
@Override
public Object getBean() {
return bean;
}
}
@@ -0,0 +1,64 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public class BeanFactoryData implements BeanFactoryApp {
private BeanFactoryApp bf;
/** Creates a new instance of BeanFactoryData */
public BeanFactoryData() {
}
/**
*
* @param app
* @throws BeanFactoryException
*/
@Override
public void init(AppView app) throws BeanFactoryException {
try {
String sfactoryname = this.getClass().getName();
if (sfactoryname.endsWith("Create")) {
sfactoryname = sfactoryname.substring(0, sfactoryname.length() - 6);
}
bf = (BeanFactoryApp) Class.forName(sfactoryname + app.getSession().DB.getName()).newInstance();
bf.init(app);
// JG 16 May use multicatch
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | BeanFactoryException ex) {
throw new BeanFactoryException(ex);
}
}
/**
*
* @return
*/
@Override
public Object getBean() {
return bf.getBean();
}
}
@@ -0,0 +1,58 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.data.loader.Session;
/**
*
* @author adrianromero
*/
public abstract class BeanFactoryDataSingle implements BeanFactoryApp {
/** Creates a new instance of BeanFactoryData */
public BeanFactoryDataSingle() {
}
/**
*
* @param s
*/
public abstract void init(Session s);
/**
*
* @param app
* @throws BeanFactoryException
*/
@Override
public void init(AppView app) throws BeanFactoryException {
init(app.getSession());
}
/**
*
* @return
*/
@Override
public Object getBean() {
return this;
}
}
@@ -0,0 +1,50 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public class BeanFactoryException extends java.lang.RuntimeException {
/**
* Creates a new instance of <code>BeanFactoryException</code> without detail message.
*/
public BeanFactoryException() {
}
/**
* Constructs an instance of <code>BeanFactoryException</code> with the specified detail message.
* @param msg the detail message.
*/
public BeanFactoryException(String msg) {
super(msg);
}
/**
*
* @param e
*/
public BeanFactoryException(Throwable e) {
super(e);
}
}
@@ -0,0 +1,45 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public class BeanFactoryObj implements BeanFactory {
private Object bean = null;
/** Creates a new instance of BeanFactoryObj
* @param bean */
public BeanFactoryObj(Object bean) {
this.bean = bean;
}
/**
*
* @return
*/
@Override
public Object getBean() {
return bean;
}
}
@@ -0,0 +1,82 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.pos.scripting.ScriptEngine;
import com.unicenta.pos.scripting.ScriptException;
import com.unicenta.pos.scripting.ScriptFactory;
import com.unicenta.pos.util.StringUtils;
import java.io.IOException;
/**
*
* @author adrianromero
*/
public class BeanFactoryScript implements BeanFactoryApp {
private BeanFactory bean = null;
private String script;
/**
*
* @param script
*/
public BeanFactoryScript(String script) {
this.script = script;
}
/**
*
* @param app
* @throws BeanFactoryException
*/
@Override
public void init(AppView app) throws BeanFactoryException {
// Resource
try {
ScriptEngine eng = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL);
eng.put("app", app);
bean = (BeanFactory) eng.eval(StringUtils.readResource(script));
if (bean == null) {
// old definition
bean = (BeanFactory) eng.get("bean");
}
// todo // llamar al init del bean
if (bean instanceof BeanFactoryApp) {
((BeanFactoryApp) bean).init(app);
}
// JG 16 May use multicatch
} catch (ScriptException | IOException e) {
throw new BeanFactoryException(e);
}
}
/**
*
* @return
*/
@Override
public Object getBean() {
return bean.getBean();
}
}
@@ -0,0 +1,81 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.*;
/**
*
* @author uniCenta
*/
public class DataLogicOrders extends BeanFactoryDataSingle {
private SentenceExec m_addOrder;
private SentenceExec m_resetPickup;
/** Creates a new instance of DataLogicOrders */
public DataLogicOrders() {
}
/**
*
* @param s
*/
@Override
public void init(Session s){
m_addOrder = new StaticSentence(s
, "INSERT INTO orders (orderid, qty, details, attributes, "
+ "notes, ticketid, ordertime, displayid, auxiliary, "
+ "completetime) " +
"VALUES (?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ? ) "
, new SerializerWriteBasic(new Datas[] {
Datas.STRING, // OrderId
Datas.INT, // Qty
Datas.STRING, // Details
Datas.STRING, // Attributes
Datas.STRING, // Notes
Datas.STRING, // TicketId
Datas.STRING, // OrderTime
Datas.INT, // DisplayId
Datas.INT, // Auxiliary
Datas.STRING // CompleteTime
}));
m_resetPickup = new PreparedSentence(s
, "UPDATE pickup_number SET id=1"
, SerializerWriteParams.INSTANCE);
}
public final void addOrder(String orderId, Integer qty,
String details, String attributes, String notes, String ticketId,
String ordertime, Integer displayId, String auxiliary, String completetime
) throws BasicException {
m_addOrder.exec(orderId, qty, details, attributes, notes, ticketId,
ordertime, displayId, auxiliary, completetime);
}
public final void resetPickup() throws BasicException {
m_resetPickup.exec();
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,891 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.*;
import com.unicenta.format.Formats;
import com.unicenta.pos.util.ThumbNailBuilder;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
/**
*
* @author JG uniCenta
*/
public class DataLogicSystem extends BeanFactoryDataSingle {
protected String m_sInitScript;
private SentenceFind m_version;
private SentenceExec m_dummy;
private String m_dbVersion;
protected SentenceList m_peoplevisible;
protected SentenceFind m_peoplebycard;
protected SerializerRead peopleread;
protected SentenceList m_permissionlist;
protected SerializerRead productIdRead;
protected SerializerRead customerIdRead;
private SentenceFind m_rolepermissions;
private SentenceExec m_changepassword;
private SentenceFind m_locationfind;
private SentenceExec m_insertCSVEntry;
private SentenceExec m_insertStockUpdateEntry;
private SentenceFind m_getProductAllFields;
private SentenceFind m_getProductRefAndCode;
private SentenceFind m_getProductRefAndName;
private SentenceFind m_getProductCodeAndName;
private SentenceFind m_getProductByReference;
private SentenceFind m_getProductByCode;
private SentenceFind m_getProductByName;
private SentenceExec m_insertCustomerCSVEntry;
private SentenceFind m_getCustomerAllFields;
private SentenceFind m_getCustomerSearchKeyAndName;
private SentenceFind m_getCustomerBySearchKey;
private SentenceFind m_getCustomerByName;
private SentenceFind m_resourcebytes;
private SentenceExec m_resourcebytesinsert;
private SentenceExec m_resourcebytesupdate;
protected SentenceFind m_sequencecash;
protected SentenceFind m_activecash;
protected SentenceFind m_closedcash;
protected SentenceExec m_insertcash;
protected SentenceExec m_draweropened;
protected SentenceExec m_updatepermissions;
protected SentenceExec m_lineremoved;
protected SentenceExec m_ticketremoved;
private String SQL;
private Map<String, byte[]> resourcescache;
private SentenceList m_voucherlist;
protected SentenceExec m_addOrder;
protected SentenceExec m_updateOrder;
protected SentenceExec m_deleteOrder;
private SentenceExec m_resetPickup;
private SentenceExec m_updatePlaces;
/** Creates a new instance of DataLogicSystem */
public DataLogicSystem() {
}
/**
*
* @param s
*/
@Override
public void init(Session s){
m_sInitScript = "/com/unicenta/pos/scripts/" + s.DB.getName();
m_dbVersion = s.DB.getName();
m_version = new PreparedSentence(s, "SELECT VERSION FROM applications WHERE ID = ?"
, SerializerWriteString.INSTANCE, SerializerReadString.INSTANCE);
m_dummy = new StaticSentence(s, "SELECT * FROM people WHERE 1 = 0");
final ThumbNailBuilder tnb = new ThumbNailBuilder(32, 32, "com/unicenta/images/user.png");
peopleread = (DataRead dr) -> new AppUser(
dr.getString(1),
dr.getString(2),
dr.getString(3),
dr.getString(4),
dr.getString(5),
new ImageIcon(tnb.getThumbNail(ImageUtils.readImage(dr.getBytes(6)))));
// START OF PRODUCT ************************************************************
productIdRead =(DataRead dr) -> (
dr.getString(1)
);
m_getProductAllFields = new PreparedSentence(s
, "SELECT ID FROM products WHERE REFERENCE=? AND CODE=? AND NAME=? "
, new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING})
, productIdRead
);
m_getProductRefAndCode = new PreparedSentence(s
, "SELECT ID FROM products WHERE REFERENCE=? AND CODE=?"
, new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})
, productIdRead
);
m_getProductRefAndName = new PreparedSentence(s
, "SELECT ID FROM products WHERE REFERENCE=? AND NAME=? "
, new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})
, productIdRead
);
m_getProductCodeAndName = new PreparedSentence(s
, "SELECT ID FROM products WHERE CODE=? AND NAME=? "
, new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})
, productIdRead
);
m_getProductByReference = new PreparedSentence(s
, "SELECT ID FROM products WHERE REFERENCE=? "
, SerializerWriteString.INSTANCE //(Datas.STRING)
, productIdRead
);
m_getProductByCode = new PreparedSentence(s
, "SELECT ID FROM products WHERE CODE=? "
, SerializerWriteString.INSTANCE //(Datas.STRING)
//, new SerializerWriteBasic(Datas.STRING)
, productIdRead
);
m_getProductByName = new PreparedSentence(s
, "SELECT ID FROM products WHERE NAME=? "
, SerializerWriteString.INSTANCE //(Datas.STRING)
//, new SerializerWriteBasic(Datas.STRING)
, productIdRead
);
// END OF PRODUCT *************************************************************
// START OF CUSTOMER ***********************************************************
customerIdRead =(DataRead dr) -> (
dr.getString(1)
);
// duplicate this for now as will extend in future release
m_getCustomerAllFields = new PreparedSentence(s
, "SELECT ID FROM customers WHERE SEARCHKEY=? AND NAME=? "
, new SerializerWriteBasic(new Datas[] {
Datas.STRING, Datas.STRING})
, customerIdRead
);
m_getCustomerSearchKeyAndName = new PreparedSentence(s
, "SELECT ID FROM customers WHERE SEARCHKEY=? AND NAME=? "
, new SerializerWriteBasic(new Datas[] {
Datas.STRING, Datas.STRING})
, customerIdRead
);
m_getCustomerBySearchKey = new PreparedSentence(s
, "SELECT ID FROM customers WHERE SEARCHKEY=? "
, SerializerWriteString.INSTANCE
, customerIdRead
);
m_getCustomerByName = new PreparedSentence(s
, "SELECT ID FROM customers WHERE NAME=? "
, SerializerWriteString.INSTANCE
, customerIdRead
);
// END OF CUSTOMER ******************************************************************
m_peoplevisible = new StaticSentence(s
, "SELECT ID, NAME, APPPASSWORD, CARD, ROLE, IMAGE FROM people WHERE VISIBLE = " + s.DB.TRUE() + " ORDER BY NAME"
, null
, peopleread);
m_peoplebycard = new PreparedSentence(s
, "SELECT ID, NAME, APPPASSWORD, CARD, ROLE, IMAGE FROM people WHERE CARD = ? AND VISIBLE = " + s.DB.TRUE()
, SerializerWriteString.INSTANCE
, peopleread);
m_resourcebytes = new PreparedSentence(s
, "SELECT CONTENT FROM resources WHERE NAME = ?"
, SerializerWriteString.INSTANCE
, SerializerReadBytes.INSTANCE);
Datas[] resourcedata = new Datas[] {
Datas.STRING, Datas.STRING,
Datas.INT, Datas.BYTES};
m_resourcebytesinsert = new PreparedSentence(s
, "INSERT INTO resources(ID, NAME, RESTYPE, CONTENT) VALUES (?, ?, ?, ?)"
, new SerializerWriteBasic(resourcedata));
m_resourcebytesupdate = new PreparedSentence(s
, "UPDATE resources SET NAME = ?, RESTYPE = ?, CONTENT = ? WHERE NAME = ?"
, new SerializerWriteBasicExt(resourcedata, new int[] {1, 2, 3, 1}));
m_rolepermissions = new PreparedSentence(s
, "SELECT PERMISSIONS FROM roles WHERE ID = ?"
, SerializerWriteString.INSTANCE
, SerializerReadBytes.INSTANCE);
m_changepassword = new StaticSentence(s
, "UPDATE people SET APPPASSWORD = ? WHERE ID = ?"
,new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}));
m_sequencecash = new StaticSentence(s,
"SELECT MAX(HOSTSEQUENCE) FROM closedcash WHERE HOST = ?",
SerializerWriteString.INSTANCE,
SerializerReadInteger.INSTANCE);
m_activecash = new StaticSentence(s
, "SELECT HOST, HOSTSEQUENCE, DATESTART, DATEEND, NOSALES FROM closedcash WHERE MONEY = ?"
, SerializerWriteString.INSTANCE
, new SerializerReadBasic(new Datas[] {
Datas.STRING,
Datas.INT,
Datas.TIMESTAMP,
Datas.TIMESTAMP,
Datas.INT}));
m_closedcash = new StaticSentence(s
, "SELECT HOST, HOSTSEQUENCE, DATESTART, DATEEND, NOSALES " +
"FROM closedcash WHERE HOSTSEQUENCE = ?"
, SerializerWriteString.INSTANCE
, new SerializerReadBasic(new Datas[] {
Datas.STRING,
Datas.INT,
Datas.TIMESTAMP,
Datas.TIMESTAMP,
Datas.INT}));
m_insertcash = new StaticSentence(s
, "INSERT INTO closedcash(MONEY, HOST, HOSTSEQUENCE, DATESTART, DATEEND) " +
"VALUES (?, ?, ?, ?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING,
Datas.INT,
Datas.TIMESTAMP,
Datas.TIMESTAMP}));
m_draweropened = new StaticSentence(s
, "INSERT INTO draweropened ( NAME, TICKETID) " +
"VALUES (?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING}));
m_lineremoved = new StaticSentence(s,
"INSERT INTO lineremoved (NAME, TICKETID, PRODUCTID, PRODUCTNAME, UNITS) " +
"VALUES (?, ?, ?, ?, ?)",
new SerializerWriteBasic(new Datas[] {
Datas.STRING, Datas.STRING,
Datas.STRING, Datas.STRING,
Datas.DOUBLE
}));
m_ticketremoved = new StaticSentence(s,
"INSERT INTO lineremoved (NAME, TICKETID, PRODUCTNAME, UNITS) " +
"VALUES (?, ?, ?, ?)",
new SerializerWriteBasic(new Datas[] {
Datas.STRING, Datas.STRING,
Datas.STRING, Datas.DOUBLE
}));
m_locationfind = new StaticSentence(s
, "SELECT NAME FROM locations WHERE ID = ?"
, SerializerWriteString.INSTANCE
, SerializerReadString.INSTANCE);
m_permissionlist = new StaticSentence(s
, "SELECT PERMISSIONS FROM permissions WHERE ID = ?"
, SerializerWriteString.INSTANCE
, new SerializerReadBasic(new Datas[] {
Datas.STRING
}));
m_updatepermissions = new StaticSentence(s
, "INSERT INTO permissions (ID, PERMISSIONS) " +
"VALUES (?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING}));
// Push Products into CSVImport table
m_insertCSVEntry = new StaticSentence(s
, "INSERT INTO csvimport ( "
+ "ID, ROWNUMBER, CSVERROR, REFERENCE, "
+ "CODE, NAME, PRICEBUY, PRICESELL, "
+ "PREVIOUSBUY, PREVIOUSSELL, CATEGORY, TAX) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.DOUBLE,
Datas.DOUBLE,
Datas.DOUBLE,
Datas.DOUBLE,
Datas.STRING,
Datas.STRING
}));
// Push Product Quantity Update into CSVImport table
m_insertStockUpdateEntry = new StaticSentence(s
, "INSERT INTO csvimport ( "
+ "ID, ROWNUMBER, CSVERROR, REFERENCE, "
+ "CODE, PRICEBUY ) "
+ "VALUES (?, ?, ?, ?, ?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.DOUBLE
}));
// Push Customers into CSVImport table
m_insertCustomerCSVEntry = new StaticSentence(s
, "INSERT INTO csvimport ( "
+ "ID, ROWNUMBER, CSVERROR, SEARCHKEY, NAME) " +
"VALUES (?, ?, ?, ?, ?)"
, new SerializerWriteBasic(new Datas[] {
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING,
Datas.STRING
}));
m_addOrder = new StaticSentence(s
, "INSERT INTO orders (ORDERID, QTY, DETAILS, ATTRIBUTES, "
+ "NOTES, TICKETID, ORDERTIME, DISPLAYID, AUXILIARY, "
+ "COMPLETETIME) " +
"VALUES (?, ?, ?, ?, ?, "
+ "?, ?, ?, ?, ? ) "
, new SerializerWriteBasic(new Datas[] {
Datas.STRING, // OrderId
Datas.INT, // Qty
Datas.STRING, // Details
Datas.STRING, // Attributes
Datas.STRING, // Notes
Datas.STRING, // TicketId
Datas.STRING, // OrderTime
Datas.INT, // DisplayId
Datas.INT, // Auxiliary
Datas.STRING // CompleteTime
}));
m_updateOrder = new StaticSentence(s
, "UPDATE orders SET "
+ "ORDERID = ?, "
+ "QTY = ?, "
+ "DETAILS = ?, "
+ "ATTRIBUTES = ?, "
+ "NOTES = ?, "
+ "TICKETID = ?, "
+ "ORDERTIME = ?, "
+ "DISPLAYID = ?, "
+ "AUXILIARY = ?, "
+ "COMPLETETIME = ? "
+ "WHERE ORDERID = ? "
, new SerializerWriteBasic(new Datas[] {
Datas.STRING, // OrderId
Datas.INT, // Qty
Datas.STRING, // Details
Datas.STRING, // Attributes
Datas.STRING, // Notes
Datas.STRING, // TicketId
Datas.STRING, // OrderTime
Datas.INT, // DisplayId
Datas.INT, // Auxiliary
Datas.STRING // CompleteTime
}));
m_deleteOrder = new StaticSentence(s
, "DELETE FROM orders WHERE ORDERID = ?"
, SerializerWriteString.INSTANCE);
m_updatePlaces = new StaticSentence(s
, "UPDATE places SET X = ?, Y = ? "
+ "WHERE ID = ? "
, new SerializerWriteBasic(new Datas[]{
Datas.INT,
Datas.INT,
Datas.STRING
}));
m_resetPickup = new StaticSentence(s
, "UPDATE pickup_number SET id=1"
, SerializerWriteInteger.INSTANCE);
resetResourcesCache();
}
/**
*
* @return
*/
public String getInitScript() {
return m_sInitScript;
}
/**
*
* @return
*/
public String getDBVersion(){
return m_dbVersion;
}
/**
*
* @return
* @throws BasicException
*/
public final String findVersion() throws BasicException {
return (String) m_version.find(AppLocal.APP_ID);
}
/**
*
* @return
* @throws BasicException
*/
public final String getUser() throws BasicException {
return ("");
}
/**
*
* @throws BasicException
*/
public final void execDummy() throws BasicException {
m_dummy.exec();
}
/**
*
* @return
* @throws BasicException
*/
public final List listPeopleVisible() throws BasicException {
return m_peoplevisible.list();
}
/**
*
* @param role
* @return
* @throws BasicException
*/
public final List<String> getPermissions(String role)throws BasicException {
return m_permissionlist.list(role);
}
/**
*
* @param card
* @return
* @throws BasicException
*/
public final AppUser findPeopleByCard(String card) throws BasicException {
return (AppUser) m_peoplebycard.find(card);
}
/**
*
* @param sRole
* @return
*/
public final String findRolePermissions(String sRole) {
try {
return Formats.BYTEA.formatValue(m_rolepermissions.find(sRole));
} catch (BasicException e) {
return null;
}
}
/**
*
* @param userdata
* @throws BasicException
*/
public final void execChangePassword(Object[] userdata) throws BasicException {
m_changepassword.exec(userdata);
}
/**
*
*/
public final void resetResourcesCache() {
resourcescache = new HashMap<>();
}
private byte[] getResource(String name) {
byte[] resource;
resource = resourcescache.get(name);
if (resource == null) {
try {
resource = (byte[]) m_resourcebytes.find(name);
resourcescache.put(name, resource);
} catch (BasicException e) {
resource = null;
}
}
return resource;
}
/**
*
* @param name
* @param type
* @param data
*/
public final void setResource(String name, int type, byte[] data) {
Object[] value = new Object[] {
UUID.randomUUID().toString(),
name,
type,
data
};
try {
if (m_resourcebytesupdate.exec(value) == 0) {
m_resourcebytesinsert.exec(value);
}
resourcescache.put(name, data);
} catch (BasicException e) {
}
}
/**
*
* @param sName
* @param data
*/
public final void setResourceAsBinary(String sName, byte[] data) {
setResource(sName, 2, data);
}
/**
*
* @param sName
* @return
*/
public final byte[] getResourceAsBinary(String sName) {
return getResource(sName);
}
/**
*
* @param sName
* @return
*/
public final String getResourceAsText(String sName) {
return Formats.BYTEA.formatValue(getResource(sName));
}
/**
*
* @param sName
* @return
*/
public final String getResourceAsXML(String sName) {
return Formats.BYTEA.formatValue(getResource(sName));
}
/**
*
* @param sName
* @return
*/
public final BufferedImage getResourceAsImage(String sName) {
try {
byte[] img = getResource(sName); // , ".png"
return img == null ? null : ImageIO.read(new ByteArrayInputStream(img));
} catch (IOException e) {
return null;
}
}
/**
*
* @param sName
* @param p
*/
public final void setResourceAsProperties(String sName, Properties p) {
if (p == null) {
setResource(sName, 0, null); // texto
} else {
try {
ByteArrayOutputStream o = new ByteArrayOutputStream();
p.storeToXML(o, AppLocal.APP_NAME, "UTF8");
setResource(sName, 0, o.toByteArray()); // El texto de las propiedades
} catch (IOException e) { // no deberia pasar nunca
}
}
}
/**
*
* @param sName
* @return
*/
public final Properties getResourceAsProperties(String sName) {
Properties p = new Properties();
try {
byte[] img = getResourceAsBinary(sName);
if (img != null) {
p.loadFromXML(new ByteArrayInputStream(img));
}
} catch (IOException e) {
}
return p;
}
/**
*
* @param host
* @return
* @throws BasicException
*/
public final int getSequenceCash(String host) throws BasicException {
Integer i = (Integer) m_sequencecash.find(host);
return (i == null) ? 1 : i;
}
/**
*
* @param sActiveCashIndex
* @return
* @throws BasicException
*/
public final Object[] findActiveCash(String sActiveCashIndex) throws BasicException {
return (Object[]) m_activecash.find(sActiveCashIndex);
}
/**
*
* @param sClosedCashIndex
* @return
* @throws BasicException
*/
public final Object[] findClosedCash(String sClosedCashIndex) throws BasicException {
return (Object[]) m_activecash.find(sClosedCashIndex);
}
/**
*
* @param cash
* @throws BasicException
*/
public final void execInsertCash(Object[] cash) throws BasicException {
m_insertcash.exec(cash);
}
/**
*
* @param drawer
* @throws BasicException
*/
public final void execDrawerOpened(Object[] drawer) throws BasicException {
m_draweropened.exec(drawer);
}
/**
*
* @param permissions
* @throws BasicException
*/
public final void execUpdatePermissions(Object[] permissions) throws BasicException {
m_updatepermissions.exec(permissions);
}
/**
*
* @param line
*/
public final void execLineRemoved(Object[] line) {
try {
m_lineremoved.exec(line);
} catch (BasicException e) {
}
}
/**
*
* @param ticket
*/
public final void execTicketRemoved(Object[] ticket) {
try {
m_ticketremoved.exec(ticket);
} catch (BasicException e) {
}
}
/**
*
* @param iLocation
* @return
* @throws BasicException
*/
public final String findLocationName(String iLocation) throws BasicException {
return (String) m_locationfind.find(iLocation);
}
/**
*
* @param csv
* @throws BasicException
*/
public final void execCSVStockUpdate(Object[] csv) throws BasicException {
m_insertStockUpdateEntry.exec(csv);
}
/**
*
* @param csv
* @throws BasicException
*/
public final void execAddCSVEntry(Object[] csv) throws BasicException {
m_insertCSVEntry.exec(csv);
}
/**
*
* @param csv
* @throws BasicException
*/
public final void execCustomerAddCSVEntry(Object[] csv) throws BasicException {
m_insertCustomerCSVEntry.exec(csv);
}
// This is used by CSVimport to detect what type of product insert we are looking at, or what error occured
/**
*
* @param myProduct
* @return
* @throws BasicException
*/
public final String getProductRecordType(Object[] myProduct) throws BasicException {
// check if the product exist with all the details, if so return product ID
if (m_getProductAllFields.find(myProduct) != null){
return m_getProductAllFields.find(myProduct).toString();
}
// check if the product exists with matching reference and code, but a different name
if (m_getProductRefAndCode.find(myProduct[0],myProduct[1]) != null){
return "Name change";
}
if (m_getProductRefAndName.find(myProduct[0],myProduct[2]) != null){
return "Barcode change";
}
if (m_getProductCodeAndName.find(myProduct[1],myProduct[2]) != null){
return "Reference change";
}
if (m_getProductByReference.find(myProduct[0]) != null){
return "Duplicate Reference found.";
}
if (m_getProductByCode.find(myProduct[1]) != null){
return "Duplicate Barcode found.";
}
if (m_getProductByName.find(myProduct[2]) != null){
return "Duplicate Description found.";
}
return "new";
}
/**
*
* @param myCustomer
* @return
* @throws BasicException
*/
public final String getCustomerRecordType(Object[] myCustomer) throws BasicException {
if (m_getCustomerAllFields.find(myCustomer) != null){
return m_getCustomerAllFields.find(myCustomer).toString();
}
if (m_getCustomerSearchKeyAndName.find(myCustomer[0],myCustomer[1]) != null){
return "reference error";
}
if (m_getCustomerBySearchKey.find(myCustomer[0]) != null){
return "Duplicate Search Key found.";
}
if (m_getCustomerByName.find(myCustomer[1]) != null){
return "Duplicate Name found.";
}
return "new";
}
public final void updatePlaces(int x, int y, String id) throws BasicException {
m_updatePlaces.exec(x, y, id);
}
public final void resetPickup(int x) throws BasicException {
m_resetPickup.exec(x);
}
public final SentenceList getVouchersActiveList() {
return m_voucherlist;
}
public final void addOrder(String orderId, Integer qty,
String details, String attributes, String notes, String ticketId,
String ordertime, Integer displayId, String auxiliary, String completetime
) throws BasicException {
m_addOrder.exec(orderId, qty, details, attributes, notes, ticketId,
ordertime, displayId, auxiliary, completetime);
}
public final void updateOrder(String orderId, Integer qty,
String details, String attributes, String notes, String ticketId,
String ordertime, Integer displayId, String auxiliary, String completetime
) throws BasicException {
m_updateOrder.exec(orderId, qty, details, attributes, notes, ticketId,
ordertime, displayId, auxiliary, completetime);
}
public void deleteOrder(String orderId) throws BasicException {
m_deleteOrder.exec(orderId);
}
}
@@ -0,0 +1,73 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import lombok.extern.slf4j.Slf4j;
import java.sql.*;
import java.util.Properties;
import java.util.logging.Logger;
/**
*
* @author adrianromero
*/
@Slf4j
public class DriverWrapper implements Driver {
private Driver driver;
/**
*
* @param d
*/
public DriverWrapper(Driver d) {
driver = d;
}
@Override
public boolean acceptsURL(String u) throws SQLException {
return driver.acceptsURL(u);
}
@Override
public Connection connect(String u, Properties p) throws SQLException {
return driver.connect(u, p);
}
@Override
public int getMajorVersion() {
return driver.getMajorVersion();
}
@Override
public int getMinorVersion() {
return driver.getMinorVersion();
}
@Override
public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
return driver.getPropertyInfo(u, p);
}
@Override
public boolean jdbcCompliant() {
return driver.jdbcCompliant();
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="title.changepassword" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="resizable" type="boolean" value="false"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-22,0,0,1,-96"/>
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_formBundle" type="java.lang.String" value="pos_messages"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
<Property name="alignment" type="int" value="2"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jcmdCancel">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/cancel.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[110, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jcmdOK">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/ok.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[110, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
</Border>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="11" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jtxtPasswordOld" min="-2" pref="180" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jtxtPasswordNew" min="-2" pref="180" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jtxtPasswordRepeat" min="-2" pref="180" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="88" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jtxtPasswordOld" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jtxtPasswordNew" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jtxtPasswordRepeat" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.passwordold" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JPasswordField" name="jtxtPasswordOld">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.passwordnew" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JPasswordField" name="jtxtPasswordNew">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JPasswordField" name="jtxtPasswordRepeat">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.passwordrepeat" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
@@ -0,0 +1,242 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.data.gui.JMessageDialog;
import com.unicenta.data.gui.MessageInf;
import com.unicenta.pos.util.Hashcypher;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import javax.swing.JFrame;
/**
*
* @author adrianromero
*/
public class JDlgChangePassword extends javax.swing.JDialog {
private String m_sOldPassword;
private String m_sNewPassword;
/** Creates new form ChangePassword */
private JDlgChangePassword(java.awt.Frame parent, boolean modal) {
super(parent, modal);
}
/** Creates new form ChangePassword */
private JDlgChangePassword(java.awt.Dialog parent, boolean modal) {
super(parent, modal);
}
private String init(String sOldPassword) {
initComponents();
getRootPane().setDefaultButton(jcmdOK);
m_sOldPassword = sOldPassword;
m_sNewPassword = null;
//show();
setVisible(true);
return m_sNewPassword;
}
private static Window getWindow(Component parent) {
if (parent == null) {
return new JFrame();
} else if (parent instanceof Frame || parent instanceof Dialog) {
return (Window)parent;
} else {
return getWindow(parent.getParent());
}
}
/**
*
* @param parent
* @param sOldPassword
* @return
*/
public static String showMessage(Component parent, String sOldPassword) {
Window window = getWindow(parent);
JDlgChangePassword myMsg;
if (window instanceof Frame) {
myMsg = new JDlgChangePassword((Frame) window, true);
} else {
myMsg = new JDlgChangePassword((Dialog) window, true);
}
return myMsg.init(sOldPassword);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
jcmdCancel = new javax.swing.JButton();
jcmdOK = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jtxtPasswordOld = new javax.swing.JPasswordField();
jLabel2 = new javax.swing.JLabel();
jtxtPasswordNew = new javax.swing.JPasswordField();
jtxtPasswordRepeat = new javax.swing.JPasswordField();
jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(AppLocal.getIntString("title.changepassword")); // NOI18N
setResizable(false);
jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N
jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N
jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45));
jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcmdCancelActionPerformed(evt);
}
});
jPanel2.add(jcmdCancel);
jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N
jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N
jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45));
jcmdOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcmdOKActionPerformed(evt);
}
});
jPanel2.add(jcmdOK);
getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
jPanel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jLabel1.setText(AppLocal.getIntString("label.passwordold")); // NOI18N
jLabel1.setPreferredSize(new java.awt.Dimension(150, 30));
jtxtPasswordOld.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jtxtPasswordOld.setPreferredSize(new java.awt.Dimension(0, 30));
jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jLabel2.setText(AppLocal.getIntString("label.passwordnew")); // NOI18N
jLabel2.setPreferredSize(new java.awt.Dimension(150, 30));
jtxtPasswordNew.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jtxtPasswordNew.setPreferredSize(new java.awt.Dimension(0, 30));
jtxtPasswordRepeat.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jtxtPasswordRepeat.setPreferredSize(new java.awt.Dimension(0, 30));
jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jLabel3.setText(AppLocal.getIntString("label.passwordrepeat")); // NOI18N
jLabel3.setPreferredSize(new java.awt.Dimension(150, 30));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jtxtPasswordOld, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jtxtPasswordNew, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jtxtPasswordRepeat, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(88, 88, 88))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jtxtPasswordOld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtxtPasswordNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jtxtPasswordRepeat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
setSize(new java.awt.Dimension(416, 234));
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
dispose();
}//GEN-LAST:event_jcmdCancelActionPerformed
private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
if (new String(jtxtPasswordNew.getPassword()).equals(new String(jtxtPasswordRepeat.getPassword()))) {
if (Hashcypher.authenticate(new String(jtxtPasswordOld.getPassword()), m_sOldPassword)) {
m_sNewPassword = Hashcypher.hashString(new String(jtxtPasswordNew.getPassword()));
dispose();
} else {
JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.BadPassword")));
}
} else {
JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.changepassworddistinct")));
}
}//GEN-LAST:event_jcmdOKActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JButton jcmdCancel;
private javax.swing.JButton jcmdOK;
private javax.swing.JPasswordField jtxtPasswordNew;
private javax.swing.JPasswordField jtxtPasswordOld;
private javax.swing.JPasswordField jtxtPasswordRepeat;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="20" left="20" right="20" top="20"/>
</Border>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_formBundle" type="java.lang.String" value="pos_messages"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,18,0,0,2,35"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="menucontainer">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
</Container>
</SubComponents>
</Form>
@@ -0,0 +1,153 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
*
* @author adrianromero
*/
public class JPanelMenu extends JPanel implements JPanelView {
private final MenuDefinition m_menu;
private boolean created = false;
/** Creates new form JPanelMenu
* @param menu */
public JPanelMenu(MenuDefinition menu) {
m_menu = menu;
created = false;
initComponents();
}
/**
*
* @return
*/
@Override
public JComponent getComponent() {
return this;
}
/**
*
* @return
*/
@Override
public String getTitle() {
return m_menu.getTitle();
}
/**
*
* @throws BasicException
*/
@Override
public void activate() throws BasicException {
if (created == false) {
for(int i = 0; i < m_menu.countMenuElements(); i++) {
MenuElement menuitem = m_menu.getMenuElement(i);
menuitem.addComponent(this);
}
created = true;
}
}
/**
*
* @return
*/
@Override
public boolean deactivate() {
return true;
}
/**
*
* @param title
*/
public void addTitle(Component title) {
currententrypanel = null;
JPanel titlepanel = new JPanel();
titlepanel.setLayout(new java.awt.BorderLayout());
titlepanel.add(title, java.awt.BorderLayout.CENTER);
titlepanel.applyComponentOrientation(getComponentOrientation());
menucontainer.add(titlepanel);
}
/**
*
* @param entry
*/
public void addEntry(Component entry) {
if (currententrypanel == null) {
currententrypanel = new JPanel();
currententrypanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 20, 0));
currententrypanel.setLayout(new java.awt.GridLayout(0, 6, 5, 5));
menucontainer.add(currententrypanel);
}
currententrypanel.add(entry);
currententrypanel.applyComponentOrientation(getComponentOrientation());
}
private JPanel currententrypanel = null;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
menucontainer = new javax.swing.JPanel();
setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20));
setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
setLayout(new java.awt.BorderLayout());
menucontainer.setBackground(new java.awt.Color(102, 102, 102));
menucontainer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
menucontainer.setLayout(new javax.swing.BoxLayout(menucontainer, javax.swing.BoxLayout.Y_AXIS));
add(menucontainer, java.awt.BorderLayout.NORTH);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel menucontainer;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,2,117"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
<Property name="useNullLayout" type="boolean" value="true"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="m_jLabelError">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.LoadError" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[110, 30]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="30" y="30" width="490" height="-1"/>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JScrollPane" name="jscrException">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
<AbsoluteConstraints x="30" y="70" width="550" height="180"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="jtxtException">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="lineWrap" type="boolean" value="true"/>
<Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
@@ -0,0 +1,115 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
*
* @author adrianromero
*/
public class JPanelNull extends JPanel implements JPanelView {
/** Creates new form JPanelNull
* @param oApp
* @param o */
public JPanelNull(AppView oApp, Object o) {
initComponents ();
if (o instanceof Exception) {
}
jtxtException.setText(o.toString());
}
/**
*
* @return
*/
@Override
public JComponent getComponent() {
return this;
}
/**
*
* @return
*/
@Override
public String getTitle() {
return null;
}
/**
*
* @throws BasicException
*/
@Override
public void activate() throws BasicException {
}
/**
*
* @return
*/
@Override
public boolean deactivate() {
return true;
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
m_jLabelError = new javax.swing.JLabel();
jscrException = new javax.swing.JScrollPane();
jtxtException = new javax.swing.JTextArea();
setLayout(null);
m_jLabelError.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
m_jLabelError.setText(AppLocal.getIntString("label.LoadError")); // NOI18N
m_jLabelError.setPreferredSize(new java.awt.Dimension(110, 30));
add(m_jLabelError);
m_jLabelError.setBounds(30, 30, 490, 30);
jtxtException.setEditable(false);
jtxtException.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jtxtException.setLineWrap(true);
jtxtException.setWrapStyleWord(true);
jscrException.setViewportView(jtxtException);
add(jscrException);
jscrException.setBounds(30, 70, 550, 180);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JScrollPane jscrException;
private javax.swing.JTextArea jtxtException;
private javax.swing.JLabel m_jLabelError;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,54 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import javax.swing.JComponent;
/**
*
* @author adrianromero
*/
public interface JPanelView {
/**
*
* @return
*/
public abstract String getTitle();
/**
*
* @throws BasicException
*/
public abstract void activate() throws BasicException;
/**
*
* @return
*/
public abstract boolean deactivate();
/**
*
* @return
*/
public abstract JComponent getComponent();
}
@@ -0,0 +1,202 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,53,0,0,1,-65"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="m_jPanelLeft">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[250, 2]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[45, 45]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace pref="88" max="32767" attributes="0"/>
<Component id="jButton1" pref="33" max="32767" attributes="0"/>
<EmptySpace pref="188" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="tooltip.menu" replaceFormat="AppLocal.getIntString(&quot;tooltip.menu&quot;)"/>
</Property>
<Property name="focusPainted" type="boolean" value="false"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="iconTextGap" type="int" value="0"/>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[10, 2, 10, 2]"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[45, 32224661]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32, 32]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[36, 45]"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="m_jPanelRight">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[200, 40]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="m_jPanelTitle">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="m_jTitle">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="df" green="a8" red="0" type="rgb"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo">
<CompoundBorder>
<Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
<MatteColorBorder bottom="1" left="0" right="0" top="0">
<Color PropertyName="color" blue="40" green="40" id="darkGray" palette="1" red="40" type="palette"/>
</MatteColorBorder>
</Border>
<Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="10" left="10" right="10" top="10"/>
</Border>
</CompoundBorder>
</Border>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 35]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[30, 25]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 35]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="m_jPanelContainer">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
@@ -0,0 +1,650 @@
// uniCenta oPOS Touch Friendly Point of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com/product
//
// This file is part of uniCenta oPOS.
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Openbravo POS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import com.unicenta.data.gui.JMessageDialog;
import com.unicenta.data.gui.MessageInf;
import com.unicenta.pos.customers.CustomerInfo;
import com.unicenta.pos.scripting.ScriptEngine;
import com.unicenta.pos.scripting.ScriptException;
import com.unicenta.pos.scripting.ScriptFactory;
import com.unicenta.pos.util.Hashcypher;
import com.unicenta.pos.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
// import java.awt.Color;
// import org.jdesktop.swingx.painter.MattePainter;
/**
* @author adrianromero
*/
@Slf4j
public class JPrincipalApp extends javax.swing.JPanel implements AppUserView {
private final JRootApp m_appview;
private final AppUser m_appuser;
private DataLogicSystem m_dlSystem;
private JLabel m_principalnotificator;
private JPanelView m_jLastView;
private Action m_actionfirst;
private Map<String, JPanelView> m_aPreparedViews; // Prepared views
private Map<String, JPanelView> m_aCreatedViews;
private Icon menu_open;
private Icon menu_close;
//HS Updates
private CustomerInfo customerInfo;
/**
* Creates new form JPrincipalApp
*
* @param appview
* @param appuser
*/
public JPrincipalApp(JRootApp appview, AppUser appuser) {
m_appview = appview;
m_appuser = appuser;
m_dlSystem = (DataLogicSystem) m_appview.getBean("com.unicenta.pos.forms.DataLogicSystem");
m_appuser.fillPermissions(m_dlSystem);
m_actionfirst = null;
m_jLastView = null;
m_aPreparedViews = new HashMap<>();
m_aCreatedViews = new HashMap<>();
initComponents();
jPanel2.add(Box.createVerticalStrut(50), 0);
m_jPanelLeft.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35));
applyComponentOrientation(appview.getComponentOrientation());
m_principalnotificator = new JLabel();
m_principalnotificator.applyComponentOrientation(getComponentOrientation());
m_principalnotificator.setText(m_appuser.getName());
m_principalnotificator.setIcon(m_appuser.getIcon());
if (jButton1.getComponentOrientation().isLeftToRight()) {
menu_open = new javax.swing.ImageIcon(getClass().getResource(
"/com/unicenta/images/menu-right.png"));
menu_close = new javax.swing.ImageIcon(getClass().getResource(
"/com/unicenta/images/menu-left.png"));
} else {
menu_open = new javax.swing.ImageIcon(getClass().getResource(
"/com/unicenta/images/menu-left.png"));
menu_close = new javax.swing.ImageIcon(getClass().getResource(
"/com/unicenta/images/menu-right.png"));
}
assignMenuButtonIcon();
m_jPanelTitle.setVisible(false);
m_jPanelContainer.add(new JPanel(), "<NULL>");
showView("<NULL>");
try {
Component scriptMenu = getScriptMenu(m_dlSystem.getResourceAsText("Menu.Root"));
m_jPanelLeft.setViewportView(scriptMenu);
} catch (ScriptException e) {
log.error("Cannot read Menu.Root resource. Trying default menu.", e.getMessage());
try {
m_jPanelLeft.setViewportView(getScriptMenu(
StringUtils.readResource("/com/unicenta/pos/templates/Menu.Root.txt")));
} catch (IOException | ScriptException ex) {
log.error("Cannot read default menu", ex.getMessage());
}
}
}
private Component getScriptMenu(String menutext) throws ScriptException {
ScriptMenu menu = new ScriptMenu();
ScriptEngine eng = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL);
eng.put("menu", menu);
eng.eval(menutext);
return menu.getTaskPane();
}
private void assignMenuButtonIcon() {
jButton1.setIcon(m_jPanelLeft.isVisible()
? menu_close
: menu_open);
}
/**
*
*/
public class ScriptMenu {
private final JXTaskPaneContainer taskPane;
private ScriptMenu() {
taskPane = new JXTaskPaneContainer();
taskPane.applyComponentOrientation(getComponentOrientation());
}
/**
* @param key
* @return
*/
public ScriptGroup addGroup(String key) {
ScriptGroup group = new ScriptGroup(key);
taskPane.add(group.getTaskGroup());
return group;
}
/**
* @return
*/
public JXTaskPaneContainer getTaskPane() {
return taskPane;
}
}
/**
*
*/
public class ScriptGroup {
private final JXTaskPane taskGroup;
private ScriptGroup(String key) {
taskGroup = new JXTaskPane();
taskGroup.applyComponentOrientation(getComponentOrientation());
taskGroup.setFocusable(false);
taskGroup.setRequestFocusEnabled(false);
taskGroup.setTitle(AppLocal.getIntString(key));
taskGroup.setVisible(false);
taskGroup.setFont(new java.awt.Font("Arial", 0, 16));
}
/**
* @param icon
* @param key
* @param classname
*/
public void addPanel(String icon, String key, String classname) {
addAction(new MenuPanelAction(m_appview, icon, key, classname));
}
/**
* @param icon
* @param key
* @param classname
*/
public void addExecution(String icon, String key, String classname) {
addAction(new MenuExecAction(m_appview, icon, key, classname));
}
/**
* @param icon
* @param key
* @param classname
* @return
*/
public ScriptSubmenu addSubmenu(String icon, String key, String classname) {
ScriptSubmenu submenu = new ScriptSubmenu(key);
m_aPreparedViews.put(classname, new JPanelMenu(submenu.getMenuDefinition()));
MenuPanelAction menuPanelAction = new MenuPanelAction(m_appview, icon, key, classname);
addAction(menuPanelAction);
return submenu;
}
/**
*
*/
public void addChangePasswordAction() {
addAction(new ChangePasswordAction("/com/unicenta/images/password.png", "Menu.ChangePassword"));
}
/**
*
*/
public void addExitAction() {
addAction(new ExitAction("/com/unicenta/images/logout.png", "Menu.Exit"));
}
private void addAction(Action act) {
String permissions = (String) act.getValue(AppUserView.ACTION_TASKNAME);
boolean hasPermission = m_appuser.hasPermission(permissions);
if (hasPermission) {
Component c = taskGroup.add(act);
c.applyComponentOrientation(getComponentOrientation());
c.setFocusable(false);
taskGroup.setVisible(true);
if (m_actionfirst == null) {
m_actionfirst = act;
}
}
}
/**
* @return
*/
public JXTaskPane getTaskGroup() {
return taskGroup;
}
}
/**
*
*/
public class ScriptSubmenu {
private final MenuDefinition menudef;
private ScriptSubmenu(String key) {
menudef = new MenuDefinition(key);
}
/**
* @param key
*/
public void addTitle(String key) {
menudef.addMenuTitle(key);
}
/**
* @param icon
* @param key
* @param classname
*/
public void addPanel(String icon, String key, String classname) {
menudef.addMenuItem(new MenuPanelAction(m_appview, icon, key, classname));
}
/**
* @param icon
* @param key
* @param classname
*/
public void addExecution(String icon, String key, String classname) {
menudef.addMenuItem(new MenuExecAction(m_appview, icon, key, classname));
}
/**
* @param icon
* @param key
* @param classname
* @return
*/
public ScriptSubmenu addSubmenu(String icon, String key, String classname) {
ScriptSubmenu submenu = new ScriptSubmenu(key);
m_aPreparedViews.put(classname, new JPanelMenu(submenu.getMenuDefinition()));
menudef.addMenuItem(new MenuPanelAction(m_appview, icon, key, classname));
return submenu;
}
/**
*
*/
public void addChangePasswordAction() {
menudef.addMenuItem(new ChangePasswordAction("/com/unicenta/images/password.png", "Menu.ChangePassword"));
}
/**
*
*/
public void addExitAction() {
menudef.addMenuItem(new ExitAction("/com/unicenta/images/logout.png", "Menu.Exit"));
}
/**
* @return
*/
public MenuDefinition getMenuDefinition() {
return menudef;
}
}
private void setMenuVisible(boolean value) {
m_jPanelLeft.setVisible(value);
assignMenuButtonIcon();
revalidate();
}
/**
* @return
*/
public JComponent getNotificator() {
return m_principalnotificator;
}
/**
*
*/
public void activate() {
setMenuVisible(getBounds().width > 800);
if (m_actionfirst != null) {
m_actionfirst.actionPerformed(null);
m_actionfirst = null;
}
}
/**
* @return
*/
public boolean deactivate() {
if (m_jLastView == null) {
return true;
} else if (m_jLastView.deactivate()) {
m_jLastView = null;
showView("<NULL>");
return true;
} else {
return false;
}
}
private class ExitAction extends AbstractAction {
public ExitAction(String icon, String keytext) {
putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon)));
putValue(Action.NAME, AppLocal.getIntString(keytext));
putValue(AppUserView.ACTION_TASKNAME, keytext);
}
@Override
public void actionPerformed(ActionEvent evt) {
m_appview.closeAppView();
}
}
/**
*
*/
public void exitToLogin() {
m_appview.closeAppView();
}
private class ChangePasswordAction extends AbstractAction {
public ChangePasswordAction(String icon, String keytext) {
putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon)));
putValue(Action.NAME, AppLocal.getIntString(keytext));
putValue(AppUserView.ACTION_TASKNAME, keytext);
}
@Override
public void actionPerformed(ActionEvent evt) {
String sNewPassword = Hashcypher.changePassword(JPrincipalApp.this, m_appuser.getPassword());
if (sNewPassword != null) {
try {
m_dlSystem.execChangePassword(new Object[]{sNewPassword, m_appuser.getId()});
m_appuser.setPassword(sNewPassword);
} catch (BasicException e) {
JMessageDialog.showMessage(JPrincipalApp.this
, new MessageInf(MessageInf.SGN_WARNING
, AppLocal.getIntString("message.cannotchangepassword")));
}
}
}
}
private void showView(String sView) {
CardLayout cl = (CardLayout) (m_jPanelContainer.getLayout());
cl.show(m_jPanelContainer, sView);
}
/**
* @return
*/
@Override
public AppUser getUser() {
return m_appuser;
}
/**
* @param sTaskClass
*/
@Override
public void showTask(String sTaskClass) {
customerInfo = new CustomerInfo("");
customerInfo.setName("");
m_appview.waitCursorBegin();
if (m_appuser.hasPermission(sTaskClass)) {
JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass);
if (m_jLastView == null|| (m_jMyView != m_jLastView && m_jLastView.deactivate())) {
if (m_jMyView == null) {
m_jMyView = m_aPreparedViews.get(sTaskClass);
if (m_jMyView == null) {
try {
m_jMyView = (JPanelView) m_appview.getBean(sTaskClass);
} catch (BeanFactoryException e) {
m_jMyView = new JPanelNull(m_appview, e);
}
}
m_jMyView.getComponent().applyComponentOrientation(getComponentOrientation());
m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass);
m_aCreatedViews.put(sTaskClass, m_jMyView);
}
try {
m_jMyView.activate();
} catch (BasicException e) {
JMessageDialog.showMessage(this
, new MessageInf(MessageInf.SGN_WARNING
, AppLocal.getIntString("message.notactive"), e));
}
m_jLastView = m_jMyView;
setMenuVisible(getBounds().width > 800);
setMenuVisible(false);
showView(sTaskClass);
String sTitle = m_jMyView.getTitle();
m_jPanelTitle.setVisible(sTitle != null);
m_jTitle.setText(sTitle);
}
} else {
JMessageDialog.showMessage(this
, new MessageInf(MessageInf.SGN_WARNING
, AppLocal.getIntString("message.notpermissions")));
}
m_appview.waitCursorEnd();
}
/**
* @param sTaskClass
*/
@Override
public void executeTask(String sTaskClass) {
m_appview.waitCursorBegin();
if (m_appuser.hasPermission(sTaskClass)) {
try {
ProcessAction myProcess = (ProcessAction) m_appview.getBean(sTaskClass);
try {
MessageInf m = myProcess.execute();
if (m != null) {
JMessageDialog.showMessage(JPrincipalApp.this, m);
}
} catch (BasicException eb) {
JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(eb));
}
} catch (BeanFactoryException e) {
JMessageDialog.showMessage(JPrincipalApp.this
, new MessageInf(MessageInf.SGN_WARNING
, AppLocal.getIntString("label.LoadError"), e));
}
} else {
JMessageDialog.showMessage(JPrincipalApp.this
, new MessageInf(MessageInf.SGN_WARNING
, AppLocal.getIntString("message.notpermissions")));
}
m_appview.waitCursorEnd();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
m_jPanelLeft = new javax.swing.JScrollPane();
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
m_jPanelRight = new javax.swing.JPanel();
m_jPanelTitle = new javax.swing.JPanel();
m_jTitle = new javax.swing.JLabel();
m_jPanelContainer = new javax.swing.JPanel();
setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
setLayout(new java.awt.BorderLayout());
jPanel1.setLayout(new java.awt.BorderLayout());
m_jPanelLeft.setBackground(new java.awt.Color(102, 102, 102));
m_jPanelLeft.setBorder(null);
m_jPanelLeft.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
m_jPanelLeft.setPreferredSize(new java.awt.Dimension(250, 2));
jPanel1.add(m_jPanelLeft, java.awt.BorderLayout.LINE_START);
jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jPanel2.setPreferredSize(new java.awt.Dimension(45, 45));
jButton1.setToolTipText(AppLocal.getIntString("tooltip.menu")); // NOI18N
jButton1.setFocusPainted(false);
jButton1.setFocusable(false);
jButton1.setIconTextGap(0);
jButton1.setMargin(new java.awt.Insets(10, 2, 10, 2));
jButton1.setMaximumSize(new java.awt.Dimension(45, 32224661));
jButton1.setMinimumSize(new java.awt.Dimension(32, 32));
jButton1.setPreferredSize(new java.awt.Dimension(36, 45));
jButton1.setRequestFocusEnabled(false);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap(88, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE)
.addContainerGap(188, Short.MAX_VALUE))
);
jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_END);
add(jPanel1, java.awt.BorderLayout.LINE_START);
m_jPanelRight.setPreferredSize(new java.awt.Dimension(200, 40));
m_jPanelRight.setLayout(new java.awt.BorderLayout());
m_jPanelTitle.setLayout(new java.awt.BorderLayout());
m_jTitle.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
m_jTitle.setForeground(new java.awt.Color(0, 168, 223));
m_jTitle.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)));
m_jTitle.setMaximumSize(new java.awt.Dimension(100, 35));
m_jTitle.setMinimumSize(new java.awt.Dimension(30, 25));
m_jTitle.setPreferredSize(new java.awt.Dimension(100, 35));
m_jPanelTitle.add(m_jTitle, java.awt.BorderLayout.NORTH);
m_jPanelRight.add(m_jPanelTitle, java.awt.BorderLayout.NORTH);
m_jPanelContainer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
m_jPanelContainer.setLayout(new java.awt.CardLayout());
m_jPanelRight.add(m_jPanelContainer, java.awt.BorderLayout.CENTER);
add(m_jPanelRight, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
setMenuVisible(!m_jPanelLeft.isVisible());
}//GEN-LAST:event_jButton1ActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel m_jPanelContainer;
private javax.swing.JScrollPane m_jPanelLeft;
private javax.swing.JPanel m_jPanelRight;
private javax.swing.JPanel m_jPanelTitle;
private javax.swing.JLabel m_jTitle;
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,443 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1024, 768]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,3,86,0,0,4,0"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="m_jPanelTitle">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
<MatteColorBorder bottom="1" left="0" right="0" top="0">
<Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/>
</MatteColorBorder>
</Border>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[449, 40]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="m_jLblTitle">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="16" style="1"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="Window.Title"/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JRootApp_m_jLblTitle"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="poweredby">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/poweredby_uni.png"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="5" right="5" top="0"/>
</Border>
</Property>
<Property name="horizontalTextPosition" type="int" value="4"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[180, 34]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[180, 34]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="16" style="1"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[180, 34]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="m_jPanelContainer">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="m_jPanelLogin">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
<CardConstraints cardName="login"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel4">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout">
<Property name="axis" type="int" value="1"/>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/unicenta.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="&quot;&lt;html&gt;&lt;center&gt;uniCenta oPOS - Touch Friendly Point of Sale&lt;br&gt;&quot; +&#xa; &quot;Copyright \u00A9 2009-2017 uniCenta &lt;br&gt;&quot; +&#xa; &quot;https://unicenta.com&lt;br&gt;&quot; +&#xa; &quot;&lt;br&gt;&quot; +&#xa; &quot;uniCenta oPOS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.&lt;br&gt;&quot; +&#xa; &quot;&lt;br&gt;&quot; +&#xa; &quot;uniCenta oPOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.&lt;br&gt;&quot; +&#xa; &quot;&lt;br&gt;&quot; +&#xa; &quot;You should have received a copy of the GNU General Public License along with uniCenta oPOS. If not, see http://www.gnu.org/licenses/&lt;br&gt;&quot; +&#xa; &quot;&lt;/center&gt;&quot;" type="code"/>
</Property>
<Property name="alignmentX" type="float" value="0.5"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[800, 1024]"/>
</Property>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="filler2">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[32767, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 10]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalGlue"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 400]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="East"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel1" max="32767" attributes="1"/>
<Component id="jScrollPane1" max="32767" attributes="1"/>
</Group>
<EmptySpace min="-2" pref="104" max="-2" attributes="0"/>
<Component id="m_jLogonName" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="m_jLogonName" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="434" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="m_jLogonName">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="0" left="5" right="5" top="0"/>
</Border>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 100]"/>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel8">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="North"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="horizontalGap" type="int" value="5"/>
<Property name="rows" type="int" value="0"/>
<Property name="verticalGap" type="int" value="5"/>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="horizontalScrollBarPolicy" type="int" value="31"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JRootApp_jScrollPane1"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="m_txtKeys" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="m_jClose" pref="267" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="m_txtKeys" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="m_jClose" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JTextField" name="m_txtKeys">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[0, 0]"/>
</Property>
</Properties>
<Events>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="m_txtKeysKeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="m_jClose">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/exit.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="button.close" replaceFormat="AppLocal.getIntString(&quot;{key}&quot;)"/>
</Property>
<Property name="focusPainted" type="boolean" value="false"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 50]"/>
</Property>
<Property name="requestFocusEnabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCloseActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="m_jPanelDown">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo">
<MatteColorBorder bottom="0" left="0" right="0" top="1">
<Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/>
</MatteColorBorder>
</Border>
</Property>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="South"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelTask">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="m_jHost">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="11" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/display.png"/>
</Property>
<Property name="text" type="java.lang.String" value="*Hostname"/>
</Properties>
</Component>
<Component class="com.alee.extended.statusbar.WebMemoryBar" name="webMemoryBar1">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="99" green="99" red="99" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value=""/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="11" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
<Property name="usedBorderColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="0" type="rgb"/>
</Property>
<Property name="usedFillColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="cc" red="0" type="rgb"/>
</Property>
</Properties>
</Component>
<Component class="com.alee.laf.progressbar.WebProgressBar" name="serverMonitor">
<Properties>
<Property name="toolTipText" type="java.lang.String" value=""/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[50, 18]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
<Property name="progressBottomColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ed" green="c5" red="4c" type="rgb"/>
</Property>
<Property name="round" type="int" value="2"/>
<Property name="string" type="java.lang.String" value="Keep Alive"/>
<Property name="stringPainted" type="boolean" value="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="After"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="0"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Form>
@@ -0,0 +1,161 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.plugins.Application;
import com.unicenta.plugins.metrics.Metrics;
import com.unicenta.pos.config.JFrmConfig;
import com.unicenta.pos.instance.AppMessage;
import com.unicenta.pos.instance.InstanceManager;
import java.awt.BorderLayout;
import java.io.IOException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import com.unicenta.pos.scripting.ScriptEngine;
import com.unicenta.pos.scripting.ScriptException;
import com.unicenta.pos.scripting.ScriptFactory;
import com.unicenta.pos.util.AltEncrypter;
import com.unicenta.pos.util.OSValidator;
import com.unicenta.pos.util.SessionKeepAlive;
import lombok.extern.slf4j.Slf4j;
/**
* @author adrianromero
*/
@Slf4j
public class JRootFrame extends javax.swing.JFrame implements AppMessage {
private InstanceManager m_instmanager = null;
private JRootApp m_rootapp;
private AppProperties m_props;
private OSValidator m_OS;
/**
* Creates new form JRootFrame
*/
public JRootFrame() {
initComponents();
}
/**
* @param props
*/
public void initFrame(AppProperties props) {
m_OS = new OSValidator();
m_props = props;
m_rootapp = new JRootApp();
if (m_rootapp.initApp(m_props)) {
if ("true".equals(props.getProperty("machine.uniqueinstance"))) {
// Register the running application
try {
m_instmanager = new InstanceManager(this);
} catch (RemoteException | AlreadyBoundException e) {
}
}
// Show the application
add(m_rootapp, BorderLayout.CENTER);
try {
this.setIconImage(ImageIO.read(JRootFrame.class.getResourceAsStream("/com/unicenta/images/favicon.png")));
} catch (IOException e) {
}
setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);
pack();
setLocationRelativeTo(null);
setVisible(true);
} else {
new JFrmConfig(props).setVisible(true); // Show the configuration window.
}
}
/**
* @throws RemoteException
*/
@Override
public void restoreWindow() throws RemoteException {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
if (getExtendedState() == JFrame.ICONIFIED) {
setExtendedState(JFrame.NORMAL);
}
requestFocus();
}
});
}
private void startSessionKeepAlive(DataLogicSystem dataLogicSystem) {
SessionKeepAlive sessionKeepAlive = new SessionKeepAlive(dataLogicSystem);
sessionKeepAlive.start();
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
}// </editor-fold>//GEN-END:initComponents
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
m_rootapp.tryToClose();
}//GEN-LAST:event_formWindowClosing
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
m_rootapp.releaseResources();
System.exit(0);
}//GEN-LAST:event_formWindowClosed
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="0"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
</Events>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,113,0,0,2,23"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
</Form>
@@ -0,0 +1,175 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.pos.config.JFrmConfig;
import com.unicenta.pos.instance.AppMessage;
import com.unicenta.pos.instance.InstanceManager;
import com.unicenta.pos.util.OSValidator;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import javax.swing.JFrame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JOptionPane;
/**
*
* @author adrianromero
*/
public class JRootKiosk extends javax.swing.JFrame implements AppMessage {
private InstanceManager m_instmanager = null;
private JRootApp m_rootapp;
private AppProperties m_props;
private OSValidator m_OS;
/** Creates new form JRootKiosk */
public JRootKiosk() {
setUndecorated(true);
setResizable(false);
initComponents();
}
/**
*
* @param props
* @throws java.io.IOException
*/
public void initFrame(AppProperties props) throws IOException {
m_OS = new OSValidator();
m_props = props;
m_rootapp = new JRootApp();
if (m_rootapp.initApp(m_props)) {
if ("true".equals(props.getProperty("machine.uniqueinstance"))) {
try {
m_instmanager = new InstanceManager(this);
} catch (RemoteException | AlreadyBoundException e) {
}
}
add(m_rootapp, BorderLayout.CENTER);
setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0, 0, d.width, d.height);
/*
* 4 Sep 17 JG
* 2 Dec 17 - Mod' Thanks Hayk Sokolov!
* Change here for Linux/Ubuntu full screen
* Thanks to Hans Lengerke for solution
*/
String osName = System.getProperty("os.name").toLowerCase();
boolean isWindows = osName.startsWith("windows");
GraphicsDevice device = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (device.isFullScreenSupported() && !isWindows) {
setResizable(true);
addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent arg0) {
setAlwaysOnTop(true);
}
@Override
public void focusLost(FocusEvent arg0) {
setAlwaysOnTop(false);
}
});
device.setFullScreenWindow(this);
} else {
setVisible(true);
}
} else {
JOptionPane.showMessageDialog(this,
AppLocal.getIntString("message.databasechange"),
"Connection", JOptionPane.INFORMATION_MESSAGE);
new JFrmConfig(props).setVisible(true); // Show the configuration window.
}
}
@Override
public void restoreWindow() throws RemoteException {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
if (getExtendedState() == JFrame.ICONIFIED) {
setExtendedState(JFrame.NORMAL);
}
requestFocus();
}
});
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosed(java.awt.event.WindowEvent evt) {
formWindowClosed(evt);
}
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
}// </editor-fold>//GEN-END:initComponents
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
m_rootapp.tryToClose();
}//GEN-LAST:event_formWindowClosing
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
m_rootapp.releaseResources();
System.exit(0);
}//GEN-LAST:event_formWindowClosed
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,94 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.util.ArrayList;
import javax.swing.Action;
/**
*
* @author adrianromero
*/
public class MenuDefinition {
private final String m_sKey;
private final ArrayList m_aMenuElements;
/** Creates a new instance of MenuDefinition
* @param skey */
public MenuDefinition(String skey) {
m_sKey = skey;
m_aMenuElements = new ArrayList();
}
/**
*
* @return
*/
public String getKey() {
return m_sKey;
}
/**
*
* @return
*/
public String getTitle() {
return AppLocal.getIntString(m_sKey);
}
/**
*
* @param act
*/
public void addMenuItem(Action act) {
MenuItemDefinition menuitem = new MenuItemDefinition(act);
m_aMenuElements.add(menuitem);
}
/**
*
* @param keytext
*/
public void addMenuTitle(String keytext) {
MenuTitleDefinition menutitle = new MenuTitleDefinition();
menutitle.KeyText = keytext;
m_aMenuElements.add(menutitle);
}
/**
*
* @param i
* @return
*/
public MenuElement getMenuElement(int i) {
return (MenuElement) m_aMenuElements.get(i);
}
/**
*
* @return
*/
public int countMenuElements() {
return m_aMenuElements.size();
}
}
@@ -0,0 +1,33 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
/**
*
* @author adrianromero
*/
public interface MenuElement {
/**
*
* @param menu
*/
public void addComponent(JPanelMenu menu);
}
@@ -0,0 +1,52 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
/**
*
* @author adrianromero
*/
public class MenuExecAction extends AbstractAction {
private final AppView m_App;
private final String m_sMyView;
/** Creates a new instance of MenuExecAction
* @param app
* @param icon
* @param keytext
* @param sMyView */
public MenuExecAction(AppView app, String icon, String keytext, String sMyView) {
putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon)));
putValue(Action.NAME, AppLocal.getIntString(keytext));
putValue(AppUserView.ACTION_TASKNAME, sMyView);
m_App = app;
m_sMyView = sMyView;
}
@Override
public void actionPerformed(ActionEvent evt) {
m_App.getAppUserView().executeTask(m_sMyView);
}
}
@@ -0,0 +1,60 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.awt.Dimension;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.SwingConstants;
/**
*
* @author adrianromero
*/
public class MenuItemDefinition implements MenuElement {
private Action act;
/**
*
* @param act
*/
public MenuItemDefinition(Action act) {
this.act = act;
}
/**
*
* @param menu
*/
@Override
public void addComponent(JPanelMenu menu) {
JButton btn = new JButton(act);
btn.setFocusPainted(false);
btn.setFocusable(false);
btn.setRequestFocusEnabled(false);
btn.setHorizontalAlignment(SwingConstants.LEADING);
btn.setPreferredSize(new Dimension(100, 100));
menu.addEntry(btn);
}
}
@@ -0,0 +1,73 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.plugins.Application;
import lombok.extern.slf4j.Slf4j;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
/**
*
* @author adrianromero
*/
@Slf4j
public class MenuPanelAction extends AbstractAction {
private final AppView m_App;
private final String m_sMyView;
/** Creates a new instance of MenuPanelAction
* @param app
* @param icon
* @param keytext
* @param sMyView */
public MenuPanelAction(AppView app, String icon, String keytext, String sMyView) {
putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon)));
putValue(Action.NAME, AppLocal.getIntString(keytext));
putValue(AppUserView.ACTION_TASKNAME, sMyView);
m_App = app;
m_sMyView = sMyView;
}
@Override
public void actionPerformed(ActionEvent evt) {
if (m_sMyView.equals("plugins.configure") ) {
log.debug("Configure plugins");
new Application().initScreen("Dashboard", getActiveWindow());
}
else {
m_App.getAppUserView().showTask(m_sMyView);
}
}
private Window getActiveWindow() {
for (Window window: Window.getWindows()) {
if (window instanceof JRootFrame) {
return window;
}
}
return null;
}
}
@@ -0,0 +1,51 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.JLabel;
import javax.swing.border.MatteBorder;
/**
*
* @author adrianromero
*/
public class MenuTitleDefinition implements MenuElement {
/**
*
*/
public String KeyText;
/**
*
* @param menu
*/
@Override
public void addComponent(JPanelMenu menu) {
JLabel lbl = new JLabel(AppLocal.getIntString(KeyText));
lbl.applyComponentOrientation(menu.getComponentOrientation());
lbl.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), new Color(0, 0, 0)));
menu.addTitle(lbl);
}
}
@@ -0,0 +1,163 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import java.util.HashMap;
/**
*
* @author Jack Gerrard
*/
public class Payments {
private Double amount;
private Double tendered;
private final HashMap paymentPaid;
private final HashMap paymentTendered;
private final HashMap rtnMessage;
private String name;
private final HashMap paymentVoucher;
private final HashMap paymentNote;
/**
*
*/
public Payments() {
paymentPaid = new HashMap();
paymentTendered = new HashMap();
rtnMessage = new HashMap();
paymentVoucher = new HashMap();
paymentNote = new HashMap();
}
/**
*
* @param pName
* @param pAmountPaid
* @param pTendered
* @param rtnMsg
*/
public void addPayment (String pName, Double pAmountPaid, Double pTendered, String rtnMsg){
if (paymentPaid.containsKey(pName)){
paymentPaid.put(pName,Double.parseDouble(paymentPaid.get(pName).toString()) + pAmountPaid);
paymentTendered.put(pName,Double.parseDouble(paymentTendered.get(pName).toString()) + pTendered);
rtnMessage.put(pName, rtnMsg);
}else {
paymentPaid.put(pName, pAmountPaid);
paymentTendered.put(pName,pTendered);
rtnMessage.put(pName, rtnMsg);
}
}
/**
*
* @param pName
* @param pAmountPaid
* @param pTendered
* @param rtnMsg
* @param pVoucher
*/
public void addPayment (String pName, Double pAmountPaid, Double pTendered, String rtnMsg, String pVoucher, String pNote){
if (paymentPaid.containsKey(pName)){
paymentPaid.put(pName,Double.parseDouble(paymentPaid.get(pName).toString()) + pAmountPaid);
paymentTendered.put(pName,Double.parseDouble(paymentTendered.get(pName).toString()) + pTendered);
rtnMessage.put(pName, rtnMsg);
paymentVoucher.put(pName, pVoucher);
paymentNote.put(pName, pNote);
}else {
paymentPaid.put(pName, pAmountPaid);
paymentTendered.put(pName,pTendered);
rtnMessage.put(pName, rtnMsg);
paymentNote.put(pName, pNote);
if (pVoucher !=null) {
paymentVoucher.put(pName, pVoucher);
} else {
pVoucher = "0";
paymentVoucher.put(pName, pVoucher);
}
}
}
/**
*
* @param pName
* @return
*/
public Double getTendered (String pName){
return(Double.parseDouble(paymentTendered.get(pName).toString()));
}
/**
*
* @param pName
* @return
*/
public Double getPaidAmount (String pName){
return(Double.parseDouble(paymentPaid.get(pName).toString()));
}
/**
*
* @return
*/
public Integer getSize(){
return (paymentPaid.size());
}
/**
*
* @param pName
* @return
*/
public String getRtnMessage(String pName){
return (rtnMessage.get(pName).toString());
}
public String getVoucher(String pName){
return (paymentVoucher.get(pName).toString());
}
public String getNote(String pName) {
String note = null;
if (paymentNote.get(pName) != null) {
note = paymentNote.get(pName).toString();
}
return note ;
}
public String getFirstElement(){
String rtnKey= paymentPaid.keySet().iterator().next().toString();
return(rtnKey);
}
/**
*
* @param pName
*/
public void removeFirst (String pName){
paymentPaid.remove(pName);
paymentTendered.remove(pName);
rtnMessage.remove(pName);
}
}
@@ -0,0 +1,37 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.forms;
import com.unicenta.basic.BasicException;
import com.unicenta.data.gui.MessageInf;
/**
*
* @author adrianromero
*/
public interface ProcessAction {
/**
*
* @return
* @throws BasicException
*/
public MessageInf execute() throws BasicException;
}
@@ -0,0 +1,138 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>
package com.unicenta.pos.forms;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme;
import com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme;
import com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme;
import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme;
import com.unicenta.format.Formats;
import com.unicenta.plugins.Application;
import com.unicenta.plugins.metrics.Metrics;
import com.unicenta.pos.instance.InstanceQuery;
import com.unicenta.pos.ticket.TicketInfo;
import lombok.extern.slf4j.Slf4j;
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.SubstanceSkin;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import java.io.IOException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Locale;
@Slf4j
public class StartPOS {
private StartPOS() {
}
public static boolean registerApp() {
InstanceQuery i = null;
try {
i = new InstanceQuery();
i.getAppMessage().restoreWindow();
return false;
} catch (RemoteException | NotBoundException e) {
return true;
}
}
public static void main(final String args[]) {
SwingUtilities.invokeLater(() -> {
if (!registerApp()) {
System.exit(1);
}
AppConfig config = new AppConfig(args);
config.load();
String slang = config.getProperty("user.language");
String scountry = config.getProperty("user.country");
String svariant = config.getProperty("user.variant");
if (slang != null
&& !slang.equals("")
&& scountry != null
&& svariant != null) {
Locale.setDefault(new Locale(slang, scountry, svariant));
}
Formats.setIntegerPattern(config.getProperty("format.integer"));
Formats.setDoublePattern(config.getProperty("format.double"));
Formats.setCurrencyPattern(config.getProperty("format.currency"));
Formats.setPercentPattern(config.getProperty("format.percent"));
Formats.setDatePattern(config.getProperty("format.date"));
Formats.setTimePattern(config.getProperty("format.time"));
Formats.setDateTimePattern(config.getProperty("format.datetime"));
// Set the look and feel
try {
Object laf = Class.forName(config.getProperty("swing.defaultlaf")).newInstance();
if (!(laf instanceof MetalLookAndFeel) && laf instanceof LookAndFeel) {
UIManager.setLookAndFeel((LookAndFeel) laf);
} else {
UIManager.setLookAndFeel("com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme");
}
} catch (Exception e) {
log.error("Cannot set Look and Feel ${0}", e.getMessage());
}
String hostname = config.getProperty("machine.hostname");
TicketInfo.setHostname(hostname);
applicationStarted(hostname);
String screenmode = config.getProperty("machine.screenmode");
if ("fullscreen".equals(screenmode)) {
JRootKiosk rootkiosk = new JRootKiosk();
try {
rootkiosk.initFrame(config);
} catch (IOException ex) {
log.error(ex.getMessage());
}
} else {
JRootFrame rootframe = new JRootFrame();
try {
rootframe.initFrame(config);
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
});
}
private static void applicationStarted(String host) {
new Thread(() -> {
Metrics metrics = new Metrics();
metrics.setDevice(host);
metrics.setUniCentaVersion(AppLocal.APP_VERSION);
new Application().postMetrics(metrics);
}).start();
}
}