Commit 18d56ada authored by Joachim Müssig's avatar Joachim Müssig
Browse files

Fix specgui recompile button bug. Add RemoveBasePathPart method in FilesUtil

parent cea89546
package keyjoana.util; package keyjoana.util;
import java.io.File; import java.io.File;
import java.nio.file.Path;
/** /**
* provides different methods to work with files * provides different methods to work with files
...@@ -39,4 +40,8 @@ public class FilesUtil { ...@@ -39,4 +40,8 @@ public class FilesUtil {
return ""; return "";
} }
} }
public static String removeBasePathPart(Path filePath, Path basePath) {
return basePath.relativize(filePath).toString();
}
} }
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
<menus> <menus>
<Menu mnemonicParsing="false" text="File"> <Menu mnemonicParsing="false" text="File">
<items> <items>
<MenuItem mnemonicParsing="false" onAction="#onChooseSrcFolder" text="Select Java Source" />
<Menu fx:id="menuOpenRecent" mnemonicParsing="false" text="Recently Loaded" /> <Menu fx:id="menuOpenRecent" mnemonicParsing="false" text="Recently Loaded" />
<MenuItem fx:id="menuItemReloadSource" mnemonicParsing="false" text="reload Java Source"> <MenuItem fx:id="menuItemReloadSource" mnemonicParsing="false" text="reload Java Source">
<accelerator> <accelerator>
......
...@@ -245,16 +245,13 @@ public class FXMLDocumentController implements Initializable { ...@@ -245,16 +245,13 @@ public class FXMLDocumentController implements Initializable {
@FXML @FXML
public void onPressCompile() { public void onPressCompile() {
String mainClass = mainClassesCB.getSelectionModel().getSelectedItem(); if (chosenFile != null) {
joanaView.preProcessAllJavaFilesInDirecotory(chosenFile); this.loadSrcFile(chosenFile);
try { } else {
joanaView.setCurrentJavaFolderFile(chosenFile); //should not happen
tryCreateJoanaAsync(); setStatusMessage("Error, reload the file");
selectMainClass(mainClass); setStatusMessageColor(Color.RED);
} catch (CompilerException e) {
compilationErrorMessage(e.getMessage());
} }
} }
@FXML @FXML
...@@ -336,16 +333,18 @@ public class FXMLDocumentController implements Initializable { ...@@ -336,16 +333,18 @@ public class FXMLDocumentController implements Initializable {
private void loadSrcFile(File chosenSrcDir) { private void loadSrcFile(File chosenSrcDir) {
buttonCompile.setDisable(true); buttonCompile.setDisable(true);
setStatusMessage("Pre processing files ..."); if (preProcessCheckBox.isScaleShape()) {
setStatusMessageColor(javafx.scene.paint.Color.BLUE); setStatusMessage("Pre processing files ...");
joanaView.preProcessAllJavaFilesInDirecotory(chosenSrcDir); setStatusMessageColor(javafx.scene.paint.Color.BLUE);
joanaView.preProcessAllJavaFilesInDirecotory(chosenSrcDir);
}
setStatusMessage("Generate Jar files ..."); setStatusMessage("Generate Jar files ...");
setStatusMessageColor(javafx.scene.paint.Color.BLUE); setStatusMessageColor(javafx.scene.paint.Color.BLUE);
try { try {
joanaView.setCurrentJavaFolderFile(chosenSrcDir); joanaView.setCurrentJavaFolderFile(chosenSrcDir);
letUserChooseMainClass(Helper.getAllClassesContainingMainMethod(joanaView.getCurrentJavaFolderFile())); letUserChooseMainClass(Helper.getAllClassesContainingMainMethod(joanaView.getCurrentJavaFolderFile()));
this.chosenFile = chosenSrcDir; this.chosenFile = chosenSrcDir;
disableMainGUIElements(false, true, true, false); disableMainGUIElements(false, true, false, false);
} catch (CompilerException e) { } catch (CompilerException e) {
compilationErrorMessage(e.getMessage()); compilationErrorMessage(e.getMessage());
} }
......
...@@ -58,7 +58,6 @@ public class JarCreator { ...@@ -58,7 +58,6 @@ public class JarCreator {
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) { for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
// read error dertails from the diagnostic object // read error dertails from the diagnostic object
// compileErrorMessage.append(diagnostic.getMessage(null)); // compileErrorMessage.append(diagnostic.getMessage(null));
System.out.println("\n"+diagnostic + "\n");
compileErrorMessage.append(diagnostic.getSource().getName()+"\nLine "+diagnostic.getLineNumber()+" "+diagnostic.getMessage(null)+"\n"); compileErrorMessage.append(diagnostic.getSource().getName()+"\nLine "+diagnostic.getLineNumber()+" "+diagnostic.getMessage(null)+"\n");
} }
CompilerException ex = new CompilerException(compileErrorMessage.toString()); CompilerException ex = new CompilerException(compileErrorMessage.toString());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment