Skip to content

Commit 65ad570

Browse files
Merge pull request #73
Moved project installation from user files to system files
2 parents 18966fe + dcf1999 commit 65ad570

20 files changed

+58
-91
lines changed

build.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@echo off
2-
SET VERSION="7.27.2"
2+
SET VERSION="7.27.3"
33
SET DIR=".\build\dist\\%VERSION%\Emrick Designer"
44
SET NAME="Emrick Designer"
55
call .\gradlew.bat clean
66
call .\gradlew.bat jpackage
7-
call xcopy /s/e .\src ""%DIR%"\src\" > nul
7+
call xcopy /s/e .\src\main\resources ""%DIR%"\res\" > nul
88
echo Files Copied
9-
call jpackage --type exe --app-image %DIR% --name %NAME% --app-version "%VERSION%" -d ".\build\dist" --file-associations "FAemrick.properties" --file-associations "FApacket.properties" --win-per-user-install --win-dir-chooser --win-shortcut
9+
call jpackage --type exe --app-image %DIR% --name %NAME% --app-version "%VERSION%" -d ".\build\dist" --file-associations "FAemrick.properties" --file-associations "FApacket.properties" --win-dir-chooser --win-shortcut
1010
echo BUILD COMPLETE

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group 'org.emrick.project'
8-
version '7.27.2'
8+
version '7.27.3'
99
var jarTitle = "Emrick-Designer-$version"
1010

1111
repositories {

build.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#echo BUILD COMPLETE
1111

1212

13-
VERSION="7.27.2"
13+
VERSION="7.27.3"
1414
DIR="./build/dist/$VERSION/Emrick Designer.app"
1515
NAME="Emrick Designer"
1616

1717
./gradlew clean
1818
./gradlew jpackage
1919

20-
cp -r ./src "$DIR/src/"
20+
cp -r ./src/main/resources "$DIR/res/"
2121
echo "File Copied"
2222
jpackage --type dmg --app-image "$DIR" --name "$NAME" --app-version "$VERSION" -d "./build/dist" --file-associations "FAemrick.properties" --file-associations "FApacket.properties" --mac-package-name "$NAME"

src/main/java/org/emrick/project/ImportArchive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void fullImport(String archiveSrc, String drillSrc) {
3333
// Unzip into application resources/unzip/ subfolder. Within "AppData" on Windows, "Applications" on Mac
3434
File archiveFile = new File(archiveSrc);
3535
String fileNameNoExt = archiveFile.getName().replaceFirst("[.][^.]+$", "");
36-
String unzipPath = PathConverter.pathConverter("show_data/" + fileNameNoExt);
36+
String unzipPath = PathConverter.pathConverter("show_data/" + fileNameNoExt, false);
3737

3838
Unzip.unzip(archiveSrc, unzipPath);
3939

src/main/java/org/emrick/project/MediaEditorGUI.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public MediaEditorGUI(String file) {
224224

225225
// Main frame
226226
frame = new JFrame("Emrick Designer");
227-
Image icon = Toolkit.getDefaultToolkit().getImage(PathConverter.pathConverter("src/main/resources/images/icon.png"));
227+
Image icon = Toolkit.getDefaultToolkit().getImage(PathConverter.pathConverter("res/images/icon.png", true));
228228
frame.setIconImage(icon);
229229

230230
// Scrub Bar
@@ -236,9 +236,13 @@ public MediaEditorGUI(String file) {
236236

237237
currentID = MAX_CONNECTIONS;
238238

239+
// Make sure user dir exists
240+
File userDir = new File(PathConverter.pathConverter("", false));
241+
userDir.mkdirs();
242+
239243

240244
// Delete leftover files from show_data/
241-
File showDataDir = new File(PathConverter.pathConverter("show_data/"));
245+
File showDataDir = new File(PathConverter.pathConverter("show_data/", false));
242246
if (showDataDir.exists()) {
243247
showDataDir.mkdirs();
244248
if (showDataDir.isDirectory()) {
@@ -672,7 +676,7 @@ public void createAndShowGUI() {
672676
stopWebServer.setEnabled(false);
673677
runWebServer.setEnabled(true);
674678

675-
File dir = new File(PathConverter.pathConverter("tmp/"));
679+
File dir = new File(PathConverter.pathConverter("tmp/", false));
676680
File[] files = dir.listFiles();
677681
for (File f : files) {
678682
f.delete();
@@ -803,7 +807,7 @@ public void windowClosing(WindowEvent e) {
803807
requestIDs = null;
804808
runWebServer.setEnabled(true);
805809
stopWebServer.setEnabled(false);
806-
File dir = new File(PathConverter.pathConverter("tmp/"));
810+
File dir = new File(PathConverter.pathConverter("tmp/", false));
807811
File[] files = dir.listFiles();
808812
for (File f : files) {
809813
f.delete();
@@ -831,7 +835,7 @@ public void windowClosing(WindowEvent e) {
831835
}
832836
}
833837
}
834-
File showDataDir = new File(PathConverter.pathConverter("show_data/"));
838+
File showDataDir = new File(PathConverter.pathConverter("show_data/", false));
835839
showDataDir.mkdirs();
836840
File[] cleanFiles = showDataDir.listFiles();
837841
for (File f : cleanFiles) {
@@ -931,7 +935,7 @@ public SerialTransmitter comPortPrompt() {
931935
}
932936
String port = (String) JOptionPane.showInputDialog(null, "Choose",
933937
"Menu", JOptionPane.INFORMATION_MESSAGE,
934-
new ImageIcon(PathConverter.pathConverter("icon.ico")),
938+
new ImageIcon(PathConverter.pathConverter("icon.ico", true)),
935939
allPortNames, allPortNames[0]);
936940
st.setSerialPort(port);
937941
return st;
@@ -958,7 +962,7 @@ public void runServer(String path) {
958962
}
959963
else{ //there is a project open
960964
if (path.equals("")) {
961-
f = new File("tempPkt.pkt");
965+
f = new File(PathConverter.pathConverter("tempPkt.pkt", false));
962966
exportPackets(f);
963967
} else {
964968
f = new File(path);
@@ -983,13 +987,13 @@ public void runServer(String path) {
983987

984988
serialTransmitter = comPortPrompt();
985989

986-
Unzip.unzip(f.getAbsolutePath(), PathConverter.pathConverter("tmp/"));
990+
Unzip.unzip(f.getAbsolutePath(), PathConverter.pathConverter("tmp/", false));
987991

988992
server = HttpServer.create(new InetSocketAddress(port), 250);
989993
writeSysMsg("server started at " + port);
990994
requestIDs = new ArrayList<>();
991995

992-
server.createContext("/", new GetHandler(PathConverter.pathConverter("tmp/"), this));
996+
server.createContext("/", new GetHandler(PathConverter.pathConverter("tmp/", false), this));
993997
server.setExecutor(new ServerExecutor());
994998
server.start();
995999
currentID = Math.min(MAX_CONNECTIONS, footballFieldPanel.drill.ledStrips.size());
@@ -1019,7 +1023,7 @@ public void loadProject(File path) {
10191023
try {
10201024
// TODO: pdf loading is redundant with project file. fix? - LHD
10211025

1022-
File showDataDir = new File(PathConverter.pathConverter("show_data/"));
1026+
File showDataDir = new File(PathConverter.pathConverter("show_data/", false));
10231027
showDataDir.mkdirs();
10241028
File[] cleanFiles = showDataDir.listFiles();
10251029
for (File f : cleanFiles) {
@@ -1029,7 +1033,7 @@ public void loadProject(File path) {
10291033
f.delete();
10301034
}
10311035
}
1032-
Unzip.unzip(path.getAbsolutePath(), PathConverter.pathConverter("show_data/"));
1036+
Unzip.unzip(path.getAbsolutePath(), PathConverter.pathConverter("show_data/", false));
10331037
File[] dataFiles = showDataDir.listFiles();
10341038
for (File f : dataFiles) {
10351039
if (!f.isDirectory()) {
@@ -1045,7 +1049,7 @@ public void loadProject(File path) {
10451049
r.close();
10461050
ImportArchive ia = new ImportArchive(this);
10471051

1048-
archivePath = new File(PathConverter.pathConverter("show_data/" + pf.archivePath));
1052+
archivePath = new File(PathConverter.pathConverter("show_data/" + pf.archivePath, false));
10491053

10501054
ia.fullImport(archivePath.getAbsolutePath(), null);
10511055
footballFieldPanel.drill = pf.drill;
@@ -1943,7 +1947,7 @@ public void saveProject(File path, File archivePath) {
19431947

19441948
String jsonName = path.getName();
19451949
jsonName = jsonName.substring(0, jsonName.indexOf(".emrick")) + ".json";
1946-
File dir = new File(PathConverter.pathConverter("show_data/"));
1950+
File dir = new File(PathConverter.pathConverter("show_data/", false));
19471951
dir.mkdirs();
19481952
File[] cleanJson = dir.listFiles();
19491953
for (File f : cleanJson) {
@@ -1953,15 +1957,15 @@ public void saveProject(File path, File archivePath) {
19531957
}
19541958

19551959
try {
1956-
FileWriter w = new FileWriter(PathConverter.pathConverter("show_data/" + jsonName));
1960+
FileWriter w = new FileWriter(PathConverter.pathConverter("show_data/" + jsonName, false));
19571961
w.write(g);
19581962
w.close();
19591963
} catch (IOException e) {
19601964
writeSysMsg("Failed to save to `" + path + "`.");
19611965
throw new RuntimeException(e);
19621966
}
19631967

1964-
File showDataDir = new File(PathConverter.pathConverter("show_data/"));
1968+
File showDataDir = new File(PathConverter.pathConverter("show_data/", false));
19651969
showDataDir.mkdirs();
19661970
File[] saveFiles = showDataDir.listFiles();
19671971
ArrayList<String> files = new ArrayList<>();
@@ -2060,7 +2064,7 @@ public void exportPackets(File path) {
20602064
timesMS = timeMS.toArray(timesMS);
20612065
try {
20622066
String out = "";
2063-
File dir = new File(PathConverter.pathConverter("tmp/"));
2067+
File dir = new File(PathConverter.pathConverter("tmp/", false));
20642068
dir.mkdirs();
20652069
ArrayList<String> files = new ArrayList<>();
20662070
ArrayList<LEDStrip> list0 = new ArrayList<>();
@@ -2073,7 +2077,7 @@ public void exportPackets(File path) {
20732077
ArrayList<LEDStrip> list7 = new ArrayList<>();
20742078
for (int k = 0; k < footballFieldPanel.drill.ledStrips.size(); k++) {
20752079
LEDStrip l = footballFieldPanel.drill.ledStrips.get(k);
2076-
File curr = new File(PathConverter.pathConverter("tmp/" + l.getId()));
2080+
File curr = new File(PathConverter.pathConverter("tmp/" + l.getId(), false));
20772081
curr.createNewFile();
20782082
files.add(curr.getAbsolutePath());
20792083

@@ -2269,7 +2273,7 @@ public void run() {
22692273
int a = 0;
22702274
for (LEDStrip l : ledStrips) {
22712275
a++;
2272-
File curr = new File(PathConverter.pathConverter("tmp/" + l.getId()));
2276+
File curr = new File(PathConverter.pathConverter("tmp/" + l.getId(), false));
22732277

22742278
BufferedWriter bfw = new BufferedWriter(new FileWriter(curr));
22752279

src/main/java/org/emrick/project/PathConverter.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
public class PathConverter {
44

5-
public static String pathConverter(String path) {
6-
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
7-
return System.getProperty("user.home") + "/AppData/Local/Emrick Designer/" + path;
8-
}
9-
else {
10-
return "/Applications/Emrick Designer.app/" + path;
5+
public static String pathConverter(String path, boolean system) {
6+
if (!system) {
7+
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
8+
return System.getProperty("user.home") + "/AppData/Local/Emrick Designer/" + path;
9+
} else {
10+
return "/Applications/Emrick Designer.app/" + path;
11+
}
12+
} else {
13+
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
14+
return System.getenv("PROGRAMFILES") + "/Emrick Designer/" + path;
15+
} else {
16+
return "/System/Applications/Emrick Designer.app/" + path;
17+
}
1118
}
1219
}
1320
}

src/main/java/org/emrick/project/ScrubBarGUI.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
public class ScrubBarGUI extends JComponent implements ActionListener {
1515

1616
// String definitions
17-
private static final String PATH_SYNC_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/time_sync_flaticon.png");
18-
private static final String PATH_PREV_SET_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/prev_set_flaticon.png");
19-
private static final String PATH_NEXT_SET_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/next_set_flaticon.png");
20-
public static final String PATH_PLAY_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/play_flaticon.png");
21-
private static final String PATH_PAUSE_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/pause_flaticon.png");
22-
private static final String PATH_PREV_COUNT_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/prev_count_flaticon.png");
23-
private static final String PATH_NEXT_COUNT_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/next_count_flaticon.png");
24-
private static final String PATH_AUDIO_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/audio_flaticon.png");
25-
private static final String PATH_FAST_PLAY_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/fast_play_flaticon.png");
26-
private static final String PATH_FULL_PLAY_ICON = PathConverter.pathConverter("src/main/resources/images/scrub/double_arrow_flaticon.png");
17+
private static final String PATH_SYNC_ICON = PathConverter.pathConverter("res/images/scrub/time_sync_flaticon.png", true);
18+
private static final String PATH_PREV_SET_ICON = PathConverter.pathConverter("res/images/scrub/prev_set_flaticon.png", true);
19+
private static final String PATH_NEXT_SET_ICON = PathConverter.pathConverter("res/images/scrub/next_set_flaticon.png", true);
20+
public static final String PATH_PLAY_ICON = PathConverter.pathConverter("res/images/scrub/play_flaticon.png", true);
21+
private static final String PATH_PAUSE_ICON = PathConverter.pathConverter("res/images/scrub/pause_flaticon.png", true);
22+
private static final String PATH_PREV_COUNT_ICON = PathConverter.pathConverter("res/images/scrub/prev_count_flaticon.png", true);
23+
private static final String PATH_NEXT_COUNT_ICON = PathConverter.pathConverter("res/images/scrub/next_count_flaticon.png", true);
24+
private static final String PATH_AUDIO_ICON = PathConverter.pathConverter("res/images/scrub/audio_flaticon.png", true);
25+
private static final String PATH_FAST_PLAY_ICON = PathConverter.pathConverter("res/images/scrub/fast_play_flaticon.png", true);
26+
private static final String PATH_FULL_PLAY_ICON = PathConverter.pathConverter("res/images/scrub/double_arrow_flaticon.png", true);
2727

2828
// Swing
2929
private JPanel scrubBarPanel;

src/main/java/org/emrick/project/SelectFileGUI.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ else if (sourceButton.equals(importButton)) {
246246
if (csvFile != null) {
247247
files.add(csvFile.getAbsolutePath());
248248
}
249-
copyFiles(files, PathConverter.pathConverter("show_data"));
250-
archiveFile = new File(PathConverter.pathConverter("show_data/" + archiveFile.getName()));
249+
copyFiles(files, PathConverter.pathConverter("show_data", false));
250+
archiveFile = new File(PathConverter.pathConverter("show_data/" + archiveFile.getName(), false));
251251
if (csvFile != null) {
252-
csvFile = new File(PathConverter.pathConverter("show_data/" + csvFile.getName()));
252+
csvFile = new File(PathConverter.pathConverter("show_data/" + csvFile.getName(), false));
253253
}
254254

255255
importListener.onFileSelect(archiveFile, coordsFile, csvFile);

src/main/java/org/emrick/project/SyncTimeGUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class SyncTimeGUI implements ActionListener {
1212
private static boolean IS_DEBUG = false;
1313

1414
// String Constants
15-
private static final String PATH_INSTR_IMAGE = PathConverter.pathConverter("/src/main/resources/images/sync_time_instr.jpg");
15+
private static final String PATH_INSTR_IMAGE = PathConverter.pathConverter("res/images/sync_time_instr.jpg", true);
1616
private static final String START_TIMESTAMP_INSTRUCTION = "Provide a start delay in seconds (optional):";
1717
private static final String BPM_INSTRUCTION = "<html><p>" +
1818
"Please enter the BPM (beats-per-minute) for each set. Example: '105' or '105.5'. " +

src/main/java/org/emrick/project/UserAuthGUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.nio.file.Path;
1010
import java.nio.file.Paths;
1111

12-
12+
// TODO: remove
1313
public class UserAuthGUI implements ActionListener {
1414
private JTextField usernameField;
1515
private JTextField passwordField;
@@ -107,7 +107,7 @@ public void actionPerformed(ActionEvent e) {
107107
System.out.println(enteredCredentials);
108108
try {
109109
// String credentials = PathConverter.pathConverter("src/main/resources/credentials.txt");
110-
String credentialString = new String(Files.readAllBytes(Paths.get(PathConverter.pathConverter("src/main/resources/credentials.txt"))));
110+
String credentialString = new String(Files.readAllBytes(Paths.get(PathConverter.pathConverter("res/credentials.txt", true))));
111111
System.out.println(credentialString);
112112
valids = credentialString.contains(enteredCredentials);
113113
} catch (IOException IoE) {

0 commit comments

Comments
 (0)