Author: koen.aers(a)jboss.com
Date: 2011-04-29 16:29:40 -0400 (Fri, 29 Apr 2011)
New Revision: 30979
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsolePage.java
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleView.java
Log:
- support for "entity" command
- maintain the focus in the forge console after the commands
Modified: trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF 2011-04-29
19:04:47 UTC (rev 30978)
+++ trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF 2011-04-29
20:29:40 UTC (rev 30979)
@@ -12,7 +12,8 @@
org.eclipse.ui.editors,
org.eclipse.ui.ide,
org.eclipse.m2e.core;bundle-version="0.13.0",
- org.eclipse.m2e.maven.runtime;bundle-version="0.13.0"
+ org.eclipse.m2e.maven.runtime;bundle-version="0.13.0",
+ org.eclipse.jdt.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.seam.forge.ForgePlugin
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java 2011-04-29
19:04:47 UTC (rev 30978)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java 2011-04-29
20:29:40 UTC (rev 30979)
@@ -5,6 +5,10 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -15,6 +19,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;
+import org.jboss.tools.seam.forge.ForgePlugin;
import org.jboss.tools.seam.forge.importer.ProjectImporter;
public class CommandRecorder implements IDocumentListener {
@@ -73,12 +78,23 @@
return "new-project";
} else if ("persistence".equals(candidateCommand)) {
return "persistence";
+ } else if ("entity".equals(candidateCommand)) {
+ return "entity";
} else {
return null;
}
}
private void postProcessCurrentCommand() {
+ IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
+ String projectName = currentPrompt.substring(1, currentPrompt.indexOf(']'));
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ try {
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (CoreException e) {
+ ForgePlugin.log(e);
+ }
if ("pwd".equals(currentCommand)) {
// do nothing
} else if ("new-project".equals(currentCommand)) {
@@ -100,30 +116,73 @@
} else if ("persistence".equals(currentCommand)) {
int index = beforePrompt.lastIndexOf("***SUCCESS*** Installed [forge.spec.jpa]
successfully.\nWrote ");
if (index == -1) return;
- String projectName = currentPrompt.substring(1, currentPrompt.indexOf(']'));
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+// String projectName = currentPrompt.substring(1,
currentPrompt.indexOf(']'));
+// IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+// try {
+// project.refreshLocal(IResource.DEPTH_INFINITE, null);
+// } catch (CoreException e) {
+// ForgePlugin.log(e);
+// }
try {
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- } catch (CoreException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ IFile file =
project.getFile("/src/main/resources/META-INF/persistence.xml");
+ if (file == null) return;
+ Object objectToSelect = file;
+ IDE.openEditor(workbenchPage, file);
+ IViewPart packageExplorer =
workbenchPage.showView("org.eclipse.jdt.ui.PackageExplorer");
+ if (packageExplorer instanceof ISetSelectionTarget) {
+ ((ISetSelectionTarget)packageExplorer).selectReveal(new
StructuredSelection(objectToSelect));
+ }
+ IViewPart outlineViewer =
workbenchPage.showView("org.eclipse.ui.views.ContentOutline");
+ if (outlineViewer instanceof ISetSelectionTarget) {
+ ((ISetSelectionTarget)outlineViewer).selectReveal(new
StructuredSelection(objectToSelect));
+ }
+ } catch (PartInitException e) {
+ ForgePlugin.log(e);
}
+ } else if ("entity".equals(currentCommand)) {
+ int index = beforePrompt.lastIndexOf("Picked up type <JavaResource>:
");
+ if (index == -1) return;
+// String projectName = currentPrompt.substring(1,
currentPrompt.indexOf(']'));
+// IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (index + 31 > beforePrompt.length() -1) return;
+ String entityName = beforePrompt.substring(index + 31, beforePrompt.length() -
1).replace('.', '/');
+// try {
+// project.refreshLocal(IResource.DEPTH_INFINITE, null);
+// } catch (CoreException e) {
+// ForgePlugin.log(e);
+// }
try {
- IWorkbenchWindow workbenchWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
- IFile file =
project.getFile("/src/main/resources/META-INF/persistence.xml");
+ IFile file = project.getFile("/src/main/java/" + entityName +
".java");
+ if (file == null) return;
+ Object objectToSelect = file;
IDE.openEditor(workbenchPage, file);
+ IJavaElement javaElement = JavaCore.create(file);
+ if (javaElement != null && javaElement.getElementType() ==
IJavaElement.COMPILATION_UNIT) {
+ try {
+ objectToSelect = ((ICompilationUnit)javaElement).getTypes()[0];
+ } catch (JavaModelException e) {
+ ForgePlugin.log(e);
+ }
+ }
IViewPart packageExplorer =
workbenchPage.showView("org.eclipse.jdt.ui.PackageExplorer");
if (packageExplorer instanceof ISetSelectionTarget) {
- ((ISetSelectionTarget)packageExplorer).selectReveal(new StructuredSelection(file));
+ ((ISetSelectionTarget)packageExplorer).selectReveal(new
StructuredSelection(objectToSelect));
}
+ IViewPart outlineViewer =
workbenchPage.showView("org.eclipse.ui.views.ContentOutline");
+ if (outlineViewer instanceof ISetSelectionTarget) {
+ ((ISetSelectionTarget)outlineViewer).selectReveal(new
StructuredSelection(objectToSelect));
+ }
} catch (PartInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ ForgePlugin.log(e);
}
} else {
}
+ try {
+ workbenchPage.showView("org.jboss.tools.seam.forge.console").setFocus();
+ } catch (PartInitException e) {
+ ForgePlugin.log(e);
+ }
}
}
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsolePage.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsolePage.java 2011-04-29
19:04:47 UTC (rev 30978)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsolePage.java 2011-04-29
20:29:40 UTC (rev 30979)
@@ -26,6 +26,7 @@
@Override
public void setFocus() {
+ viewer.getControl().setFocus();
}
public Console getConsole() {
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleView.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleView.java 2011-04-29
19:04:47 UTC (rev 30978)
+++
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/view/ConsoleView.java 2011-04-29
20:29:40 UTC (rev 30979)
@@ -67,7 +67,11 @@
}
@Override
- public void setFocus() {}
+ public void setFocus() {
+ if (ForgeRuntime.STATE_RUNNING.equals(ForgeRuntime.INSTANCE.getRuntimeState())) {
+ forgeIsRunningPage.setFocus();
+ }
+ }
@Override
public void propertyChange(PropertyChangeEvent evt) {