public void init() { log.debug("Initializing StyleCreator"); versions = currentContentItem.getVersions(); if (versions == null) { return; } if (perRevision) { numberOfColours = versions.size(); } else { HashMap<String, Set<CIVersion>> styles = new HashMap<String, Set<CIVersion>>(); for (CIVersion v : versions) { if (v.getTextContentUpdate() != null) { User user = v.getRevision().getUser(); if (!styles.containsKey(user.getLogin())) { Set<CIVersion> revSet = new HashSet<CIVersion>(); revSet.add(v); styles.put(user.getLogin(), revSet); } else { Set<CIVersion> revSet = styles.get(user.getLogin()); revSet.add(v); } } } this.styles = styles; numberOfColours = styles.size(); } }
public void generateStyle() { log.debug("Generating Style"); if (styles != null) { colourLegend.clear(); List<String> colours = calcColours(); if (perRevision) { SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy"); for (CIVersion v : versions) { String content = "<span class=\"revision_" + v.getId() + "\">Revision " + v.getId() + " (" + df.format(v.getRevision().getCreationDate()) + ")</span>"; v.setColour(colours.get(0)); colourLegend.add(content); colours.remove(0); } } else { for (String login : styles.keySet()) { for (CIVersion r : styles.get(login)) { r.setColour(colours.get(0)); } String content = "<span class=\"revision_" + styles.get(login).iterator().next().getId() + "\">User: "******"</span>"; colourLegend.add(content); colours.remove(0); } } } }