Author: koen.aers(a)jboss.com
Date: 2012-01-13 06:07:05 -0500 (Fri, 13 Jan 2012)
New Revision: 37819
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/icons/goto_obj.gif
trunk/forge/plugins/org.jboss.tools.forge.ui/icons/redo_edit.gif
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/commands/GoToHandler.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java
Log:
JBIDE-10270: Bring back the 'Show in Forge' functionality
Added: trunk/forge/plugins/org.jboss.tools.forge.ui/icons/goto_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/forge/plugins/org.jboss.tools.forge.ui/icons/goto_obj.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/forge/plugins/org.jboss.tools.forge.ui/icons/redo_edit.gif
===================================================================
(Binary files differ)
Property changes on: trunk/forge/plugins/org.jboss.tools.forge.ui/icons/redo_edit.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml 2012-01-13 09:54:00 UTC (rev
37818)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml 2012-01-13 11:07:05 UTC (rev
37819)
@@ -46,9 +46,14 @@
name="Stop Forge"/>
<command
categoryId="org.jboss.tools.forge.ui"
- description="Link the currently selected item to the running Forge
runtime"
+ description="Link the editor currently on top to the running Forge
runtime"
id="org.jboss.tools.forge.ui.link"
- name="Link To Selection"/>
+ name="Link with Editor"/>
+ <command
+ categoryId="org.jboss.tools.forge.ui"
+ description="Instruct the running Forge runtime to go to the current
selection"
+ id="org.jboss.tools.forge.ui.goto"
+ name="Go To Selection"/>
<command
categoryId="org.eclipse.ui.category.window"
defaultHandler="org.jboss.tools.forge.ui.commands.ForgeCommandListHandler"
@@ -77,12 +82,20 @@
tooltip="Stop the running Forge runtime">
</command>
<command
+ commandId="org.jboss.tools.forge.ui.goto"
+ icon="icons/goto_obj.gif"
+ label="Go to Selection"
+ mnemonic="G"
+ style="push"
+ tooltip="Go to Selection">
+ </command>
+ <command
commandId="org.jboss.tools.forge.ui.link"
icon="icons/link.gif"
- label="Link To Forge"
+ label="Link with Editor"
mnemonic="L"
style="toggle"
- tooltip="Link the current selection to Forge">
+ tooltip="Link with Editor">
</command>
</menuContribution>
</extension>
@@ -138,6 +151,18 @@
</enabledWhen>
</handler>
<handler
+ class="org.jboss.tools.forge.ui.commands.GoToHandler"
+ commandId="org.jboss.tools.forge.ui.goto">
+ <enabledWhen>
+ <with
+ variable="org.jboss.tools.forge.runtime.state">
+ <equals
+ value="org.jboss.tools.forge.runtime.running">
+ </equals>
+ </with>
+ </enabledWhen>
+ </handler>
+ <handler
class="org.jboss.tools.forge.ui.commands.LinkHandler"
commandId="org.jboss.tools.forge.ui.link">
<enabledWhen>
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/commands/GoToHandler.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/commands/GoToHandler.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/commands/GoToHandler.java 2012-01-13
11:07:05 UTC (rev 37819)
@@ -0,0 +1,18 @@
+package org.jboss.tools.forge.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.jboss.tools.forge.ui.part.ForgeView;
+import org.jboss.tools.forge.ui.util.ForgeHelper;
+
+public class GoToHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent executionEvent) {
+ ForgeView forgeView = ForgeHelper.getForgeView();
+ if (forgeView != null) {
+ forgeView.goToSelection(forgeView.getSelection());
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/commands/GoToHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-13
09:54:00 UTC (rev 37818)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java 2012-01-13
11:07:05 UTC (rev 37819)
@@ -4,7 +4,6 @@
import java.beans.PropertyChangeListener;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -13,10 +12,13 @@
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.Page;
@@ -72,7 +74,7 @@
private String notRunningMessage;
private ForgeRuntime runtime;
-// private ISelection selection;
+ private ISelection selection;
private SelectionSynchronizer synchronizer;
@Override
@@ -81,17 +83,17 @@
pageBook = new PageBook(parent, SWT.NONE);
createNotRunningPage(parent);
showPage(notRunning);
-// getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(new
ISelectionListener() {
-// @Override
-// public void selectionChanged(IWorkbenchPart part, ISelection newSelection) {
-// selection = newSelection;
-// }
-// });
+ getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(new
ISelectionListener() {
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection newSelection) {
+ selection = newSelection;
+ }
+ });
}
-// public ISelection getSelection() {
-// return selection;
-// }
+ public ISelection getSelection() {
+ return selection;
+ }
public void setSynchronized(boolean synced) {
synchronizer.setEnabled(synced);
@@ -265,25 +267,38 @@
return false;
}
if (runtime != null &&
ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
- ISelection sel = context.getSelection();
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection)sel;
- Object first = ss.getFirstElement();
- if (first instanceof IResource) {
- IPath path = ((IResource)first).getLocation();
- runtime.sendInput("pick-up " + path + "\n");
- } else if (first instanceof IJavaElement) {
- try {
- IPath path = ((IJavaElement)first).getCorrespondingResource().getLocation();
- runtime.sendInput("pick-up " + path + "\n");
- } catch (JavaModelException e) {
- ForgeUIPlugin.log(e);
- }
- }
- return true;
- }
+ return goToSelection(context.getSelection());
}
return false;
}
+ public boolean goToSelection(ISelection sel) {
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)sel;
+ Object first = ss.getFirstElement();
+ if (first instanceof IResource) {
+ goToPath(((IResource)first).getLocation().toOSString());
+ } else if (first instanceof IJavaElement) {
+ try {
+ goToPath(((IJavaElement)first).getCorrespondingResource().getLocation().toOSString());
+ } catch (JavaModelException e) {
+ ForgeUIPlugin.log(e);
+ return false;
+ }
+ } else if (first instanceof IRemoteFile) {
+ goToPath(((IRemoteFile)first).getAbsolutePath());
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private void goToPath(String str) {
+ if (str.indexOf(' ') != -1) {
+ str = '\"' + str + '\"';
+ }
+ runtime.sendInput("pick-up " + str + "\n");
+ }
+
}
\ No newline at end of file