Author: koen.aers(a)jboss.com
Date: 2011-11-21 12:17:07 -0500 (Mon, 21 Nov 2011)
New Revision: 36506
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/OpenPostProcessor.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/AllCommandsInterceptor.java
trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
Log:
JBIDE-10203: File opens in Editor
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/AllCommandsInterceptor.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/AllCommandsInterceptor.java 2011-11-21
17:01:28 UTC (rev 36505)
+++
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/AllCommandsInterceptor.java 2011-11-21
17:17:07 UTC (rev 36506)
@@ -21,6 +21,11 @@
str = project.getProjectRoot().getName();
}
sendEscaped("Intercepted Command: " + line + " Current Project
Directory: " + str);
+ if (line.startsWith("open ")) {
+ str = shell.getCurrentResource().getFullyQualifiedName();
+ sendEscaped("Execute Command: " + line + " Current Resource: " +
str);
+ return null;
+ }
return line;
}
Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF 2011-11-21 17:01:28
UTC (rev 36505)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/META-INF/MANIFEST.MF 2011-11-21 17:17:07
UTC (rev 36506)
@@ -15,7 +15,8 @@
org.eclipse.m2e.maven.runtime;bundle-version="[1.0,2.0)",
org.eclipse.jdt.core,
org.eclipse.ui.views,
- org.jboss.tools.forge.core;bundle-version="1.0.0"
+ org.jboss.tools.forge.core;bundle-version="1.0.0",
+ org.eclipse.core.filesystem;bundle-version="1.3.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.forge.ui.ForgeUIPlugin
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java 2011-11-21
17:01:28 UTC (rev 36505)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java 2011-11-21
17:17:07 UTC (rev 36506)
@@ -52,6 +52,15 @@
currentCommand = null;
}
+ public void executeCommand(final String line, final String resourcePath) {
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ new OpenPostProcessor().postProcess(line, resourcePath);
+ }
+ });
+ }
+
public void log(String str) {
if (currentCommand != null) {
buffer.append(str);
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java 2011-11-21
17:01:28 UTC (rev 36505)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java 2011-11-21
17:17:07 UTC (rev 36506)
@@ -186,6 +186,16 @@
commandProcessor.startCommand(str.substring(21));
} else if (str.startsWith("Executed Command: ")) {
commandProcessor.stopCurrentCommand();
+ } else if (str.startsWith("Execute Command: ")) {
+ str = str.substring(17);
+ int index = str.indexOf("Current Resource: ");
+ String line = "";
+ String resource = "";
+ if (index != -1) {
+ line = str.substring(0, index);
+ resource = str.substring(index + 18);
+ commandProcessor.executeCommand(line, resource);
+ }
} else if (str.startsWith("POM File Modified: ")) {
IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(str.substring(19));
if (project != null) {
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/OpenPostProcessor.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/OpenPostProcessor.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/OpenPostProcessor.java 2011-11-21
17:17:07 UTC (rev 36506)
@@ -0,0 +1,48 @@
+package org.jboss.tools.forge.ui.console;
+
+import java.io.File;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.forge.ui.ForgeUIPlugin;
+
+public class OpenPostProcessor {
+
+ public void postProcess(String line, String currentResourcePath) {
+ try {
+ String resourceToOpen = currentResourcePath + File.separator +
line.substring(5).trim();
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(resourceToOpen));
+ if (fileStore.fetchInfo().isDirectory()) {
+ expandDirectoryInExplorer(resourceToOpen);
+ } else {
+ openFileInEditor(fileStore);
+ }
+ IWorkbenchPage workbenchPage =
ForgeCommandPostProcessorHelper.getActiveWorkbenchPage();
+ if (workbenchPage != null) {
+ IDE.openEditorOnFileStore(workbenchPage, fileStore);
+ }
+ } catch (PartInitException e) {
+ ForgeUIPlugin.log(e);
+ }
+ }
+
+ private void openFileInEditor(IFileStore fileStore) {
+ try {
+ IWorkbenchPage workbenchPage =
ForgeCommandPostProcessorHelper.getActiveWorkbenchPage();
+ if (workbenchPage != null) {
+ IDE.openEditorOnFileStore(workbenchPage, fileStore);
+ }
+ } catch (PartInitException e) {
+ ForgeUIPlugin.log(e);
+ }
+ }
+
+ private void expandDirectoryInExplorer(String resourceToOpen) {
+
+ }
+
+}
Property changes on:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/OpenPostProcessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain