});
eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
public void onSessionInit(SessionInitEvent sie)
{
SessionInfo sessionInfo = session.getSessionInfo();
// remove devtools commands if it isn't installed
if (!sessionInfo.isDevtoolsInstalled())
{
commands.devtoolsLoadAll().remove();
}
// adapt or remove package commands if this isn't a package
String type = sessionInfo.getBuildToolsType();
if (!type.equals(SessionInfo.BUILD_TOOLS_PACKAGE))
{
commands.devtoolsLoadAll().remove();
commands.buildSourcePackage().remove();
commands.buildBinaryPackage().remove();
commands.roxygenizePackage().remove();
commands.checkPackage().remove();
commands.testPackage().remove();
commands.buildAll().setImageResource(
BuildPaneResources.INSTANCE.iconBuild());
commands.buildAll().setMenuLabel("_Build All");
commands.buildAll().setButtonLabel("Build All");
commands.buildAll().setDesc("Build all");
}
// remove makefile commands if this isn't a makefile
if (type.equals(SessionInfo.BUILD_TOOLS_CUSTOM))
{
commands.rebuildAll().remove();
}
if (!type.equals(SessionInfo.BUILD_TOOLS_MAKEFILE))
{
commands.cleanAll().remove();
}
// remove all other commands if there are no build tools
if (type.equals(SessionInfo.BUILD_TOOLS_NONE))
{
commands.buildAll().remove();
commands.rebuildAll().remove();
commands.cleanAll().remove();
commands.stopBuild().remove();
commands.activateBuild().remove();
}
// initialize from build state if necessary
BuildState buildState = sessionInfo.getBuildState();
if (buildState != null)
shim.initialize(buildState);
}
});