properties para cuando se necesiten!

This commit is contained in:
Daniel Cortés
2019-06-20 13:01:52 -04:00
parent 0e40880518
commit 41ef86d79b
5 changed files with 42 additions and 17 deletions

5
configuration.properties Normal file
View File

@@ -0,0 +1,5 @@
look_and_feel = javax.swing.plaf.nimbus.NimbusLookAndFeel
#look_and_feel = javax.swing.plaf.metal.MetalLookAndFeel
#look_and_feel = com.sun.java.swing.plaf.motif.MotifLookAndFeel
#look_and_feel = com.sun.java.swing.plaf.gtk.GTKLookAndFeel
#look_and_feel = com.sun.java.swing.plaf.windows.WindowsLookAndFeel

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,6 +5,7 @@ import java.lang.reflect.Field;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import xyz.danielcortes.controllers.LaunchController;
import xyz.danielcortes.framework.Config;
import xyz.danielcortes.login.LoginController;
import xyz.danielcortes.login.LoginPanel;
@@ -30,6 +31,7 @@ public class App {
});
}
/**
* Configura el look and feel del programa.
* <p>
@@ -45,13 +47,7 @@ public class App {
System.setProperty("swing.aatext", "true");
try {
String windows = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
String motif = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
String nimbus = "javax.swing.plaf.nimbus.NimbusLookAndFeel";
String metal = "javax.swing.plaf.metal.MetalLookAndFeel";
String gtk = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
UIManager.setLookAndFeel(nimbus);
UIManager.setLookAndFeel(Config.get("look_and_feel"));
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

View File

@@ -0,0 +1,23 @@
package xyz.danielcortes.framework;
import java.io.FileInputStream;
import java.util.Properties;
public class Config {
private static Properties defaultProps = new Properties();
static {
try {
FileInputStream in = new FileInputStream("configuration.properties");
defaultProps.load(in);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static String get(String key) {
return defaultProps.getProperty(key);
}
}

View File

@@ -1,7 +1,7 @@
package xyz.danielcortes.repository;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import xyz.danielcortes.framework.BaseRepository;
import xyz.danielcortes.models.Compra;
@@ -14,12 +14,13 @@ public class CompraRepository extends BaseRepository<Compra> {
}
public List<Compra> search(String term) {
Query query = this.em.createQuery("SELECT c FROM Compra c WHERE "
+ "LOWER(c.factura.folio) LIKE :term OR "
+ "c.factura.precioNeto LIKE :term OR "
+ "c.factura.precioNeto + c.factura.precioIVA LIKE :term OR "
+ "LOWER(c.distribuidor.rut) LIKE :term OR "
+ "COCOUNT(c.ejemplares.size) LIKE :term"
);
// Query query = this.em.createQuery("SELECT c FROM Compra c WHERE "
// + "LOWER(c.factura.folio) LIKE :term OR "
// + "c.factura.precioNeto LIKE :term OR "
// + "c.factura.precioNeto + c.factura.precioIVA LIKE :term OR "
// + "LOWER(c.distribuidor.rut) LIKE :term OR "
// + "COUNT(c.ejemplares.size) LIKE :term"
// );
return new ArrayList<>();
}
}