From fd45e1a26338cc0b9f4c727ded56bee6acb55880 Mon Sep 17 00:00:00 2001
From: potzplitz <127513690+potzplitz@users.noreply.github.com>
Date: Wed, 28 Feb 2024 00:13:43 +0100
Subject: [PATCH] began gui
---
.classpath | 16 ++++-
.gitignore | 1 +
.project | 6 ++
.settings/org.eclipse.core.resources.prefs | 2 -
.settings/org.eclipse.jdt.core.prefs | 1 +
.settings/org.eclipse.m2e.core.prefs | 4 ++
bin/data/DownloadLevels.class | Bin 2631 -> 2556 bytes
bin/data/ManageFiles.class | Bin 2392 -> 2469 bytes
pom.xml | 39 ++++++++++++
src/data/DownloadLevels.java | 26 ++++----
src/data/GuiData.java | 50 +++++++++++++++
src/data/ManageFiles.java | 6 ++
src/gui/MainGUI.java | 70 +++++++++++++++++++--
src/gui/MissingLevels.java | 7 ++-
src/gui/components/Components.java | 19 ------
src/module-info.java | 2 +
16 files changed, 207 insertions(+), 42 deletions(-)
delete mode 100644 .settings/org.eclipse.core.resources.prefs
create mode 100644 .settings/org.eclipse.m2e.core.prefs
create mode 100644 pom.xml
create mode 100644 src/data/GuiData.java
delete mode 100644 src/gui/components/Components.java
diff --git a/.classpath b/.classpath
index 57bca72..9c7983f 100644
--- a/.classpath
+++ b/.classpath
@@ -2,9 +2,19 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index ae3c172..09e3bc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
/bin/
+/target/
diff --git a/.project b/.project
index 8c9809a..57ac853 100644
--- a/.project
+++ b/.project
@@ -10,8 +10,14 @@
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+ org.eclipse.m2e.core.maven2Nature
org.eclipse.jdt.core.javanature
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 99f26c0..0000000
--- a/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,2 +0,0 @@
-eclipse.preferences.version=1
-encoding/=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 8c9943d..43c8d71 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -9,6 +9,7 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/bin/data/DownloadLevels.class b/bin/data/DownloadLevels.class
index fdf6771a7280cd9e864d68b5afded038e54bd359..7fb951ba93396313f7b28154c9bab8a482dc4036 100644
GIT binary patch
delta 1390
zcmZ8hTT@$A6#jN{E+O63B!tp~Kud)-A*3n2V2e|d%8cx!ja8-$S
zsn_DM`rwSd`QSK?mzk5=jE*mkqmMq+8D|{*2|oDfIIbOv&X`QrI_ukC)?Vvdd!O&a
ze^vW`{QLGd0J`zsmcLz7x=hO~oM!MwqEiggnQYqd!;7k|o5o;}p?X1I))QtnF*G``
zI%nhxX4XwB{4TgL!??@S%o5oy?{6f|2(lgjx<6dz~Iu*Bn9}$9}r7!U2x^(agY!c)_sEb$vENY$^LkF;
z!yJzYJV1PbjThE3#&kBHRx#rAdh2--qeAd8hT4delfqo+mBa;(ankF$cb_kbNscKB
zKJzvyNp!17IX`n7nIga#BQR9U?
z2|A{mR>4S%u|CN$k1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akz;UX?uafu-_C96f_F>m{9
zLRZFQwBri@B9z)%By=KdMHiRFy|odPGgv3+yt+oyF!adq7!q0NlhKa>1~H+|DJg-V
z1SbY%4B;B@5f2m$Go;6+RBtG%#seM1D#$e!RmLcPDR%L1tcrgZYb?{4vEnALGP{KU
zW_iTCB2J~@7XM*(72Y9zRx+%NXgb*yjK`J9CM}vsC@(wk0NXn3^@U5bE8+BpNLJBzHNTTrrnzqmkY$6z{NaFl+
z)UKm#r{Z5i2av>7&;M`|-Jb9UT;jl6xRw}m{GpTRef8@F1+Eq3&~HBtW<*IuSCO#|
zB^=sBtd(XRF-8?qqt;_L?ek%U12PJ65XJO(OX%@95k@K9nFBgpm?!2T8St1aSSA;r
zqLP12vpcR+JtNKs4P#`*G8th-oUn23wB_!aKm(!aq+!Ah-ehz7t5cTBlwp{*W2u12
cR7QfdKpjn(BYr-$-o^r9#v5D2JuD&rH)GqcN&o-=
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..159a701
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,39 @@
+
+ 4.0.0
+ ExtremeDemonList
+ ExtremeDemonList
+ 0.0.1-SNAPSHOT
+
+
+
+ org.json
+ json
+ 20140107
+
+
+ com.google.code.gson
+ gson
+ 2.8.6
+
+
+
+ commons-io
+ commons-io
+ 2.6
+
+
+
+
+ src
+
+
+ maven-compiler-plugin
+ 3.8.1
+
+ 17
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/data/DownloadLevels.java b/src/data/DownloadLevels.java
index 63011c1..6ea9104 100644
--- a/src/data/DownloadLevels.java
+++ b/src/data/DownloadLevels.java
@@ -16,9 +16,6 @@ import gui.MainGUI;
public class DownloadLevels {
- private ManageFiles data = new ManageFiles();
-
-
public void download() throws IOException {
@@ -28,7 +25,7 @@ public class DownloadLevels {
main.setResizable(false);
main.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- JLabel info = new JLabel("Es werden " + data.missingLevels().size() + " Level heruntergeladen.");
+ JLabel info = new JLabel("Es werden " + ManageFiles.getMissinglevels().size() + " Level heruntergeladen.");
info.setBounds(80, 1, 500, 30);
JTextArea area = new JTextArea();
@@ -45,7 +42,7 @@ public class DownloadLevels {
JProgressBar bar = new JProgressBar();
bar.setBounds(1, 29, 382, 30);
bar.setMinimum(0);
- bar.setMaximum(data.missingLevels().size());
+ bar.setMaximum(ManageFiles.getMissinglevels().size());
bar.setStringPainted(true);
main.add(info);
@@ -59,20 +56,20 @@ public class DownloadLevels {
@Override
public void run() {
String fileURL;
- for(int i = 0; i < data.missingLevels().size(); i++) {
+ for(int i = 0; i < ManageFiles.getMissinglevels().size(); i++) {
area.setCaretPosition(area.getDocument().getLength());
bar.setValue(i + 1);
- area.append(i + 1 + "| " + data.missingLevels().get(i) + " wird heruntergeladen. ");
+ area.append(i + 1 + "| " + ManageFiles.getMissinglevels().get(i) + " wird heruntergeladen. ");
- System.out.println("downloading " + data.missingLevels().get(i));
- fileURL = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/" + data.missingLevels().get(i) + ".json";
+ System.out.println("downloading " + ManageFiles.getMissinglevels().get(i));
+ fileURL = "https://raw.githubusercontent.com/All-Rated-Extreme-Demon-List/AREDL/main/data/" + ManageFiles.getMissinglevels().get(i) + ".json";
try (BufferedInputStream in = new BufferedInputStream(new URL(fileURL).openStream());
- FileOutputStream fileOutputStream = new FileOutputStream("C:\\ExtremeDemonList\\levels\\" + data.missingLevels().get(i) + ".json")) {
+ FileOutputStream fileOutputStream = new FileOutputStream("C:\\ExtremeDemonList\\levels\\" + ManageFiles.getMissinglevels().get(i) + ".json")) {
byte dataBuffer[] = new byte[1024];
int bytesRead;
@@ -87,11 +84,16 @@ public class DownloadLevels {
}
area.append(" >> ERFOLGREICH \n");
}
- JOptionPane.showMessageDialog(null, "Alle " + data.missingLevels().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();
MainGUI gui = new MainGUI();
- gui.build();
+ try {
+ gui.build();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
diff --git a/src/data/GuiData.java b/src/data/GuiData.java
new file mode 100644
index 0000000..be154ab
--- /dev/null
+++ b/src/data/GuiData.java
@@ -0,0 +1,50 @@
+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.JSONObject;
+
+public class GuiData {
+
+ private ArrayList localLevels = new ArrayList();
+ private int localLength;
+
+ public int getLocalLength() {
+ return localLength;
+ }
+
+ public ArrayList getLocalLevels() {
+ return localLevels;
+ }
+
+ public void IndexLevelName() throws IOException {
+
+
+ File filelength = new File("C:\\ExtremeDemonList\\levels");
+ File[] filelengthindex = filelength.listFiles();
+
+ String jsonstring;
+
+ localLength = filelengthindex.length;
+
+ System.out.println(filelengthindex.length);
+
+ for(int i = 0; i < filelengthindex.length; i++) {
+ jsonstring = FileUtils.readFileToString(new File("C:\\ExtremeDemonList\\levels\\" + filelengthindex[i].getName()), StandardCharsets.UTF_8);
+ jsonstring = jsonstring.trim().replace("\n", "").replace("\t", "").replace("\\", "");
+
+ JSONObject obj = new JSONObject(jsonstring);
+
+ localLevels.add(obj.getString("name"));
+
+ }
+ }
+
+}
diff --git a/src/data/ManageFiles.java b/src/data/ManageFiles.java
index 0d42f4b..f3f0c7b 100644
--- a/src/data/ManageFiles.java
+++ b/src/data/ManageFiles.java
@@ -15,11 +15,17 @@ public class ManageFiles {
private int missing = 0;
+ public static ArrayList getMissinglevels() {
+ return missinglevels;
+ }
+
private void feedMissingLevelsArray(String levelname) { // fehlende level werden missinglevels hinzugefĆ¼gt
missinglevels.add(levelname);
}
+
+
public void compareArrays() throws IOException { // downloadedlevels und onlinelevels werden verglichen und die fehlenden level in missinglevels gepackt
fetch.getGithubString();
diff --git a/src/gui/MainGUI.java b/src/gui/MainGUI.java
index 0f1bdc6..77592b5 100644
--- a/src/gui/MainGUI.java
+++ b/src/gui/MainGUI.java
@@ -1,27 +1,87 @@
package gui;
import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.io.IOException;
+import javax.swing.BorderFactory;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
-import gui.components.Components;
+import data.GuiData;
public class MainGUI {
+
+ public JFrame main = new JFrame();
- public void build() {
- Components components = new Components();
+ public void build() throws IOException {
+
+ GuiData data = new GuiData();
+ data.IndexLevelName();
- JFrame main = new JFrame();
main.setSize(900, 700);
main.setLayout(null);
main.setResizable(false);
main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ JProgressBar progress = new JProgressBar();
+ progress.setBounds(200, 300, 500, 30);
+ progress.setStringPainted(true);
+ progress.setMaximum(data.getLocalLength());
+ JLabel info = new JLabel("Die Liste wird geladen");
+ info.setBounds(380, 270, 300, 30);
- main.add(components.LevelPanel());
+ JLabel currentLevel = new JLabel();
+ currentLevel.setBounds(200, 330, 200, 30);
+
+ JPanel levelpanel = new JPanel();
+ levelpanel.setBackground(Color.LIGHT_GRAY);
+ levelpanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+ levelpanel.setLayout(new GridLayout(data.getLocalLevels().size(), 1));
+
+ JScrollPane scroll = new JScrollPane(levelpanel);
+ scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
+ scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ scroll.setBounds(0, 61, 700, 600);
+ scroll.setVisible(false);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ for(int i = 0; i < data.getLocalLevels().size(); i++) {
+ progress.setValue(i + 1);
+
+ currentLevel.setText(data.getLocalLevels().get(i));
+
+ JPanel contents = new JPanel();
+ contents.setPreferredSize(new Dimension(600, 50));
+ contents.setBorder(BorderFactory.createLineBorder(Color.BLACK));
+
+ JLabel levelname = new JLabel(data.getLocalLevels().get(i));
+
+ contents.add(levelname);
+ levelpanel.add(contents);
+
+ }
+ scroll.setVisible(true);
+ progress.setVisible(false);
+ info.setVisible(false);
+ currentLevel.setVisible(false);
+ }
+
+ });
+ thread.start();
+
+ main.add(currentLevel);
+ main.add(info);
+ main.add(scroll);
+ main.add(progress);
main.setVisible(true);
}
diff --git a/src/gui/MissingLevels.java b/src/gui/MissingLevels.java
index 77abae9..e91ceb2 100644
--- a/src/gui/MissingLevels.java
+++ b/src/gui/MissingLevels.java
@@ -74,7 +74,12 @@ public class MissingLevels {
public void actionPerformed(ActionEvent e) {
main.dispose();
MainGUI gui = new MainGUI();
- gui.build();
+ try {
+ gui.build();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
}
});
diff --git a/src/gui/components/Components.java b/src/gui/components/Components.java
deleted file mode 100644
index 6c64fc4..0000000
--- a/src/gui/components/Components.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package gui.components;
-
-import java.awt.Color;
-
-import javax.swing.JPanel;
-
-public class Components {
-
- public JPanel LevelPanel() {
-
- JPanel levelpanel = new JPanel();
- levelpanel.setBounds(0, 63, 700, 600);
- levelpanel.setBackground(Color.LIGHT_GRAY);
-
- return levelpanel;
-
- }
-
-}
diff --git a/src/module-info.java b/src/module-info.java
index 29428f7..8745ad2 100644
--- a/src/module-info.java
+++ b/src/module-info.java
@@ -6,4 +6,6 @@
*/
module ExtremeDemonList {
requires java.desktop;
+ requires json;
+ requires org.apache.commons.io;
}
\ No newline at end of file