Author: koen.aers(a)jboss.com
Date: 2012-01-16 04:56:38 -0500 (Mon, 16 Jan 2012)
New Revision: 37855
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/SelectionSynchronizer.java
Log:
JBIDE-10359: show in Forge console does not offer to start forge
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 2012-01-16
09:46:22 UTC (rev 37854)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java 2012-01-16
09:56:38 UTC (rev 37855)
@@ -10,6 +10,7 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
@@ -267,11 +268,39 @@
return false;
}
if (runtime != null &&
ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
- return goToSelection(context.getSelection());
+ return goToSelection(context.getSelection());
+ } else {
+ return startForgeIsOK(context);
}
- return false;
}
+ private boolean startForgeIsOK(final ShowInContext context) {
+ boolean start = MessageDialog.open(
+ MessageDialog.QUESTION,
+ null,
+ "Forge Not Running",
+ "Forge is not running. Do you want to start the Forge runtime?",
+ SWT.NONE);
+ if (start) {
+ startForge();
+ Thread waitThread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ while (runtime != null &&
!ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ ForgeUIPlugin.log(e);
+ }
+ }
+ goToSelection(context.getSelection());
+ }
+ });
+ waitThread.start();
+ }
+ return start;
+ }
+
public boolean goToSelection(ISelection sel) {
if (sel instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection)sel;
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/SelectionSynchronizer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/SelectionSynchronizer.java 2012-01-16
09:46:22 UTC (rev 37854)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/SelectionSynchronizer.java 2012-01-16
09:56:38 UTC (rev 37855)
@@ -8,7 +8,6 @@
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IPartService;
import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.jboss.tools.forge.core.process.ForgeRuntime;
@@ -17,29 +16,19 @@
public class SelectionSynchronizer implements ISelectionListener {
private ForgeView forgeView;
- private ISelectionService selectionService;
private IEditorPart selectedPart;
private IPartService partService;
private IPartListener partListener = new IPartListener() {
@Override
- public void partOpened(IWorkbenchPart part) {
- // TODO Auto-generated method stub
-
- }
+ public void partOpened(IWorkbenchPart part) {}
@Override
- public void partDeactivated(IWorkbenchPart part) {
- // TODO Auto-generated method stub
-
- }
+ public void partDeactivated(IWorkbenchPart part) {}
@Override
- public void partClosed(IWorkbenchPart part) {
- // TODO Auto-generated method stub
-
- }
+ public void partClosed(IWorkbenchPart part) {}
@Override
public void partBroughtToTop(IWorkbenchPart part) {
@@ -69,17 +58,13 @@
public SelectionSynchronizer(ForgeView forgeView) {
this.forgeView = forgeView;
IWorkbenchWindow workbenchWindow = forgeView.getSite().getWorkbenchWindow();
- selectionService =
- forgeView.getSite().getWorkbenchWindow().getSelectionService();
partService = workbenchWindow.getPartService();
}
public void setEnabled(boolean enabled) {
if (enabled) {
-// selectionService.addSelectionListener(this);
partService.addPartListener(partListener);
} else {
-// selectionService.removeSelectionListener(this);
partService.removePartListener(partListener);
}
}
Show replies by date