Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MacEclipse support #387

Merged
merged 18 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
git config --global core.mergeoptions --no-edit
git fetch --depth=1

- name: Checkout Development
run: |
git checkout development

- name: Set Release Number Studio
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Repository;

import com.neuronrobotics.bowlerstudio.assets.AssetFactory;
import com.neuronrobotics.video.OSUtil;

import eu.mihosoft.vrl.v3d.JavaFXInitializer;
import javafx.scene.control.Button;
import javafx.scene.image.Image;

public class ArduinoExternalEditor implements IExternalEditor {

Expand All @@ -37,6 +39,16 @@ public void launch(File file, Button advanced) {



}

public Image getImage() {
try {
return AssetFactory.loadAsset("Script-Tab-Arduino.png");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository;

import com.neuronrobotics.bowlerstudio.assets.AssetFactory;
import com.neuronrobotics.video.OSUtil;

import javafx.scene.control.Button;
import javafx.scene.image.Image;

public abstract class EclipseExternalEditor implements IExternalEditor {

Expand All @@ -40,9 +42,18 @@ protected static String readAll(Reader rd) throws IOException {
}
return sb.toString();
}

public Image getImage() {
try {
Image loadAsset = AssetFactory.loadAsset("eclipse.png");
return loadAsset;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

protected boolean OSSupportsEclipse() {
return OSUtil.isLinux() || OSUtil.isWindows();
return OSUtil.isLinux() || OSUtil.isWindows()|| OSUtil.isOSX();
}


Expand All @@ -61,6 +72,19 @@ public void launch(File file, Button advanced) {
"eclipse")
.getAbsolutePath();

} catch (GitAPIException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else if (OSUtil.isOSX()) {
try {
ScriptingEngine.cloneRepo("https://github.com/CommonWealthRobotics/ESP32ArduinoEclipseInstaller.git",null);
ScriptingEngine.pull("https://github.com/CommonWealthRobotics/ESP32ArduinoEclipseInstaller.git");
eclipseEXE = ScriptingEngine
.fileFromGit("https://github.com/CommonWealthRobotics/ESP32ArduinoEclipseInstaller.git",
"eclipse-mac")
.getAbsolutePath();

} catch (GitAPIException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down Expand Up @@ -123,6 +147,9 @@ public void launch(File file, Button advanced) {
}

File currentws = null;
if (OSUtil.isOSX())
currentws= new File(System.getProperty("user.home")+"/bin/eclipse/Eclipse.app/Contents/Eclipse/configuration/.settings/org.eclipse.ui.ide.prefs");

if (OSUtil.isLinux())
currentws= new File(System.getProperty("user.home")+"/bin/eclipse-slober-rbe/eclipse/configuration/.settings/org.eclipse.ui.ide.prefs");
if (OSUtil.isWindows())
Expand Down Expand Up @@ -158,11 +185,14 @@ public void launch(File file, Button advanced) {


}catch(Exception ex) {
ex.printStackTrace();
//ex.printStackTrace();
System.out.println("Workspace missing, opening eclipse");
}

System.out.println("Opening workspace "+ws);
if(!isEclipseOpen( ws)) {
if (OSUtil.isOSX())
run( ScriptingEngine.getWorkspace(),System.out, "bash", eclipseEXE, "-data", ws);
if (OSUtil.isLinux())
run( ScriptingEngine.getWorkspace(),System.out, "bash", eclipseEXE, "-data", ws);
if (OSUtil.isWindows())
Expand Down Expand Up @@ -194,6 +224,8 @@ public void launch(File file, Button advanced) {
}
}
}
if (OSUtil.isOSX())
run(dir,System.err, "bash", eclipseEXE, dir.getAbsolutePath() + delim());
if (OSUtil.isLinux())
run(dir,System.err, "bash", eclipseEXE, dir.getAbsolutePath() + delim());
if (OSUtil.isWindows())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@ public class ExternalEditorController {
boolean hasEditor = false;
private Button advanced = new Button();
private ImageView image=new ImageView();
private static ArrayList<IExternalEditor> editors=new ArrayList<IExternalEditor>();
static {
private ArrayList<IExternalEditor> editors=new ArrayList<IExternalEditor>();

private void loadEditors() {
editors.add(new SVGExternalEditor());
editors.add(new GroovyEclipseExternalEditor());
editors.add(new ArduinoExternalEditor());
}
private IExternalEditor myEditor=null;
public ExternalEditorController(File f, CheckBox autoRun){
loadEditors();
this.currentFile = f;
try {
Image loadAsset = AssetFactory.loadAsset("Script-Tab-"+ScriptingEngine.getShellType(currentFile.getName())+".png");
image.setImage(loadAsset);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


for(IExternalEditor e:editors) {
if(e.isSupportedByExtention(f)) {
hasEditor=true;
myEditor=e;
image.setImage(e.getImage());
System.err.println("ExternalEditorController: FOUND "+f.getName()+" is supported by "+e.getClass());
break;
}else {
System.err.println(":ExternalEditorController: "+f.getName()+" is not supported by "+e.getClass());
}

}
if(hasEditor) {

advanced.setGraphic(image);
advanced.setTooltip(new Tooltip("Click here to launch "+myEditor.nameOfEditor()+" the advanced editor for this file"));
advanced.setText(myEditor.nameOfEditor());
Expand All @@ -52,6 +51,14 @@ public ExternalEditorController(File f, CheckBox autoRun){
myEditor.launch(currentFile,advanced);
//autoRun.setSelected(true);
});
}else {
try {
Image loadAsset = AssetFactory.loadAsset("Script-Tab-"+ScriptingEngine.getShellType(currentFile.getName())+".png");
image.setImage(loadAsset);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected boolean checkForExistingProjectFiles(File dir ) {

@Override
public Class getSupportedLangauge() {
if (OSUtil.isLinux() || OSUtil.isWindows())
if (OSSupportsEclipse() )
return GroovyHelper.class;
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.image.Image;

public interface IExternalEditor {

Expand All @@ -39,6 +40,8 @@ default boolean isSupportedByExtention(File file) {

void onProcessExit(int ev);

Image getImage();

default String delim() {
if (OSUtil.isWindows())
return "\\";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import org.eclipse.jgit.api.errors.TransportException;
import org.eclipse.jgit.errors.NoWorkTreeException;

import com.neuronrobotics.bowlerstudio.assets.AssetFactory;
import com.neuronrobotics.video.OSUtil;

import javafx.scene.control.Button;
import javafx.scene.image.Image;

public class SVGExternalEditor implements IExternalEditor {

Expand Down Expand Up @@ -65,7 +67,15 @@ public URL getInstallURL() throws MalformedURLException {
public String nameOfEditor() {
return "Inkscape";
}

public Image getImage() {
try {
return AssetFactory.loadAsset("Script-Tab-SVG.png");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static void main(String [] args) throws InvalidRemoteException, TransportException, GitAPIException, IOException {
File f =ScriptingEngine.fileFromGit("https://github.com/Technocopia/Graphics.git", "Graphics/SimplifiedLogo/simplified logo.svg");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,9 @@ public class ScriptingFileWidget extends BorderPane implements IFileChangeListen
private Button printbed;
private FileChangeWatcher watch;;
public ScriptingFileWidget(File currentFile) throws IOException {
this(ScriptingWidgetType.FILE, currentFile);
load(ScriptingWidgetType.FILE, currentFile);

loadCodeFromFile(currentFile);
// publish.setDisable(!isOwnedByLoggedInUser);
runfx.setGraphic(AssetFactory.loadIcon("Run.png"));
if (isOwnedByLoggedInUser)
publish.setGraphic(AssetFactory.loadIcon("Publish.png"));
else
publish.setGraphic(AssetFactory.loadIcon("Fork.png"));
arrange.setGraphic(AssetFactory.loadIcon("Edit-CAD-Engine.png"));
arrange.setDisable(true);

}

private void startStopAction() {
Expand All @@ -116,7 +108,7 @@ private void startStopAction() {
}).start();
}

private ScriptingFileWidget(ScriptingWidgetType type, File currentFile) {
private void load(ScriptingWidgetType type, File currentFile) {
isOwnedByLoggedInUser = ScriptingEngine.checkOwner(currentFile);
this.type = type;
this.currentFile = currentFile;
Expand Down Expand Up @@ -176,7 +168,12 @@ private ScriptingFileWidget(ScriptingWidgetType type, File currentFile) {
// little bit
});
});
externalEditorController = new ExternalEditorController(currentFile, autoRun);
System.err.println("\n\n\nScriptingFileWidget loading the editor loader:\n\n\n");
try {
externalEditorController = new ExternalEditorController(currentFile, autoRun);
}catch(Throwable t) {
t.printStackTrace();
}

Button openFile = new Button("Open...");
openFile.setOnAction(event -> {
Expand Down Expand Up @@ -216,7 +213,8 @@ private ScriptingFileWidget(ScriptingWidgetType type, File currentFile) {
controlPane.getChildren().add(arrange);
controlPane.getChildren().add(printbed);
}
controlPane.getChildren().add(externalEditorController.getControl());
if(externalEditorController!=null)
controlPane.getChildren().add(externalEditorController.getControl());
controlPane.getChildren().add(autoRun);
controlPane.getChildren().add(publish);
controlPane.getChildren().add(openFile);
Expand All @@ -232,6 +230,21 @@ private ScriptingFileWidget(ScriptingWidgetType type, File currentFile) {
setTop(controlPane);

addIScriptEventListener(BowlerStudioController.getBowlerStudio());

try {
loadCodeFromFile(currentFile);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// publish.setDisable(!isOwnedByLoggedInUser);
runfx.setGraphic(AssetFactory.loadIcon("Run.png"));
if (isOwnedByLoggedInUser)
publish.setGraphic(AssetFactory.loadIcon("Publish.png"));
else
publish.setGraphic(AssetFactory.loadIcon("Fork.png"));
arrange.setGraphic(AssetFactory.loadIcon("Edit-CAD-Engine.png"));
arrange.setDisable(true);
reset();
}
private void exportAll(boolean makePrintBed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void uncaughtException(Thread t, Throwable e) {

private static LocalFileScriptTab selectedTab = null;
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
private long timeSinceLastUpdate = 0;
static {
BowlerStudio.invokeLater(() -> Thread.setDefaultUncaughtExceptionHandler(new IssueReportingExceptionHandler()));

Expand Down Expand Up @@ -200,6 +201,7 @@ public void changedUpdate(DocumentEvent arg0) {
new Thread() {
public void run() {
try {
timeSinceLastUpdate=System.currentTimeMillis();
if (textArea.isEnabled())
setContent(textArea.getText());
getScripting().removeIScriptEventListener(l);
Expand Down Expand Up @@ -424,6 +426,13 @@ public void onScriptChanged(String previous, String current, File source) {
private void setContent(String current) {
if (current.length() > 3 && !content.contentEquals(current)) {
content = current; // writes
long now=System.currentTimeMillis();
if(now<(timeSinceLastUpdate+100)) {
System.err.println("Ovewrite Protect!");
return;
}

timeSinceLastUpdate=now;

System.out.println("External change of " + file.getName() + " on " + dateFormat.format(new Date()));
if (current.length() > MaxTextSize) {
Expand Down
Loading