Author: koen.aers(a)jboss.com
Date: 2011-10-13 10:51:37 -0400 (Thu, 13 Oct 2011)
New Revision: 35621
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StartDelegate.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StopDelegate.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java
Log:
JBIDE-9866: Closing and Reopening the Forge Console View Results in Errors When Starting
the Forge Runtime
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StartDelegate.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StartDelegate.java 2011-10-13
13:32:15 UTC (rev 35620)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StartDelegate.java 2011-10-13
14:51:37 UTC (rev 35621)
@@ -8,9 +8,13 @@
public class StartDelegate implements IViewActionDelegate {
+ private IViewPart part = null;
+
@Override
public void run(IAction action) {
- ForgeView.INSTANCE.startForge();
+ if (part != null && part instanceof ForgeView) {
+ ((ForgeView)part).startForge();
+ }
}
@Override
@@ -21,8 +25,7 @@
@Override
public void init(IViewPart view) {
- // TODO Auto-generated method stub
-
+ part = view;
}
}
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StopDelegate.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StopDelegate.java 2011-10-13
13:32:15 UTC (rev 35620)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/action/StopDelegate.java 2011-10-13
14:51:37 UTC (rev 35621)
@@ -8,9 +8,13 @@
public class StopDelegate implements IViewActionDelegate {
+ private IViewPart part = null;
+
@Override
public void run(IAction action) {
- ForgeView.INSTANCE.stopForge();
+ if (part != null && part instanceof ForgeView) {
+ ((ForgeView)part).stopForge();
+ }
}
@Override
@@ -21,8 +25,7 @@
@Override
public void init(IViewPart view) {
- // TODO Auto-generated method stub
-
+ part = view;
}
}
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java 2011-10-13
13:32:15 UTC (rev 35620)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java 2011-10-13
14:51:37 UTC (rev 35621)
@@ -28,8 +28,6 @@
private static final String NOT_RUNNING_MESSAGE = "Forge is not running.";
private static final String STARTING_MESSAGE = "Please wait while Forge is
starting";
- public static ForgeView INSTANCE;
-
private class ForgePage extends Page {
private ForgeTextViewer viewer;
@@ -65,12 +63,12 @@
private ForgeRuntime runtime;
- public ForgeView() {
- if (INSTANCE == null) {
- INSTANCE = this;
- }
- }
-
+// public ForgeView() {
+// if (INSTANCE == null) {
+// INSTANCE = this;
+// }
+// }
+//
@Override
public void createPartControl(Composite parent) {
pageBook = new PageBook(parent, SWT.NONE);
@@ -130,7 +128,7 @@
private void handleStateNotRunning() {
if (runtime != null) {
- runtime.removePropertyChangeListener(INSTANCE);
+ runtime.removePropertyChangeListener(this);
runtime = null;
}
getDisplay().asyncExec(new Runnable() {
@@ -172,9 +170,8 @@
}
public void dispose() {
- if (runtime != null) {
- runtime.stop(null);
- runtime = null;
+ if (runtime != null && ForgeRuntime.STATE_RUNNING.equals(runtime.getState()))
{
+ stopForge();
}
super.dispose();
}
@@ -182,7 +179,7 @@
public void startForge() {
if (runtime != null) return;
runtime = ForgeRuntimesPreferences.INSTANCE.getDefault();
- runtime.addPropertyChangeListener(INSTANCE);
+ runtime.addPropertyChangeListener(this);
Job job = new Job("Starting Forge") {
@Override
protected IStatus run(IProgressMonitor monitor) {
@@ -221,6 +218,7 @@
if (runtime == null) return;
final IProgressMonitor progressMonitor =
getViewSite().getActionBars().getStatusLineManager().getProgressMonitor();
runtime.stop(progressMonitor);
+ runtime = null;
}
private Display getDisplay() {