Search in sources :

Example 1 with Framework

use of org.kanonizo.Framework in project kanonizo by kanonizo.

the class KanonizoFrame method load.

@FXML
public void load() {
    try {
        FileChooser fc = new FileChooser();
        File loadLocation = new File(System.getProperty("user.home") + File.separator + ".kanonizo");
        if (!loadLocation.exists()) {
            loadLocation.mkdir();
        }
        fc.setInitialDirectory(loadLocation);
        File toRead = fc.showOpenDialog(KanonizoFxApplication.stage);
        if (toRead != null) {
            new Thread(() -> {
                try {
                    Framework read = fw.read(toRead);
                    this.fw.setSourceFolder(read.getSourceFolder());
                    this.fw.setRootFolder(read.getRootFolder());
                    this.fw.setTestFolder(read.getTestFolder());
                    this.fw.setAlgorithm(read.getAlgorithm());
                    this.fw.setInstrumenter(read.getInstrumenter());
                    read.getLibraries().forEach(lib -> this.fw.addLibrary(lib));
                    Platform.runLater(() -> {
                        File root = fw.getRootFolder();
                        rootFolderTextField.setText(root.getAbsolutePath());
                        sourceTree.setRoot(GuiUtils.createDynamicFileTree(root));
                        sourceTree.scrollTo(findIndexOfChild(fw.getSourceFolder(), sourceTree));
                        testTree.setRoot(GuiUtils.createDynamicFileTree(root));
                        testTree.scrollTo(findIndexOfChild(fw.getTestFolder(), testTree));
                        libs.getItems().addAll(fw.getLibraries());
                        algorithmChoices.getSelectionModel().select(fw.getAlgorithm());
                        instrumenterChoices.getSelectionModel().select(fw.getInstrumenter());
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }).start();
        }
    } catch (Exception e) {
        AlertUtils.alert(AlertType.ERROR, e.getClass().getName(), e.getMessage());
    }
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Arrays(java.util.Arrays) Initializable(javafx.fxml.Initializable) AlertUtils(org.kanonizo.gui.AlertUtils) TestSuite(org.kanonizo.framework.objects.TestSuite) URL(java.net.URL) Control(javafx.scene.control.Control) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Application(javafx.application.Application) Task(javafx.concurrent.Task) AlertType(javafx.scene.control.Alert.AlertType) ComboBox(javafx.scene.control.ComboBox) ContextMenu(javafx.scene.control.ContextMenu) Method(java.lang.reflect.Method) ScriptException(javax.script.ScriptException) Rectangle2D(javafx.geometry.Rectangle2D) TextField(javafx.scene.control.TextField) SearchAlgorithm(org.kanonizo.algorithms.SearchAlgorithm) MenuItem(javafx.scene.control.MenuItem) Set(java.util.Set) ConditionalParameter(org.kanonizo.annotations.ConditionalParameter) Screen(javafx.stage.Screen) OptionProvider(org.kanonizo.annotations.OptionProvider) Collectors(java.util.stream.Collectors) TreeView(javafx.scene.control.TreeView) InvocationTargetException(java.lang.reflect.InvocationTargetException) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) Util(org.kanonizo.util.Util) Logger(org.apache.logging.log4j.Logger) PropertyChangeListener(java.beans.PropertyChangeListener) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Display(org.kanonizo.display.Display) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) ListView(javafx.scene.control.ListView) MouseEvent(javafx.scene.input.MouseEvent) Framework(org.kanonizo.Framework) ReadableConverter(org.kanonizo.display.fx.converters.ReadableConverter) Parameter(com.scythe.instrumenter.InstrumentationProperties.Parameter) HashSet(java.util.HashSet) ResourceBundle(java.util.ResourceBundle) FXMLLoader(javafx.fxml.FXMLLoader) Prerequisite(org.kanonizo.annotations.Prerequisite) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) DirectoryChooser(javafx.stage.DirectoryChooser) KanonizoFxApplication(org.kanonizo.gui.KanonizoFxApplication) ProgressIndicator(javafx.scene.control.ProgressIndicator) Label(javafx.scene.control.Label) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ScriptEngineManager(javax.script.ScriptEngineManager) StringConverter(javafx.util.StringConverter) Field(java.lang.reflect.Field) File(java.io.File) GuiUtils(org.kanonizo.gui.GuiUtils) FileChooser(javafx.stage.FileChooser) Condition(java.util.concurrent.locks.Condition) ActionEvent(javafx.event.ActionEvent) ScriptEngine(javax.script.ScriptEngine) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) LogManager(org.apache.logging.log4j.LogManager) FileChooser(javafx.stage.FileChooser) File(java.io.File) Framework(org.kanonizo.Framework) ScriptException(javax.script.ScriptException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FXML(javafx.fxml.FXML)

Example 2 with Framework

use of org.kanonizo.Framework in project kanonizo by kanonizo.

the class SearchAlgorithmTest method setup.

@Before
public void setup() {
    Framework f = Framework.getInstance();
    f.setInstrumenter(scytheInst);
    f.setSourceFolder(new File("./testing/src"));
    f.setTestFolder(new File("./testing/test"));
    try {
        InstrumentationProperties.WRITE_CLASS_IF_MODIFIED = true;
        Thread.currentThread().setContextClassLoader(InstrumentingClassLoader.getInstance());
        scytheInst.loadClass("sample_classes.Stack");
        scytheInst.loadClass("sample_tests.StackTest");
    } catch (ClassNotFoundException e) {
        fail("Couldn't find class sample_classes.Stack");
    }
    f.setAlgorithm(algorithm);
    try {
        f.run();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : File(java.io.File) Framework(org.kanonizo.Framework) Before(org.junit.Before)

Aggregations

File (java.io.File)2 Parameter (com.scythe.instrumenter.InstrumentationProperties.Parameter)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Modifier (java.lang.reflect.Modifier)1 URL (java.net.URL)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 ResourceBundle (java.util.ResourceBundle)1 Set (java.util.Set)1 Condition (java.util.concurrent.locks.Condition)1 Collectors (java.util.stream.Collectors)1 Application (javafx.application.Application)1 Platform (javafx.application.Platform)1 ObservableList (javafx.collections.ObservableList)1 Task (javafx.concurrent.Task)1