Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package net.sf.gluebooster.java.booster.basic.text.general;
import java.util.Locale;
import java.util.ResourceBundle;
import net.sf.gluebooster.java.booster.basic.container.BoostedNode;
import net.sf.gluebooster.java.booster.basic.meta.DocumentationContext;
import net.sf.gluebooster.java.booster.basic.meta.HasDocumentation;
import net.sf.gluebooster.java.booster.essentials.eventsCommands.Callable;
import net.sf.gluebooster.java.booster.essentials.logging.LogBooster;
import net.sf.gluebooster.java.booster.essentials.meta.Documentation;
import net.sf.gluebooster.java.booster.essentials.utils.Check;
import net.sf.gluebooster.java.booster.essentials.utils.ContainerBoostUtils;
import net.sf.gluebooster.java.booster.essentials.utils.ReflectionBoostUtils;
/**
* {@Feature}Software documentation support.{@FeatureEnd} Utility
* methods for software documentation.
*
* @author CBauer
* @defaultParamText context the context of the creation. Contains the locale of
* the documentation. Missing data are filled in with defaults
* whenever possible a default changeListener is created, if
* no one is present.
* @defaultParamText content the creator of the documentation
* @defaultParamText closeRoot should the root be closed after finish. Only the
* closing may trigger the documentation writing.
*
*/
public class SoftwareDocumentationBoostUtils extends BookBoostUtils {
/**
* The default log.
*/
public static final LogBooster log = new LogBooster(SoftwareDocumentationBoostUtils.class);
/**
* The documentation types of a software documenation.
*/
public static final Object[] SOFTWARE_DOCUMENTATION_TYPES = {
DocumentationResourcesId.DOCUMENTATION_TECHNICAL,
DocumentationResourcesId.DOCUMENTATION_DEVELOPER,
DocumentationResourcesId.DOCUMENTATION_USER,
DocumentationResourcesId.DOCUMENTATION_MARKETING };
/**
* Creates the software documentation. The changeListener of the context is
* informed..
*
* @param addDefaultsWhenNecessary
* are default values inserted into the context
* @return the root node of the documentation
*/
@SuppressWarnings("unchecked")
public static BoostedNode createSoftwareDocumentation(
HasDocumentation content, DocumentationContext context)
throws Exception {
log.debug("beginn creating documentation");
BoostedNode bookshelf = BookBoostUtils.createBookshelf(null);
BoostedNode root = createSoftwareDocumentationSlipcase(bookshelf, content, context);
Callable writer = context.getDocumentationWriter();
if (writer != null) {
writer.call(bookshelf, context.getAttributes().getAttributesHashtable());
}
log.debug("beginn creating documentation ended");
return bookshelf;
}
/**
* Create a slipcase with the different software documentations.
*
* @param close
* is the slipcase to be closed immediately
* @param parent
* the parent of the slipcase
* @return the node of the created slipcase
*/
public static BoostedNode createSoftwareDocumentationSlipcase(BoostedNode parent, HasDocumentation content, DocumentationContext context) throws Exception {
log.debug("createSoftwareDocumentationSlipcase");
BoostedNode slipcase = createSlipcase(
parent,
context.getChangeListener(),
getDocumentationResourcesTranslation(context,
DocumentationResourcesId.SOFTWARE_DOCUMENTATION));
for (Object documentationType: SOFTWARE_DOCUMENTATION_TYPES){
log.debug("creating book " , documentationType);
BoostedNode bookNode = newZoomInBook(slipcase, documentationType, content, context);
context.getDocumentationTypeMap(documentationType, true).put(
BookBoostUtils.BOOK, bookNode);
if (context.getAttribute(DocumentationContext.DOCUMENTATION_CONTENT_GENERATORS) != null) {
for (HasDocumentation contentGenerator : (HasDocumentation[]) context.getAttribute(DocumentationContext.DOCUMENTATION_CONTENT_GENERATORS)) {
contentGenerator.fillDocumentation(documentationType, bookNode, context);
}
}
}
log.debug("createSoftwareDocumentationSlipcase ended");
return slipcase; //BoostedNode slipcase =
}
/**
* Create a new book that is result of a zoom in process.
*
* @param listener
* change listener of the new node.
* @param parent
* parent of the new node
* @param documentationType
* the type of the created book.
* @return the created book.
*/
@SuppressWarnings("unchecked")
public static BoostedNode newZoomInBook(BoostedNode parent,
Object documentationType, HasDocumentation content,
DocumentationContext context) throws Exception {
Check.notNull(context.getLocale(), "context.locale");
BoostedNode book = BookBoostUtils.createBook(
parent,
context,
getDocumentationResourcesTranslation(context,
documentationType), null);
// book.getAttributes().setType(BookBoostUtils.BOOK);
//todo create heading, title, etc.
content.fillDocumentation(documentationType, book, context);
return book;
}
/**
* Get the resource bundle with documentation resources that are used for
* translation.
*
* @param context
* contains the wanted locale
* @return the found bundle.
*/
private static ResourceBundle getDocumentationResourcesTranslation(DocumentationContext context){
return getDocumentationResourcesTranslation(context.getLocale());
}
/**
* Get the resource bundle with documentation resources that are used for
* translation.
*
* @param locale
* the wanted locale
* @return the found bundle.
*/
private static ResourceBundle getDocumentationResourcesTranslation(
Locale locale) {
return ContainerBoostUtils.getResourceBundle(
SoftwareDocumentationBoostUtils.class.getPackage().getName()
+ ".DocumentationResources", locale);
}
/**
* Translates a key of the DocumentationResources in a given documentation
* context.
*
* @param keyOfText
* must be one of the DocumentationResourcesId
* @return the translated key
*/
public static String getDocumentationResourcesTranslation(
DocumentationContext context, Object keyOfText) {
return getDocumentationResourcesTranslation(context).getString(
keyOfText.toString());
}
/**
* Translates a key of the DocumentationResources in a given locale.
*
* @param locale
* the wanted locale
*
* @param keyOfText
* must be one of the DocumentationResourcesId
* @return the translated key
*/
public static String getDocumentationResourcesTranslation(Locale locale,
Object keyOfText) {
return getDocumentationResourcesTranslation(locale).getString(
keyOfText.toString());
}
/**
* Adds documentation annotations to a document
*
* @param documentationParent
* the parent node in the document below which the annotations
* are inserted
* @param typeOfAnnotation
* the type of the documentation annotations that is added
* (Example DocumentationResourcesId.DOCUMENTATION_TECHNICAL)
* @param objectThatContainsTheAnnotations
* the object which annotations are evaluated
* @throws Exception
*/
public static void addDocumentationAnnotations(
BoostedNode documentationParent, DocumentationContext context,
Object typeOfAnnotation, Object objectThatContainsTheAnnotations)
throws Exception {
if (typeOfAnnotation == null)
typeOfAnnotation = "";
for (Documentation documentation : ReflectionBoostUtils
.getDocumentationAnnotations(objectThatContainsTheAnnotations,
context.getLocale())) {
if ("".equals(documentation.type())
|| typeOfAnnotation.equals(documentation.type()))
BookBoostUtils.createDiv(documentationParent,
documentation.text());
}
}
}