Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBranden Phillips2021-01-07 21:04:19 +0000
committerRyan Brooks2021-01-11 17:00:51 +0000
commitfcf532673f040aa9eaa25d750fd7ec5a8c43ffa7 (patch)
tree12d348120c45539de2bf3390de96e4490e949979
parentf8ee31d2ff4e136f341c22557d57f5abdc01e1ba (diff)
downloadorg.eclipse.osee-fcf532673f040aa9eaa25d750fd7ec5a8c43ffa7.tar.gz
org.eclipse.osee-fcf532673f040aa9eaa25d750fd7ec5a8c43ffa7.tar.xz
org.eclipse.osee-fcf532673f040aa9eaa25d750fd7ec5a8c43ffa7.zip
bug[TW18568]: Fix issues with Word previews/differences on merge conflicts
Change-Id: Ibe3c3790d77a98d2506a978a07879f5f509a6a12 Signed-off-by: Branden Phillips <branden.w.phillips@boeing.com>
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/UnmodifiedArtifactDelta.java34
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/WordChangeUtil.java3
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/AbstractWordCompare.java93
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java20
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeCustomMenu.java14
5 files changed, 114 insertions, 50 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/UnmodifiedArtifactDelta.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/UnmodifiedArtifactDelta.java
new file mode 100644
index 00000000000..110fd34f562
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/UnmodifiedArtifactDelta.java
@@ -0,0 +1,34 @@
+/*********************************************************************
+ * Copyright (c) 2021 Boeing
+ *
+ * This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License 2.0
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.osee.framework.skynet.core.change;
+
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+
+/**
+ * @author Branden W. Phillips
+ */
+public class UnmodifiedArtifactDelta extends ArtifactDelta {
+
+ /**
+ * ArtifactDelta's are objects to contain new and old versions of artifacts, sometimes including the transaction id's
+ * of that change. These are used to assist in creating word file comparisons. This class, UnmodifiedArtifactDelta,
+ * is used to make a mock version of those ArtifactDeltas that is just the same exact artifact as the start and end
+ * artifact. This is primarily used for adding in contextual artifacts for word comparisons that only have 1 version
+ * of the artifact. Utilizing this method tells the processing that the artifact content only needs to be rendered
+ * once instead of twice.
+ */
+ public UnmodifiedArtifactDelta(Artifact artifact) {
+ super(artifact, artifact);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/WordChangeUtil.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/WordChangeUtil.java
index 796648c7523..38e433d3a74 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/WordChangeUtil.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/change/WordChangeUtil.java
@@ -35,6 +35,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactHierarchyComparat
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
import org.eclipse.osee.framework.skynet.core.change.Change;
+import org.eclipse.osee.framework.skynet.core.change.UnmodifiedArtifactDelta;
import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
import org.eclipse.osee.framework.ui.skynet.internal.Activator;
@@ -158,7 +159,7 @@ public final class WordChangeUtil {
for (Artifact art : artList) {
ArtifactDelta delta = originalDeltaMap.get(art);
if (delta == null) {
- delta = new ArtifactDelta(art, art);
+ delta = new UnmodifiedArtifactDelta(art);
}
returnDeltas.add(delta);
}
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 4d2a0d3249e..4b82c050400 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
@@ -40,6 +40,7 @@ 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.skynet.core.change.UnmodifiedArtifactDelta;
import org.eclipse.osee.framework.ui.skynet.internal.Activator;
import org.eclipse.osee.framework.ui.skynet.preferences.MsWordPreferencePage;
import org.eclipse.osee.framework.ui.skynet.render.FileSystemRenderer;
@@ -173,52 +174,68 @@ public abstract class AbstractWordCompare implements IComparator {
}
protected void addToCompare(IProgressMonitor monitor, CompareData data, PresentationType presentationType, ArtifactDelta artifactDelta) {
- Pair<String, Boolean> originalValue = null;
-
- Artifact baseArtifact = artifactDelta.getStartArtifact();
- Artifact newerArtifact = artifactDelta.getEndArtifact();
+ Pair<IFile, IFile> compareFiles;
+ if (artifactDelta instanceof UnmodifiedArtifactDelta) {
+ compareFiles = converter.convertToFileAndCopy(presentationType, artifactDelta);
+ } else {
+ Pair<String, Boolean> originalValue = null;
- Attribute<String> baseContent = getWordContent(baseArtifact);
- Attribute<String> newerContent = getWordContent(newerArtifact);
+ Artifact baseArtifact = artifactDelta.getStartArtifact();
+ Artifact newerArtifact = artifactDelta.getEndArtifact();
- if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
- originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
- }
- monitor.setTaskName(
- "Preparing comparison for: " + (newerArtifact == null ? baseArtifact.getName() : newerArtifact.getName()));
+ Attribute<String> baseContent = getWordContent(baseArtifact);
+ Attribute<String> newerContent = getWordContent(newerArtifact);
- Pair<IFile, IFile> compareFiles;
- if (artifactDelta.getStartArtifact() == artifactDelta.getBaseArtifact()) {
- compareFiles = converter.convertToFile(presentationType, artifactDelta);
- } else {
- // The artifactDelta is a 3 Way Merge
- List<IFile> outputFiles = new ArrayList<>();
- converter.convertToFileForMerge(outputFiles, artifactDelta.getTxDelta(), artifactDelta.getBaseArtifact(),
- artifactDelta.getStartArtifact());
- converter.convertToFileForMerge(outputFiles, artifactDelta.getTxDelta(), artifactDelta.getBaseArtifact(),
- artifactDelta.getEndArtifact());
- // this is where we are getting the exception that the length of outputFiles is 1
- // This happens because the artifact did not exist on the previous
- // branch or was removed on the current branch
- if (outputFiles.size() == 1) {
- String outputFileName = outputFiles.get(0).getRawLocation().toOSString();
- try {
- String tempFileName = Lib.removeExtension(outputFileName);
- File tempFile = new File(tempFileName + ".temp.xml");
- Lib.writeStringToFile("", tempFile);
- IFile constructIFile = AIFile.constructIFile(tempFile.getPath());
- outputFiles.add(constructIFile);
- } catch (IOException ex) {
- throw new OseeCoreException(ex, "Empty file for comparison could not be created, [%s]", outputFileName);
- }
+ if (!UserManager.getBooleanSetting(MsWordPreferencePage.IDENTFY_IMAGE_CHANGES)) {
+ originalValue = WordImageChecker.checkForImageDiffs(baseContent, newerContent);
+ }
+ monitor.setTaskName(
+ "Preparing comparison for: " + (newerArtifact == null ? baseArtifact.getName() : newerArtifact.getName()));
+
+ if (artifactDelta.getStartArtifact() == artifactDelta.getBaseArtifact()) {
+ compareFiles = converter.convertToFile(presentationType, artifactDelta);
+ } else {
+ // The artifactDelta is a 3 Way Merge
+ compareFiles = handle3WayMerge(data, artifactDelta);
}
- compareFiles = new Pair<>(outputFiles.get(0), outputFiles.get(1));
- data.addMerge(outputFiles.get(0).getLocation().toOSString());
+ WordImageChecker.restoreOriginalValue(baseContent, originalValue);
}
- WordImageChecker.restoreOriginalValue(baseContent, originalValue);
data.add(compareFiles.getFirst().getLocation().toOSString(), compareFiles.getSecond().getLocation().toOSString());
}
+ private Pair<IFile, IFile> handle3WayMerge(CompareData data, ArtifactDelta artifactDelta) {
+ Pair<IFile, IFile> toReturnFiles;
+ List<IFile> outputFiles = new ArrayList<>();
+ converter.convertToFileForMerge(outputFiles, artifactDelta.getTxDelta(), artifactDelta.getBaseArtifact(),
+ artifactDelta.getStartArtifact());
+ converter.convertToFileForMerge(outputFiles, artifactDelta.getTxDelta(), artifactDelta.getBaseArtifact(),
+ artifactDelta.getEndArtifact());
+ // this is where we are getting the exception that the length of outputFiles is 1
+ // This happens because the artifact did not exist on the previous
+ // branch or was removed on the current branch
+ if (outputFiles.size() == 1) {
+ String outputFileName = outputFiles.get(0).getRawLocation().toOSString();
+ String tempFileName = Lib.removeExtension(outputFileName);
+ IFile tempFile = getEmptyFileFromName(tempFileName);
+ outputFiles.add(tempFile);
+ }
+ toReturnFiles = new Pair<>(outputFiles.get(0), outputFiles.get(1));
+ data.addMerge(outputFiles.get(0).getLocation().toOSString());
+
+ return toReturnFiles;
+ }
+
+ private IFile getEmptyFileFromName(String fileName) {
+ try {
+ File tempFile = new File(fileName + ".temp.xml");
+ Lib.writeStringToFile("", tempFile);
+ return AIFile.constructIFile(tempFile.getPath());
+ } catch (IOException ex) {
+ OseeCoreException.wrap(ex);
+ }
+ return null;
+ }
+
private Attribute<String> getWordContent(Artifact artifact) {
Attribute<String> toReturn = null;
if (artifact != null && !artifact.isDeleted()) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java
index ae009c17dbc..72bcf931eac 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java
@@ -49,14 +49,22 @@ public class ArtifactDeltaToFileConverter {
IOseeBranch branch = artifactDelta.getBranch();
IFile baseFile = renderer.renderToFile(baseArtifact, branch, presentationType);
- IFile newerFile = null;
- if (artifactDelta.getTxDelta() == null) {
- newerFile = renderer.copyToNewFile(newerArtifact, branch, presentationType, baseFile);
- } else {
- newerFile = renderer.renderToFile(newerArtifact, branch, presentationType);
+ IFile newerFile = renderer.renderToFile(newerArtifact, branch, presentationType);
+ return new Pair<>(baseFile, newerFile);
+ }
+
+ public Pair<IFile, IFile> convertToFileAndCopy(PresentationType presentationType, ArtifactDelta artifactDelta) {
+ Artifact baseArtifact = artifactDelta.getStartArtifact();
+ Artifact newerArtifact = artifactDelta.getEndArtifact();
+ if (newerArtifact.getModType().isDeleted()) {
+ newerArtifact = null;
}
+ IOseeBranch branch = artifactDelta.getBranch();
- return new Pair<>(baseFile, newerFile);
+ IFile baseFile = renderer.renderToFile(baseArtifact, branch, presentationType);
+ IFile copiedFile = renderer.copyToNewFile(newerArtifact, branch, presentationType, baseFile);
+
+ return new Pair<>(baseFile, copiedFile);
}
public void convertToFileForMerge(final Collection<IFile> outputFiles, TransactionDelta txDelta, Artifact baseVersion, Artifact newerVersion) {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeCustomMenu.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeCustomMenu.java
index a5214f28279..39d9d0f4561 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeCustomMenu.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/widgets/xmerge/MergeCustomMenu.java
@@ -479,16 +479,20 @@ public class MergeCustomMenu extends XViewerCustomMenu {
for (Conflict conflict : conflicts) {
try {
- if (partToPreview == 3) {
+ if (partToPreview == 1) { // source artifact
+ Artifact artifact = conflict.getSourceArtifact();
+ artifacts.clear();
+ artifacts.add(artifact);
+ } else if (partToPreview == 2) {
+ Artifact artifact = conflict.getDestArtifact();
+ artifacts.clear();
+ artifacts.add(artifact);
+ } else if (partToPreview == 3) {
ConflictStatus status = conflict.getStatus();
if (status.isInformational()) {
return false;
}
}
- Artifact artifact = conflict.getArtifact();
- if (!artifacts.contains(artifact)) {
- artifacts.add(artifact);
- }
} catch (Exception ex) {
OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex);
}

Back to the top