/** * Imports the mappings defined in the RtfImportMappings into the * RtfImportHeader of this RtfParser2. * * @param importMappings * The RtfImportMappings to import. * @since 2.1.3 */ private void handleImportMappings(RtfImportMappings importMappings) { Iterator it = importMappings.getFontMappings().keySet().iterator(); while(it.hasNext()) { String fontNr = (String) it.next(); this.importMgr.importFont(fontNr, (String) importMappings.getFontMappings().get(fontNr)); } it = importMappings.getColorMappings().keySet().iterator(); while(it.hasNext()) { String colorNr = (String) it.next(); this.importMgr.importColor(colorNr, (Color) importMappings.getColorMappings().get(colorNr)); } it = importMappings.getListMappings().keySet().iterator(); while(it.hasNext()) { String listNr = (String) it.next(); this.importMgr.importList(listNr, (String)importMappings.getListMappings().get(listNr)); } it = importMappings.getStylesheetListMappings().keySet().iterator(); while(it.hasNext()) { String stylesheetListNr = (String) it.next(); this.importMgr.importStylesheetList(stylesheetListNr, (List) importMappings.getStylesheetListMappings().get(stylesheetListNr)); } }
/** * This method handles the filtered blogs. * * @param resourcesManager * {@link ResourceBundleManager}. * @param locale * The locale. * @param filters * {@link List}. * @param utpExt * {@link TaggingCoreItemUTPExtension}. */ private void handleBlogFilter(ResourceBundleManager resourcesManager, Locale locale, List filters, TaggingCoreItemUTPExtension utpExt) { if (utpExt.getBlogFilter() != null) { Collection<Blog> blogs = ServiceLocator.instance().getService(BlogManagement.class) .findBlogsById(utpExt.getBlogFilter()); if (blogs != null && blogs.size() > 0) { Collection<String> titles = new ArrayList<String>(blogs.size()); String localizedBlogTitle = StringUtils.EMPTY; for (Blog b : blogs) { localizedBlogTitle = b.getTitle(); titles.add(localizedBlogTitle); } filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.blog", locale, StringUtils.join(titles, ", ")))); } } }
/** * Handles the flags denoting whether only favorite, followed or direct items are to be * retrieved. * * @param queryInstance * The {@link NoteQueryParameters} * @param locale * The locale. * @param resourcesManager * {@link ResourceBundleManager}. * @param filters * Filters as {@link List}. */ private void handleFollowFavoriteDirectOnly(NoteQueryParameters queryInstance, Locale locale, ResourceBundleManager resourcesManager, List filters) { if (queryInstance.isRetrieveOnlyFollowedItems()) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.follow", locale))); } if (queryInstance.isFavorites()) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.favorite", locale))); } if (queryInstance.isDirectMessage()) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.direct.only", locale))); } }
/** * This method handles the parent post. * * @param resourcesManager * {@link ResourceBundleManager}. * @param dateFormatter * Date formatter. * @param locale * The local. * @param filters * Filters as {@link List}. * @param utpExt * {@link TaggingCoreItemUTPExtension}. * @throws NoteNotFoundException * exception. * @throws AuthorizationException * Exception. */ private void handleParentPostFilter(ResourceBundleManager resourcesManager, DateFormat dateFormatter, Locale locale, List filters, TaggingCoreItemUTPExtension utpExt) throws NoteNotFoundException, AuthorizationException { if (utpExt.getParentPostId() == null) { return; } // no need to pass a render mode and trigger the pre-processors because we are only // interested in the author NoteData noteData = ServiceLocator.instance().getService(NoteService.class) .getNote(utpExt.getParentPostId(), new NoteRenderContext(null, locale)); if (noteData != null) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.parentpost", locale, UserNameHelper.getDetailedUserSignature(noteData.getUser()), dateFormatter.format(noteData.getCreationDate().getTime())))); } }
/** * This method handles the set tags. * * @param tagFormula * the tag formula * @param tagIds * Id's of filtered tags. * @param locale * The locale. * @param resourcesManager * The {@link ResourceBundleManager}. * @param filters * The filters to be added to. */ private void handleTagsFilter(LogicalTagFormula tagFormula, Set<Long> tagIds, Locale locale, ResourceBundleManager resourcesManager, List filters) { String tags = FilterParameterResolver.getInstance().resolveTags(tagFormula); if (tagIds != null && !tagIds.isEmpty()) { tags = StringUtils.isBlank(tags) ? "" : tags + ","; TagManagement tagManagement = ServiceLocator.instance().getService(TagManagement.class); String prefix = ""; for (Long tagId : tagIds) { Tag storedTag = tagManagement.findTag(tagId); if (storedTag != null) { tags = tags + prefix + storedTag.getName(); prefix = ","; } } } if (StringUtils.isNotBlank(tags)) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.tags", locale, tags))); } }
/** * This method handles the users to be notified filter string. * * @param resourcesManager * The {@link ResourceBundleManager}. * @param locale * The locale. * @param filters * The list of filters. * @param usersToBeNotifiedAsLong * The list of users. */ private void handleUsersFilter(ResourceBundleManager resourcesManager, Locale locale, List filters, Long[] usersToBeNotifiedAsLong) { if (!ArrayUtils.isEmpty(usersToBeNotifiedAsLong)) { final Collection<String> usersToBeNotified = new ArrayList<String>(); for (Long id : usersToBeNotifiedAsLong) { ServiceLocator.findService(UserManagement.class).getUserById(id, new Converter<User, Object>() { @Override public Object convert(User source) { usersToBeNotified.add(UserNameHelper .getDetailedUserSignature(source)); return null; } }); } if (!usersToBeNotified.isEmpty()) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.usernotify", locale, StringUtils.join(usersToBeNotified, ", ")))); } } }
/** * creates the intentional elements in the report * * @param document * the document in which the report is created * @param grlspec * the grl specification used to retrieve elements */ public void writeIntElements(Document document, GRLspec grlspec) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.IntentionalElements"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); list1.setIndentationLeft(10); for (Iterator iter = grlspec.getIntElements().iterator(); iter.hasNext();) { // generate report documentation for intentional elements (name, description, criticality, priority) IntentionalElement intElement = (IntentionalElement) iter.next(); list1.add(new ListItem(ReportUtils .getParagraphWithSeparator(document, intElement.getName(), ": ", intElement.getDescription(), descriptionFont))); //$NON-NLS-1$ } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * creates the actors in the report * * @param document * the document in which the report is created * @param grlspec * the grl specification used to retrieve elements */ public void writeActors(Document document, GRLspec grlspec) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.Actors"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); list1.setIndentationLeft(10); for (Iterator iter = grlspec.getActors().iterator(); iter.hasNext();) { // generate report documentation for actors(name, description) Actor actor = (Actor) iter.next(); list1.add(new ListItem(ReportUtils.getParagraphWithSeparator(document, actor.getName(), ": ", actor.getDescription(), descriptionFont))); //$NON-NLS-1$ } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * creates the responsibilities in the report * * @param document * the document in which the report is created * @param urndef * the urn definition used to retrieve elements */ public void writeResponsibilities(Document document, URNdefinition urndef) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.Responsibilities"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); list1.setIndentationLeft(10); for (Iterator iter = urndef.getResponsibilities().iterator(); iter.hasNext();) { Responsibility responsibility = (Responsibility) iter.next(); list1.add(new ListItem(ReportUtils.getParagraphWithSeparator(document, responsibility.getName(), ": ", responsibility.getDescription(), //$NON-NLS-1$ descriptionFont))); } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * creates the responsibilities in the report * * @param document * the document in which the report is created * @param urndef * the urn definition used to retrieve elements */ public void writeComponents(Document document, URNdefinition urndef) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.Components"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); list1.setIndentationLeft(10); for (Iterator iter = urndef.getComponents().iterator(); iter.hasNext();) { Component component = (Component) iter.next(); list1 .add(new ListItem(ReportUtils.getParagraphWithSeparator(document, component.getName(), ": ", component.getDescription(), //$NON-NLS-1$ descriptionFont))); } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
private void addList(List list, float left, float right, int alignment) { PdfChunk chunk; PdfChunk overflow; ArrayList allActions = new ArrayList(); processActions(list, null, allActions); int aCounter = 0; for (Iterator it = list.getItems().iterator(); it.hasNext();) { Element ele = (Element)it.next(); switch (ele.type()) { case Element.LISTITEM: ListItem item = (ListItem)ele; line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading()); line.setListItem(item); for (Iterator j = item.getChunks().iterator(); j.hasNext();) { chunk = new PdfChunk((Chunk) j.next(), (PdfAction) (allActions.get(aCounter++))); while ((overflow = line.add(chunk)) != null) { addLine(line); line = new PdfLine(left + item.getIndentationLeft(), right, alignment, item.getLeading()); chunk = overflow; } line.resetAlignment(); addLine(line); line = new PdfLine(left + item.getIndentationLeft(), right, alignment, leading); } break; case Element.LIST: List sublist = (List)ele; addList(sublist, left + sublist.getIndentationLeft(), right, alignment); break; } } }
/** * Processes all actions contained in the cell. * @param element an element in the cell * @param action an action that should be coupled to the cell * @param allActions */ protected void processActions(Element element, PdfAction action, ArrayList allActions) { if (element.type() == Element.ANCHOR) { String url = ((Anchor) element).getReference(); if (url != null) { action = new PdfAction(url); } } Iterator i; switch (element.type()) { case Element.PHRASE: case Element.SECTION: case Element.ANCHOR: case Element.CHAPTER: case Element.LISTITEM: case Element.PARAGRAPH: for (i = ((ArrayList) element).iterator(); i.hasNext();) { processActions((Element) i.next(), action, allActions); } break; case Element.CHUNK: allActions.add(action); break; case Element.LIST: for (i = ((List) element).getItems().iterator(); i.hasNext();) { processActions((Element) i.next(), action, allActions); } break; default: int n = element.getChunks().size(); while (n-- > 0) allActions.add(action); break; } }
/** * Imports a stylesheet list value. The stylesheet number for the stylesheet defined * is determined and then the resulting mapping is added. */ public boolean importStylesheetList(String listNr, List listIn) { RtfList rtfList = new RtfList(this.rtfDoc, listIn); rtfList.setRtfDocument(this.rtfDoc); // TODO HGS - Finish implementation of import //this.importStylesheetListMapping.put(listNr, Integer.toString(this.rtfDoc.getDocumentHeader().getRtfParagraphStyle(styleName)(rtfList))); return true; }
/** * This method handles the start and end date of filters. * * @param queryInstance * The {@link NoteQueryParameters} * @param locale * The locale. * @param dateFormatter * Date formater. * @param resourcesManager * {@link ResourceBundleManager}. * @param filters * Filters as {@link List}. */ private void handleDatesFilter(NoteQueryParameters queryInstance, Locale locale, DateFormat dateFormatter, ResourceBundleManager resourcesManager, List filters) { String startDateString = (queryInstance.getLowerTagDate() != null) ? dateFormatter .format(queryInstance.getLowerTagDate()) : null; String endDateString = (queryInstance.getUpperTagDate() != null) ? dateFormatter .format(queryInstance.getUpperTagDate()) : null; String msgKeyPart = null; String[] dateArgs = null; if (StringUtils.isNotEmpty(startDateString)) { msgKeyPart = "after"; dateArgs = new String[] { startDateString }; } if (StringUtils.isNotEmpty(endDateString)) { if (msgKeyPart != null) { if (endDateString.equals(startDateString)) { msgKeyPart = "at"; } else { dateArgs = new String[] { startDateString, endDateString }; msgKeyPart = "between"; } } else { msgKeyPart = "before"; dateArgs = new String[] { endDateString }; } } if (msgKeyPart != null) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.date." + msgKeyPart, locale, (Object[]) dateArgs))); } }
/** * creates the scenario groups in the report * * @param document * the document in which the report is created * @param ucmspec * the ucm specification used to retrieve elements */ public void writeScenarioGroups(Document document, UCMspec ucmspec) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.UCMScenarioGroupsDocumentation"), header1Font)); //$NON-NLS-1$ for (Iterator iter = ucmspec.getScenarioGroups().iterator(); iter.hasNext();) { ScenarioGroup group = (ScenarioGroup) iter.next(); // generate report documentation for ScenarioGroup if (group != null) { // create list for this scenario group String sScenarioGroupName = new String(group.getName()); List list1 = new List(List.UNORDERED); list1.add(new ListItem(sScenarioGroupName + ":")); //$NON-NLS-1$ document.add(list1); if (group.getScenarios() != null) { // scenario description List list2 = new List(List.ORDERED); for (Iterator iterator = group.getScenarios().iterator(); iterator.hasNext();) { // create a list for the scenario group ScenarioDef scen = (ScenarioDef) iterator.next(); list2.setIndentationLeft(10); list2.add(new ListItem(ReportUtils .getParagraphWithSeparator(document, scen.getName(), ": ", scen.getDescription(), descriptionFont))); //$NON-NLS-1$ } document.add(list2); } } } // TODO get scenarios diagrams } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * creates the variables in the report * * @param document * the document in which the report is created * @param ucmspec * the ucm specification used to retrieve elements */ public void writeVariables(Document document, UCMspec ucmspec) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.Variables"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); for (Iterator iter = ucmspec.getVariables().iterator(); iter.hasNext();) { // generate report documentation for variables Variable var = (Variable) iter.next(); if (var != null) { String varName = var.getName(); String varType = var.getType(); String varDescription = var.getDescription(); list1.setIndentationLeft(10); if (var.getEnumerationType() != null) { // the variable type is enumeration String enumType = var.getEnumerationType().getName(); list1.add(new ListItem(ReportUtils.getParagraphWithSeparator(document, var.getName() + Messages.getString("ReportDataDictionary.ParEnum") + enumType + Messages.getString("ReportDataDictionary.ParEnumClose"), ": ", var //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ .getDescription(), descriptionFont))); } else list1.add(new ListItem(ReportUtils.getParagraphWithSeparator(document, var.getName() + " (" + varType + ")", ": ", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ var.getDescription(), descriptionFont))); } } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
protected ArrayList extractRows(ArrayList cells, RenderingContext ctx) { PdfCell cell; PdfCell previousCell = null; ArrayList rows = new ArrayList(); java.util.List rowCells = new ArrayList(); Iterator iterator = cells.iterator(); while (iterator.hasNext()) { cell = (PdfCell) iterator.next(); boolean isAdded = false; boolean isEndOfRow = !iterator.hasNext(); boolean isCurrentCellPartOfRow = !iterator.hasNext(); if (previousCell != null) { if (cell.getLeft() <= previousCell.getLeft()) { isEndOfRow = true; isCurrentCellPartOfRow = false; } } if (isCurrentCellPartOfRow) { rowCells.add(cell); isAdded = true; } if (isEndOfRow) { if (!rowCells.isEmpty()) { // add to rowlist rows.add(rowCells); } // start a new list for next line rowCells = new ArrayList(); } if (!isAdded) { rowCells.add(cell); } previousCell = cell; } if (!rowCells.isEmpty()) { rows.add(rowCells); } // fill row information with rowspan cells to get complete "scan lines" for (int i = rows.size() - 1; i >= 0; i--) { ArrayList row = (ArrayList) rows.get(i); // iterator through row for (int j = 0; j < row.size(); j++) { PdfCell c = (PdfCell) row.get(j); int rowspan = c.rowspan(); // fill in missing rowspan cells to complete "scan line" for (int k = 1; k < rowspan && rows.size() < i+k; k++) { ArrayList spannedRow = ((ArrayList) rows.get(i + k)); if (spannedRow.size() > j) spannedRow.add(j, c); } } } return rows; }
/** * Creates a List object based on a list of properties. * @param attributes * @return the List */ public static List getList(Properties attributes) { List list = new List(); list.setNumbered(Utilities.checkTrueOrFalse(attributes, ElementTags.NUMBERED)); list.setLettered(Utilities.checkTrueOrFalse(attributes, ElementTags.LETTERED)); list.setLowercase(Utilities.checkTrueOrFalse(attributes, ElementTags.LOWERCASE)); list.setAutoindent(Utilities.checkTrueOrFalse(attributes, ElementTags.AUTO_INDENT_ITEMS)); list.setAlignindent(Utilities.checkTrueOrFalse(attributes, ElementTags.ALIGN_INDENTATION_ITEMS)); String value; value = attributes.getProperty(ElementTags.FIRST); if (value != null) { char character = value.charAt(0); if (Character.isLetter(character)) { list.setFirst(character); } else { list.setFirst(Integer.parseInt(value)); } } value = attributes.getProperty(ElementTags.LISTSYMBOL); if (value != null) { list .setListSymbol(new Chunk(value, FontFactory .getFont(attributes))); } value = attributes.getProperty(ElementTags.INDENTATIONLEFT); if (value != null) { list.setIndentationLeft(Float.parseFloat(value + "f")); } value = attributes.getProperty(ElementTags.INDENTATIONRIGHT); if (value != null) { list.setIndentationRight(Float.parseFloat(value + "f")); } value = attributes.getProperty(ElementTags.SYMBOLINDENT); if (value != null) { list.setSymbolIndent(Float.parseFloat(value)); } return list; }
/** * This method returns the current filter settings as an unordered list. * * @param queryParameters * The query instance with filter settings. * @param resourcesManager * The {@link ResourceBundleManager}. * @param user * The user. * @param dateFormatter * Date formater. * @throws NoteNotFoundException * NoteNotFoundException * @throws AuthorizationException * Exception. * @return Filters as {@link List}. */ private Element getFilters(NoteQueryParameters queryParameters, User user, DateFormat dateFormatter, ResourceBundleManager resourcesManager) throws NoteNotFoundException, AuthorizationException { List filters = new List(List.UNORDERED); filters.setIndentationLeft(20); if (queryParameters.getNoteId() != null) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.single.post", user.getLanguageLocale()))); return filters; } handleFollowFavoriteDirectOnly(queryParameters, user.getLanguageLocale(), resourcesManager, filters); TaggingCoreItemUTPExtension utpExt = queryParameters.getTypeSpecificExtension(); handleUsersFilter(resourcesManager, user.getLanguageLocale(), filters, queryParameters.getUserToBeNotified()); handleParentPostFilter(resourcesManager, dateFormatter, user.getLanguageLocale(), filters, utpExt); handleDatesFilter(queryParameters, user.getLanguageLocale(), dateFormatter, resourcesManager, filters); handleBlogFilter(resourcesManager, user.getLanguageLocale(), filters, utpExt); handleDiscussionFilter(resourcesManager, user.getLanguageLocale(), dateFormatter, queryParameters.getDiscussionId(), filters); if (queryParameters.getUserIds() != null) { final Collection<String> authorList = new ArrayList<String>(); for (Long id : queryParameters.getUserIds()) { ServiceLocator.instance().getService(UserManagement.class) .getUserById(id, new Converter<User, Object>() { @Override public Object convert(User source) { authorList.add(UserNameHelper.getDetailedUserSignature(source)); return null; } }); } filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.authors", user.getLanguageLocale(), StringUtils.join(authorList, ", ")))); } handleTagsFilter(queryParameters.getLogicalTags(), queryParameters.getTagIds(), user.getLanguageLocale(), resourcesManager, filters); handleUserSearchFilter(queryParameters.getUserSearchFilters(), user.getLanguageLocale(), resourcesManager, filters); if (queryParameters.getFullTextSearchFilters() != null) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.text", user.getLanguageLocale(), StringUtils.join(queryParameters.getFullTextSearchFilters(), " ")))); } if (filters.size() == 0) { Font italic = new Font(); italic.setSize(10); italic.setStyle(Font.ITALIC); Element empty = RtfElementFactory.createListItem( resourcesManager.getText("export.postlist.filter.none", user.getLanguageLocale()), italic); filters.add(empty); } return filters; }
/** * creates the enumeration types in the report * * @param document * the document in which the report is created * @param ucmspec * the ucm specification used to retrieve elements */ public void writeEnumerationTypes(Document document, UCMspec ucmspec) { try { document.add(new Paragraph(Messages.getString("ReportDataDictionary.EnumerationTypes"), header1Font)); //$NON-NLS-1$ List list1 = new List(List.ORDERED); list1.setIndentationLeft(10); for (Iterator iter = ucmspec.getEnumerationTypes().iterator(); iter.hasNext();) { // generate report documentation for variables EnumerationType enumType = (EnumerationType) iter.next(); String enumTypeName = enumType.getName(); String enumString = new String(""); //$NON-NLS-1$ if (enumType.getValues() != null) { Chunk chunk1 = new Chunk(enumTypeName, descriptionFont); String[] enumValues = enumType.getValues().split(","); //$NON-NLS-1$ if (enumValues[0] != null) { if (enumValues[0].length() == 0) { enumString = enumString + enumTypeName; } else { enumString = enumString + enumTypeName + ": "; //$NON-NLS-1$ } } else { enumString = enumString + enumTypeName; } for (int i = 0; i < enumValues.length; i++) { enumString = enumString + enumValues[i]; // checks if last element if (!(i == enumValues.length - 1)) { enumString = enumString + ", "; //$NON-NLS-1$ } } } list1.add(enumString); } document.add(list1); } catch (Exception e) { jUCMNavErrorDialog error = new jUCMNavErrorDialog(e.getMessage()); e.printStackTrace(); } }
/** * This method handles the user search filter. * * @param userSearchFilters * List of users to be searched for. * @param locale * The locale. * @param resourcesManager * The {@link ResourceBundleManager}. * @param filters * The list of filters. */ private void handleUserSearchFilter(String[] userSearchFilters, Locale locale, ResourceBundleManager resourcesManager, List filters) { if (!ArrayUtils.isEmpty(userSearchFilters)) { filters.add(RtfElementFactory.createListItem(resourcesManager.getText( "export.postlist.filter.usertext", locale, StringUtils.join(userSearchFilters, ", ")))); } }