-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSploty.java
More file actions
115 lines (94 loc) · 3.54 KB
/
Sploty.java
File metadata and controls
115 lines (94 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package me.david.sploty4;
import javafx.application.Application;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import me.david.sploty4.constants.AppConstants;
import me.david.sploty4.document.DocumentHandler;
import me.david.sploty4.features.DownloadManager;
import me.david.sploty4.features.History;
import me.david.sploty4.gui.GuiManager;
import me.david.sploty4.setting.SettingManager;
import me.david.sploty4.setting.settings.GeneralSettings;
import me.david.sploty4.storage.FileSerializer;
import me.david.sploty4.storage.SQLite;
import me.david.sploty4.storage.StorageHelper;
import me.david.sploty4.util.FXUtil;
import me.david.sploty4.util.SplotyLogger;
import java.io.File;
import java.net.URL;
import java.security.Security;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.logging.Level;
public class Sploty extends Application {
public static void main(String[] args){
launch(args);
}
private static File directory;
private static Sploty instance;
private static GuiManager guiManager;
private static SettingManager settingManager = new SettingManager();
private static SplotyLogger logger;
private Executor siteExecutor = Executors.newFixedThreadPool(3);
public static final Image SPLOTY_ICON = FXUtil.getImage("/Sploty.png");
private DocumentHandler documentHandler;
private DownloadManager downloadManager;
private History history;
public static File getDirectory() {
return directory;
}
@Override
public void start(Stage stage) throws Exception {
instance = this;
GeneralSettings settings = new GeneralSettings();
settings.setDefaultsite(new URL("https://google.com/"));
settings.setDownloadDirectory(new File("/home/david/Downloads/"));
settings.setScriptblock(true);
FileSerializer serializer = new FileSerializer();
settings.write(serializer);
serializer.writeFile(new File("/home/david/testi.txt"));
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
directory = new StorageHelper().getSplotyFolder();
logger = new SplotyLogger(Level.ALL);
logger.printBanner();
logger.info("Starting Sploty4 " + AppConstants.VERSION + "... ");
settingManager.load();
SQLite.INSTANCE.connect();
documentHandler = new DocumentHandler();
downloadManager = new DownloadManager();
history = new History();
//System.getProperties().list(System.out);
guiManager = new GuiManager(stage);
Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
logger.info("Successfully started Sploty!");
}
public void stop(){
Thread.currentThread().setName("Sploty - Shutdown Thread");
SQLite.INSTANCE.disconnect();
}
public static GuiManager getGuiManager() {
return guiManager;
}
public static Sploty getInstance() {
return instance;
}
public DocumentHandler getDocumentHandler() {
return documentHandler;
}
public static SettingManager getSettingManager() {
return settingManager;
}
public History getHistory() {
return history;
}
public DownloadManager getDownloadManager() {
return downloadManager;
}
public Executor getSiteExecutor() {
return siteExecutor;
}
public static SplotyLogger getLogger() {
return logger;
}
}