Skip to content

Commit

Permalink
Merge pull request #104 from deadlocker8/v1_2_0
Browse files Browse the repository at this point in the history
merge v_1_2_0 into master
  • Loading branch information
deadlocker8 authored May 25, 2017
2 parents 5b2ac46 + 286cf3b commit d2e71f2
Show file tree
Hide file tree
Showing 66 changed files with 3,207 additions and 504 deletions.
Binary file modified build/BudgetMaster.exe
Binary file not shown.
Binary file modified build/BudgetMasterClient.jar
Binary file not shown.
Binary file modified build/BudgetMasterServer.jar
Binary file not shown.
82 changes: 82 additions & 0 deletions src/de/deadlocker8/budgetmaster/logic/CategoryInOutSum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package de.deadlocker8.budgetmaster.logic;

import javafx.scene.paint.Color;

public class CategoryInOutSum
{
private int ID;
private String name;
private Color color;
private int budgetIN;
private int budgetOUT;

public CategoryInOutSum(int ID, String name, Color color, int budgetIN, int budgetOUT)
{
this.ID = ID;
this.name = name;
this.color = color;
this.budgetIN = budgetIN;
this.budgetOUT = budgetOUT;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}

public Color getColor()
{
return color;
}

public void setColor(Color color)
{
this.color = color;
}

public int getBudgetIN()
{
return budgetIN;
}

public void setBudgetIN(int budgetIN)
{
this.budgetIN = budgetIN;
}

public int getBudgetOUT()
{
return budgetOUT;
}

public void setBudgetOUT(int budgetOUT)
{
this.budgetOUT = budgetOUT;
}

@Override
public boolean equals(Object obj)
{
if(this == obj)
return true;
if(obj == null)
return false;
if(getClass() != obj.getClass())
return false;
CategoryInOutSum other = (CategoryInOutSum)obj;
if(ID != other.ID)
return false;
return true;
}

@Override
public String toString()
{
return "CategoryInOutSum [ID=" + ID + ", name=" + name + ", color=" + color + ", budgetIN=" + budgetIN + ", budgetOUT=" + budgetOUT + "]";
}
}
40 changes: 40 additions & 0 deletions src/de/deadlocker8/budgetmaster/logic/ExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.deadlocker8.budgetmaster.logic;

public class ExceptionHandler
{
public static String getMessageForException(Exception e)
{
if(e instanceof ServerConnectionException)
{
return handleServerConnectionException(e);
}

if(e.getMessage() == null)
{
return "Unbekannter Fehler (" + e.getClass() + ")";
}

if(e.getMessage().contains("Connection refused"))
{
return "Server nicht erreichbar.";
}
else if(e.getMessage().contains("HTTPS hostname wrong"))
{
return "Der Server verwendet ein selbst signiertes Zertifkat für die Verschlüsselung. "
+ "Aus Sicherheitsgründen werden diese Zertifikate standardmäßig blockiert. "
+ "Wenn du dem Zertifikat trotzdem vertrauen möchtest, dann füge den Hostnamen des Servers zur Liste der vertrauenswürdigen Hosts in den Einstellungen hinzu.";
}
return e.getMessage();
}

private static String handleServerConnectionException(Exception e)
{
switch(e.getMessage())
{
case "400": return "Der Server erhielt eine fehlerhafte Anfrage oder ungültige Parameter.";
case "401": return "Ungültiges Passwort.";
case "500": return "Beim Ausführen der Anfrage ist ein interner Serverfehler ist aufgetreten.";
default: return e.getMessage();
}
}
}
35 changes: 34 additions & 1 deletion src/de/deadlocker8/budgetmaster/logic/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;

public class Helpers
{
public static final DecimalFormat NUMBER_FORMAT = new DecimalFormat("0.00");

public static final String COLOR_INCOME = "#22BAD9";
public static final String COLOR_PAYMENT = "#F2612D";
public static final String SALT = "ny9/Y+G|WrJ,82|oIYQQ X %i-sq#4,uA-qKPtwFPnw+s(k2`rV)^-a1|t{D3Z>S";

public static String getURLEncodedString(String input)
{
try
Expand All @@ -21,7 +26,7 @@ public static String getURLEncodedString(String input)
return input;
}
}

public static String getDateString(LocalDate date)
{
if(date == null)
Expand All @@ -31,4 +36,32 @@ public static String getDateString(LocalDate date)
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
return date.format(formatter);
}

public static ArrayList<String> getMonthList()
{
ArrayList<String> monthNames = new ArrayList<>();
monthNames.add("Januar");
monthNames.add("Februar");
monthNames.add("März");
monthNames.add("April");
monthNames.add("Mai");
monthNames.add("Juni");
monthNames.add("Juli");
monthNames.add("August");
monthNames.add("September");
monthNames.add("Oktober");
monthNames.add("November");
monthNames.add("Dezember");
return monthNames;
}

public static ArrayList<String> getYearList()
{
ArrayList<String> years = new ArrayList<>();
for(int i = 2000; i < 2100; i++)
{
years.add(String.valueOf(i));
}
return years;
}
}
67 changes: 67 additions & 0 deletions src/de/deadlocker8/budgetmaster/logic/MonthInOutSum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package de.deadlocker8.budgetmaster.logic;

import java.util.ArrayList;

import org.joda.time.DateTime;

public class MonthInOutSum
{
private int month;
private int year;
private ArrayList<CategoryInOutSum> sums;

public MonthInOutSum(int month, int year, ArrayList<CategoryInOutSum> sums)
{
this.month = month;
this.year = year;
this.sums = sums;
}

public int getMonth()
{
return month;
}

public int getYear()
{
return year;
}

public ArrayList<CategoryInOutSum> getSums()
{
return sums;
}

public DateTime getDate()
{
return DateTime.now().withYear(year).withMonthOfYear(month).withDayOfMonth(1);
}

public int getBudgetIN()
{
int budget = 0;
for(CategoryInOutSum currentCategorySum : sums)
{
budget += currentCategorySum.getBudgetIN();
}

return budget;
}

public int getBudgetOUT()
{
int budget = 0;
for(CategoryInOutSum currentCategorySum : sums)
{
budget += currentCategorySum.getBudgetOUT();
}

return budget;
}

@Override
public String toString()
{
return "MonthInOutSum [month=" + month + ", year=" + year + ", sums=" + sums + "]";
}
}
Loading

0 comments on commit d2e71f2

Please sign in to comment.