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

scrollpane for specgui status

parent 02f3b5b9
......@@ -9,34 +9,41 @@
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ProgressIndicator?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.input.KeyCodeCombination?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane id="AnchorPane" prefHeight="602.0" prefWidth="666.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="specgui.FXMLDocumentController">
<AnchorPane id="AnchorPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="602.0" prefWidth="666.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="specgui.FXMLDocumentController">
<children>
<AnchorPane fx:id="buttonRecompile" layoutX="14.0" layoutY="45.0" prefHeight="172.0" prefWidth="659.0">
<AnchorPane fx:id="buttonRecompile" layoutX="14.0" layoutY="45.0" prefHeight="209.0" prefWidth="631.0" AnchorPane.bottomAnchor="365.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="21.0" AnchorPane.topAnchor="45.0">
<children>
<TextField fx:id="javaPathText" prefHeight="26.0" prefWidth="386.0" />
<Button layoutX="397.0" mnemonicParsing="false" onAction="#onChooseSrcFolder" prefHeight="26.0" prefWidth="165.0" text="Select Java Sources" />
<ComboBox fx:id="mainClassesCB" layoutY="33.0" prefHeight="26.0" prefWidth="386.0" />
<Label layoutX="397.0" layoutY="38.0" text="Choose Main Class" />
<CheckBox fx:id="preProcessCheckBox" layoutX="286.0" layoutY="70.0" mnemonicParsing="false" onAction="#onPreProcessingSelected" selected="true" text="Pre Process" />
<ProgressIndicator fx:id="progressIndicator" layoutX="608.0" layoutY="5.0" prefHeight="43.0" prefWidth="44.0" />
<ProgressIndicator fx:id="progressIndicator" layoutX="585.0" layoutY="5.0" prefHeight="42.0" prefWidth="40.0" />
<Button id="compilationUpdate" fx:id="buttonCompile" disable="true" layoutY="66.0" mnemonicParsing="false" onAction="#onPressCompile" prefHeight="26.0" prefWidth="165.0" text="recompile" />
<Label fx:id="labelStatusCompile" layoutY="140.0" text="State">
<font>
<Font size="15.0" />
</font></Label>
<ScrollPane fx:id="statusScrollPane" layoutY="124.0" prefHeight="105.0" prefWidth="631.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="124.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="103.0" prefWidth="629.0">
<children>
<Text fx:id="statusText" layoutX="14.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" />
</children>
</AnchorPane>
</content>
</ScrollPane>
<Label fx:id="labelStatusCompile" layoutY="107.0" text="State" />
</children>
</AnchorPane>
<AnchorPane fx:id="srcSinkAP" layoutY="217.0" prefHeight="383.0" prefWidth="695.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="21.0">
<children>
<Label layoutX="14.0" layoutY="26.0" text="Sources" />
<Label layoutX="14.0" layoutY="186.0" text="Sinks" />
<ListView fx:id="sourcesList" layoutX="14.0" layoutY="42.0" prefHeight="91.0" prefWidth="659.0" />
<ListView fx:id="sinkList" layoutX="14.0" layoutY="203.0" prefHeight="91.0" prefWidth="659.0" />
<ListView fx:id="sourcesList" layoutX="14.0" layoutY="42.0" prefHeight="91.0" prefWidth="659.0" AnchorPane.bottomAnchor="250.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="42.0" />
<ListView fx:id="sinkList" layoutX="14.0" layoutY="203.0" prefHeight="91.0" prefWidth="659.0" AnchorPane.bottomAnchor="89.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="203.0" />
<Button layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#onAddSrc" text="Add" />
<Button layoutX="14.0" layoutY="304.0" mnemonicParsing="false" onAction="#onAddSink" text="Add" />
<Button layoutX="74.0" layoutY="143.0" mnemonicParsing="false" onAction="#onRemoveSrc" text="Remove" />
......@@ -44,23 +51,20 @@
<Button layoutX="261.0" layoutY="343.0" mnemonicParsing="false" onAction="#createJoak" prefHeight="26.0" prefWidth="165.0" text="Create *.joak (Json)" />
</children>
</AnchorPane>
<AnchorPane>
<children>
<MenuBar fx:id="menuBarMain" prefHeight="29.0" prefWidth="694.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<Menu fx:id="menuOpenRecent" mnemonicParsing="false" text="Recently Loaded" />
<MenuItem fx:id="menuItemReloadSource" mnemonicParsing="false" text="reload Java Source">
<accelerator>
<KeyCodeCombination alt="UP" code="R" control="ANY" meta="UP" shift="UP" shortcut="UP" />
</accelerator></MenuItem>
<MenuItem fx:id="menuItemExit" mnemonicParsing="false" text="Exit" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
<MenuBar fx:id="menuBarMain" prefHeight="29.0" prefWidth="694.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<Menu fx:id="menuOpenRecent" mnemonicParsing="false" text="Recently Loaded" />
<MenuItem fx:id="menuItemReloadSource" mnemonicParsing="false" text="reload Java Source">
<accelerator>
<KeyCodeCombination alt="UP" code="R" control="ANY" meta="UP" shift="UP" shortcut="UP" />
</accelerator>
</MenuItem>
<MenuItem fx:id="menuItemExit" mnemonicParsing="false" text="Exit" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>
......@@ -5,6 +5,7 @@
*/
package specgui;
import javafx.scene.control.TextArea;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -18,10 +19,13 @@ import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException;
import gui.RecentlyUsedFilesManager;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
......@@ -31,15 +35,17 @@ import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import joanakey.AutomationHelper;
import joanakey.CombinedApproach;
import keyjoana.settings.SettingsPaths;
import keyjoana.util.FilesUtil;
import specgui.joanahandler.Helper;
import specgui.joanahandler.JoanaInstance;
......@@ -99,6 +105,10 @@ public class FXMLDocumentController implements Initializable {
private MenuItem menuItemExit;
@FXML
private MenuItem menuItemReloadSource;
@FXML
private Text statusText;
@FXML
private ScrollPane statusScrollPane;
@FXML
public void onAddSrc() {
......@@ -237,9 +247,14 @@ public class FXMLDocumentController implements Initializable {
public void onPressCompile() {
String mainClass = mainClassesCB.getSelectionModel().getSelectedItem();
joanaView.preProcessAllJavaFilesInDirecotory(chosenFile);
joanaView.setCurrentJavaFolderFile(chosenFile);
tryCreateJoanaAsync();
selectMainClass(mainClass);
try {
joanaView.setCurrentJavaFolderFile(chosenFile);
tryCreateJoanaAsync();
selectMainClass(mainClass);
} catch (CompilerException e) {
compilationErrorMessage(e.getMessage());
}
}
@FXML
......@@ -281,8 +296,20 @@ public class FXMLDocumentController implements Initializable {
boolean debug = false;
if (debug) {
joanaView.setCurrentJarFile(new File(DEBUG_FOLDER + DEBUG_JAR));
joanaView.setCurrentJavaFolderFile(new File(DEBUG_FOLDER + "src"));
try {
joanaView.setCurrentJavaFolderFile(new File(DEBUG_FOLDER + "src"));
} catch (CompilerException e) {
this.setStatusMessage(e.getMessage());
this.setStatusMessageColor(Color.RED);
e.printStackTrace();
}
}
// Scene scene = new Scene(statusScrollPane,300,200);
statusText = new Text();
// statusText.wrappingWidthProperty().bind(scene.widthProperty());
statusScrollPane.setFitToWidth(true);
statusScrollPane.setContent(statusText);
}
public void setStage(Stage stage) {
......@@ -314,11 +341,16 @@ public class FXMLDocumentController implements Initializable {
joanaView.preProcessAllJavaFilesInDirecotory(chosenSrcDir);
setStatusMessage("Generate Jar files ...");
setStatusMessageColor(javafx.scene.paint.Color.BLUE);
joanaView.setCurrentJavaFolderFile(chosenSrcDir);
letUserChooseMainClass(
Helper.getAllClassesContainingMainMethod(joanaView.getCurrentJavaFolderFile()));
try {
joanaView.setCurrentJavaFolderFile(chosenSrcDir);
letUserChooseMainClass(Helper.getAllClassesContainingMainMethod(joanaView.getCurrentJavaFolderFile()));
this.chosenFile = chosenSrcDir;
disableMainGUIElements(false, true, true, false);
} catch (CompilerException e) {
compilationErrorMessage(e.getMessage());
}
this.chosenFile = chosenSrcDir;
}
public void enableProgressIndicator(boolean enable) {
......@@ -326,11 +358,13 @@ public class FXMLDocumentController implements Initializable {
}
private void setStatusMessage(String message) {
this.labelStatusCompile.setText(message);
this.statusText.setText(message);
// this.labelStatusCompile.setText(message);
}
private void setStatusMessageColor(javafx.scene.paint.Color color) {
this.labelStatusCompile.setTextFill(color);
this.statusText.setFill(color);
// this.labelStatusCompile.setTextFill(color);
}
private void selectMainClass(String mainClass) {
......@@ -353,7 +387,7 @@ public class FXMLDocumentController implements Initializable {
File file = new File(path);
disableMainGUIElements(true, true, true, true);
loadSrcFile(file);
disableMainGUIElements(false, true, true, false);
// disableMainGUIElements(false, true, true, false);
});
}
menuOpenRecent.getItems().addAll(items);
......@@ -366,7 +400,6 @@ public class FXMLDocumentController implements Initializable {
} else {
disableMainGUIElements(true, true, true, true);
loadSrcFile(mostRecentlyLoadedFile);
disableMainGUIElements(false, true, true, false);
}
}
......@@ -379,5 +412,11 @@ public class FXMLDocumentController implements Initializable {
mainClassesCB.setDisable(cbMainClass);
}
private void compilationErrorMessage(String message) {
this.setStatusMessage("Compilation Error \n" + message);
this.setStatusMessageColor(Color.RED);
disableMainGUIElements(false, true, false, true);
}
}
......@@ -19,6 +19,7 @@ import java.util.logging.Logger;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.graph.GraphIntegrity;
import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException;
import edu.kit.joana.ifc.sdg.graph.SDGSerializer;
import joanakey.customlistener.PreProcessor;
......@@ -100,8 +101,9 @@ public class JoanaView {
/**
* set current java folder of this {@link JoanaView} object and creates a Jar file.
* @param folderDir the java source directory
* @throws CompilerException if the jar creation throws a compilation exception
*/
public void setCurrentJavaFolderFile(File folderDir) {
public void setCurrentJavaFolderFile(File folderDir) throws CompilerException {
if (folderDir == null) {
return;
}
......@@ -198,7 +200,7 @@ public class JoanaView {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalStateException ex) {
Logger.getLogger(JoanaView.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex.getCause());
System.out.println("Illegal State: "+ex+ " " );
}
}
......
......@@ -10,12 +10,15 @@ import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import com.sun.org.apache.xalan.internal.xsltc.compiler.CompilerException;
public class JarCreator {
// buffer size for the .jar creation
......@@ -38,15 +41,34 @@ public class JarCreator {
* @return The path of the created file.
* @throws IOException Any IOException that may occur.
*/
public static String createJarFromDirectory(File dir, String name) throws IOException {
public static String createJarFromDirectory(File dir, String name) throws IOException, CompilerException {
// compile .java files to .class files
if (!dir.isDirectory()) throw new IllegalArgumentException("The given File \"dir\" is not a directory.");
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
DiagnosticCollector<JavaFileObject> diagnosticsCollector = new DiagnosticCollector<JavaFileObject>();
List<File> javaFiles = filterForType(dirToFileList(dir), DOT_JAVA);
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(javaFiles);
compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits).call();
try {
boolean compileSuccess = compiler.getTask(null, fileManager, diagnosticsCollector, null, null, compilationUnits)
.call();
if (!compileSuccess) {
StringBuilder compileErrorMessage = new StringBuilder();
List<Diagnostic<? extends JavaFileObject>> diagnostics = diagnosticsCollector.getDiagnostics();
for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) {
// read error dertails from the diagnostic object
// compileErrorMessage.append(diagnostic.getMessage(null));
System.out.println("\n"+diagnostic + "\n");
compileErrorMessage.append(diagnostic.getSource().getName()+"\nLine "+diagnostic.getLineNumber()+" "+diagnostic.getMessage(null)+"\n");
}
CompilerException ex = new CompilerException(compileErrorMessage.toString());
throw ex;
}
} catch (RuntimeException e) {
System.out.println(e.getCause());
}
fileManager.close();
// set up .jar file
......
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