Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
Delete trash and update StylesLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
po4yka committed May 28, 2021
1 parent 0e76250 commit 2d1ad25
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 245 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/discord.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/jarRepositories.xml

This file was deleted.

65 changes: 0 additions & 65 deletions .idea/libraries-with-intellij-classes.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/misc.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/modules/markdown-editor.iml

This file was deleted.

51 changes: 0 additions & 51 deletions .idea/modules/markdown-editor.main.iml

This file was deleted.

49 changes: 0 additions & 49 deletions .idea/modules/markdown-editor.test.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

28 changes: 20 additions & 8 deletions src/main/java/markdowneditor/model/utils/StyleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@
import java.nio.file.Files;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicReference;

public abstract class StyleLoader {
public static Map<String, String> getAllStyles() throws IOException {
var map = new HashMap<String, String>();
URL pathUrl = StyleLoader.class.getResource("/stylesToLoad");
assert (pathUrl != null) : "pathUrl in StyleLoader is null";
var folder = new File(pathUrl.getPath());
var files = folder.listFiles();
assert (files != null) : "files in StyleLoader is null";
for (File file : files) {
var text = new String(Files.readAllBytes(file.toPath()));
map.put(file.getName().replaceAll(".css$", ""), text);

URL darkStylePath = StyleLoader.class.getResource("/stylesToLoad/Dark.css");
assert darkStylePath != null;
Scanner scannerDark = new Scanner(darkStylePath.openStream());
StringBuilder textDark = new StringBuilder();
while (scannerDark.hasNext()) {
textDark.append(scannerDark.next());
}
map.put("Dark", textDark.toString());

URL defaultStylePath = StyleLoader.class.getResource("/stylesToLoad/Default.css");
assert defaultStylePath != null;
Scanner scannerDefault = new Scanner(defaultStylePath.openStream());
StringBuilder textDefault = new StringBuilder();
while (scannerDefault.hasNext()) {
textDefault.append(scannerDefault.next());
}
map.put("Default", textDefault.toString());

return map;
}
}

0 comments on commit 2d1ad25

Please sign in to comment.