Skip to content

Commit

Permalink
JBIDE-17628: Ctrl+4 does not open the default Forge runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Aug 27, 2014
1 parent b629732 commit b589181
Showing 1 changed file with 24 additions and 1 deletion.
Expand Up @@ -15,16 +15,33 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.forge.core.furnace.FurnaceRuntime;
import org.jboss.tools.forge.core.preferences.ForgeCorePreferences;
import org.jboss.tools.forge.core.runtime.ForgeRuntime;
import org.jboss.tools.forge.core.runtime.ForgeRuntimeState;
import org.jboss.tools.forge.ui.internal.ForgeUIPlugin;
import org.jboss.tools.forge.ui.internal.ext.dialog.UICommandListDialog;
import org.jboss.tools.forge.ui.internal.part.ForgeConsoleView;
import org.jboss.tools.forge.ui.util.ForgeHelper;

public class ForgeCommandHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) {
ForgeRuntime runtime = ForgeCorePreferences.INSTANCE.getDefaultRuntime();
if (runtime == FurnaceRuntime.INSTANCE) {
handleFurnace(event);
} else {
startForgeRuntime(runtime);
}
return null;
}

private void handleFurnace(ExecutionEvent event) {
try {
ForgeConsoleView forgeConsoleView = ForgeHelper.findForgeConsoleView();
if (forgeConsoleView != null && forgeConsoleView.isShowing()) {
ForgeHelper.showForgeConsole(FurnaceRuntime.INSTANCE);
}
final IWorkbenchWindow window = HandlerUtil
.getActiveWorkbenchWindowChecked(event);
if (!ForgeRuntimeState.RUNNING.equals(FurnaceRuntime.INSTANCE.getState())) {
Expand All @@ -47,7 +64,13 @@ public void run() {
} catch (Exception e) {
ForgeUIPlugin.log(e);
}
return null;
}

private void startForgeRuntime(ForgeRuntime runtime) {
ForgeHelper.showForgeConsole(runtime);
if (!ForgeRuntimeState.RUNNING.equals(runtime.getState())) {
ForgeHelper.start(runtime);
}
}

}

0 comments on commit b589181

Please sign in to comment.