began gui
This commit is contained in:
parent
f3f73fd13d
commit
fd45e1a263
16 changed files with 207 additions and 42 deletions
16
.classpath
16
.classpath
|
@ -2,9 +2,19 @@
|
|||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
/bin/
|
||||
/target/
|
||||
|
|
6
.project
6
.project
|
@ -10,8 +10,14 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -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
|
||||
|
|
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
Binary file not shown.
Binary file not shown.
39
pom.xml
Normal file
39
pom.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ExtremeDemonList</groupId>
|
||||
<artifactId>ExtremeDemonList</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<!-- https://mvnrepository.com/artifact/org.json/json -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<release>17</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</project>
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
50
src/data/GuiData.java
Normal file
50
src/data/GuiData.java
Normal file
|
@ -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<String> localLevels = new ArrayList<String>();
|
||||
private int localLength;
|
||||
|
||||
public int getLocalLength() {
|
||||
return localLength;
|
||||
}
|
||||
|
||||
public ArrayList<String> 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"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -15,11 +15,17 @@ public class ManageFiles {
|
|||
private int missing = 0;
|
||||
|
||||
|
||||
public static ArrayList<String> 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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -6,4 +6,6 @@
|
|||
*/
|
||||
module ExtremeDemonList {
|
||||
requires java.desktop;
|
||||
requires json;
|
||||
requires org.apache.commons.io;
|
||||
}
|
Loading…
Reference in a new issue