Index: plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/EventHandler.java =================================================================== --- plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/EventHandler.java (revision 41239) +++ plugins/org.jboss.tools.forge.runtime.ext/src/org/jboss/tools/forge/runtime/ext/EventHandler.java (working copy) @@ -1,8 +1,5 @@ package org.jboss.tools.forge.runtime.ext; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import javax.enterprise.event.Observes; import javax.inject.Inject; @@ -27,20 +24,7 @@ if (project != null) { projectName = project.getProjectRoot().getFullyQualifiedName(); } - String parameterString = ""; - try { - Method method = event.getClass().getMethod("getParameters", new Class[] {}); - Object object = method.invoke(event, new Object[] {}); - if (object instanceof Object[]) { - Object[] parameters = (Object[])object; - for (Object parameter : parameters) { - parameterString += parameter + " "; - } - } - } catch (NoSuchMethodException e) { - } catch (InvocationTargetException e) { - } catch (IllegalAccessException e) {} - + String parameterString = getParameterString(event); String command = event.getCommand().getParent().getName() + " " + event.getCommand().getName(); sendEscaped( " EC: " + command + @@ -50,6 +34,23 @@ " PAR: " + parameterString); } + private String getParameterString(CommandExecuted event) { + return flattenObjectArray(event.getParameters()); + } + + private String flattenObjectArray(Object[] objects) { + String result = ""; + for (Object object : objects) { + if (object instanceof Object[]) { + result += '[' + flattenObjectArray((Object[])object) + ']'; + } else { + result += object; + result += ' '; + } + } + return result.trim(); + } + private void sendEscaped(String str) { shell.print(ESCAPE + str + ESCAPE); } Index: plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java =================================================================== --- plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java (revision 41361) +++ plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java (working copy) @@ -1,48 +1,48 @@ package org.jboss.tools.forge.ui.console; +import java.io.File; +import java.util.ArrayList; import java.util.Map; +import java.util.StringTokenizer; -import org.eclipse.core.filesystem.EFS; -import org.eclipse.core.filesystem.IFileInfo; -import org.eclipse.core.filesystem.IFileStore; -import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.jboss.tools.forge.ui.ForgeUIPlugin; public class RmPostProcessor implements ForgeCommandPostProcessor { - private String getResourceToDelete(Map commandDetails) { - return commandDetails.get("crn"); + private ArrayList getResourcesToDelete(Map commandDetails) { + String crn = commandDetails.get("crn"); + String par = commandDetails.get("par"); + int start = par.lastIndexOf('['); + int end = par.lastIndexOf(']'); + if (start == -1 || end == -1) return null; + par = par.substring(start + 1, end); + ArrayList result = new ArrayList(); + StringTokenizer tokenizer = new StringTokenizer(par); + while (tokenizer.hasMoreTokens()) { + result.add(crn + File.separator + tokenizer.nextToken()); + } + return result; } @Override public void postProcess(Map commandDetails) { - String crn = getResourceToDelete(commandDetails); - if (crn == null) return; - IPath path = new Path(crn); - IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(crn)); - IFileInfo fileInfo = fileStore.fetchInfo(); - if (!fileInfo.exists()) return; - IResource resource = null; - if (fileInfo.isDirectory()) { - resource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path); - } else { - resource = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path); - } - if (resource != null) { - delete(resource); - } - } - - private void delete(IResource resource) { - try { - resource.delete(true, null); - } catch (CoreException e) { - ForgeUIPlugin.log(e); + ArrayList resourceNames = getResourcesToDelete(commandDetails); + if (resourceNames == null) return; + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + for (String resourceName : resourceNames) { + for (IProject project : projects) { + if (project.exists() && resourceName.equals(project.getLocation().toOSString())) { + try { + project.delete(true, true, null); + } catch (CoreException e) { + ForgeUIPlugin.log(e); + } + } + } } }