Skip to content
Snippets Groups Projects
Commit 03d0d35a authored by dgelessus's avatar dgelessus
Browse files

Remove support for BMotionStudio Groovy observer scripts

This feature wasn't accessible in the GUI for 10 years and I can only
find a single incomplete example of a Groovy observer script. Although
the feature is now fully working again, let's remove it properly now
while nobody is relying on it.
parent 8f3126f5
Branches
No related tags found
No related merge requests found
Pipeline #116462 passed
...@@ -52,7 +52,6 @@ project(":de.bmotionstudio.gef.editor") { ...@@ -52,7 +52,6 @@ project(":de.bmotionstudio.gef.editor") {
// hardcode a specific MXParser version here. // hardcode a specific MXParser version here.
// It *should* be safe to update this when a new version is released. // It *should* be safe to update this when a new version is released.
implementation group: "io.github.x-stream", name: "mxparser", version: "1.2.2" implementation group: "io.github.x-stream", name: "mxparser", version: "1.2.2"
implementation group: "org.codehaus.groovy", name: "groovy", version: "2.5.22"
} }
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/groovy-2.5.22.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/mxparser-1.2.2.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/mxparser-1.2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/xmlpull-1.1.3.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/xmlpull-1.1.3.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/dependencies/xstream-1.4.20.jar"/> <classpathentry exported="true" kind="lib" path="lib/dependencies/xstream-1.4.20.jar"/>
......
...@@ -149,7 +149,6 @@ Export-Package: de.bmotionstudio.gef.editor; ...@@ -149,7 +149,6 @@ Export-Package: de.bmotionstudio.gef.editor;
org.eclipse.swt.widgets, org.eclipse.swt.widgets,
de.bmotionstudio.gef.editor" de.bmotionstudio.gef.editor"
Bundle-ClassPath: ., Bundle-ClassPath: .,
lib/dependencies/groovy-2.5.22.jar,
lib/dependencies/mxparser-1.2.2.jar, lib/dependencies/mxparser-1.2.2.jar,
lib/dependencies/xmlpull-1.1.3.1.jar, lib/dependencies/xmlpull-1.1.3.1.jar,
lib/dependencies/xstream-1.4.20.jar lib/dependencies/xstream-1.4.20.jar
...@@ -348,10 +348,6 @@ ...@@ -348,10 +348,6 @@
class="de.bmotionstudio.gef.editor.observer.ColumnObserver" class="de.bmotionstudio.gef.editor.observer.ColumnObserver"
name="Column Observer"> name="Column Observer">
</observer> </observer>
<observer
class="de.bmotionstudio.gef.editor.observer.ExternalObserverScript"
name="External Observer Script">
</observer>
</extension> </extension>
<extension <extension
point="de.bmotionstudio.gef.editor.schedulerEvent"> point="de.bmotionstudio.gef.editor.schedulerEvent">
...@@ -577,63 +573,6 @@ ...@@ -577,63 +573,6 @@
id="de.bmotionstudio.gef.editor.visualization"> id="de.bmotionstudio.gef.editor.visualization">
</control> </control>
</observer> </observer>
<observer
id="de.bmotionstudio.gef.editor.observer.ExternalObserverScript">
<control
id="de.bmotionstudio.gef.editor.image">
</control>
<control
id="de.bmotionstudio.gef.editor.button">
</control>
<control
id="de.bmotionstudio.gef.editor.composite">
</control>
<control
id="de.bmotionstudio.gef.editor.text">
</control>
<control
id="de.bmotionstudio.gef.editor.rectangle">
</control>
<control
id="de.bmotionstudio.gef.editor.radiobutton">
</control>
<control
id="de.bmotionstudio.gef.editor.checkbox">
</control>
<control
id="de.bmotionstudio.gef.editor.connection">
</control>
<control
id="de.bmotionstudio.gef.editor.ellipse">
</control>
<control
id="de.bmotionstudio.gef.editor.textfield">
</control>
<control
id="de.bmotionstudio.gef.editor.tablecell">
</control>
<control
id="de.bmotionstudio.gef.editor.table">
</control>
<control
id="de.bmotionstudio.gef.editor.tablecolumn">
</control>
<control
id="de.bmotionstudio.gef.editor.light">
</control>
<control
id="de.bmotionstudio.gef.editor.signal">
</control>
<control
id="de.bmotionstudio.gef.editor.switch">
</control>
<control
id="de.bmotionstudio.gef.editor.track">
</control>
<control
id="de.bmotionstudio.gef.editor.tracknode">
</control>
</observer>
<observer <observer
id="de.bmotionstudio.gef.editor.observer.SwitchImage"> id="de.bmotionstudio.gef.editor.observer.SwitchImage">
<control <control
......
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.observer;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
import java.io.File;
import java.io.IOException;
import org.codehaus.groovy.control.CompilationFailedException;
import org.eclipse.core.resources.IFile;
import de.bmotionstudio.gef.editor.Animation;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.wizard.WizardObserverExternalObserverScript;
public class ExternalObserverScript extends Observer {
public static String ID = "de.bmotionstudio.gef.editor.observer.ExternalObserverScript";
private transient GroovyObject groovyObject;
private String scriptPath;
// private String language;
@Override
public void check(Animation animation, BControl control) {
try {
if (groovyObject == null) {
IFile pFile = control.getVisualization().getProjectFile();
String myPath = (pFile.getProject().getLocation() + "/" + scriptPath)
.replace("file:", "");
ClassLoader parent = getClass().getClassLoader();
GroovyClassLoader loader = new GroovyClassLoader(parent);
Class<?> groovyClass;
groovyClass = loader.parseClass(new File(myPath));
// let's call some method on an instance
groovyObject = (GroovyObject) groovyClass.newInstance();
}
Object[] args = { animation, control };
groovyObject.invokeMethod("check", args);
} catch (CompilationFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public ObserverWizard getWizard(BControl control) {
return new WizardObserverExternalObserverScript(control, this);
}
public String getScriptPath() {
return scriptPath;
}
public void setScriptPath(String scriptPath) {
this.scriptPath = scriptPath;
}
}
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.observer.wizard;
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.observer.ExternalObserverScript;
import de.bmotionstudio.gef.editor.observer.Observer;
import de.bmotionstudio.gef.editor.observer.ObserverWizard;
public class WizardObserverExternalObserverScript extends ObserverWizard {
private class ObserverExternalObserverScriptPage extends WizardPage {
private Text txtScriptPath;
protected ObserverExternalObserverScriptPage(final String pageName) {
super(pageName);
}
public Text getTxtScriptPath() {
return txtScriptPath;
}
public void createControl(final Composite parent) {
final DataBindingContext dbc = new DataBindingContext();
Composite container = new Composite(parent, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
container.setLayout(new GridLayout(2, false));
Label lb = new Label(container, SWT.NONE);
lb.setText("Script File:");
txtScriptPath = new Text(container, SWT.BORDER);
txtScriptPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
txtScriptPath.setFont(new Font(Display.getDefault(), new FontData(
"Arial", 10, SWT.NONE)));
initBindings(dbc);
setControl(container);
}
private void initBindings(DataBindingContext dbc) {
dbc.bindValue(
SWTObservables.observeText(txtScriptPath, SWT.Modify),
BeansObservables.observeValue(
(ExternalObserverScript) getObserver(),
"scriptPath"));
}
}
public WizardObserverExternalObserverScript(BControl bcontrol,
Observer bobserver) {
super(bcontrol, bobserver);
addPage(new ObserverExternalObserverScriptPage(
"ObserverExternalObserverScriptPage"));
}
@Override
protected Boolean prepareToFinish() {
ObserverExternalObserverScriptPage page = (ObserverExternalObserverScriptPage) getPage("ObserverExternalObserverScriptPage");
String errorStr = "";
if (page.getTxtScriptPath().getText().length() == 0)
errorStr += "Please enter a path for a script file.\n";
if (errorStr.length() > 0) {
MessageDialog.openError(Display.getDefault().getActiveShell(),
"An Error occured", errorStr);
return false;
}
return true;
}
@Override
public Point getSize() {
return new Point(600, 500);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment