Search in sources :

Example 1 with ReadableConverter

use of org.kanonizo.display.fx.converters.ReadableConverter in project kanonizo by kanonizo.

the class KanonizoFrame method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    assert sourceTree != null : "fx:id sourceTree was not injected";
    this.fw = Framework.getInstance();
    fw.addPropertyChangeListener(Framework.ROOT_FOLDER_PROPERTY_NAME, (e) -> {
        File newRoot = (File) e.getNewValue();
        rootFolderTextField.setText(newRoot.getAbsolutePath());
        sourceTree.setRoot(GuiUtils.createDynamicFileTree(newRoot));
        testTree.setRoot(GuiUtils.createDynamicFileTree(newRoot));
    });
    fw.addPropertyChangeListener(Framework.ALGORITHM_PROPERTY_NAME, (e) -> {
        SearchAlgorithm alg = (SearchAlgorithm) e.getNewValue();
        // remove existing children
        paramLayout.getChildren().clear();
        addParams(alg, paramLayout, true);
        addErrors(alg);
    });
    fw.addPropertyChangeListener(Framework.INSTRUMENTER_PROPERTY_NAME, (e) -> {
        org.kanonizo.framework.instrumentation.Instrumenter inst = (org.kanonizo.framework.instrumentation.Instrumenter) e.getNewValue();
        instParamLayout.getChildren().clear();
        addParams(inst, instParamLayout, false);
        addErrors(inst);
    });
    fw.addPropertyChangeListener(Framework.LIBS_PROPERTY_NAME, (e) -> {
        libs.getItems().add((File) e.getNewValue());
    });
    fw.setDisplay(this);
    Screen main = Screen.getPrimary();
    Rectangle2D bounds = main.getVisualBounds();
    rootFolderTextField.setText(fw.getRootFolder().getAbsolutePath());
    addSourceListeners();
    addTestListeners();
    addLibListeners();
    selectRoot.setOnAction(ev -> selectRoot());
    try {
        algorithmChoices.getItems().addAll(Framework.getAvailableAlgorithms());
        algorithmChoices.setConverter(new ReadableConverter());
        algorithmChoices.valueProperty().addListener((ov, t, t1) -> {
            SearchAlgorithm alg = (SearchAlgorithm) ov.getValue();
            fw.setAlgorithm(alg);
        });
        algorithmChoices.getSelectionModel().select(fw.getAlgorithm());
        instrumenterChoices.getItems().addAll(Framework.getAvailableInstrumenters());
        instrumenterChoices.setConverter(new ReadableConverter());
        instrumenterChoices.valueProperty().addListener((ov, t, t1) -> {
            org.kanonizo.framework.instrumentation.Instrumenter inst = (org.kanonizo.framework.instrumentation.Instrumenter) ov.getValue();
            fw.setInstrumenter(inst);
        });
        instrumenterChoices.getSelectionModel().select(fw.getInstrumenter());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : ReadableConverter(org.kanonizo.display.fx.converters.ReadableConverter) Screen(javafx.stage.Screen) SearchAlgorithm(org.kanonizo.algorithms.SearchAlgorithm) Rectangle2D(javafx.geometry.Rectangle2D) File(java.io.File) ScriptException(javax.script.ScriptException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Screen (javafx.stage.Screen)1 ScriptException (javax.script.ScriptException)1 SearchAlgorithm (org.kanonizo.algorithms.SearchAlgorithm)1 ReadableConverter (org.kanonizo.display.fx.converters.ReadableConverter)1