Add test templates
This commit is contained in:
@@ -35,7 +35,8 @@ public class Main extends Application {
|
||||
*/
|
||||
private void setupWindow(Stage window) {
|
||||
window.setTitle(TITLE);
|
||||
window.getIcons().add(new Image(getClass().getResourceAsStream(ICON_PATH)));
|
||||
if (window.getIcons().isEmpty())
|
||||
window.getIcons().add(new Image(getClass().getResourceAsStream(ICON_PATH)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +54,7 @@ public class Main extends Application {
|
||||
*/
|
||||
private void createScene() {
|
||||
this.scene = new Scene(fxmlRoot);
|
||||
this.scene.setUserData(this.fxmlLoader);
|
||||
Model.setScene(scene);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,16 @@ public class MainController implements Initializable {
|
||||
return hostServices;
|
||||
}
|
||||
|
||||
//TODO: Document
|
||||
public List<Controller> getInnerControllers() {
|
||||
return List.of(
|
||||
editorController,
|
||||
filetreeController,
|
||||
modelineController,
|
||||
menubarController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a reference to the global Host Services API
|
||||
*
|
||||
|
||||
@@ -66,6 +66,11 @@ public class EditorController implements Initializable, Controller, FileManageme
|
||||
this.eventBus.register(this);
|
||||
}
|
||||
|
||||
// TODO: document
|
||||
public CodeArea getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies highlighting to the editor.
|
||||
*
|
||||
@@ -146,21 +151,20 @@ public class EditorController implements Initializable, Controller, FileManageme
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public void setEditorContent(String filePath) {
|
||||
if (filePath == null) {
|
||||
editor.clear();
|
||||
editor.appendText("// New File");
|
||||
return;
|
||||
}
|
||||
// if (filePath == null) {
|
||||
// editor.clear();
|
||||
// editor.appendText("// New File");
|
||||
// return;
|
||||
// }
|
||||
try (Scanner sc = new Scanner(new File(filePath))) {
|
||||
if (filePath.endsWith(".java") || filePath.endsWith(".md")) {
|
||||
// if (filePath.endsWith(".java") || filePath.endsWith(".md")) {
|
||||
editor.clear();
|
||||
while (sc.hasNextLine()) {
|
||||
editor.appendText(sc.nextLine());
|
||||
editor.appendText("\n");
|
||||
editor.appendText(sc.nextLine() + "\n");
|
||||
}
|
||||
} else {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
// } else {
|
||||
// throw new FileNotFoundException();
|
||||
// }
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
Alert error = new Alert(AlertType.ERROR);
|
||||
@@ -208,8 +212,8 @@ public class EditorController implements Initializable, Controller, FileManageme
|
||||
* Updates Code Area (read from file) whenever the FileSelected is changed
|
||||
*/
|
||||
@Subscribe
|
||||
private void handle(FileSelectedEvent event) {
|
||||
this.setEditorContent(event.getPath());
|
||||
public void handle(FileSelectedEvent event) {
|
||||
this.setEditorContent(event.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +230,7 @@ public class EditorController implements Initializable, Controller, FileManageme
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void handle(ToggleCommentEvent event) {
|
||||
public void handle(ToggleCommentEvent event) {
|
||||
this.toggleComment();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -124,12 +125,26 @@ public class FiletreeController implements Initializable, Controller {
|
||||
String name = file.getName();
|
||||
String ext = (name.substring(file.getName().lastIndexOf(".") + 1, file.getName().length()));
|
||||
|
||||
if ("java".equals(ext))
|
||||
createExtension(name, java, parent);
|
||||
else if ("md".equals(ext))
|
||||
createExtension(name, md, parent);
|
||||
else
|
||||
createExtension(name, placeholder, parent);
|
||||
try {
|
||||
createExtension(name, getIconForFile(file), parent);
|
||||
} catch (Exception e) {
|
||||
System.err.println("ICON NOT FOUND: " + file.getPath());
|
||||
}
|
||||
|
||||
// if ("java".equals(ext))
|
||||
// createExtension(name, java, parent);
|
||||
// else if ("md".equals(ext))
|
||||
// createExtension(name, md, parent);
|
||||
// else
|
||||
// createExtension(name, placeholder, parent);
|
||||
}
|
||||
|
||||
private Image getIconForFile(File file) throws IOException {
|
||||
String mimeType = Files.probeContentType(file.toPath()).replace('/', '-');
|
||||
String iconPath = (mimeType != null)
|
||||
? "/graphics/filetreeicons/" + mimeType + ".png"
|
||||
: "/graphics/filetreeicons/file.png";
|
||||
return new Image(getClass().getResourceAsStream(iconPath));
|
||||
}
|
||||
|
||||
private void createExtension(String name, Image image, CheckBoxTreeItem<String> parent) {
|
||||
|
||||
@@ -3,4 +3,4 @@ package app.events;
|
||||
/**
|
||||
* Base class for any type of event of the eventbus
|
||||
*/
|
||||
abstract class Event {}
|
||||
public abstract class Event {}
|
||||
|
||||
@@ -13,7 +13,7 @@ import app.model.ProgrammingLanguage;
|
||||
* Common static operations that can be executed on any class
|
||||
* that implements {@link app.model.ProgrammingLanguage ProgrammingLanguage}
|
||||
*/
|
||||
public class LanguageOperations {
|
||||
public final class LanguageOperations {
|
||||
|
||||
/**
|
||||
* Use a matcher to find the styleclass of the next match
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
prefHeight="400"
|
||||
xmlns="http://javafx.com/javafx/8.0.65"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="app.MainController">
|
||||
fx:controller="app.MainController"
|
||||
fx:id="root">
|
||||
|
||||
<top>
|
||||
<!-- Menubar -->
|
||||
|
||||
Reference in New Issue
Block a user