Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2011-02-25 16:59:55 +0000
committerRyan D. Brooks2011-02-25 16:59:55 +0000
commitb95a49e1a006cac894b18a4d38afb73ee7d30a4e (patch)
tree297dfc38d9e39b034637bd493551e5e3ebcae6e7 /plugins/org.eclipse.osee.framework.ui.skynet
parente9abd65d12a1f5d3f1ddbef26e15c7934d6aae3f (diff)
downloadorg.eclipse.osee-b95a49e1a006cac894b18a4d38afb73ee7d30a4e.tar.gz
org.eclipse.osee-b95a49e1a006cac894b18a4d38afb73ee7d30a4e.tar.xz
org.eclipse.osee-b95a49e1a006cac894b18a4d38afb73ee7d30a4e.zip
refactor: Allow composition of RenameFiles and ExportChangeReportOperation
Diffstat (limited to 'plugins/org.eclipse.osee.framework.ui.skynet')
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/RenameFiles.java41
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java9
3 files changed, 14 insertions, 37 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
index 8fbad8d72f3..7a371d7538c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF
@@ -57,6 +57,7 @@ Import-Package: com.lowagie.text;version="2.1.7",
org.eclipse.osee.framework.core.model.event,
org.eclipse.osee.framework.core.model.type,
org.eclipse.osee.framework.core.operation,
+ org.eclipse.osee.framework.core.ops,
org.eclipse.osee.framework.core.services,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.database,
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/RenameFiles.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/RenameFiles.java
index c4747d34480..a6290aa6e3d 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/RenameFiles.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/operation/RenameFiles.java
@@ -10,16 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.blam.operation;
-import java.io.File;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
-import java.util.regex.Pattern;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.jdk.core.text.Rule;
-import org.eclipse.osee.framework.jdk.core.text.change.ChangeSet;
-import org.eclipse.osee.framework.jdk.core.text.rules.ReplaceAll;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.core.ops.RenameFilesOperation;
import org.eclipse.osee.framework.ui.skynet.blam.AbstractBlam;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
@@ -27,36 +22,12 @@ import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
* @author Ryan D. Brooks
*/
public class RenameFiles extends AbstractBlam {
-
@Override
- public void runOperation(VariableMap variableMap, IProgressMonitor monitor) throws Exception {
- File parentFolder = new File(variableMap.getString("Parent Folder"));
+ public IOperation createOperation(VariableMap variableMap, OperationLogger logger) throws Exception {
+ String parentFolder = variableMap.getString("Parent Folder");
String pathPattern = variableMap.getString("Full Path Pattern");
String replacement = variableMap.getString("Replacement");
-
- Rule rule = new ReplaceAll(Pattern.compile(pathPattern), replacement);
- List<File> files = Lib.recursivelyListFiles(parentFolder.getCanonicalFile(), null);
- int size = files.size();
- int renamedFileCount = 0;
-
- for (int i = 0; i < size; i++) {
- if (monitor.isCanceled()) {
- return;
- }
- File file = files.get(i);
- rule.setRuleWasApplicable(false);
- ChangeSet newName = rule.computeChanges(file.getPath());
- if (rule.ruleWasApplicable()) {
- File newFile = new File(newName.toString());
- if (file.renameTo(newFile)) {
- report(file.getPath() + " became " + newFile.getPath());
- renamedFileCount++;
- } else {
- report(file.getPath() + " failed to become " + newFile.getPath());
- }
- }
- }
- report("Changed " + renamedFileCount + " files");
+ return new RenameFilesOperation(logger, parentFolder, pathPattern, replacement);
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java
index be98d6a51b3..80e9bc738ea 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RendererManager.java
@@ -214,6 +214,11 @@ public final class RendererManager {
Operations.executeAsJob(new DiffUsingRenderer(collector, artifactDelta, pathPrefix, options), true);
}
+ public static void diff(CompareDataCollector collector, Collection<ArtifactDelta> artifactDelta, String pathPrefix, Object... options) {
+ DiffUsingRenderer operation = new DiffUsingRenderer(collector, artifactDelta, pathPrefix, options);
+ Operations.executeWork(operation);
+ }
+
public static void diff(CompareDataCollector collector, ArtifactDelta artifactDelta, String pathPrefix, Object... options) {
DiffUsingRenderer operation = new DiffUsingRenderer(collector, artifactDelta, pathPrefix, options);
Operations.executeWork(operation);
@@ -225,9 +230,9 @@ public final class RendererManager {
Operations.executeAsJob(operation, true);
}
- public static void diff(Collection<ArtifactDelta> artifactDeltas, String diffPrefix, Object... options) {
+ public static void diff(Collection<ArtifactDelta> artifactDeltas, String pathPrefix, Object... options) {
CompareDataCollector collector = new NoOpCompareDataCollector();
- IOperation operation = new DiffUsingRenderer(collector, artifactDeltas, diffPrefix, options);
+ IOperation operation = new DiffUsingRenderer(collector, artifactDeltas, pathPrefix, options);
Operations.executeWork(operation);
}
} \ No newline at end of file

Back to the top