Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2008-11-13 17:30:57 +0000
committerrbrooks2008-11-13 17:30:57 +0000
commit7dd7a5317bd043d65e38925e7e6990fe65ecb662 (patch)
treee8717d7b811a861661d198c0512417c9b930e185 /org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet
parentdab100a3c288cbb16d5a8eb3c8d8fa635e8537a5 (diff)
downloadorg.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.tar.gz
org.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.tar.xz
org.eclipse.osee-7dd7a5317bd043d65e38925e7e6990fe65ecb662.zip
"Team Workflow" - J9HHT - "Improve rendering design to make it more extensible"
Diffstat (limited to 'org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet')
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java220
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java2
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ITemplateRenderer.java2
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/Renderer.java15
-rw-r--r--org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java2
5 files changed, 129 insertions, 112 deletions
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java
index 69af685aa31..b83c60dcc2a 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/blam/VariableMap.java
@@ -1,111 +1,111 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.blam;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import org.eclipse.osee.framework.db.connection.exception.OseeArgumentException;
-import org.eclipse.osee.framework.skynet.core.User;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.ArtifactType;
-import org.eclipse.osee.framework.skynet.core.artifact.Branch;
-import org.eclipse.osee.framework.skynet.core.attribute.AttributeType;
-
-/**
- * @author Ryan D. Brooks
- */
-public class VariableMap {
- private final HashMap<String, Object> variableMap = new HashMap<String, Object>();
-
- public VariableMap() {
- }
-
- /**
- * @throws OseeArgumentException
- */
- public VariableMap(Object... optionArgs) throws OseeArgumentException {
- for (int i = 0; i < optionArgs.length; i += 2) {
- if (optionArgs[i] instanceof String) {
- variableMap.put((String) optionArgs[i], optionArgs[i + 1]);
- } else if (optionArgs[i] == null) {
- throw new OseeArgumentException(String.format("The %dth option must not be null", i));
- } else {
- throw new OseeArgumentException(String.format("The %dth option must be of type string but is of type %s",
- i, optionArgs[i].getClass().getName()));
- }
- }
- }
-
- public void setValue(String variableName, Object value) {
- variableMap.put(variableName, value);
- }
-
- public ArtifactType getArtifactType(String parameterName) throws OseeArgumentException {
- return getSingleCollectionValue(ArtifactType.class, parameterName);
- }
-
- public AttributeType getAttributeType(String parameterName) throws OseeArgumentException {
- return getSingleCollectionValue(AttributeType.class, parameterName);
- }
-
- public String getString(String parameterName) throws OseeArgumentException {
- return getValue(String.class, parameterName);
- }
-
- public Branch getBranch(String parameterName) throws OseeArgumentException {
- return getValue(Branch.class, parameterName);
- }
-
- public boolean getBoolean(String parameterName) throws OseeArgumentException {
- return getValue(Boolean.class, parameterName) != null && getValue(Boolean.class, parameterName);
- }
-
- @SuppressWarnings("unchecked")
- public <T> Collection<T> getCollection(Class<T> clazz, String parameterName) throws OseeArgumentException {
- return getValue(Collection.class, parameterName);
- }
-
- public User getUser(String parameterName) throws OseeArgumentException {
- return getValue(User.class, parameterName);
- }
-
- public List<Artifact> getArtifacts(String parameterName) throws OseeArgumentException {
- Collection<Artifact> artiafcts = getCollection(Artifact.class, parameterName);
- if (artiafcts == null) {
- return new ArrayList<Artifact>();
- }
- return new ArrayList<Artifact>(artiafcts);
- }
-
- private <T> T getSingleCollectionValue(Class<T> clazz, String parameterName) throws OseeArgumentException {
- Collection<T> objects = getCollection(clazz, parameterName);
- if (objects.size() != 1) {
- throw new OseeArgumentException("Require a collection of size 1 not " + objects.size());
- }
- return objects.iterator().next();
- }
-
- private <T> T getValue(Class<T> clazz, String variableName) throws OseeArgumentException {
- Object value = variableMap.get(variableName);
-
- if (value != null && !clazz.isInstance(value)) {
- throw new OseeArgumentException(
- "Expecting object of type " + clazz.getName() + " not " + value.getClass().getName());
- }
- return clazz.cast(value);
- }
-
- public Object getValue(String variableName) throws OseeArgumentException {
- return variableMap.get(variableName);
- }
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 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.blam;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import org.eclipse.osee.framework.db.connection.exception.OseeArgumentException;
+import org.eclipse.osee.framework.skynet.core.User;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactType;
+import org.eclipse.osee.framework.skynet.core.artifact.Branch;
+import org.eclipse.osee.framework.skynet.core.attribute.AttributeType;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public class VariableMap {
+ private final HashMap<String, Object> variableMap = new HashMap<String, Object>();
+
+ public VariableMap() {
+ }
+
+ /**
+ * @throws OseeArgumentException
+ */
+ public VariableMap(Object... optionArgs) throws OseeArgumentException {
+ for (int i = 0; i < optionArgs.length; i += 2) {
+ if (optionArgs[i] instanceof String) {
+ variableMap.put((String) optionArgs[i], optionArgs[i + 1]);
+ } else if (optionArgs[i] == null) {
+ throw new OseeArgumentException(String.format("The %dth option must not be null", i));
+ } else {
+ throw new OseeArgumentException(String.format("The %dth option must be of type string but is of type %s",
+ i, optionArgs[i].getClass().getName()));
+ }
+ }
+ }
+
+ public void setValue(String variableName, Object value) {
+ variableMap.put(variableName, value);
+ }
+
+ public ArtifactType getArtifactType(String parameterName) throws OseeArgumentException {
+ return getSingleCollectionValue(ArtifactType.class, parameterName);
+ }
+
+ public AttributeType getAttributeType(String parameterName) throws OseeArgumentException {
+ return getSingleCollectionValue(AttributeType.class, parameterName);
+ }
+
+ public String getString(String parameterName) throws OseeArgumentException {
+ return getValue(String.class, parameterName);
+ }
+
+ public Branch getBranch(String parameterName) throws OseeArgumentException {
+ return getValue(Branch.class, parameterName);
+ }
+
+ public Boolean getBoolean(String parameterName) throws OseeArgumentException {
+ return getValue(Boolean.class, parameterName);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> Collection<T> getCollection(Class<T> clazz, String parameterName) throws OseeArgumentException {
+ return getValue(Collection.class, parameterName);
+ }
+
+ public User getUser(String parameterName) throws OseeArgumentException {
+ return getValue(User.class, parameterName);
+ }
+
+ public List<Artifact> getArtifacts(String parameterName) throws OseeArgumentException {
+ Collection<Artifact> artiafcts = getCollection(Artifact.class, parameterName);
+ if (artiafcts == null) {
+ return new ArrayList<Artifact>();
+ }
+ return new ArrayList<Artifact>(artiafcts);
+ }
+
+ private <T> T getSingleCollectionValue(Class<T> clazz, String parameterName) throws OseeArgumentException {
+ Collection<T> objects = getCollection(clazz, parameterName);
+ if (objects.size() != 1) {
+ throw new OseeArgumentException("Require a collection of size 1 not " + objects.size());
+ }
+ return objects.iterator().next();
+ }
+
+ private <T> T getValue(Class<T> clazz, String variableName) throws OseeArgumentException {
+ Object value = variableMap.get(variableName);
+
+ if (value != null && !clazz.isInstance(value)) {
+ throw new OseeArgumentException(
+ "Expecting object of type " + clazz.getName() + " not " + value.getClass().getName());
+ }
+ return clazz.cast(value);
+ }
+
+ public Object getValue(String variableName) throws OseeArgumentException {
+ return variableMap.get(variableName);
+ }
} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java
index 62815a42570..94a8c7e4660 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/IRenderer.java
@@ -71,6 +71,8 @@ public interface IRenderer {
public abstract String getStringOption(String key) throws OseeArgumentException;
+ public abstract boolean getBooleanOption(String key) throws OseeArgumentException;
+
public abstract VariableMap getOptions();
public abstract IRenderer newInstance() throws OseeCoreException;
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ITemplateRenderer.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ITemplateRenderer.java
index 87ee5ea23e7..2488720e86d 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ITemplateRenderer.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/ITemplateRenderer.java
@@ -16,7 +16,7 @@ package org.eclipse.osee.framework.ui.skynet.render;
public interface ITemplateRenderer extends IRenderer {
public static final String TEMPLATE_OPTION = "template";
public static final String TRANSACTION_OPTION = "skynetTransaction";
- public static final String PREVIEW_WITH_RECURSE_VALUE = "PREVIEW_WITH_RECURSE_OPTION_PAIR";
+ public static final String PREVIEW_WITH_RECURSE_VALUE = "PREVIEW_WITH_RECURSE";
public static final Object[] PREVIEW_WITH_RECURSE_OPTION_PAIR =
new String[] {TEMPLATE_OPTION, PREVIEW_WITH_RECURSE_VALUE};
}
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/Renderer.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/Renderer.java
index 4558def2a8d..6430688f8a7 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/Renderer.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/Renderer.java
@@ -204,4 +204,19 @@ public abstract class Renderer implements IRenderer {
public String getStringOption(String key) throws OseeArgumentException {
return options == null ? null : options.getString(key);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.osee.framework.ui.skynet.render.IRenderer#getBooleanOption(java.lang.String)
+ */
+ @Override
+ public boolean getBooleanOption(String key) throws OseeArgumentException {
+ if (options != null) {
+ Boolean option = options.getBoolean(key);
+ if (option != null) {
+ return option;
+ }
+ }
+ return false;
+ }
+
} \ No newline at end of file
diff --git a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
index 7c7426aafa0..98071269552 100644
--- a/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
+++ b/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/render/word/WordTemplateProcessor.java
@@ -431,7 +431,7 @@ public class WordTemplateProcessor {
CharSequence paragraphNumber = wordMl.startOutlineSubSection("Times New Roman", headingText, outlineType);
VariableMap options = renderer.getOptions();
- if (paragraphNumber != null && options != null && options.getBoolean(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION)) {
+ if (renderer.getBooleanOption(WordTemplateRenderer.UPDATE_PARAGRAPH_NUMBER_OPTION)) {
if (artifact.isAttributeTypeValid("Imported Paragraph Number")) {
artifact.setSoleAttributeValue("Imported Paragraph Number", paragraphNumber.toString());
artifact.persistAttributes((SkynetTransaction) options.getValue(WordTemplateRenderer.TRANSACTION_OPTION));

Back to the top