Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2014-08-19 16:35:06 +0000
committerRoberto E. Escobar2014-09-29 22:55:22 +0000
commit926511e9a869dd0d169958de9cc973232da50577 (patch)
treed373a18d11b05c537e8670fc428bbe08b4984f89
parentdfcc5600fafb6dbc2e50643eca76a82b5045b83f (diff)
downloadorg.eclipse.osee-926511e9a869dd0d169958de9cc973232da50577.tar.gz
org.eclipse.osee-926511e9a869dd0d169958de9cc973232da50577.tar.xz
org.eclipse.osee-926511e9a869dd0d169958de9cc973232da50577.zip
feature[ats_ATS81639]: Add data rights support for landscape PageType
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java18
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordMLProducer.java7
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java58
3 files changed, 65 insertions, 18 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java
index 426c989ee1a..57e19b93331 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/ArtifactDataRightsProvider.java
@@ -39,7 +39,7 @@ public class ArtifactDataRightsProvider implements DataRightsProvider {
private Map<String, String> dataRightsToFooters;
@Override
- public String getDataClassificationFooter(String classification, boolean createNewPageFooter) {
+ public String getDataClassificationFooter(String classification, FooterOption option) {
if (dataRightsToFooters == null) {
initialize();
}
@@ -50,13 +50,25 @@ public class ArtifactDataRightsProvider implements DataRightsProvider {
key = "DEFAULT";
}
- footer = String.format(GENERIC_FOOTER, "DATA RIGHTS CLASSIFICATION MISSING");
footer = dataRightsToFooters.get(key);
if (!Strings.isValid(footer)) {
String text = String.format("FOOTER NOT DEFINED FOR [%s]", key);
footer = String.format(GENERIC_FOOTER, text);
}
- return createNewPageFooter ? String.format(NEW_PAGE_TEMPLATE, footer) : String.format(SAME_PAGE_TEMPLATE, footer);
+
+ switch (option) {
+ case NEW_PAGE:
+ footer = String.format(NEW_PAGE_TEMPLATE, footer);
+ break;
+ case SAME_PAGE:
+ footer = String.format(SAME_PAGE_TEMPLATE, footer);
+ break;
+ case FOOTER_ONLY:
+ default:
+ // do nothing, return footer only
+ }
+
+ return footer;
}
private void initialize() {
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordMLProducer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordMLProducer.java
index 4547c1ffc87..c95e190a132 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordMLProducer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordMLProducer.java
@@ -367,6 +367,10 @@ public class WordMLProducer extends Producer {
* would be set back to portrait.
*/
public void setPageLayout(Artifact artifact) throws OseeCoreException {
+ setPageLayout(artifact, null);
+ }
+
+ public void setPageLayout(Artifact artifact, String footerMl) throws OseeCoreException {
String pageTypeValue = null;
if (artifact.isAttributeTypeValid(CoreAttributeTypes.PageType)) {
pageTypeValue = artifact.getSoleAttributeValue(CoreAttributeTypes.PageType, "Portrait");
@@ -378,6 +382,9 @@ public class WordMLProducer extends Producer {
append("<w:p>");
append("<w:pPr>");
append("<w:sectPr>");
+ if (Strings.isValid(footerMl)) {
+ append(footerMl);
+ }
append("<w:pgSz w:w=\"15840\" w:h=\"12240\" w:orient=\"landscape\" w:code=\"1\" />");
append("</w:sectPr>");
append("</w:pPr>");
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 0c23ebcf04a..1d755f0f1e8 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
@@ -57,6 +57,7 @@ import org.eclipse.osee.framework.ui.skynet.render.PresentationType;
import org.eclipse.osee.framework.ui.skynet.render.RendererManager;
import org.eclipse.osee.framework.ui.skynet.render.RenderingUtil;
import org.eclipse.osee.framework.ui.skynet.render.WordTemplateRenderer;
+import org.eclipse.osee.framework.ui.skynet.render.word.WordTemplateProcessor.DataRightsProvider.FooterOption;
import org.eclipse.osee.framework.ui.skynet.util.WordUiUtil;
import org.eclipse.osee.framework.ui.swt.Displays;
import org.eclipse.swt.program.Program;
@@ -121,10 +122,18 @@ public class WordTemplateProcessor {
private String previousClassification = null;
private boolean firstArtifact = true;
private boolean dataRightsDetected = false;
+ private boolean previousWasLandscape = false;
private final DataRightsProvider dataRightsProvider;
public static interface DataRightsProvider {
- String getDataClassificationFooter(String classification, boolean createNewPageFooter);
+
+ public enum FooterOption {
+ NEW_PAGE,
+ SAME_PAGE,
+ FOOTER_ONLY
+ }
+
+ String getDataClassificationFooter(String classification, FooterOption option);
}
public WordTemplateProcessor(WordTemplateRenderer renderer, DataRightsProvider dataRightsProvider) {
@@ -273,8 +282,11 @@ public class WordTemplateProcessor {
for (Artifact artifact : artifacts) {
processObjectArtifact(artifact, wordMl, outlineType, presentationType, artifacts.size() > 1);
}
- if (dataRightsDetected) {
- String footer = dataRightsProvider.getDataClassificationFooter(previousClassification, false);
+
+ // if previous was landscape, it would've had the footer inserted in the setPageLayout
+ if (dataRightsDetected && !previousWasLandscape) {
+ String footer =
+ dataRightsProvider.getDataClassificationFooter(previousClassification, FooterOption.SAME_PAGE);
wordMl.addWordMl(footer);
}
}
@@ -397,6 +409,7 @@ public class WordTemplateProcessor {
dataRights = artifact.getSoleAttributeValueAsString(CoreAttributeTypes.DataRightsClassification, "");
dataRightsDetected = dataRightsDetected || Strings.isValid(dataRights);
+ boolean isLandscape = isLandscape(artifact);
handleLandscapeArtifactSectionBreak(artifact, wordMl, multipleArtifacts);
@@ -413,15 +426,20 @@ public class WordTemplateProcessor {
headingText = headingText.concat(" [MERGED]");
}
- if (!firstArtifact && !dataRights.equals(previousClassification)) {
- String footer = dataRightsProvider.getDataClassificationFooter(previousClassification, true);
- wordMl.addWordMl(footer);
+ String footer = null;
+ if (!firstArtifact && (!dataRights.equals(previousClassification) || isLandscape != previousWasLandscape)) {
+ footer =
+ dataRightsProvider.getDataClassificationFooter(previousClassification, FooterOption.NEW_PAGE);
} else if (dataRightsDetected && !Strings.isValid(dataRights)) {
- String footer = dataRightsProvider.getDataClassificationFooter(dataRights, true);
- wordMl.addWordMl(footer);
+ footer = dataRightsProvider.getDataClassificationFooter(dataRights, FooterOption.NEW_PAGE);
}
firstArtifact = false;
+ // if previous was landscape, it would've had the footer inserted in the setPageLayout
+ if (Strings.isValid(footer) && !previousWasLandscape) {
+ wordMl.addWordMl(footer);
+ }
+
if (!publishInline && !templateOnly) {
paragraphNumber = wordMl.startOutlineSubSection("Times New Roman", headingText, outlineType);
startedSection = true;
@@ -447,8 +465,9 @@ public class WordTemplateProcessor {
}
}
- processAttributes(artifact, wordMl, presentationType, multipleArtifacts, publishInline);
+ previousWasLandscape = isLandscape;
previousClassification = dataRights;
+ processAttributes(artifact, wordMl, presentationType, multipleArtifacts, publishInline);
}
// Check for option that may have been set from Publish with Diff BLAM to recurse
if ((recurseChildren && !renderer.getBooleanOption(RECURSE_ON_LOAD)) || (renderer.getBooleanOption(RECURSE_ON_LOAD) && !renderer.getBooleanOption("Orig Publish As Diff"))) {
@@ -468,14 +487,10 @@ public class WordTemplateProcessor {
}
private void handleLandscapeArtifactSectionBreak(Artifact artifact, WordMLProducer wordMl, boolean multipleArtifacts) throws OseeCoreException {
- String pageTypeValue = null;
// There is no reason to add an additional page break if there is a
// single artifacts
if (multipleArtifacts) {
- if (artifact.isAttributeTypeValid(CoreAttributeTypes.PageType)) {
- pageTypeValue = artifact.getSoleAttributeValue(CoreAttributeTypes.PageType, "Portrait");
- }
- boolean landscape = pageTypeValue != null && pageTypeValue.equals("Landscape");
+ boolean landscape = isLandscape(artifact);
if (landscape) {
wordMl.setPageBreak();
@@ -483,6 +498,15 @@ public class WordTemplateProcessor {
}
}
+ private boolean isLandscape(Artifact artifact) {
+ String pageTypeValue = null;
+ if (artifact.isAttributeTypeValid(CoreAttributeTypes.PageType)) {
+ pageTypeValue = artifact.getSoleAttributeValue(CoreAttributeTypes.PageType, "Portrait");
+ }
+ boolean landscape = pageTypeValue != null && pageTypeValue.equals("Landscape");
+ return landscape;
+ }
+
private void processAttributes(Artifact artifact, WordMLProducer wordMl, PresentationType presentationType, boolean multipleArtifacts, boolean publishInLine) throws OseeCoreException {
for (AttributeElement attributeElement : attributeElements) {
String attributeName = attributeElement.getAttributeName();
@@ -503,7 +527,11 @@ public class WordTemplateProcessor {
}
}
}
- wordMl.setPageLayout(artifact);
+ String footer = null;
+ if (dataRightsDetected) {
+ footer = dataRightsProvider.getDataClassificationFooter(previousClassification, FooterOption.FOOTER_ONLY);
+ }
+ wordMl.setPageLayout(artifact, footer);
}
private void processAttribute(Artifact artifact, WordMLProducer wordMl, AttributeElement attributeElement, IAttributeType attributeType, boolean allAttrs, PresentationType presentationType, boolean multipleArtifacts, boolean publishInLine) throws OseeCoreException {

Back to the top