Author: koen.aers(a)jboss.com
Date: 2011-11-09 14:41:22 -0500 (Wed, 09 Nov 2011)
New Revision: 36252
Added:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/PomFileModifiedHandler.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/importer/ProjectConfigurationUpdater.java
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
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/PrettyFacesPostProcessor.java
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java
Log:
JBIDE-10036:
- Run 'Update Project Configuration' whenever the pom.xml changes
- Refresh workspace after each Forge command
Modified: trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF 2011-11-09
17:23:47 UTC (rev 36251)
+++ trunk/forge/plugins/org.jboss.tools.forge.runtime/META-INF/MANIFEST.MF 2011-11-09
19:41:22 UTC (rev 36252)
@@ -11,6 +11,7 @@
javax.inject,
org.jboss.forge.project,
org.jboss.forge.resources,
+ org.jboss.forge.resources.events,
org.jboss.forge.shell,
org.jboss.forge.shell.command,
org.jboss.forge.shell.events,
Added:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/PomFileModifiedHandler.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/PomFileModifiedHandler.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/PomFileModifiedHandler.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -0,0 +1,26 @@
+package org.jboss.tools.forge.runtime.ext;
+
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.jboss.forge.resources.events.ResourceEvent;
+import org.jboss.forge.shell.Shell;
+
+public class PomFileModifiedHandler {
+
+ private static final String ESCAPE = new String(new char[] { 27, '%'} );
+
+ @Inject
+ private Shell shell;
+
+ public void handleResourceChanged(@Observes ResourceEvent event) {
+ if (event.getResource() != null &&
"pom.xml".equals(event.getResource().getName())) {
+ sendEscaped("POM File Modified: " +
event.getResource().getParent().getName());
+ }
+ }
+
+ private void sendEscaped(String str) {
+ shell.print(ESCAPE + str + ESCAPE);
+ }
+
+}
Property changes on:
trunk/forge/plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/PomFileModifiedHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/importer/ProjectConfigurationUpdater.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/importer/ProjectConfigurationUpdater.java 2011-11-09
17:23:47 UTC (rev 36251)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/importer/ProjectConfigurationUpdater.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -11,14 +11,8 @@
public class ProjectConfigurationUpdater {
- private IProject project;
-
- public ProjectConfigurationUpdater(IProject project) {
- this.project = project;
- }
-
- public void updateProject() {
- Job job = new WorkspaceJob("Importing Forge project") {
+ public static void updateProject(final IProject project) {
+ Job job = new WorkspaceJob("Updating project configuration") {
public IStatus runInWorkspace(IProgressMonitor monitor) {
try {
MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(
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-09
17:23:47 UTC (rev 36251)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -40,7 +40,14 @@
public void stopCurrentCommand() {
if (currentCommand != null) {
- postProcessCommand(currentCommand, buffer.toString());
+ final String command = currentCommand;
+ final String output = buffer.toString();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ postProcessCurrentCommand(command, output);
+ }
+ });
}
currentCommand = null;
}
@@ -51,25 +58,21 @@
}
}
- private void postProcessCommand(final String command, final String output) {
- String mainCommand = command;
+ private void postProcessCurrentCommand(String currentCommand, String output) {
+ if (currentCommand == null) return;
+ String mainCommand = currentCommand;
int i = mainCommand.indexOf(' ');
if (i != -1) {
- mainCommand = command.substring(0, i);
+ mainCommand = currentCommand.substring(0, i);
}
- final ForgeCommandPostProcessor postProcessor = getPostProcessors().get(mainCommand);
+ refreshWorkspace();
+ ForgeCommandPostProcessor postProcessor = getPostProcessors().get(mainCommand);
if (postProcessor != null) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- refreshWorkspace();
- postProcessor.postProcessCommand(command, output);
- showForgeConsole();
- }
- });
+ postProcessor.postProcessCommand(mainCommand, output);
}
+ showForgeConsole();
}
-
+
private void refreshWorkspace() {
try {
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE,
null);
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-09
17:23:47 UTC (rev 36251)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -3,6 +3,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
@@ -22,6 +24,7 @@
import org.jboss.tools.forge.core.io.ForgeHiddenOutputFilter;
import org.jboss.tools.forge.core.io.ForgeOutputListener;
import org.jboss.tools.forge.core.process.ForgeRuntime;
+import org.jboss.tools.forge.importer.ProjectConfigurationUpdater;
import org.jboss.tools.forge.ui.ForgeUIPlugin;
public class ForgeTextViewer extends TextViewer {
@@ -185,6 +188,11 @@
commandProcessor.stopCurrentCommand();
// } else {
// System.out.println("unhandled hidden output: " + str);
+ } else if (str.startsWith("POM File Modified: ")) {
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(str.substring(19));
+ if (project != null) {
+ ProjectConfigurationUpdater.updateProject(project);
+ }
}
}
};
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/PrettyFacesPostProcessor.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/PrettyFacesPostProcessor.java 2011-11-09
17:23:47 UTC (rev 36251)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/PrettyFacesPostProcessor.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -8,7 +8,6 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;
-import org.jboss.tools.forge.importer.ProjectConfigurationUpdater;
import org.jboss.tools.forge.ui.ForgeUIPlugin;
public class PrettyFacesPostProcessor implements ForgeCommandPostProcessor {
@@ -30,7 +29,7 @@
IFile file = project.getFile(str);
if (file == null) return;
Object objectToSelect = file;
- new ProjectConfigurationUpdater(project).updateProject();
+// ProjectConfigurationUpdater.updateProject(project);
try {
IWorkbenchPage workbenchPage =
ForgeCommandPostProcessorHelper.getActiveWorkbenchPage();
IDE.openEditor(workbenchPage, file);
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-11-09
17:23:47 UTC (rev 36251)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/part/ForgeView.java 2011-11-09
19:41:22 UTC (rev 36252)
@@ -191,7 +191,7 @@
Thread waitThread = new Thread(new Runnable() {
@Override
public void run() {
- while (!ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
+ while (runtime != null &&
!ForgeRuntime.STATE_RUNNING.equals(runtime.getState())) {
try {
Thread.sleep(1000);
updateNonRunningPage();
Show replies by date