Author: koen.aers(a)jboss.com
Date: 2012-05-24 12:27:34 -0400 (Thu, 24 May 2012)
New Revision: 41361
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java
Modified:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java
Log:
JBIDE-11124: Removing project via forge is not working properly
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 2012-05-24
16:21:42 UTC (rev 41360)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeCommandProcessor.java 2012-05-24
16:27:34 UTC (rev 41361)
@@ -29,6 +29,7 @@
POST_PROCESSORS.put("open", new OpenPostProcessor());
POST_PROCESSORS.put("field", new FieldPostProcessor());
POST_PROCESSORS.put("cd", new CdPostProcessor());
+ POST_PROCESSORS.put("rm", new RmPostProcessor());
}
return POST_PROCESSORS;
}
Added:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java
(rev 0)
+++
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java 2012-05-24
16:27:34 UTC (rev 41361)
@@ -0,0 +1,49 @@
+package org.jboss.tools.forge.ui.console;
+
+import java.util.Map;
+
+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.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<String, String> commandDetails) {
+ return commandDetails.get("crn");
+ }
+
+ @Override
+ public void postProcess(Map<String, String> 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);
+ }
+ }
+
+}
Property changes on:
trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/RmPostProcessor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Show replies by date