Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2011-01-24 17:51:28 +0000
committerRyan D. Brooks2011-01-24 17:51:28 +0000
commitb195106846b6e81994165ba3f4f247890d291a14 (patch)
tree2d498730bf44a8bab94fe6e2146a1f59de98bcfb
parentec1afcdb8a9cfff9b73e89b4899a1f784c8dcb30 (diff)
downloadorg.eclipse.osee-b195106846b6e81994165ba3f4f247890d291a14.tar.gz
org.eclipse.osee-b195106846b6e81994165ba3f4f247890d291a14.tar.xz
org.eclipse.osee-b195106846b6e81994165ba3f4f247890d291a14.zip
refactor: Simplify usage of FileSystemRenderer's public methods
-rw-r--r--plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java2
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java7
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/OtherEditorHandler.java5
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/FileSystemRenderer.java44
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/compare/ArtifactDeltaToFileConverter.java15
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java14
6 files changed, 32 insertions, 55 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
index 2824856ec02..89c643842ed 100644
--- a/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
+++ b/plugins/org.eclipse.osee.framework.core.dsl.ui.integration/src/org/eclipse/osee/framework/core/dsl/ui/integration/internal/OseeDslRenderer.java
@@ -94,7 +94,7 @@ public final class OseeDslRenderer extends FileSystemRenderer {
public void run() {
if (!artifacts.isEmpty()) {
try {
- IFile file = getRenderedFile(artifacts, resultantpresentationType);
+ IFile file = renderToFile(artifacts, resultantpresentationType);
if (file != null) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
index 2124b6c44b7..a3b387b9274 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet.test/src/org/eclipse/osee/framework/ui/skynet/test/cases/WordEditTest.java
@@ -127,8 +127,7 @@ public class WordEditTest {
}
private static IFile openArtifactForEdit(FileSystemRenderer renderer, Artifact artifact) throws OseeCoreException {
- List<Artifact> artifacts = Collections.singletonList(artifact);
- IFile editFile = renderer.getRenderedFile(artifacts, PresentationType.SPECIALIZED_EDIT);
+ IFile editFile = renderer.renderToFile(artifact, artifact.getBranch(), PresentationType.SPECIALIZED_EDIT);
Assert.assertNotNull(editFile);
return editFile;
}
@@ -155,8 +154,8 @@ public class WordEditTest {
Assert.assertNotNull(renderer);
Assert.assertNotNull(artifact);
- List<Artifact> artifacts = Collections.singletonList(artifact);
- IFile renderedFileFromModifiedStorage = renderer.getRenderedFile(artifacts, PresentationType.SPECIALIZED_EDIT);
+ IFile renderedFileFromModifiedStorage =
+ renderer.renderToFile(artifact, artifact.getBranch(), PresentationType.SPECIALIZED_EDIT);
Assert.assertNotNull(renderedFileFromModifiedStorage);
InputStream inputStream = null;
try {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/OtherEditorHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/OtherEditorHandler.java
index 3ba7d99a68c..da795db1538 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/OtherEditorHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/renderer/handlers/OtherEditorHandler.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
import org.eclipse.osee.framework.ui.skynet.render.NativeRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.IWorkbenchPage;
@@ -45,7 +46,7 @@ public class OtherEditorHandler extends AbstractEditorHandler {
if (dialog.open() == Window.OK) {
IEditorDescriptor editor = dialog.getSelectedEditor();
if (editor != null) {
- IFile file = renderer.getRenderedFileForOpen(artifacts);
+ IFile file = renderer.renderToFile(artifacts, PresentationType.SPECIALIZED_EDIT);
openEditor(editor, file, editor.isOpenExternal());
}
}
@@ -73,4 +74,4 @@ public class OtherEditorHandler extends AbstractEditorHandler {
OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, "Open Editor Error", ex);
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/FileSystemRenderer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/FileSystemRenderer.java
index d0081928153..68b18922307 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/FileSystemRenderer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/FileSystemRenderer.java
@@ -12,13 +12,13 @@ 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.PREVIEW;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.SPECIALIZED_EDIT;
import java.io.File;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
@@ -42,32 +42,17 @@ import org.eclipse.ui.part.FileEditorInput;
public abstract class FileSystemRenderer extends DefaultArtifactRenderer {
private static final ArtifactFileMonitor monitor = new ArtifactFileMonitor();
- public IFile getRenderedFileForOpen(List<Artifact> artifacts) throws OseeCoreException {
- return getRenderedFile(artifacts, PresentationType.SPECIALIZED_EDIT);
- }
-
- public IFile getRenderedFile(List<Artifact> artifacts, PresentationType presentationType) throws OseeCoreException {
- IFile toReturn = null;
- if (!artifacts.isEmpty()) {
- Artifact firstArtifact = artifacts.iterator().next();
- IFolder baseFolder = RenderingUtil.getRenderFolder(firstArtifact.getBranch(), presentationType);
- toReturn = renderToFileSystem(baseFolder, artifacts, presentationType);
- }
- return toReturn;
- }
-
- public IFile renderToFileSystem(IFolder baseFolder, Artifact artifact, Branch branch, PresentationType presentationType) throws OseeCoreException {
- String fileName = RenderingUtil.getFilenameFromArtifact(this, artifact, presentationType);
+ public IFile renderToFile(Artifact artifact, Branch branch, PresentationType presentationType) throws OseeCoreException {
List<Artifact> artifacts;
- if (artifact != null) {
- artifacts = Collections.singletonList(artifact);
- } else {
+ if (artifact == null) {
artifacts = Collections.emptyList();
+ } else {
+ artifacts = Collections.singletonList(artifact);
}
- return renderToFile(baseFolder, fileName, branch, presentationType, artifacts);
+ return renderToFile(artifacts, branch, presentationType);
}
- public IFile renderToFileSystem(IFolder baseFolder, List<Artifact> artifacts, PresentationType presentationType) throws OseeCoreException {
+ public IFile renderToFile(List<Artifact> artifacts, PresentationType presentationType) throws OseeCoreException {
Branch initialBranch = null;
for (Artifact artifact : artifacts) {
if (initialBranch == null) {
@@ -79,20 +64,15 @@ public abstract class FileSystemRenderer extends DefaultArtifactRenderer {
}
}
- Artifact artifact = null;
- if (artifacts.size() == 1) {
- artifact = artifacts.iterator().next();
- }
- String fileName = RenderingUtil.getFilenameFromArtifact(this, artifact, presentationType);
- return renderToFile(baseFolder, fileName, initialBranch, presentationType, artifacts);
+ return renderToFile(artifacts, initialBranch, presentationType);
}
- public IFile renderToFile(IFolder baseFolder, String fileName, Branch branch, PresentationType presentationType, List<Artifact> artifacts) throws OseeCoreException {
+ public IFile renderToFile(List<Artifact> artifacts, Branch branch, PresentationType presentationType) throws OseeCoreException {
InputStream renderInputStream = getRenderInputStream(presentationType, artifacts);
- IFile workingFile = baseFolder.getFile(fileName);
+ IFile workingFile = RenderingUtil.getRenderFile(this, artifacts, branch, presentationType);
AIFile.writeToFile(workingFile, renderInputStream);
- if (presentationType == PresentationType.SPECIALIZED_EDIT || presentationType == PresentationType.MERGE_EDIT) {
+ if (presentationType == SPECIALIZED_EDIT) {
File file = workingFile.getLocation().toFile();
monitor.addFile(file, getUpdateOperation(file, artifacts, branch, presentationType));
} else if (presentationType == PresentationType.PREVIEW) {
@@ -113,7 +93,7 @@ public abstract class FileSystemRenderer extends DefaultArtifactRenderer {
presentationType = PREVIEW;
}
- IFile file = getRenderedFile(artifacts, presentationType);
+ IFile file = renderToFile(artifacts, presentationType);
if (file != null) {
String dummyName = file.getName();
if (!artifacts.isEmpty()) {
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 cd58cbe64eb..8d9e4858e51 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
@@ -11,7 +11,6 @@
package org.eclipse.osee.framework.ui.skynet.render.compare;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.type.Pair;
@@ -49,21 +48,17 @@ public class ArtifactDeltaToFileConverter {
if (artifact == null) {
throw new IllegalArgumentException("Artifact can not be null.");
}
- IFolder baseFolder;
- if (presentationType == PresentationType.MERGE_EDIT) {
- baseFolder = RenderingUtil.getRenderFolder(artifact.getBranch(), PresentationType.MERGE_EDIT);
- } else {
- baseFolder = RenderingUtil.getRenderFolder(artifact.getBranch(), PresentationType.DIFF);
+ if (presentationType != PresentationType.MERGE_EDIT) {
+ presentationType = PresentationType.DIFF;
}
- return renderer.renderToFileSystem(baseFolder, artifact, artifact.getBranch(), presentationType);
+ return renderer.renderToFile(artifact, artifact.getBranch(), presentationType);
}
private Pair<IFile, IFile> asFiles(FileSystemRenderer renderer, PresentationType presentationType, ArtifactDelta artifactDelta) throws OseeCoreException {
Pair<Artifact, Artifact> renderInput = RenderingUtil.asRenderInput(artifactDelta);
Branch branch = artifactDelta.getBranch();
- IFolder renderingFolder = RenderingUtil.getRenderFolder(branch, presentationType);
- IFile baseFile = renderer.renderToFileSystem(renderingFolder, renderInput.getFirst(), branch, presentationType);
- IFile newerFile = renderer.renderToFileSystem(renderingFolder, renderInput.getSecond(), branch, presentationType);
+ IFile baseFile = renderer.renderToFile(renderInput.getFirst(), branch, presentationType);
+ IFile newerFile = renderer.renderToFile(renderInput.getSecond(), branch, presentationType);
return new Pair<IFile, IFile>(baseFile, newerFile);
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
index a6e48601b5d..b95a9d3be93 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
@@ -13,10 +13,12 @@ package org.eclipse.osee.framework.ui.skynet.render.word;
import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.WordTemplateContent;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import static org.eclipse.osee.framework.ui.skynet.render.PresentationType.PREVIEW;
import java.io.InputStream;
import java.nio.charset.CharacterCodingException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@@ -51,7 +53,6 @@ import org.eclipse.osee.framework.skynet.core.linking.LinkType;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.word.WordUtil;
import org.eclipse.osee.framework.ui.skynet.blam.VariableMap;
-import org.eclipse.osee.framework.ui.skynet.render.IRenderer;
import org.eclipse.osee.framework.ui.skynet.render.ITemplateRenderer;
import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
@@ -109,9 +110,9 @@ public class WordTemplateProcessor {
final List<Artifact> nonTemplateArtifacts = new LinkedList<Artifact>();
private final Set<String> ignoreAttributeExtensions = new HashSet<String>();
private final Set<Artifact> processedArtifacts = new HashSet<Artifact>();
- private final IRenderer renderer;
+ private final WordTemplateRenderer renderer;
- public WordTemplateProcessor(IRenderer renderer) {
+ public WordTemplateProcessor(WordTemplateRenderer renderer) {
this.renderer = renderer;
loadIgnoreAttributeExtensions();
}
@@ -130,11 +131,12 @@ public class WordTemplateProcessor {
slaveTemplate = slaveTemplateArtifact.getSoleAttributeValue(CoreAttributeTypes.WholeWordContent, "");
}
- IFolder folder = RenderingUtil.ensureRenderFolderExists(PresentationType.PREVIEW);
+ Branch branch = variableMap.getBranch("Branch");
+ RenderingUtil.getRenderFile(renderer, Collections.singletonList(masterTemplateArtifact), branch, PREVIEW);
+ IFolder folder = RenderingUtil.ensureRenderFolderExists(PREVIEW);
String fileName = String.format("%s_%s.xml", masterTemplateArtifact.getSafeName(), Lib.getDateTimeString());
IFile file = folder.getFile(fileName);
- AIFile.writeToFile(file,
- applyTemplate(variableMap, artifacts, masterTemplate, folder, null, null, PresentationType.PREVIEW));
+ AIFile.writeToFile(file, applyTemplate(variableMap, artifacts, masterTemplate, folder, null, null, PREVIEW));
if (variableMap.getBoolean("OpenDocument") && file != null) {
RenderingUtil.ensureFilenameLimit(file);

Back to the top