This commit is contained in:
2018-07-01 13:14:51 -04:00
commit bdbb262ec1
31 changed files with 2206 additions and 0 deletions
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
Formula [Formula Manager](http://zakscode.com)
=======================
Presenting [Formula Manager v1.0](http://zakscode.com),
Software to record **vendors**, **materials**, and **formulas** using the materials.
+14
View File
@@ -0,0 +1,14 @@
#Fri Jun 29 23:27:23 EDT 2018
debug=false
resolution-y=600
port=
resolution-x=1120
metric=true
username=
allow-publish=false
large-units=false
temp-path=/temp/
data-path=/data/
data-URL=/formulaManagerData/
URL=screenprintingsuppliescanada.com
password=
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

+48
View File
@@ -0,0 +1,48 @@
java.io.IOException: expected='endstream' actual='' at offset 555094
at org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:607)
at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:650)
at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1227)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1194)
at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1165)
at com.zakscode.FormulaManager.Export.printPDF(Export.java:133)
at com.zakscode.FormulaManager.Frame$13.actionPerformed(Frame.java:201)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.
Binary file not shown.
+85
View File
@@ -0,0 +1,85 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Main;
import com.zakscode.FormulaManager.TableArray;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;
public class Component
implements Serializable,
TableArray {
private static final long serialVersionUID = -2154735157565376110L;
private String partNum;
private String vendor;
private String description;
private double cost;
private Date date;
public Component(String partNum, String vendor, String description, double cost) {
this.partNum = partNum;
this.vendor = vendor;
this.description = description;
this.cost = cost;
this.date = Calendar.getInstance().getTime();
}
public String getPartNum() {
return this.partNum;
}
public String getVendor() {
return this.vendor;
}
public String getDescription() {
return this.description;
}
public double getCost() {
DecimalFormat df = new DecimalFormat("0.00");
if (Main.metric) {
return Double.parseDouble(df.format(this.cost));
}
return Double.parseDouble(df.format(this.cost / 2.2));
}
public Date getDate() {
return this.date;
}
public void setPartNum(String partNum) {
this.partNum = partNum;
this.date = Calendar.getInstance().getTime();
}
public void setVendor(String vendor) {
this.vendor = vendor;
this.date = Calendar.getInstance().getTime();
}
public void setDescription(String description) {
this.description = description;
this.date = Calendar.getInstance().getTime();
}
public void setCost(double cost) {
this.cost = Main.metric ? cost : cost * 2.2046;
this.date = Calendar.getInstance().getTime();
}
@Override
public Object[] toArray() {
DecimalFormat df = new DecimalFormat("$0.00 ");
return new Object[]{this.partNum, this.vendor, this.description, df.format(this.getCost()), this.date};
}
public String toString() {
return this.partNum;
}
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import java.io.Serializable;
public class ComponentQuantity
implements Serializable {
private static final long serialVersionUID = 218124235517877938L;
private String component;
private double quantity;
public ComponentQuantity(String component, double quantity) {
this.component = component;
this.quantity = quantity;
}
public String getComponent() {
return this.component;
}
public double getQuantity() {
return this.quantity;
}
public void setComponent(String component) {
this.component = component;
}
public void setQuantity(double quantity) {
this.quantity = quantity;
}
}
+52
View File
@@ -0,0 +1,52 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Main;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
public class Configuration
extends Properties {
private static final long serialVersionUID = 5884857151380277240L;
private InputStream inputStream;
private final String name;
public Configuration() {
this.name = "configuration.properties";
try {
this.inputStream = new FileInputStream(Main.baseDir + this.name);
this.load(this.inputStream);
}
catch (IOException e) {
Logger.write(e);
}
finally {
try {
this.inputStream.close();
}
catch (IOException e) {
Logger.write(e);
}
}
}
public void save() {
File f = new File(Main.baseDir + this.name);
try {
FileOutputStream out = new FileOutputStream(f);
this.store(out, null);
}
catch (IOException e) {
Logger.write(e);
}
}
}
+161
View File
@@ -0,0 +1,161 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Component;
import com.zakscode.FormulaManager.ComponentQuantity;
import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.FileManager;
import com.zakscode.FormulaManager.Formula;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Main;
import com.zakscode.FormulaManager.Vendor;
import java.io.File;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Set;
import org.apache.pdfbox.pdmodel.PDDocument;
class Export {
private static final String HEADER = "<!DOCTYPE html><html><body><center><h1>FH &#38; Sons</h1></center>";
private static final String FOOTER = "</body></html>";
Export() {
}
public static File vendorsToHTML(FileManager<Vendor> v) {
try {
File doc = new File(Main.baseDir + Main.conf.getProperty("temp-path") + "Vendors.html");
PrintWriter pw = new PrintWriter(doc);
String html = "<!DOCTYPE html><html><body><center><h1>FH &#38; Sons</h1></center>";
Set keys = v.keySet();
Object[] keysArray = keys.toArray(new String[keys.size()]);
Arrays.sort(keysArray);
boolean floatLeft = true;
for (Object key : keysArray) {
html = html + (floatLeft ? "<div style=\"overflow: hidden;\">" : "") + "<div style=\"float: " + (floatLeft ? "left; " : "right; ") + "width: 45%; overflow: hidden; padding: 0px 20px 0px 20px\">";
html = html + "<p><strong style=\"float: left\">Name: </strong>" + (String)key + "</p>";
html = html + (key.trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Phone: </strong> " + ((Vendor)v.get(key)).getPhone() + "</p>";
html = html + (((Vendor)v.get(key)).getPhone().trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Email: </strong> " + ((Vendor)v.get(key)).getEmail() + "</p>";
html = html + (((Vendor)v.get(key)).getEmail().trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Website: </strong> " + ((Vendor)v.get(key)).getWebsite() + "</p>";
html = html + "<br /></div>" + (floatLeft ? "" : "</div><br />");
floatLeft = !floatLeft;
}
if (keysArray.length % 2 == 1) {
html = html + "</div>";
}
html = html + "</body></html>";
pw.write(html);
pw.close();
return doc;
}
catch (Exception e) {
Logger.write(e);
return null;
}
}
public static File componentsToHTML(FileManager<Component> c) {
try {
File doc = new File(Main.baseDir + Main.conf.getProperty("temp-path") + "Components.html");
PrintWriter pw = new PrintWriter(doc);
String html = "<!DOCTYPE html><html><body><center><h1>FH &#38; Sons</h1></center>";
Set keys = c.keySet();
Object[] keysArray = keys.toArray(new String[keys.size()]);
Arrays.sort(keysArray);
boolean floatLeft = true;
for (Object key : keysArray) {
html = html + (floatLeft ? "<div style=\"overflow: hidden;\">" : "") + "<div style=\"float: " + (floatLeft ? "left; " : "right; ") + "width: 45%; overflow: hidden; padding: 0px 20px 0px 20px\">";
html = html + "<p><strong style=\"float: left\">Name:</strong> " + (String)key + "</p>";
html = html + (key.trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Vendor:</strong> " + ((Component)c.get(key)).getVendor() + "</p>";
html = html + (((Component)c.get(key)).getVendor().trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Description:</strong> " + ((Component)c.get(key)).getDescription() + "</p>";
html = html + (((Component)c.get(key)).getDescription().trim().equals("") ? "<br />" : "");
html = html + "<p><strong style=\"float: left\">Cost (per " + (Main.metric ? "kg" : "lb") + "): </strong> " + new DecimalFormat("$0.00").format(((Component)c.get(key)).getCost() / (double)(Main.metric ? true : true) ? 1 : 0) + "</p>";
html = html + "</div>" + (floatLeft ? "" : "</div><br />");
floatLeft = !floatLeft;
}
if (keysArray.length % 2 == 1) {
html = html + "</div>";
}
html = html + "</body></html>";
pw.write(html);
pw.close();
return doc;
}
catch (Exception e) {
Logger.write(e);
return null;
}
}
public static File formulasToHTML(FileManager<Formula> f) {
try {
File doc = new File(Main.baseDir + Main.conf.getProperty("temp-path") + "Formulas.html");
PrintWriter pw = new PrintWriter(doc);
String html = "<!DOCTYPE html><html><body><center><h1>FH &#38; Sons</h1></center>";
Set keys = f.keySet();
Object[] keysArray = keys.toArray(new String[keys.size()]);
Arrays.sort(keysArray);
boolean floatLeft = true;
for (Object key : keysArray) {
html = html + (floatLeft ? "<div style=\"overflow: hidden;\">" : "") + "<div style=\"float: " + (floatLeft ? "left; " : "right; ") + "width: 45%; overflow: hidden; padding: 0px 20px 0px 20px\">";
html = html + "<p><strong style=\"float: left\">" + (String)key + "</strong></p> <strong style=\"float: right\">" + ((Formula)f.get(key)).getDescription() + "</strong>";
double total = 0.0;
for (ComponentQuantity cq : (Formula)f.get(key)) {
total += cq.getQuantity();
html = html + "<br />";
html = html + "<p style=\"float: left; margin: 0px 0px 0px 0px\">" + cq.getComponent() + "</p><p style=\"float: right; margin: 0px 0px 0px 0px\">" + new DecimalFormat("0.00").format(cq.getQuantity()) + (Main.metric ? " g" : " oz") + "</p>";
}
html = html + "<br /><hr></hr>";
html = html + "<p style=\"float: right; margin: 0px 0px 0px 0px\"><strong>Total: </strong>" + new DecimalFormat("0.00").format(total) + (Main.metric ? " g" : " oz") + "</p>";
html = html + "<br /><hr></hr></div>" + (floatLeft ? "" : "</div><br />");
floatLeft = !floatLeft;
}
if (keysArray.length % 2 == 1) {
html = html + "</div>";
}
html = html + "</body></html>";
pw.write(html);
pw.close();
return doc;
}
catch (Exception e) {
Logger.write(e);
return null;
}
}
public static File HTMLToPDF(File in) {
try {
File out = new File(in.toString().replace(".html", ".pdf"));
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("\"" + Main.baseDir + "resources/wkhtmltopdf\" \"" + in.getAbsoluteFile() + "\" \"" + out.getAbsolutePath() + "\"");
pr.waitFor();
return out;
}
catch (Exception e) {
Logger.write(e);
return null;
}
}
public static boolean printPDF(File file) {
try {
PDDocument doc = PDDocument.load(file);
doc.print();
return true;
}
catch (Exception e) {
Logger.write(e);
return false;
}
}
}
+95
View File
@@ -0,0 +1,95 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Main;
import it.sauronsoftware.ftp4j.FTPClient;
import java.io.File;
public class FTPManager {
private String url;
private int port;
private String user;
private String password;
private FTPClient client;
public FTPManager(String url, int port, String user, String password) {
this.url = url;
this.port = port;
this.user = user;
this.password = password;
this.client = new FTPClient();
try {
this.client.connect(this.url, this.port);
this.client.login(this.user, this.password);
}
catch (Exception e) {
Logger.write(e);
}
}
public String getUrl() {
return this.url;
}
public int getPort() {
return this.port;
}
public String getUser() {
return this.user;
}
public String getPassword() {
return this.password;
}
public FTPClient getClient() {
return this.client;
}
public void setUrl(String url) {
this.url = url;
}
public void setPort(int port) {
this.port = port;
}
public void setUser(String user) {
this.user = user;
}
public void setPassword(String password) {
this.password = password;
}
public void setClient(FTPClient client) {
this.client = client;
}
public void writeFiles() {
try {
this.client.changeDirectory(Main.conf.getProperty("data-URL"));
this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "vendors.data"));
this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "components.data"));
this.client.upload(new File(Main.baseDir + Main.conf.getProperty("data-path") + "formulas.data"));
}
catch (Exception e) {
Logger.write(e);
}
}
public void disconnect() {
try {
this.client.disconnect(false);
}
catch (Exception e) {
Logger.write(e);
}
}
}
+67
View File
@@ -0,0 +1,67 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Main;
import com.zakscode.FormulaManager.TableArray;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class FileManager<T extends TableArray>
extends HashMap<String, T> {
private static final long serialVersionUID = -1737198376121713564L;
private final String file;
public FileManager(String file) {
this.file = file;
}
public void save() {
try {
FileOutputStream fileOut = new FileOutputStream(Main.baseDir + Main.conf.getProperty("data-path") + this.file);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
fileOut.close();
}
catch (Exception e) {
Logger.write(e);
}
}
public void load() {
try {
FileInputStream fileIn = new FileInputStream(Main.baseDir + Main.conf.getProperty("data-path") + this.file);
ObjectInputStream in = new ObjectInputStream(fileIn);
this.putAll((HashMap)in.readObject());
in.close();
fileIn.close();
}
catch (EOFException fileIn) {
}
catch (Exception e) {
Logger.write(e);
}
}
public Object[][] toArray() {
Object[][] data = new Object[this.size()][];
int i = 0;
for (Map.Entry e : this.entrySet()) {
data[i++] = ((TableArray)this.get(e.getKey())).toArray();
}
return data;
}
}
+111
View File
@@ -0,0 +1,111 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.ComponentQuantity;
import com.zakscode.FormulaManager.TableArray;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
public class Formula
extends ArrayList<ComponentQuantity>
implements Serializable,
TableArray {
private static final long serialVersionUID = 6070397926573850223L;
private String name;
private String description;
private boolean approved;
private boolean rejected;
private Date date;
private Date proofDate;
public Formula(String name, String description) {
this.name = name;
this.description = description;
this.approved = false;
this.rejected = false;
this.date = Calendar.getInstance().getTime();
this.proofDate = null;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
this.date = Calendar.getInstance().getTime();
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
this.date = Calendar.getInstance().getTime();
}
public boolean getApproved() {
return this.approved;
}
public void setApproved(boolean approved) {
this.approved = approved;
this.proofDate = Calendar.getInstance().getTime();
}
public boolean getRejected() {
return this.rejected;
}
public void setRejected(boolean rejected) {
this.rejected = rejected;
this.proofDate = Calendar.getInstance().getTime();
}
public Date getDate() {
return this.date;
}
public Date getProofDate() {
return this.proofDate;
}
public double yield() {
double yield = 0.0;
for (ComponentQuantity cq : this) {
yield += cq.getQuantity();
}
return yield;
}
public ArrayList<ComponentQuantity> calculateForYield(double newYield) {
double yield = this.yield();
Formula newFormula = this;
for (ComponentQuantity cq : newFormula) {
cq.setQuantity(Math.round(cq.getQuantity() / yield * newYield));
}
return newFormula;
}
public void add(String component, double quantity) {
this.add(new ComponentQuantity(component, quantity));
}
@Override
public Object[] toArray() {
String status = "";
if (this.approved) {
status = "Approved";
}
if (this.rejected) {
status = "Rejected";
}
return new Object[]{this.name, this.description, this.date, status, this.proofDate};
}
}
+1229
View File
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.Main;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
class Logger {
Logger() {
}
public static void write(Exception e) {
if (!Boolean.parseBoolean(Main.conf.getProperty("debug"))) {
File file = new File(Main.baseDir + "log.txt");
try {
FileOutputStream fos = new FileOutputStream(file, true);
PrintStream ps = new PrintStream(fos);
e.printStackTrace(ps);
ps.append('\n');
ps.flush();
ps.close();
}
catch (FileNotFoundException fos) {}
} else {
e.printStackTrace();
}
}
}
+175
View File
@@ -0,0 +1,175 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.Component;
import com.zakscode.FormulaManager.Configuration;
import com.zakscode.FormulaManager.FileManager;
import com.zakscode.FormulaManager.Formula;
import com.zakscode.FormulaManager.Frame;
import com.zakscode.FormulaManager.Logger;
import com.zakscode.FormulaManager.Vendor;
import java.awt.EventQueue;
import java.awt.Image;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
class Main {
public static String baseDir;
public static Configuration conf;
public static FileManager<Vendor> vendors;
public static FileManager<Vendor> userVendors;
public static FileManager<Component> components;
public static FileManager<Component> userComponents;
public static FileManager<Formula> formulas;
public static FileManager<Formula> userFormulas;
private static int windowCount;
public static boolean metric;
public static boolean largeUnits;
public static ImageIcon icon;
Main() {
}
public static void main(String[] args) {
baseDir = new File(" ").getAbsolutePath().trim();
icon = new ImageIcon(baseDir + "icon.png");
conf = new Configuration();
JFrame splash = new JFrame("Formula Manager");
splash.setIconImage(icon.getImage());
splash.setUndecorated(true);
splash.add(new JLabel(new ImageIcon(baseDir + "splash.png")));
splash.pack();
splash.setLocationRelativeTo(null);
splash.setVisible(true);
File dataLocation = new File(baseDir + conf.getProperty("data-path"));
if (!dataLocation.exists()) {
dataLocation.mkdir();
}
if (!(dataLocation = new File(baseDir + conf.getProperty("temp-path"))).exists()) {
dataLocation.mkdir();
}
metric = Boolean.parseBoolean(conf.getProperty("metric"));
largeUnits = Boolean.parseBoolean(conf.getProperty("large-units"));
windowCount = 0;
Main.downloadData(true, false);
userVendors = new FileManager("userVendors.data");
userVendors.load();
userComponents = new FileManager("userComponents.data");
userComponents.load();
userFormulas = new FileManager("userFormulas.data");
userFormulas.load();
EventQueue.invokeLater(Main::newWindow);
splash.dispose();
}
public static void newWindow() {
++windowCount;
new Frame(Integer.parseInt(conf.getProperty("resolution-x")), Integer.parseInt(conf.getProperty("resolution-y")));
}
public static void close(JFrame frame) {
if (--windowCount <= 0) {
conf.setProperty("metric", String.valueOf(metric));
conf.setProperty("large-units", String.valueOf(largeUnits));
conf.setProperty("resolution-x", String.valueOf(frame.getWidth()));
conf.setProperty("resolution-y", String.valueOf(frame.getHeight()));
conf.save();
System.exit(0);
}
frame.dispose();
}
public static void downloadData(boolean suppress, boolean overwrite) {
long date;
ReadableByteChannel rbc;
FileOutputStream fos;
HttpURLConnection httpCon;
boolean success = true;
try {
URL vendorURL = new URL("http://" + conf.getProperty("URL") + conf.getProperty("data-URL") + "vendors.data");
httpCon = (HttpURLConnection)vendorURL.openConnection();
date = httpCon.getLastModified();
if (date > new File(baseDir + conf.getProperty("data-path") + "vendors.data").lastModified() || overwrite) {
fos = new FileOutputStream(baseDir + conf.getProperty("data-path") + "vendors.data");
rbc = Channels.newChannel(vendorURL.openStream());
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
rbc.close();
fos.close();
}
}
catch (IOException e) {
success = false;
Logger.write(e);
}
vendors = new FileManager("vendors.data");
vendors.load();
try {
URL componentURL = new URL("http://" + conf.getProperty("URL") + conf.getProperty("data-URL") + "components.data");
httpCon = (HttpURLConnection)componentURL.openConnection();
date = httpCon.getLastModified();
if (date > new File(baseDir + conf.getProperty("data-path") + "components.data").lastModified() || overwrite) {
fos = new FileOutputStream(baseDir + conf.getProperty("data-path") + "components.data");
rbc = Channels.newChannel(componentURL.openStream());
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
rbc.close();
fos.close();
}
}
catch (IOException e) {
success = false;
Logger.write(e);
}
components = new FileManager("components.data");
components.load();
try {
URL formulaURL = new URL("http://" + conf.getProperty("URL") + conf.getProperty("data-URL") + "formulas.data");
httpCon = (HttpURLConnection)formulaURL.openConnection();
date = httpCon.getLastModified();
if (date > new File(baseDir + conf.getProperty("data-path") + "formulas.data").lastModified() || overwrite) {
fos = new FileOutputStream(baseDir + conf.getProperty("data-path") + "formulas.data");
rbc = Channels.newChannel(formulaURL.openStream());
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
rbc.close();
fos.close();
}
}
catch (IOException e) {
success = false;
Logger.write(e);
}
formulas = new FileManager("formulas.data");
formulas.load();
if (!suppress) {
if (success) {
JOptionPane.showMessageDialog(null, "Update completed successfully", "Update", 1);
} else {
JOptionPane.showMessageDialog(null, "Update Failed\nCheck log for additional information", "Update", 0);
}
}
}
public static void saveAll() {
vendors.save();
userVendors.save();
components.save();
userComponents.save();
formulas.save();
userFormulas.save();
}
}
+9
View File
@@ -0,0 +1,9 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
interface TableArray {
public Object[] toArray();
}
+82
View File
@@ -0,0 +1,82 @@
/*
* Decompiled with CFR 0_123.
*/
package com.zakscode.FormulaManager;
import com.zakscode.FormulaManager.TableArray;
import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
public class Vendor
implements Serializable,
TableArray {
private static final long serialVersionUID = -5375130332194611512L;
private String name;
private String phone;
private String email;
private String website;
private Date date;
public Vendor(String name, String phone, String email, String website) {
this.name = name;
this.phone = phone;
this.email = email;
this.website = website;
this.date = Calendar.getInstance().getTime();
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
this.date = Calendar.getInstance().getTime();
}
public String getPhone() {
return this.phone;
}
public void setPhone(String phone) {
this.phone = phone;
this.date = Calendar.getInstance().getTime();
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
this.date = Calendar.getInstance().getTime();
}
public String getWebsite() {
return this.website;
}
public void setWebsite(String website) {
this.website = website;
this.date = Calendar.getInstance().getTime();
}
public Date getDate() {
return this.date;
}
public String toString() {
return this.name;
}
public boolean equals(Vendor v) {
return v.getName().equals(this.name) && v.getPhone().equals(this.phone) && v.getEmail().equals(this.email) && v.getWebsite().equals(this.website);
}
@Override
public Object[] toArray() {
return new Object[]{this.name, this.phone, this.email, this.website, this.date};
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.