Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2011-01-21 21:49:58 +0000
committerRyan D. Brooks2011-01-21 21:49:58 +0000
commitec1afcdb8a9cfff9b73e89b4899a1f784c8dcb30 (patch)
treefbc1d09ef17fa313f4c6d02adbf51d5ffe6b4ac6
parent61b759dc7f72a3ee1ba8f197b366536d8dc9e1f4 (diff)
downloadorg.eclipse.osee-ec1afcdb8a9cfff9b73e89b4899a1f784c8dcb30.tar.gz
org.eclipse.osee-ec1afcdb8a9cfff9b73e89b4899a1f784c8dcb30.tar.xz
org.eclipse.osee-ec1afcdb8a9cfff9b73e89b4899a1f784c8dcb30.zip
refactor: Remove redundant word compare logic by utilizing AbstractWordCompare
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RenderingUtil.java35
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java107
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WholeWordCompare.java43
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordChangeReportOperation.java147
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordTemplateCompare.java76
5 files changed, 115 insertions, 293 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RenderingUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RenderingUtil.java
index a311509132e..632801258a9 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RenderingUtil.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/RenderingUtil.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.framework.ui.skynet.render;
import java.net.URLEncoder;
import java.util.Date;
+import java.util.List;
import java.util.Random;
import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
@@ -88,24 +89,6 @@ public final class RenderingUtil {
Artifact artFile1;
Artifact artFile2;
- // if (delta.getTxDelta() == null
- // || !delta.getTxDelta().areOnTheSameBranch()) {
- // // Assumptions - when comparing data between transactions on
- // // different branches, the start artifact will never be null;
- // if (delta.getStartArtifact().getModType().isDeleted()) {
- // artFile1 = delta.getStartArtifact();
- // artFile2 = null;
- // } else if (delta.getEndArtifact() == null) {
- // artFile1 = null;
- // artFile2 = delta.getStartArtifact();
- // } else { // case where there are new, modified, or deleted attributes (are artifact is not new or deleted)
- // // also could be introduced in both branches
- // artFile1 = delta.getEndArtifact();
- // artFile2 = delta.getStartArtifact();
- // }
- // } else {
- // Assumptions - when comparing data between transactions on the
- // same branch, the end artifact will never be null;
if (artifactDelta.getEndArtifact().getModType().isDeleted()) {
artFile1 = artifactDelta.getStartArtifact();
artFile2 = null;
@@ -116,10 +99,24 @@ public final class RenderingUtil {
artFile1 = artifactDelta.getStartArtifact();
artFile2 = artifactDelta.getEndArtifact();
}
- // }
return new Pair<Artifact, Artifact>(artFile1, artFile2);
}
+ public static IFile getRenderFile(FileSystemRenderer renderer, List<Artifact> artifacts, IOseeBranch branch, PresentationType presentationType) throws OseeCoreException {
+ Artifact aritfact = artifacts.isEmpty() ? null : artifacts.get(0);
+ String fileName = getFilenameFromArtifact(renderer, aritfact, presentationType);
+ return getRenderFile(fileName, branch, presentationType);
+ }
+
+ public static IFile getRenderFile(String fileName, IOseeBranch branch, PresentationType presentationType) throws OseeCoreException {
+ IFolder baseFolder = getRenderFolder(branch, presentationType);
+ return baseFolder.getFile(fileName);
+ }
+
+ public static String getRenderPath(String fileName, IOseeBranch branch, PresentationType presentationType) throws OseeCoreException {
+ return getRenderFile(fileName, branch, presentationType).getLocation().toOSString();
+ }
+
public static String getFilenameFromArtifact(FileSystemRenderer renderer, Artifact artifact, PresentationType presentationType) throws OseeCoreException {
String fileName = renderer.getStringOption(IRenderer.FILE_NAME_OPTION);
if (Strings.isValid(fileName)) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java
index 7ffc7b04cea..bc0e18d4464 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java
@@ -10,18 +10,26 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.render.compare;
+import java.util.Collections;
import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.UserManager;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
+import org.eclipse.osee.framework.ui.skynet.preferences.MsWordPreferencePage;
import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
import org.eclipse.osee.framework.ui.skynet.render.IRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil;
+import org.eclipse.osee.framework.ui.skynet.render.WordImageChecker;
import org.eclipse.osee.framework.ui.skynet.util.IVbaDiffGenerator;
import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
@@ -30,9 +38,13 @@ import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
*/
public abstract class AbstractWordCompare implements IComparator {
private final FileSystemRenderer renderer;
+ private final ArtifactDeltaToFileConverter converter;
+ private final IAttributeType wordAttributeType;
- public AbstractWordCompare(FileSystemRenderer renderer) {
+ public AbstractWordCompare(FileSystemRenderer renderer, IAttributeType wordAttributeType) {
this.renderer = renderer;
+ this.wordAttributeType = wordAttributeType;
+ converter = new ArtifactDeltaToFileConverter(renderer);
}
protected FileSystemRenderer getRenderer() {
@@ -40,54 +52,73 @@ public abstract class AbstractWordCompare implements IComparator {
}
protected abstract PresentationType getMergePresentationType();
-
- private String getComparePath(Artifact baseVersion, Artifact newerVersion, IFile baseFile, IFile newerFile) throws OseeCoreException {
- String diffPath;
- String fileName = renderer.getStringOption(IRenderer.FILE_NAME_OPTION);
- if (!Strings.isValid(fileName)) {
- if (baseVersion != null) {
- String baseFileStr = baseFile.getLocation().toOSString();
- diffPath =
- baseFileStr.substring(0, baseFileStr.lastIndexOf(')') + 1) + " to " + (newerVersion != null ? newerVersion.getTransactionNumber() : " deleted") + baseFileStr.substring(baseFileStr.lastIndexOf(')') + 1);
- } else {
- String baseFileStr = newerFile.getLocation().toOSString();
- diffPath =
- baseFileStr.substring(0, baseFileStr.lastIndexOf('(') + 1) + "new " + baseFileStr.substring(baseFileStr.lastIndexOf('(') + 1);
- }
- } else {
- PresentationType mergePresentation = getMergePresentationType();
- IFolder folder = RenderingUtil.getRenderFolder(baseVersion.getBranch(), mergePresentation);
- diffPath = folder.getLocation().toOSString() + '\\' + fileName;
- }
+ @Override
+ public String compare(IProgressMonitor monitor, PresentationType presentationType, ArtifactDelta artifactDelta) throws OseeCoreException {
+ boolean show = !getRenderer().getBooleanOption(IRenderer.NO_DISPLAY);
+ IVbaDiffGenerator diffGenerator = WordUiUtil.createScriptGenerator();
+ diffGenerator.initialize(show, presentationType == PresentationType.MERGE);
+ String diffPath = addTocompare(monitor, diffGenerator, presentationType, artifactDelta);
+ finish(diffGenerator, artifactDelta.getStartArtifact().getBranch(), presentationType);
return diffPath;
}
@Override
public String compare(Artifact baseVersion, Artifact newerVersion, IFile baseFile, IFile newerFile, PresentationType presentationType) throws OseeCoreException {
- String diffPath = getComparePath(baseVersion, newerVersion, baseFile, newerFile);
-
+ boolean show = !renderer.getBooleanOption(IRenderer.NO_DISPLAY);
IVbaDiffGenerator diffGenerator = WordUiUtil.createScriptGenerator();
- diffGenerator.initialize(presentationType == PresentationType.DIFF,
- presentationType == PresentationType.MERGE_EDIT);
+ diffGenerator.initialize(show, presentationType == PresentationType.MERGE);
+ String diffPath = addTocompare(diffGenerator, baseVersion, newerVersion, baseFile, newerFile, presentationType);
+ finish(diffGenerator, baseVersion.getBranch(), presentationType);
+ return diffPath;
+ }
- if (presentationType == PresentationType.MERGE_EDIT && baseVersion != null) {
- diffGenerator.addComparison(baseFile, newerFile, diffPath, true);
- launchCompareVbs(diffGenerator, diffPath, "mergeDocs.vbs");
- } else {
- diffGenerator.addComparison(baseFile, newerFile, diffPath, false);
- launchCompareVbs(diffGenerator, diffPath, "/compareDocs.vbs");
- }
+ protected String addTocompare(IVbaDiffGenerator diffGenerator, Artifact baseVersion, Artifact newerVersion, IFile baseFile, IFile newerFile, PresentationType presentationType) throws OseeCoreException {
+ String diffPath =
+ RenderingUtil.getRenderFile(renderer, Collections.singletonList(baseVersion), baseVersion.getBranch(),
+ presentationType).getLocation().toOSString();
+
+ diffGenerator.addComparison(baseFile, newerFile, diffPath, presentationType == PresentationType.MERGE);
return diffPath;
}
- private void launchCompareVbs(IVbaDiffGenerator diffGenerator, String diffPath, String vbsScriptName) throws OseeCoreException {
+ protected String addTocompare(IProgressMonitor monitor, IVbaDiffGenerator diffGenerator, PresentationType presentationType, ArtifactDelta artifactDelta) throws OseeCoreException {
+ Pair<String, Boolean> originalValue = null;
+
+ Artifact baseArtifact = artifactDelta.getStartArtifact();
+ Artifact newerArtifact = artifactDelta.getEndArtifact();
+
+ Attribute<String> baseContent = getWordContent(baseArtifact, wordAttributeType);
+ Attribute<String> newerContent = getWordContent(newerArtifact, wordAttributeType);
+
+ if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
+ originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
+ }
+
+ Pair<IFile, IFile> compareFiles = converter.convertToFile(presentationType, artifactDelta);
+
+ WordImageChecker.restoreOriginalValue(baseContent, originalValue);
+
+ monitor.setTaskName("Adding to Diff Script: " + (newerArtifact == null ? baseArtifact.getName() : newerArtifact.getName()));
+
+ return addTocompare(diffGenerator, baseArtifact, newerArtifact, compareFiles.getFirst(),
+ compareFiles.getSecond(), presentationType);
+ }
+
+ private Attribute<String> getWordContent(Artifact artifact, IAttributeType attributeType) throws OseeCoreException {
+ Attribute<String> toReturn = null;
+ if (artifact != null && !artifact.isDeleted()) {
+ toReturn = artifact.getSoleAttribute(attributeType);
+ }
+ return toReturn;
+ }
+
+ protected void finish(IVbaDiffGenerator diffGenerator, IOseeBranch branch, PresentationType presentationType) throws OseeCoreException {
boolean show = !renderer.getBooleanOption(IRenderer.NO_DISPLAY);
- String vbsPath = diffPath.substring(0, diffPath.lastIndexOf('\\')) + vbsScriptName;
+ String vbsPath = RenderingUtil.getRenderPath("compareDocs.vbs", branch, presentationType);
if (RenderingUtil.arePopupsAllowed()) {
diffGenerator.finish(vbsPath, show);
} else {
- OseeLog.log(SkynetGuiPlugin.class, Level.INFO,
- String.format("Test - Skip launch of [%s] for [%s]", vbsScriptName, vbsPath));
+ OseeLog.log(SkynetGuiPlugin.class, Level.INFO, String.format("Test - Skip launch of [%s]", vbsPath));
}
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WholeWordCompare.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WholeWordCompare.java
index 14418c49e19..995a40b49d4 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WholeWordCompare.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WholeWordCompare.java
@@ -11,26 +11,16 @@
package org.eclipse.osee.framework.ui.skynet.render.compare;
import java.util.Collection;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.skynet.core.UserManager;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
-import org.eclipse.osee.framework.ui.skynet.preferences.MsWordPreferencePage;
import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
-import org.eclipse.osee.framework.ui.skynet.render.WordImageChecker;
public class WholeWordCompare extends AbstractWordCompare {
- private static final IAttributeType ATTRIBUTE_TYPE = CoreAttributeTypes.WholeWordContent;
-
public WholeWordCompare(FileSystemRenderer renderer) {
- super(renderer);
+ super(renderer, CoreAttributeTypes.WholeWordContent);
}
@Override
@@ -39,40 +29,9 @@ public class WholeWordCompare extends AbstractWordCompare {
}
@Override
- public String compare(IProgressMonitor monitor, PresentationType presentationType, ArtifactDelta artifactDelta) throws OseeCoreException {
- Pair<String, Boolean> originalValue = null;
- Pair<String, Boolean> newAnnotationValue = null;
-
- Artifact baseArtifact = artifactDelta.getStartArtifact();
- Artifact newerArtifact = artifactDelta.getEndArtifact();
-
- Attribute<String> baseContent = getWordContent(baseArtifact, ATTRIBUTE_TYPE);
- Attribute<String> newerContent = getWordContent(newerArtifact, ATTRIBUTE_TYPE);
-
- if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
- originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
- }
-
- ArtifactDeltaToFileConverter converter = new ArtifactDeltaToFileConverter(getRenderer());
- Pair<IFile, IFile> compareFiles = converter.convertToFile(presentationType, artifactDelta);
-
- WordImageChecker.restoreOriginalValue(baseContent, originalValue);
- WordImageChecker.restoreOriginalValue(newerContent, newAnnotationValue);
- return compare(baseArtifact, newerArtifact, compareFiles.getFirst(), compareFiles.getSecond(), presentationType);
- }
-
- @Override
public void compareArtifacts(IProgressMonitor monitor, PresentationType presentationType, Collection<ArtifactDelta> artifactDeltas) throws OseeCoreException {
for (ArtifactDelta entry : artifactDeltas) {
compare(monitor, presentationType, entry);
}
}
-
- private Attribute<String> getWordContent(Artifact artifact, IAttributeType attributeType) throws OseeCoreException {
- Attribute<String> toReturn = null;
- if (artifact != null && !artifact.isDeleted()) {
- toReturn = artifact.getSoleAttribute(attributeType);
- }
- return toReturn;
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordChangeReportOperation.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordChangeReportOperation.java
deleted file mode 100644
index da0aa47ee33..00000000000
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordChangeReportOperation.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.ui.skynet.render.compare;
-
-import java.util.Collection;
-import java.util.logging.Level;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLevel;
-import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.framework.plugin.core.util.OseeData;
-import org.eclipse.osee.framework.skynet.core.UserManager;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
-import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
-import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
-import org.eclipse.osee.framework.ui.skynet.preferences.MsWordPreferencePage;
-import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
-import org.eclipse.osee.framework.ui.skynet.render.IRenderer;
-import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
-import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil;
-import org.eclipse.osee.framework.ui.skynet.render.WordImageChecker;
-import org.eclipse.osee.framework.ui.skynet.util.IVbaDiffGenerator;
-import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
-
-public final class WordChangeReportOperation extends AbstractOperation {
- private final Collection<ArtifactDelta> artifactDeltas;
-
- private final String reportDirName;
- private final String fileName;
- private final boolean isSuppressWord;
- private final IAttributeType attributeType;
- private final ArtifactDeltaToFileConverter converter;
- private final boolean skipDialogs;
- private IFolder changeReportFolder;
-
- public WordChangeReportOperation(Collection<ArtifactDelta> artifactDeltas, FileSystemRenderer renderer) throws OseeArgumentException {
- super("Word Change Report", SkynetGuiPlugin.PLUGIN_ID);
- this.converter = new ArtifactDeltaToFileConverter(renderer);
- this.artifactDeltas = artifactDeltas;
- String diffFolderName = renderer.getStringOption("diffReportFolderName");
- this.reportDirName = Strings.isValid(diffFolderName) ? diffFolderName : GUID.create();
-
- fileName = renderer.getStringOption(IRenderer.FILE_NAME_OPTION);
- isSuppressWord = renderer.getBooleanOption(IRenderer.NO_DISPLAY);
- skipDialogs = renderer.getBooleanOption(IRenderer.SKIP_DIALOGS);
- this.attributeType = CoreAttributeTypes.WordTemplateContent;
- }
-
- private IFolder getChangeReportFolder() throws OseeCoreException {
- if (changeReportFolder == null) {
- RenderingUtil.ensureRenderFolderExists(PresentationType.DIFF);
- changeReportFolder = OseeData.getFolder(".diff/" + reportDirName);
- }
- return changeReportFolder;
- }
-
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- if (!artifactDeltas.isEmpty()) {
- double workPercentage = 0.70 / artifactDeltas.size();
-
- IVbaDiffGenerator generator = WordUiUtil.createScriptGenerator();
- generator.initialize(false, false);
-
- String baseFileStr = getChangeReportFolder().getLocation().toOSString();
-
- int countSuccessful = 0;
-
- for (ArtifactDelta artifactDelta : artifactDeltas) {
- checkForCancelledStatus(monitor);
-
- try {
- //Remove tracked changes and display image diffs
- Pair<String, Boolean> originalValue = null;
- Pair<String, Boolean> newAnnotationValue = null;
-
- Artifact baseArtifact = artifactDelta.getStartArtifact();
- Artifact newerArtifact = artifactDelta.getEndArtifact();
-
- Attribute<String> baseContent = getWordContent(baseArtifact, attributeType);
- Attribute<String> newerContent = getWordContent(newerArtifact, attributeType);
-
- if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
- originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
- }
- Pair<IFile, IFile> fileDeltas = converter.convertToFile(PresentationType.DIFF, artifactDelta);
-
- WordImageChecker.restoreOriginalValue(baseContent, originalValue);
- WordImageChecker.restoreOriginalValue(newerContent, newAnnotationValue);
-
- monitor.setTaskName("Adding to Diff Script: " + (newerArtifact == null ? "Unnamed Artifact" : newerArtifact.getName()));
-
- String localFileName = fileName != null ? fileName : GUID.create() + ".xml";
- localFileName = baseFileStr + "/" + localFileName;
- generator.addComparison(fileDeltas.getFirst(), fileDeltas.getSecond(), localFileName, false);
-
- countSuccessful++;
- } catch (OseeCoreException ex) {
- OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
- } finally {
- monitor.worked(calculateWork(workPercentage));
- }
- }
-
- checkForCancelledStatus(monitor);
- if (countSuccessful > 0) {
- monitor.setTaskName("Running Diff Script");
- if (RenderingUtil.arePopupsAllowed()) {
- generator.finish(baseFileStr + "/compareDocs.vbs", !isSuppressWord);
- } else {
- OseeLog.log(SkynetGuiPlugin.class, Level.INFO, "Test - Skipping - Compare vbs ");
- }
- }
- monitor.worked(calculateWork(0.20));
- checkForCancelledStatus(monitor);
- monitor.worked(calculateWork(0.10));
- } else {
- monitor.worked(calculateWork(1.0));
- }
- }
-
- private Attribute<String> getWordContent(Artifact artifact, IAttributeType attributeType) throws OseeCoreException {
- Attribute<String> toReturn = null;
- if (artifact != null && !artifact.isDeleted()) {
- toReturn = artifact.getSoleAttribute(attributeType);
- }
- return toReturn;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordTemplateCompare.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordTemplateCompare.java
index 76b8d184da4..15ac9dca22d 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordTemplateCompare.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/WordTemplateCompare.java
@@ -11,28 +11,23 @@
package org.eclipse.osee.framework.ui.skynet.render.compare;
import java.util.Collection;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.skynet.core.UserManager;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
-import org.eclipse.osee.framework.ui.skynet.preferences.MsWordPreferencePage;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
-import org.eclipse.osee.framework.ui.skynet.render.WordImageChecker;
+import org.eclipse.osee.framework.ui.skynet.util.IVbaDiffGenerator;
+import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
public class WordTemplateCompare extends AbstractWordCompare {
- private static final IAttributeType ATTRIBUTE_TYPE = CoreAttributeTypes.WordTemplateContent;
public WordTemplateCompare(FileSystemRenderer renderer) {
- super(renderer);
+ super(renderer, CoreAttributeTypes.WordTemplateContent);
}
@Override
@@ -40,46 +35,33 @@ public class WordTemplateCompare extends AbstractWordCompare {
return PresentationType.MERGE_EDIT;
}
+ /**
+ * Creates a difference report for each artifact between baseArtifact and newerArtifact. Then produces a single
+ * report by combining each of the difference reports together for a single report.
+ */
@Override
- public String compare(IProgressMonitor monitor, PresentationType presentationType, ArtifactDelta artifactDelta) throws OseeCoreException {
- Pair<String, Boolean> originalValue = null;
- Pair<String, Boolean> newAnnotationValue = null;
-
- Artifact baseArtifact = artifactDelta.getStartArtifact();
- Artifact newerArtifact = artifactDelta.getEndArtifact();
+ public void compareArtifacts(IProgressMonitor monitor, PresentationType presentationType, Collection<ArtifactDelta> artifactDeltas) throws OseeCoreException {
+ IVbaDiffGenerator diffGenerator = WordUiUtil.createScriptGenerator();
+ diffGenerator.initialize(false, false);
- Attribute<String> baseContent = getWordContent(baseArtifact, ATTRIBUTE_TYPE);
- Attribute<String> newerContent = getWordContent(newerArtifact, ATTRIBUTE_TYPE);
+ for (ArtifactDelta artifactDelta : artifactDeltas) {
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
+ }
- if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
- originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
+ try {
+ addTocompare(monitor, diffGenerator, PresentationType.DIFF, artifactDelta);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ } finally {
+ monitor.worked(1);
+ }
}
- ArtifactDeltaToFileConverter converter = new ArtifactDeltaToFileConverter(getRenderer());
- Pair<IFile, IFile> compareFiles = converter.convertToFile(presentationType, artifactDelta);
-
- WordImageChecker.restoreOriginalValue(baseContent, originalValue);
- WordImageChecker.restoreOriginalValue(newerContent, newAnnotationValue);
-
- return compare(baseArtifact, newerArtifact, compareFiles.getFirst(), compareFiles.getSecond(), presentationType);
- }
-
- private Attribute<String> getWordContent(Artifact artifact, IAttributeType attributeType) throws OseeCoreException {
- Attribute<String> toReturn = null;
- if (artifact != null && !artifact.isDeleted()) {
- toReturn = artifact.getSoleAttribute(attributeType);
+ if (monitor.isCanceled()) {
+ throw new OperationCanceledException();
}
- return toReturn;
- }
- /**
- * Creates a difference report for each artifact between baseArtifact and newerArtifact. Then produces a single
- * report by combining each of the difference reports together for a single report.
- */
- @Override
- public void compareArtifacts(IProgressMonitor monitor, PresentationType presentationType, Collection<ArtifactDelta> artifactDeltas) throws OseeCoreException {
- IOperation operation = new WordChangeReportOperation(artifactDeltas, getRenderer());
- Operations.executeWorkAndCheckStatus(operation, monitor);
+ finish(diffGenerator, artifactDeltas.iterator().next().getStartArtifact().getBranch(), presentationType);
}
-
-}
+} \ No newline at end of file

Back to the top