package greenfoot.extension;
import bluej.Boot;
import bluej.collect.DataSubmissionFailedDialog;
import bluej.extensions.event.CompileEvent;
import bluej.extensions.event.CompileListener;
import greenfoot.guifx.GreenfootGuiHandler;
import java.net.MalformedURLException;
import java.net.URL;
import bluej.Config;
import bluej.Main;
import bluej.extensions.BlueJ;
import bluej.extensions.Extension;
import bluej.extensions.event.ApplicationEvent;
import bluej.extensions.event.ApplicationListener;
import javafx.application.Platform;
import threadchecker.OnThread;
import threadchecker.Tag;
| This is the starting point of Greenfoot as a BlueJ Extension.
|
| @author Poul Henriksen
|
@OnThread(Tag.SwingIsFX)
public class GreenfootExtension
extends Extension implements ApplicationListener{
private BlueJ theBlueJ;
| When this method is called, the extension may start its work.
|
public void startup(BlueJ bluej)
{
theBlueJ = bluej;
Main.setGuiHandler(new GreenfootGuiHandler());
bluej.addApplicationListener(new ApplicationListener()
{
@Override
public void blueJReady(ApplicationEvent event)
{
}
@Override
public void dataSubmissionFailed(ApplicationEvent event)
{
if (Boot.isTrialRecording())
{
Platform.runLater(() -> {
new DataSubmissionFailedDialog().show();
});
}
}
});
bluej.addCompileListener(new CompileListener() {
@Override
public void compileWarning(CompileEvent event)
{
}
@Override
public void compileSucceeded(CompileEvent event)
{
System.gc();
}
@Override
public void compileStarted(CompileEvent event)
{
}
@Override
public void compileFailed(CompileEvent event)
{
}
@Override
public void compileError(CompileEvent event)
{
}
});
theBlueJ.addApplicationListener(this);
}
| This method must decide if this Extension is compatible with the current
| release of the BlueJ Extensions API
|
public boolean isCompatible()
{
return Config.isGreenfoot();
}
| Returns the version number of this extension
|
public String getVersion()
{
return ("2003.03");
}
| Returns the user-visible name of this extension
|
public String getName()
{
return ("greenfoot Extension");
}
@Override
public String getDescription()
{
return ("greenfoot extension");
}
| Returns a URL where you can find info on this extension. The real problem
| is making sure that the link will still be alive in three years...
|
@Override
public URL getURL()
{
try {
return new URL("http://www.greenfoot.org");
}
catch (MalformedURLException e) {
return null;
}
}
@Override
public void blueJReady(ApplicationEvent event)
{
}
@Override
public void dataSubmissionFailed(ApplicationEvent event)
{
}
}
top,
use,
map,
class GreenfootExtension
. startup
. blueJReady
. dataSubmissionFailed
. compileWarning
. compileSucceeded
. compileStarted
. compileFailed
. compileError
. isCompatible
. getVersion
. getName
. getDescription
. getURL
. blueJReady
. dataSubmissionFailed
163 neLoCode
+ 9 LoComm