new database system done
only better explaination and better gui left
This commit is contained in:
parent
9b31a71b84
commit
295f5ad96c
13 changed files with 169 additions and 736 deletions
|
@ -12,8 +12,8 @@ import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
import database.DatabaseManager;
|
||||||
import gui.MainGUI;
|
import gui.MainGUI;
|
||||||
import gui.MainGUI_Deprecated;
|
|
||||||
import settingsfunctions.LoadSettings;
|
import settingsfunctions.LoadSettings;
|
||||||
|
|
||||||
public class DownloadLevels {
|
public class DownloadLevels {
|
||||||
|
@ -89,39 +89,21 @@ public class DownloadLevels {
|
||||||
}
|
}
|
||||||
area.append(" >> ERFOLGREICH \n");
|
area.append(" >> ERFOLGREICH \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, "Alle " + ManageFiles.getMissinglevels().size() + " Level wurden erfolgreich heruntergeladen.", "Download abgeschlossen", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Alle " + ManageFiles.getMissinglevels().size() + " Level wurden erfolgreich heruntergeladen.", "Download abgeschlossen", JOptionPane.INFORMATION_MESSAGE);
|
||||||
main.dispose();
|
main.dispose();
|
||||||
|
|
||||||
if(settings.isOldsystem()) {
|
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
|
DatabaseManager mgr = new DatabaseManager();
|
||||||
|
mgr.migrateData();
|
||||||
try {
|
try {
|
||||||
gui.build();
|
gui.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MainGUI_Deprecated gui = new MainGUI_Deprecated();
|
}
|
||||||
try {
|
|
||||||
gui.build();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
serverThread.start();
|
serverThread.start();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class GuiData {
|
||||||
localLevels.add(obj.getString("name"));
|
localLevels.add(obj.getString("name"));
|
||||||
id.add(obj.getInt("id") + "");
|
id.add(obj.getInt("id") + "");
|
||||||
verifier.add(obj.getString("verifier"));
|
verifier.add(obj.getString("verifier"));
|
||||||
creator.add(obj.getString("author"));
|
creator.add(obj.getString("author"));
|
||||||
qualification.add(obj.getInt("percentToQualify") + "");
|
qualification.add(obj.getInt("percentToQualify") + "");
|
||||||
ytlink.add(obj.getString("verification") + "");
|
ytlink.add(obj.getString("verification") + "");
|
||||||
creators.add(obj.getJSONArray("creators") + "");
|
creators.add(obj.getJSONArray("creators") + "");
|
||||||
|
@ -101,4 +101,4 @@ public class GuiData {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,129 +0,0 @@
|
||||||
package data;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import database.DatabaseManager;
|
|
||||||
|
|
||||||
public class GuiData_Deprecated {
|
|
||||||
|
|
||||||
private ArrayList<String> localLevels = new ArrayList<String>();
|
|
||||||
private ArrayList<String> qualification = new ArrayList<String>();
|
|
||||||
private ArrayList<String> id = new ArrayList<String>();
|
|
||||||
private ArrayList<String> verifier = new ArrayList<String>();
|
|
||||||
private ArrayList<String> creator = new ArrayList<String>();
|
|
||||||
private ArrayList<String> ytlink = new ArrayList<String>();
|
|
||||||
private ArrayList<String> creators = new ArrayList<String>();
|
|
||||||
private ArrayList<String> victors = new ArrayList<String>();
|
|
||||||
public ArrayList<String> completed = new ArrayList<String>();
|
|
||||||
|
|
||||||
private FetchData data = new FetchData();
|
|
||||||
|
|
||||||
private int localLength;
|
|
||||||
|
|
||||||
public int getLocalLength() {
|
|
||||||
return localLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getLocalLevels() {
|
|
||||||
return localLevels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getVerifier() {
|
|
||||||
return verifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getQualification() {
|
|
||||||
return qualification;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getYoutubeLink() {
|
|
||||||
return ytlink;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getCreators() {
|
|
||||||
return creators;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<String> getVictors() {
|
|
||||||
return victors;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void IndexData() throws IOException {
|
|
||||||
|
|
||||||
DatabaseManager mgr = new DatabaseManager();
|
|
||||||
mgr.queryData("levels");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FetchData data = new FetchData();
|
|
||||||
|
|
||||||
File filelength = new File("C:\\ExtremeDemonList\\levels");
|
|
||||||
File[] filelengthindex = filelength.listFiles();
|
|
||||||
|
|
||||||
String jsonstring;
|
|
||||||
|
|
||||||
localLength = filelengthindex.length;
|
|
||||||
|
|
||||||
for(int i = 0; i < filelengthindex.length; i++) {
|
|
||||||
|
|
||||||
jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + data.allLevels().get(i) + ".json"), StandardCharsets.UTF_8);
|
|
||||||
jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
|
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(jsonstring);
|
|
||||||
JSONArray recordsArray = obj.getJSONArray("records");
|
|
||||||
|
|
||||||
localLevels.add(obj.getString("name"));
|
|
||||||
id.add(obj.getInt("id") + "");
|
|
||||||
verifier.add(obj.getString("verifier"));
|
|
||||||
creator.add(obj.getString("author"));
|
|
||||||
qualification.add(obj.getInt("percentToQualify") + "");
|
|
||||||
ytlink.add(obj.getString("verification") + "");
|
|
||||||
creators.add(obj.getJSONArray("creators") + "");
|
|
||||||
victors.add(obj.getJSONArray("records") + "");
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> allVictors(String levelname) throws IOException {
|
|
||||||
ArrayList<String> completed = new ArrayList<>();
|
|
||||||
|
|
||||||
// JSON-Datei einlesen
|
|
||||||
String jsonContent = new String(Files.readAllBytes(Paths.get("C:\\ExtremeDemonList\\levels\\" + levelname + ".json")));
|
|
||||||
JSONObject jsonObject = new JSONObject(jsonContent);
|
|
||||||
|
|
||||||
// Victors extrahieren
|
|
||||||
JSONArray recordsArray = jsonObject.getJSONArray("records");
|
|
||||||
for (int i = 0; i < recordsArray.length(); i++) {
|
|
||||||
JSONObject record = recordsArray.getJSONObject(i);
|
|
||||||
int percent = record.getInt("percent");
|
|
||||||
if (percent == 100) {
|
|
||||||
completed.add(record.getString("user"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return completed;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
import gui.MainGUI;
|
import gui.MainGUI;
|
||||||
import gui.MainGUI_Deprecated;
|
|
||||||
|
|
||||||
import gui.MissingLevels;
|
import gui.MissingLevels;
|
||||||
|
|
||||||
|
@ -30,20 +29,11 @@ public class ManageFiles {
|
||||||
|
|
||||||
fetch.getGithubString();
|
fetch.getGithubString();
|
||||||
database.queryData("levels");
|
database.queryData("levels");
|
||||||
|
|
||||||
|
|
||||||
if(system) {
|
|
||||||
System.out.println(database.getLevelname().size());
|
|
||||||
|
|
||||||
int difference = fetch.allLevels().size() - database.getLevelname().size();
|
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
||||||
System.out.println(difference);
|
|
||||||
|
|
||||||
for(int i = 0; i < database.getLevelname().size(); i++) {
|
|
||||||
//System.out.println("fetch.allLevels(): " + fetch.allLevels().get(i) + "\t database.getRawLevelNames(): " + database.getRawLevelNames().get(i));
|
|
||||||
if(!database.getRawLevelNames().contains(fetch.allLevels().get(i))) {
|
if(!database.getRawLevelNames().contains(fetch.allLevels().get(i))) {
|
||||||
System.out.println(missing);
|
missinglevels.add(fetch.allLevels().get(i));
|
||||||
missing++;
|
missing++;
|
||||||
missinglevels.add(fetch.allLevels().get(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,28 +43,6 @@ public class ManageFiles {
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
gui.build();
|
gui.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\levels\\" + fetch.allLevels().get(i) + ".json");
|
|
||||||
|
|
||||||
if(!file.exists()) { // wenn der level lokal nicht vorhanden ist, wird er als fehlend gemeldet.
|
|
||||||
System.out.println(fetch.allLevels().get(i) + " fehlt");
|
|
||||||
feedMissingLevelsArray(fetch.allLevels().get(i));
|
|
||||||
missing++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(missing > 0) {
|
|
||||||
|
|
||||||
gui.show(missinglevels, missing);
|
|
||||||
} else {
|
|
||||||
MainGUI_Deprecated gui = new MainGUI_Deprecated();
|
|
||||||
gui.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class SortDatabase {
|
|
||||||
|
|
||||||
public void sort() {
|
|
||||||
FetchData data = new FetchData();
|
|
||||||
|
|
||||||
|
|
||||||
String[][] levels = {};
|
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < data.allLevels().size(); i++) {
|
|
||||||
levels[i][0] = i + "";
|
|
||||||
levels[i][1] = data.allLevels().get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -5,13 +5,12 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.GuiData;
|
import data.GuiData;
|
||||||
import data.GuiData_Deprecated;
|
|
||||||
import gui.MainGUI;
|
import gui.MainGUI;
|
||||||
import gui.MainGUI_Deprecated;
|
|
||||||
import settingsfunctions.LoadSettings;
|
import settingsfunctions.LoadSettings;
|
||||||
|
|
||||||
public class DatabaseManager {
|
public class DatabaseManager {
|
||||||
|
@ -19,12 +18,9 @@ public class DatabaseManager {
|
||||||
public void manage() {
|
public void manage() {
|
||||||
Sqlite createLevelDB = new Sqlite("levels");
|
Sqlite createLevelDB = new Sqlite("levels");
|
||||||
if(createLevelDB.exists()) {
|
if(createLevelDB.exists()) {
|
||||||
System.out.println(true);
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println(false);
|
createLevelDB.createNewDatabase("levels");
|
||||||
createLevelDB.createNewDatabase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createLevelDB.createNewTable("levels");
|
createLevelDB.createNewTable("levels");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +46,6 @@ public class DatabaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
for(int i = 0; i < fetch.allLevels().size(); i++) {
|
||||||
System.out.println(fetch.allLevels().get(i));
|
|
||||||
if(rawLevels.indexOf(fetch.allLevels().get(i) + ".json") != -1) {
|
if(rawLevels.indexOf(fetch.allLevels().get(i) + ".json") != -1) {
|
||||||
levels.add(rawLevels.get(rawLevels.indexOf(fetch.allLevels().get(i) + ".json")));
|
levels.add(rawLevels.get(rawLevels.indexOf(fetch.allLevels().get(i) + ".json")));
|
||||||
}
|
}
|
||||||
|
@ -58,30 +53,32 @@ public class DatabaseManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiData data = new GuiData();
|
GuiData data = new GuiData();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data.IndexData(levels);
|
data.IndexData(levels);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
fetch.getGithubString();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
fetch.getGithubString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(data.getLocalLevels().size() + " ====== lovallevelsize");
|
||||||
|
|
||||||
for (int i = 0; i < data.getLocalLevels().size(); i++) {
|
for (int i = 0; i < data.getLocalLevels().size(); i++) {
|
||||||
|
|
||||||
System.out.println(levels.get(i) + " hat den index " + levels.indexOf(levels.get(i)));
|
System.out.println(data.getLocalLevels().get(i));
|
||||||
|
|
||||||
database.insertData(
|
database.insertData(
|
||||||
"levels", // Tabellenname
|
"levels", // Tabellenname
|
||||||
fetch.allLevels().indexOf(levels.get(i).replace(".json", "")) + 1,
|
fetch.allLevels().indexOf(levels.get(i).replace(".json", "")) + 1,
|
||||||
data.getLocalLevels().get(i), // Level-Name
|
data.getLocalLevels().get(i), // Level-Name
|
||||||
fetch.allLevels().get(i), // Level-Name-Raw (oder entsprechender Wert aus fetch.allLevels())
|
levels.get(i).replace(".json", ""), // Level-Name-Raw (oder entsprechender Wert aus fetch.allLevels())
|
||||||
Integer.parseInt(data.getId().get(i)), // ID
|
Integer.parseInt(data.getId().get(i)), // ID
|
||||||
data.getCreator().get(i), // Ersteller
|
data.getCreator().get(i), // Ersteller
|
||||||
data.getCreators().get(i), // Ersteller
|
data.getCreators().get(i), // Ersteller
|
||||||
|
@ -91,10 +88,13 @@ public class DatabaseManager {
|
||||||
data.getVictors().get(i), // Sieger
|
data.getVictors().get(i), // Sieger
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
database.sortData("levels");
|
try {
|
||||||
|
database.sortData("levels");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import data.FetchData;
|
||||||
|
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -84,14 +87,17 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createNewDatabase() { // erstellt eine neue datenbank
|
public void createNewDatabase(String dbname) { // erstellt eine neue datenbank
|
||||||
try (Connection conn = DriverManager.getConnection(url)) {
|
url = "jdbc:sqlite:C:\\ExtremeDemonList\\database\\sqlite\\";
|
||||||
DatabaseMetaData meta = conn.getMetaData();
|
url += dbname + ".db";
|
||||||
|
filename = dbname;
|
||||||
} catch(SQLException e) {
|
try (Connection conn = DriverManager.getConnection(url)) {
|
||||||
e.printStackTrace();
|
DatabaseMetaData meta = conn.getMetaData();
|
||||||
}
|
} catch(SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createNewTable(String tablename) {
|
public void createNewTable(String tablename) {
|
||||||
String sql = "CREATE TABLE IF NOT EXISTS " + tablename + " (\n"
|
String sql = "CREATE TABLE IF NOT EXISTS " + tablename + " (\n"
|
||||||
|
@ -121,7 +127,9 @@ public class Sqlite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertData(String tablename, int placement, String levelname, String levelnameRaw, int levelid, String author, String creators, String verifier, String verificationLink, int percenttoqualify, String records, boolean completed) {
|
public void insertData(String tablename, int placement, String levelname, String levelnameRaw, int levelid, String author, String creators, String verifier, String verificationLink, int percenttoqualify, String records, boolean completed) {
|
||||||
String sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, completed) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
String sql = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, completed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
|
System.out.println("tablename: " + levelname);
|
||||||
|
|
||||||
try (Connection conn = DriverManager.getConnection(url);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||||
|
@ -171,41 +179,99 @@ public class Sqlite {
|
||||||
} catch(SQLException e) {
|
} catch(SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortData(String tablename) {
|
public void sortData(String tablename) throws SQLException {
|
||||||
String sql = "SELECT * FROM " + tablename + " ORDER BY placement ASC";
|
FetchData data = new FetchData();
|
||||||
|
|
||||||
|
ArrayList<String> levelnamelocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> levelIDlocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> authorlocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> creatorslocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> verifierlocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> verificationLinklocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> percenttoqualifylocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> recordslocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> completedlocal = new ArrayList<String>();
|
||||||
|
ArrayList<String> rawLevelNameslocal = new ArrayList<String>();
|
||||||
|
|
||||||
try (Connection conn = DriverManager.getConnection(url);
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement()) {
|
||||||
ResultSet rs = stmt.executeQuery(sql)) {
|
|
||||||
|
|
||||||
// Leere die ArrayLists, bevor du die sortierten Daten hinzufügst
|
// Erstelle eine neue Tabelle mit einem temporären Namen
|
||||||
levelname.clear();
|
String tempTableName = tablename + "_temp";
|
||||||
levelID.clear();
|
createNewTable(tempTableName);
|
||||||
author.clear();
|
|
||||||
creators.clear();
|
|
||||||
verifier.clear();
|
|
||||||
verificationLink.clear();
|
|
||||||
percenttoqualify.clear();
|
|
||||||
completed.clear();
|
|
||||||
records.clear();
|
|
||||||
rawLevelNames.clear();
|
|
||||||
|
|
||||||
// Loop durch das Ergebnis der sortierten Abfrage und füge die Daten in die entsprechenden ArrayLists ein
|
// Holen Sie sich die maximale Platzierung in der Tabelle
|
||||||
while (rs.next()) {
|
int maxPlacement = 0;
|
||||||
levelname.add(rs.getString("levelname"));
|
String getMaxPlacementQuery = "SELECT MAX(placement) AS maxPlacement FROM " + tablename;
|
||||||
levelID.add(rs.getInt("levelID") + "");
|
ResultSet maxPlacementResult = stmt.executeQuery(getMaxPlacementQuery);
|
||||||
author.add(rs.getString("author"));
|
if (maxPlacementResult.next()) {
|
||||||
creators.add(rs.getString("creators"));
|
maxPlacement = maxPlacementResult.getInt("maxPlacement");
|
||||||
verifier.add(rs.getString("verifier"));
|
|
||||||
verificationLink.add(rs.getString("verificationLink"));
|
|
||||||
percenttoqualify.add(rs.getInt("percentToQualify") + "");
|
|
||||||
completed.add(rs.getBoolean("completed") + "");
|
|
||||||
records.add(rs.getString("records"));
|
|
||||||
rawLevelNames.add(rs.getString("levelNameRaw"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Durchlaufen Sie die Platzierungen und holen Sie die Daten entsprechend
|
||||||
|
for (int i = 1; i <= maxPlacement; i++) {
|
||||||
|
String sql = "SELECT * FROM " + tablename + " WHERE placement = " + i;
|
||||||
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
|
while (rs.next()) {
|
||||||
|
levelnamelocal.add(rs.getString("levelname"));
|
||||||
|
levelIDlocal.add(rs.getInt("levelID") + "");
|
||||||
|
authorlocal.add(rs.getString("author"));
|
||||||
|
creatorslocal.add(rs.getString("creators"));
|
||||||
|
verifierlocal.add(rs.getString("verifier"));
|
||||||
|
verificationLinklocal.add(rs.getString("verificationLink"));
|
||||||
|
percenttoqualifylocal.add(rs.getInt("percentToQualify") + "");
|
||||||
|
completedlocal.add(rs.getBoolean("completed") + "");
|
||||||
|
recordslocal.add(rs.getString("records"));
|
||||||
|
rawLevelNameslocal.add(rs.getString("levelNameRaw"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lösche die alte Tabelle
|
||||||
|
stmt.executeUpdate("DROP TABLE IF EXISTS " + tablename);
|
||||||
|
|
||||||
|
// Erstelle eine neue Tabelle mit dem ursprünglichen Namen
|
||||||
|
createNewTable(tablename);
|
||||||
|
|
||||||
|
// Füge Daten in die neue Tabelle ein
|
||||||
|
String insert = "INSERT INTO " + tablename + " (placement, levelname, levelnameRaw, levelID, author, creators, verifier, verificationLink, percentToQualify, records, completed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
try (PreparedStatement pstmt = conn.prepareStatement(insert)) {
|
||||||
|
for (int i = 0; i < levelnamelocal.size(); i++) {
|
||||||
|
pstmt.setInt(1, i + 1);
|
||||||
|
pstmt.setString(2, levelnamelocal.get(i));
|
||||||
|
pstmt.setString(3, rawLevelNameslocal.get(data.allLevels().indexOf(rawLevelNameslocal.get(i))));
|
||||||
|
pstmt.setInt(4, Integer.parseInt(levelIDlocal.get(i)));
|
||||||
|
pstmt.setString(5, authorlocal.get(i));
|
||||||
|
pstmt.setString(6, creatorslocal.get(i));
|
||||||
|
pstmt.setString(7, verifierlocal.get(i));
|
||||||
|
pstmt.setString(8, verificationLinklocal.get(i));
|
||||||
|
pstmt.setInt(9, Integer.parseInt(percenttoqualifylocal.get(i)));
|
||||||
|
pstmt.setString(10, recordslocal.get(i));
|
||||||
|
pstmt.setBoolean(11, false);
|
||||||
|
pstmt.executeUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void modifyData(String levelname, boolean completedStatus) {
|
||||||
|
String sql = "UPDATE levels SET completed = ? WHERE levelname = ?";
|
||||||
|
|
||||||
|
try (Connection conn = DriverManager.getConnection(url);
|
||||||
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||||
|
pstmt.setBoolean(1, completedStatus);
|
||||||
|
pstmt.setString(2, levelname);
|
||||||
|
|
||||||
|
int rowsUpdated = pstmt.executeUpdate();
|
||||||
|
if (rowsUpdated > 0) {
|
||||||
|
System.out.println("Data updated successfully.");
|
||||||
|
} else {
|
||||||
|
System.out.println("Data not found for levelname: " + levelname);
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package filestructure;
|
package filestructure;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CreateFileStructure {
|
public class CreateFileStructure {
|
||||||
|
|
||||||
|
@ -8,8 +10,9 @@ public class CreateFileStructure {
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\levels");
|
File file = new File("C:\\ExtremeDemonList\\levels");
|
||||||
File file2 = new File("C:\\ExtremeDemonList\\completed");
|
File file2 = new File("C:\\ExtremeDemonList\\completed");
|
||||||
File file3 = new File("C:\\ExtremeDemonList\\index");
|
File file3 = new File("C:\\ExtremeDemonList\\database\\sqlite");
|
||||||
File file4 = new File("C:\\ExtremeDemonList\\songs");
|
File file4 = new File("C:\\ExtremeDemonList\\songs");
|
||||||
|
File file5 = new File("C:\\ExtremeDemonList\\config");
|
||||||
|
|
||||||
if(!file.isDirectory()) {
|
if(!file.isDirectory()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
|
@ -27,6 +30,27 @@ public class CreateFileStructure {
|
||||||
file4.mkdirs();
|
file4.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!file5.exists()) {
|
||||||
|
file5.mkdirs();
|
||||||
|
File config = new File("C:\\ExtremeDemonList\\config\\config.json");
|
||||||
|
if(!config.exists()) {
|
||||||
|
try {
|
||||||
|
config.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
FileWriter writer = new FileWriter("C:\\ExtremeDemonList\\config\\config.json");
|
||||||
|
writer.write("{\"newSystem\":true}");
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import javax.swing.JTextField;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.GuiData_Deprecated;
|
import data.GuiData;
|
||||||
import database.Sqlite;
|
import database.Sqlite;
|
||||||
import settingsfunctions.LoadSettings;
|
import settingsfunctions.LoadSettings;
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public class MainGUI {
|
||||||
uncompleted.setBounds(640, 17, 17, 17);
|
uncompleted.setBounds(640, 17, 17, 17);
|
||||||
uncompleted.setMargin(new Insets(0,0,0,0));
|
uncompleted.setMargin(new Insets(0,0,0,0));
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json");
|
|
||||||
|
|
||||||
completed.addActionListener(new ActionListener() {
|
completed.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,12 +175,7 @@ public class MainGUI {
|
||||||
completed.setVisible(false);
|
completed.setVisible(false);
|
||||||
uncompleted.setVisible(true);
|
uncompleted.setVisible(true);
|
||||||
|
|
||||||
try {
|
data.modifyData(data.getLevelname().get(index), true);
|
||||||
file.createNewFile();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -190,11 +185,11 @@ public class MainGUI {
|
||||||
contents.setBackground(Color.WHITE);
|
contents.setBackground(Color.WHITE);
|
||||||
uncompleted.setVisible(false);
|
uncompleted.setVisible(false);
|
||||||
completed.setVisible(true);
|
completed.setVisible(true);
|
||||||
file.delete();
|
data.modifyData(data.getLevelname().get(index), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json").exists()) {
|
if(Boolean.parseBoolean(data.getCompleted().get(index))) {
|
||||||
contents.setBackground(Color.decode("#cbffbf"));
|
contents.setBackground(Color.decode("#cbffbf"));
|
||||||
uncompleted.setVisible(true);
|
uncompleted.setVisible(true);
|
||||||
completed.setVisible(false);
|
completed.setVisible(false);
|
||||||
|
@ -222,9 +217,9 @@ public class MainGUI {
|
||||||
|
|
||||||
|
|
||||||
FetchData fetchData = new FetchData();
|
FetchData fetchData = new FetchData();
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
recordspanel.setLayout(new GridLayout(GuiData_Deprecated.allVictors(fetchData.allLevels().get(index)).size(), 1));
|
//TODO: recordspanel.setLayout(new GridLayout(GuiData.allVictors(fetchData.allLevels().get(index)).size(), 1));
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
|
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -236,7 +231,7 @@ public class MainGUI {
|
||||||
recordspanel.removeAll();
|
recordspanel.removeAll();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ArrayList<String> victors = GuiData_Deprecated.allVictors(fetchData.allLevels().get(index));
|
TODO: ArrayList<String> victors = GuiData.allVictors(fetchData.allLevels().get(index));
|
||||||
|
|
||||||
victorcount.setText("Anzahl Victors: " + victors.size());
|
victorcount.setText("Anzahl Victors: " + victors.size());
|
||||||
|
|
||||||
|
@ -260,6 +255,8 @@ public class MainGUI {
|
||||||
|
|
||||||
recordspanel.revalidate();
|
recordspanel.revalidate();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
copyid.addActionListener(new ActionListener() {
|
copyid.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
|
@ -1,443 +0,0 @@
|
||||||
package gui;
|
|
||||||
|
|
||||||
import java.awt.Button;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GridLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
import java.awt.Toolkit;
|
|
||||||
import java.awt.datatransfer.Clipboard;
|
|
||||||
import java.awt.datatransfer.StringSelection;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ItemEvent;
|
|
||||||
import java.awt.event.ItemListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JProgressBar;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
|
|
||||||
import data.FetchData;
|
|
||||||
import data.GuiData_Deprecated;
|
|
||||||
import database.Sqlite;
|
|
||||||
import settingsfunctions.LoadSettings;
|
|
||||||
|
|
||||||
public class MainGUI_Deprecated {
|
|
||||||
|
|
||||||
public JFrame main = new JFrame("Extreme Demon List");
|
|
||||||
public JProgressBar progress = new JProgressBar();
|
|
||||||
public JLabel info = new JLabel("Die Liste wird geladen");
|
|
||||||
public JLabel currentLevel = new JLabel();
|
|
||||||
public JPanel levelpanel = new JPanel();
|
|
||||||
public JScrollPane scroll = new JScrollPane(levelpanel);
|
|
||||||
public JTextField search = new JTextField();
|
|
||||||
public JLabel levelname;
|
|
||||||
public JLabel level = new JLabel("Liste");
|
|
||||||
public JLabel creator = new JLabel("Creator");
|
|
||||||
public JLabel separator = new JLabel("_______________________________________________________________________________________________________________");
|
|
||||||
public JLabel separator2 = new JLabel("_______________________________________________________________________________________________________________");
|
|
||||||
public JLabel separator3 = new JLabel("_______________________________________________________________________________________________________________");
|
|
||||||
public JLabel verifier = new JLabel("Verifier");
|
|
||||||
public JLabel victorcount = new JLabel("Anzahl Victors");
|
|
||||||
public JLabel victor = new JLabel("Victors: ");
|
|
||||||
public JLabel idshow = new JLabel("ID");
|
|
||||||
public JLabel qualify = new JLabel("Qualifikation");
|
|
||||||
public JPanel recordspanel = new JPanel();
|
|
||||||
public JScrollPane records = new JScrollPane(recordspanel);
|
|
||||||
public JCheckBox filtercompleted = new JCheckBox("Nach geschafft filtern");
|
|
||||||
public Button copyid = new Button("Level ID kopieren");
|
|
||||||
public Button showinfos = new Button("Mehr Infos anzeigen");
|
|
||||||
public JButton settings = new JButton("⚙");
|
|
||||||
GridLayout gridLayout = new GridLayout(3, 1);
|
|
||||||
private String[] showing = {"Alle anzeigen", "Top 3", "Top 50", "Top 150", "Top 200"};
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
public JComboBox show = new JComboBox(showing);
|
|
||||||
private FetchData fetch = new FetchData();
|
|
||||||
private Elements elements = new Elements();
|
|
||||||
|
|
||||||
private int completedcount = 0;
|
|
||||||
|
|
||||||
public void build() throws IOException {
|
|
||||||
LoadSettings load = new LoadSettings();
|
|
||||||
|
|
||||||
|
|
||||||
GuiData_Deprecated data = new GuiData_Deprecated();
|
|
||||||
data.IndexData();
|
|
||||||
|
|
||||||
//Sqlite data = new Sqlite("levels");
|
|
||||||
|
|
||||||
gridLayout.setRows(data.getLocalLevels().size());
|
|
||||||
|
|
||||||
main.setSize(900, 700);
|
|
||||||
main.setLayout(null);
|
|
||||||
main.setResizable(false);
|
|
||||||
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
level.setBounds(10, 10, 200, 30);
|
|
||||||
level.setFont(level.getFont().deriveFont(15f));
|
|
||||||
|
|
||||||
filtercompleted.setBounds(710, 15, 200, 30);
|
|
||||||
|
|
||||||
progress.setBounds(200, 300, 500, 30);
|
|
||||||
progress.setStringPainted(true);
|
|
||||||
progress.setMaximum(data.getLocalLength());
|
|
||||||
|
|
||||||
info.setBounds(380, 270, 300, 30);
|
|
||||||
|
|
||||||
currentLevel.setBounds(200, 330, 200, 30);
|
|
||||||
|
|
||||||
levelpanel.setBackground(Color.LIGHT_GRAY);
|
|
||||||
levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
||||||
levelpanel.setLayout(gridLayout);
|
|
||||||
|
|
||||||
victorcount.setBounds(10, 130, 164, 30);
|
|
||||||
|
|
||||||
idshow.setBounds(10, 150, 164, 30);
|
|
||||||
|
|
||||||
copyid.setBounds(10, 50, 164, 30);
|
|
||||||
|
|
||||||
qualify.setBounds(10, 170, 164, 30);
|
|
||||||
|
|
||||||
settings.setBounds(1, 1, 60, 60);
|
|
||||||
settings.setFont(settings.getFont().deriveFont(30f));
|
|
||||||
settings.setBackground(Color.LIGHT_GRAY);
|
|
||||||
|
|
||||||
victor.setBounds(1, 276, 164, 30);
|
|
||||||
records.getVerticalScrollBar().setUnitIncrement(16);
|
|
||||||
|
|
||||||
showinfos.setBounds(12, 227, 160, 30);
|
|
||||||
|
|
||||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
||||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
||||||
scroll.setBounds(0, 61, 700, 600);
|
|
||||||
scroll.getVerticalScrollBar().setUnitIncrement(16);
|
|
||||||
scroll.setVisible(false);
|
|
||||||
|
|
||||||
elements.infopanel().setBounds(700, 61, 184, 600);
|
|
||||||
elements.infopanel().setVisible(false);
|
|
||||||
|
|
||||||
separator.setBounds(0, 70, 300, 30);
|
|
||||||
separator2.setBounds(0 ,178, 400, 30);
|
|
||||||
separator3.setBounds(0, 263, 300, 30);
|
|
||||||
|
|
||||||
creator.setBounds(10, 90, 164, 30);
|
|
||||||
|
|
||||||
verifier.setBounds(10, 110, 164, 30);
|
|
||||||
|
|
||||||
search.setBounds(60, 1, 440, 60);
|
|
||||||
|
|
||||||
show.setBounds(500, 1, 200, 60);
|
|
||||||
|
|
||||||
recordspanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
for(int i = 0; i < data.getLocalLevels().size(); i++) {
|
|
||||||
final int index = i;
|
|
||||||
progress.setValue(i + 1);
|
|
||||||
|
|
||||||
currentLevel.setText(data.getLocalLevels().get(i));
|
|
||||||
|
|
||||||
JPanel contents = new JPanel();
|
|
||||||
contents.setName(data.getLocalLevels().get(i));
|
|
||||||
contents.setPreferredSize(new Dimension(600, 50));
|
|
||||||
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
|
||||||
contents.setLayout(null);
|
|
||||||
|
|
||||||
JButton completed = new JButton("x");
|
|
||||||
completed.setBounds(640, 17, 17, 17);
|
|
||||||
completed.setMargin(new Insets(0,0,0,0));
|
|
||||||
|
|
||||||
JButton uncompleted = new JButton("\u2713");
|
|
||||||
uncompleted.setBounds(640, 17, 17, 17);
|
|
||||||
uncompleted.setMargin(new Insets(0,0,0,0));
|
|
||||||
|
|
||||||
File file = new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json");
|
|
||||||
|
|
||||||
completed.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
contents.setBackground(Color.decode("#cbffbf"));
|
|
||||||
completed.setVisible(false);
|
|
||||||
uncompleted.setVisible(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
file.createNewFile();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
uncompleted.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
contents.setBackground(Color.WHITE);
|
|
||||||
uncompleted.setVisible(false);
|
|
||||||
completed.setVisible(true);
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(new File("C:\\ExtremeDemonList\\completed\\" + fetch.allLevels().get(i)+ ".json").exists()) {
|
|
||||||
contents.setBackground(Color.decode("#cbffbf"));
|
|
||||||
uncompleted.setVisible(true);
|
|
||||||
completed.setVisible(false);
|
|
||||||
completedcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
contents.addMouseListener(new MouseListener() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
showinfos.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
String url = data.getYoutubeLink().get(index);
|
|
||||||
VerifyInfo ver = VerifyInfo.getInstance();
|
|
||||||
ver.showInfo(url, Integer.parseInt(data.getId().get(index)));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
level.setText(data.getLocalLevels().get(index));
|
|
||||||
verifier.setText("Verifier: " + data.getVerifier().get(index));
|
|
||||||
creator.setText("Creator: " + data.getCreator().get(index));
|
|
||||||
idshow.setText("ID: " + data.getId().get(index));
|
|
||||||
qualify.setText("Qualifikation: " + data.getQualification().get(index) + "%");
|
|
||||||
level.setVerticalAlignment(SwingConstants.CENTER);
|
|
||||||
|
|
||||||
|
|
||||||
FetchData fetchData = new FetchData();
|
|
||||||
|
|
||||||
try {
|
|
||||||
recordspanel.setLayout(new GridLayout(GuiData_Deprecated.allVictors(fetchData.allLevels().get(index)).size(), 1));
|
|
||||||
} catch (IOException e1) {
|
|
||||||
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
recordspanel.setBackground(Color.GRAY);
|
|
||||||
|
|
||||||
records.setBounds(0, 302, 185, 300);
|
|
||||||
|
|
||||||
recordspanel.removeAll();
|
|
||||||
|
|
||||||
try {
|
|
||||||
ArrayList<String> victors = GuiData_Deprecated.allVictors(fetchData.allLevels().get(index));
|
|
||||||
|
|
||||||
victorcount.setText("Anzahl Victors: " + victors.size());
|
|
||||||
|
|
||||||
recordspanel.setLayout(new GridLayout(victors.size(), 1));
|
|
||||||
|
|
||||||
for(String victor : victors) {
|
|
||||||
JPanel contents = new JPanel();
|
|
||||||
contents.setPreferredSize(new Dimension(165, 50));
|
|
||||||
contents.setLayout(null);
|
|
||||||
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
|
||||||
|
|
||||||
JLabel name = new JLabel(victor);
|
|
||||||
name.setBounds(10, 10, 100, 30);
|
|
||||||
contents.add(name);
|
|
||||||
|
|
||||||
recordspanel.add(contents);
|
|
||||||
}
|
|
||||||
} catch (IOException e1) {
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
recordspanel.revalidate();
|
|
||||||
|
|
||||||
copyid.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
StringSelection stringSelection = new StringSelection(data.getId().get(index));
|
|
||||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
||||||
clipboard.setContents(stringSelection, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
contents.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
contents.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JLabel rank = new JLabel("#" + (i + 1));
|
|
||||||
rank.setBounds(10, 10, 40, 30);
|
|
||||||
rank.setName(i + "");
|
|
||||||
|
|
||||||
filtercompleted.setText("nach Geschafft filtern (" + completedcount + ")");
|
|
||||||
|
|
||||||
show.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
levelpanel.add(contents, 0);
|
|
||||||
if(show.getSelectedIndex() == 1) {
|
|
||||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 2)) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
} else if(show.getSelectedIndex() == 0) {
|
|
||||||
levelpanel.add(contents, 0);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
} else if(show.getSelectedIndex() == 2) {
|
|
||||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 49)) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
} else if(show.getSelectedIndex() == 3) {
|
|
||||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 149)) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
} else if(show.getSelectedIndex() == 4) {
|
|
||||||
if(!(Integer.parseInt(rank.getName()) >= 0 && Integer.parseInt(rank.getName()) <= 199)) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gridLayout.setRows(levelpanel.getComponentCount());
|
|
||||||
gridLayout.setColumns(1);
|
|
||||||
levelpanel.revalidate();
|
|
||||||
scroll.repaint();
|
|
||||||
scroll.revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
levelname = new JLabel();
|
|
||||||
levelname.setText(data.getLocalLevels().get(i));
|
|
||||||
levelname.setBounds(290, 10, 300, 30);
|
|
||||||
|
|
||||||
search.addKeyListener(new KeyListener() {
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent e) {
|
|
||||||
if(!contents.getName().toLowerCase().contains(search.getText().toLowerCase())) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
} else if(contents.getName().toLowerCase().contains(search.getText().toLowerCase())) {
|
|
||||||
levelpanel.add(contents);
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
gridLayout.setRows(levelpanel.getComponentCount());
|
|
||||||
gridLayout.setColumns(1);
|
|
||||||
levelpanel.revalidate();
|
|
||||||
scroll.repaint();
|
|
||||||
scroll.revalidate();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
filtercompleted.addItemListener(new ItemListener() {
|
|
||||||
@Override
|
|
||||||
public void itemStateChanged(ItemEvent e) {
|
|
||||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
|
||||||
if (!contents.getBackground().equals(Color.decode("#cbffbf"))) {
|
|
||||||
levelpanel.remove(contents);
|
|
||||||
gridLayout.setRows(data.getLocalLength());
|
|
||||||
scroll.repaint();
|
|
||||||
scroll.revalidate();
|
|
||||||
}
|
|
||||||
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
|
|
||||||
levelpanel.add(contents, 0);
|
|
||||||
}
|
|
||||||
levelpanel.repaint();
|
|
||||||
levelpanel.revalidate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
contents.add(levelname);
|
|
||||||
contents.add(rank);
|
|
||||||
contents.add(completed);
|
|
||||||
contents.add(uncompleted);
|
|
||||||
levelpanel.add(contents);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
scroll.setVisible(true);
|
|
||||||
elements.infopanel().setVisible(true);
|
|
||||||
progress.setVisible(false);
|
|
||||||
info.setVisible(false);
|
|
||||||
currentLevel.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
thread.start();
|
|
||||||
|
|
||||||
settings.addActionListener(new ActionListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
SettingsGui gui = new SettingsGui();
|
|
||||||
gui.showSettings();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
elements.infopanel().add(copyid);
|
|
||||||
elements.infopanel().add(level, SwingConstants.CENTER);
|
|
||||||
elements.infopanel().add(separator);
|
|
||||||
elements.infopanel().add(separator2);
|
|
||||||
elements.infopanel().add(separator3);
|
|
||||||
elements.infopanel().add(creator);
|
|
||||||
elements.infopanel().add(verifier);
|
|
||||||
elements.infopanel().add(records);
|
|
||||||
elements.infopanel().add(victorcount);
|
|
||||||
elements.infopanel().add(idshow);
|
|
||||||
elements.infopanel().add(qualify);
|
|
||||||
elements.infopanel().add(victor);
|
|
||||||
elements.infopanel().add(showinfos);
|
|
||||||
|
|
||||||
main.add(search);
|
|
||||||
main.add(currentLevel);
|
|
||||||
main.add(info);
|
|
||||||
main.add(scroll);
|
|
||||||
main.add(progress);
|
|
||||||
main.add(filtercompleted);
|
|
||||||
main.add(show);
|
|
||||||
main.add(settings);
|
|
||||||
main.add(elements.infopanel());
|
|
||||||
main.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -85,7 +85,7 @@ public class MissingLevels {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
main.dispose();
|
main.dispose();
|
||||||
|
|
||||||
if(settings.isOldsystem()) {
|
|
||||||
MainGUI gui = new MainGUI();
|
MainGUI gui = new MainGUI();
|
||||||
try {
|
try {
|
||||||
gui.build();
|
gui.build();
|
||||||
|
@ -93,15 +93,7 @@ public class MissingLevels {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MainGUI_Deprecated gui = new MainGUI_Deprecated();
|
|
||||||
try {
|
|
||||||
gui.build();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
import api.GetApiData;
|
import api.GetApiData;
|
||||||
import data.FetchData;
|
import data.FetchData;
|
||||||
import data.GuiData_Deprecated;
|
|
||||||
import data.ManageFiles;
|
import data.ManageFiles;
|
||||||
import database.DatabaseManager;
|
import database.DatabaseManager;
|
||||||
import filestructure.CreateFileStructure;
|
import filestructure.CreateFileStructure;
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class MigrateData {
|
||||||
|
|
||||||
Files.deleteIfExists(directory);
|
Files.deleteIfExists(directory);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue