Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpotterc0k2013-09-11 19:42:59 +0000
committerRoberto E. Escobar2013-09-17 23:29:47 +0000
commitb32aaad3e80111ec1f00c4f19ca24644d1d96abe (patch)
tree66c75c2e201db3522991615ba4df237273ce5e91 /plugins
parent5bbf1edd75558232294bf8e52764fcb1ee5a1f1f (diff)
downloadorg.eclipse.osee-b32aaad3e80111ec1f00c4f19ca24644d1d96abe.tar.gz
org.eclipse.osee-b32aaad3e80111ec1f00c4f19ca24644d1d96abe.tar.xz
org.eclipse.osee-b32aaad3e80111ec1f00c4f19ca24644d1d96abe.zip
feature[ats_W611Y]: Use single generic compare for multiple artifact types
Change-Id: I5c9257e9817a170c3ea4b71191c1e814fc9d46fc Signed-off-by: mpotterc0k <marc.a.potter@boeing.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml9
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/GenericDiffHandler.java (renamed from plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/PlainTextDiffHandler.java)5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DiffUsingRenderer.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLDiffRenderer.java70
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLRenderer.java133
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextDiffRenderer.java4
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextRenderer.java5
7 files changed, 218 insertions, 10 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
index e64552df39..4438170c34 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/plugin.xml
@@ -176,6 +176,9 @@
<extension id="ascii" point="org.eclipse.osee.framework.ui.skynet.ArtifactRenderer">
<Renderer classname="org.eclipse.osee.framework.ui.skynet.render.PlainTextRenderer"/>
</extension>
+ <extension id="html" point="org.eclipse.osee.framework.ui.skynet.ArtifactRenderer">
+ <Renderer classname="org.eclipse.osee.framework.ui.skynet.render.HTMLRenderer"/>
+ </extension>
<extension id="word" point="org.eclipse.osee.framework.ui.skynet.ArtifactRenderer">
<Renderer classname="org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer"/>
</extension>
@@ -332,7 +335,7 @@
commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.viewWordChangeReportWasIs.command">
</command>
<command
- commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.plainTextDiff.command">
+ commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.genericDiff.command">
</command>
<separator
name="xChngSeparator3"
@@ -595,7 +598,7 @@
</with>
</enabledWhen>
</handler>
- <handler class="org.eclipse.osee.framework.ui.skynet.commandHandlers.change.PlainTextDiffHandler" commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.plainTextDiff.command">
+ <handler class="org.eclipse.osee.framework.ui.skynet.commandHandlers.change.GenericDiffHandler" commandId="org.eclipse.osee.framework.ui.skynet.changeReportView.genericDiff.command">
<enabledWhen>
<with
variable="selection">
@@ -1367,7 +1370,7 @@
<extension name="Commands of ChangeReportView" point="org.eclipse.ui.commands">
<command id="org.eclipse.osee.framework.ui.skynet.changeReportView.revertArtifact.command" name="Replace with Baseline Version...">
</command>
- <command id="org.eclipse.osee.framework.ui.skynet.changeReportView.plainTextDiff.command" name="View Plain Text Diff">
+ <command id="org.eclipse.osee.framework.ui.skynet.changeReportView.genericDiff.command" name="View Artifact Diff">
</command>
<command id="org.eclipse.osee.framework.ui.skynet.changeReportView.viewWordChangeReport.command" name="View Word Change Report - F5">
</command>
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/PlainTextDiffHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/GenericDiffHandler.java
index 880a111001..bbb6b34189 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/PlainTextDiffHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/change/GenericDiffHandler.java
@@ -24,14 +24,13 @@ import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.osee.framework.skynet.core.revision.ChangeManager;
import org.eclipse.osee.framework.ui.plugin.util.CommandHandler;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
-import org.eclipse.osee.framework.ui.skynet.render.PlainTextRenderer;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil;
/**
* @author Shawn F. Cook
*/
-public class PlainTextDiffHandler extends CommandHandler {
+public class GenericDiffHandler extends CommandHandler {
@Override
public boolean isEnabledWithException(IStructuredSelection structuredSelection) {
@@ -55,7 +54,7 @@ public class PlainTextDiffHandler extends CommandHandler {
Collection<ArtifactDelta> artifactDeltas = ChangeManager.getCompareArtifacts(changes);
String pathPrefix = RenderingUtil.getAssociatedArtifactName(localChanges);
- RendererManager.diffInJobWithPreferedRenderer(artifactDeltas, pathPrefix, new PlainTextRenderer());
+ RendererManager.diffInJob(artifactDeltas, pathPrefix);
}
return null;
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DiffUsingRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DiffUsingRenderer.java
index cff2a7d5c9..8178bd6ad4 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DiffUsingRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/DiffUsingRenderer.java
@@ -63,6 +63,7 @@ public final class DiffUsingRenderer extends AbstractOperation {
@Override
protected void doWork(IProgressMonitor monitor) throws Exception {
+
ArtifactDelta firstDelta = artifactDeltas.iterator().next();
Artifact sampleArtifact =
firstDelta.getStartArtifact() != null ? firstDelta.getStartArtifact() : firstDelta.getEndArtifact();
@@ -71,6 +72,7 @@ public final class DiffUsingRenderer extends AbstractOperation {
if (preferedRenderer == null) {
renderer = RendererManager.getBestRenderer(DIFF, sampleArtifact, options);
}
+
IComparator comparator = renderer.getComparator();
if (artifactDeltas.size() == 1) {
comparator.compare(monitor, collector, DIFF, firstDelta, pathPrefix);
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLDiffRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLDiffRenderer.java
new file mode 100644
index 0000000000..8d7840725a
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLDiffRenderer.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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;
+
+/*
+ * @author Marc Potter
+ */
+
+import java.util.Collection;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
+import org.eclipse.osee.framework.ui.skynet.compare.CompareHandler;
+import org.eclipse.osee.framework.ui.skynet.compare.CompareItem;
+import org.eclipse.osee.framework.ui.skynet.render.compare.CompareDataCollector;
+import org.eclipse.osee.framework.ui.skynet.render.compare.IComparator;
+import org.eclipse.swt.widgets.Display;
+
+public class HTMLDiffRenderer implements IComparator {
+
+ @Override
+ public void compare(IProgressMonitor monitor, CompareDataCollector collector, PresentationType presentationType, ArtifactDelta artifactDelta, String pathPrefix) throws OseeCoreException {
+ String was = null, is = null, artifactName = null;
+ Artifact startArtifact = artifactDelta.getStartArtifact();
+ if (startArtifact != null) {
+ was = startArtifact.getSoleAttributeValueAsString(CoreAttributeTypes.HTMLContent, "");
+ artifactName = startArtifact.getName();
+ }
+ Artifact endArtifact = artifactDelta.getEndArtifact();
+ if (endArtifact != null) {
+ is = endArtifact.getSoleAttributeValueAsString(CoreAttributeTypes.HTMLContent, "");
+ }
+ if (Strings.isValid(is) && Strings.isValid(was)) {
+ final CompareHandler compareHandler =
+ new CompareHandler(artifactName, new CompareItem("Was", was, System.currentTimeMillis()), new CompareItem(
+ "Is", is, System.currentTimeMillis()), null);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ compareHandler.compare();
+ }
+ });
+ }
+ }
+
+ @Override
+ public void compare(CompareDataCollector collector, Artifact baseVersion, Artifact newerVersion, IFile baseFile, IFile newerFile, PresentationType presentationType, String pathPrefix) throws OseeCoreException {
+ throw new OseeCoreException("The HTML Content renderer does not support the compare operation");
+ }
+
+ @Override
+ public void compareArtifacts(IProgressMonitor monitor, CompareDataCollector collector, PresentationType presentationType, Collection<ArtifactDelta> artifactDeltas, String pathPrefix) throws OseeCoreException {
+ for (ArtifactDelta artifactDelta : artifactDeltas) {
+ compare(monitor, collector, presentationType, artifactDelta, pathPrefix);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLRenderer.java
new file mode 100644
index 0000000000..5592f72066
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/HTMLRenderer.java
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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;
+
+/*
+ * @author Marc Potter
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.commands.Command;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+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.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.operation.IOperation;
+import org.eclipse.osee.framework.jdk.core.util.io.Streams;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.types.IArtifact;
+import org.eclipse.osee.framework.ui.skynet.render.compare.IComparator;
+import org.eclipse.osee.framework.ui.swt.ImageManager;
+import org.eclipse.swt.program.Program;
+
+public class HTMLRenderer extends FileSystemRenderer {
+
+ private final IComparator comparator;
+
+ public HTMLRenderer() {
+ this.comparator = new HTMLDiffRenderer();
+ }
+
+ @Override
+ public List<String> getCommandIds(CommandGroup commandGroup) {
+ ArrayList<String> commandIds = new ArrayList<String>(1);
+
+ if (commandGroup.isPreview()) {
+ // currently unsupported
+ }
+
+ if (commandGroup.isEdit()) {
+ // currently unsupported
+ }
+
+ return commandIds;
+ }
+
+ @Override
+ public ImageDescriptor getCommandImageDescriptor(Command command, Artifact artifact) {
+ return ImageManager.getProgramImageDescriptor("htm");
+ }
+
+ @Override
+ public InputStream getRenderInputStream(PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
+ InputStream stream = null;
+ try {
+ if (artifacts.size() == 1) {
+ Artifact artifact = artifacts.iterator().next();
+ stream = artifact.getSoleAttributeValue(CoreAttributeTypes.HTMLContent);
+ } else {
+ String content = "";
+ for (Artifact artifact : artifacts) {
+ content += artifact.getOrInitializeSoleAttributeValue(CoreAttributeTypes.HTMLContent);
+ content += "\n\n";
+ }
+
+ stream = Streams.convertStringToInputStream(content, "UTF-8");
+ }
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return stream;
+ }
+
+ @Override
+ public Program getAssociatedProgram(Artifact artifact) throws OseeCoreException {
+ Program program = Program.findProgram("htm");
+ if (program == null) {
+ throw new OseeArgumentException("No program associated with the extension *.htm found on your local machine.");
+ }
+ return program;
+ }
+
+ @Override
+ public int getApplicabilityRating(PresentationType presentationType, IArtifact artifact) throws OseeCoreException {
+ Artifact aArtifact = artifact.getFullArtifact();
+ int toReturn = NO_MATCH;
+ if (aArtifact.isAttributeTypeValid(CoreAttributeTypes.HTMLContent)) {
+ if (presentationType.matches(PresentationType.DIFF)) {
+ toReturn = PRESENTATION_SUBTYPE_MATCH;
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String getAssociatedExtension(Artifact artifact) {
+ return "htm";
+ }
+
+ @Override
+ protected IOperation getUpdateOperation(File file, List<Artifact> artifacts, IOseeBranch branch, PresentationType presentationType) {
+ return new FileToAttributeUpdateOperation(file, artifacts.get(0), CoreAttributeTypes.PlainTextContent);
+ }
+
+ @Override
+ public String getName() {
+ return "HTML Renderer";
+ }
+
+ @Override
+ public HTMLRenderer newInstance() {
+ return new HTMLRenderer();
+ }
+
+ @Override
+ public IComparator getComparator() {
+ return comparator;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextDiffRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextDiffRenderer.java
index c3b5a1fea8..4035ec95e1 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextDiffRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextDiffRenderer.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Display;
/**
* Class to display the differences between two ASCII plain text files in the default Eclipse diff view.
- *
+ *
* @author Shawn F. Cook
*/
public class PlainTextDiffRenderer implements IComparator {
@@ -62,7 +62,7 @@ public class PlainTextDiffRenderer implements IComparator {
@Override
public void compare(CompareDataCollector collector, Artifact baseVersion, Artifact newerVersion, IFile baseFile, IFile newerFile, PresentationType presentationType, String pathPrefix) throws OseeCoreException {
- throw new OseeCoreException("The default renderer does not support the compare operation");
+ throw new OseeCoreException("The Plain Text renderer does not support the compare operation");
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextRenderer.java
index c76efa79a5..137f5ec485 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/PlainTextRenderer.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.framework.ui.skynet.render;
import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.DEFAULT_OPEN;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.DIFF;
import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.PREVIEW;
import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.PRODUCE_ATTRIBUTE;
import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.SPECIALIZED_EDIT;
@@ -39,7 +40,7 @@ import org.eclipse.swt.program.Program;
/**
* Renderer for artifact with ASCII plain text file as its content. This is compared to the more traditional
* WordRenderer which renders artifacts (e.g.: Software Requirements) content which is Word Documents.
- *
+ *
* @author Shawn F. Cook
*/
public class PlainTextRenderer extends FileSystemRenderer {
@@ -106,7 +107,7 @@ public class PlainTextRenderer extends FileSystemRenderer {
public int getApplicabilityRating(PresentationType presentationType, IArtifact artifact) throws OseeCoreException {
Artifact aArtifact = artifact.getFullArtifact();
if (aArtifact.isAttributeTypeValid(CoreAttributeTypes.PlainTextContent)) {
- if (presentationType.matches(SPECIALIZED_EDIT, PREVIEW, DEFAULT_OPEN, PRODUCE_ATTRIBUTE)) {
+ if (presentationType.matches(SPECIALIZED_EDIT, PREVIEW, DEFAULT_OPEN, PRODUCE_ATTRIBUTE, DIFF)) {
return PRESENTATION_SUBTYPE_MATCH;
}
}

Back to the top