Skip to content

Commit

Permalink
Adding a runner for fxml files
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Harrington committed Jul 11, 2024
1 parent 041a9c3 commit 0e3afaa
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.neuronrobotics.bowlerstudio.scripting;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;

import com.neuronrobotics.bowlerstudio.vitamins.Vitamins;

import eu.mihosoft.vrl.v3d.CSG;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Tab;
import javafx.scene.layout.Pane;

public class FXMLBowlerLoader implements IScriptingLanguage {

@Override
public Object inlineScriptRun(File xml, ArrayList<Object> args) throws Exception {
FXMLLoader loader = new FXMLLoader(xml.toURI().toURL());
Pane newLoadedPane = loader.load();
// Create a tab
Tab myTab = new Tab();
//set the title of the new tab
myTab.setContent(newLoadedPane);
return myTab;
}

@Override
public Object inlineScriptRun(String code, ArrayList<Object> args) throws Exception {
throw new RuntimeException("This engine only supports files");
}

@Override
public String getShellType() {
// TODO Auto-generated method stub
return "fxml";
}
@Override
public boolean getIsTextFile() {
// TODO Auto-generated method stub
return true;
}
/**
* Get the contents of an empty file
*
* @return
*/
public String getDefaultContents() {
return "";
}
@Override
public ArrayList<String> getFileExtenetion() {
// TODO Auto-generated method stub
return new ArrayList<>(Arrays.asList("fxml","FXML","FxML"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public class ScriptingEngine {// this subclasses boarder pane for the widgets
addScriptingLanguage(new SequenceRunner());
addScriptingLanguage(new BlenderLoader());
addScriptingLanguage(new FreecadLoader());
addScriptingLanguage(new FXMLBowlerLoader());
}

public static void setWorkspace(File file) {
Expand Down

0 comments on commit 0e3afaa

Please sign in to comment.