diff --git a/config/alfresco/web-client-application-context.xml b/config/alfresco/web-client-application-context.xml index c047252535..172d097fa2 100644 --- a/config/alfresco/web-client-application-context.xml +++ b/config/alfresco/web-client-application-context.xml @@ -8,6 +8,7 @@ alfresco/web-client-config.xml alfresco/web-client-config-edit-properties.xml + alfresco/web-client-config-icons.xml diff --git a/config/alfresco/web-client-config-icons.xml b/config/alfresco/web-client-config-icons.xml new file mode 100644 index 0000000000..98da12e776 --- /dev/null +++ b/config/alfresco/web-client-config-icons.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index f9fa193ad9..5ff4136fa0 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -174,6 +174,7 @@ + diff --git a/source/java/org/alfresco/web/bean/wizard/NewForumWizard.java b/source/java/org/alfresco/web/bean/wizard/NewForumWizard.java index ee889b6e78..66c596a86d 100644 --- a/source/java/org/alfresco/web/bean/wizard/NewForumWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/NewForumWizard.java @@ -17,7 +17,6 @@ */ package org.alfresco.web.bean.wizard; -import java.util.ArrayList; import java.util.List; import javax.faces.context.FacesContext; @@ -32,8 +31,6 @@ import org.alfresco.web.ui.common.component.UIListItem; */ public class NewForumWizard extends NewSpaceWizard { - public static final String FORUM_ICON_DEFAULT = "forum_large"; - protected String forumStatus; protected List forumIcons; @@ -66,31 +63,8 @@ public class NewForumWizard extends NewSpaceWizard super.init(); this.spaceType = ForumModel.TYPE_FORUM.toString(); - this.icon = FORUM_ICON_DEFAULT; this.forumStatus = "0"; } - - /** - * Returns a list of icons to allow the user to select from. - * - * @return A list of icons - */ - @SuppressWarnings("unchecked") - public List getIcons() - { - // return the various forum icons - if (this.forumIcons == null) - { - this.forumIcons = new ArrayList(1); - - UIListItem item = new UIListItem(); - item.setValue(FORUM_ICON_DEFAULT); - item.getAttributes().put("image", "/images/icons/forum_large.gif"); - this.forumIcons.add(item); - } - - return this.forumIcons; - } /** * @see org.alfresco.web.bean.wizard.NewSpaceWizard#performCustomProcessing(javax.faces.context.FacesContext) diff --git a/source/java/org/alfresco/web/bean/wizard/NewForumsWizard.java b/source/java/org/alfresco/web/bean/wizard/NewForumsWizard.java index 08fdbfe817..bf526c9ce6 100644 --- a/source/java/org/alfresco/web/bean/wizard/NewForumsWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/NewForumsWizard.java @@ -17,7 +17,6 @@ */ package org.alfresco.web.bean.wizard; -import java.util.ArrayList; import java.util.List; import org.alfresco.model.ForumModel; @@ -30,8 +29,6 @@ import org.alfresco.web.ui.common.component.UIListItem; */ public class NewForumsWizard extends NewSpaceWizard { - public static final String FORUMS_ICON_DEFAULT = "forums_large"; - protected List forumsIcons; /** @@ -42,28 +39,5 @@ public class NewForumsWizard extends NewSpaceWizard super.init(); this.spaceType = ForumModel.TYPE_FORUMS.toString(); - this.icon = FORUMS_ICON_DEFAULT; - } - - /** - * Returns a list of icons to allow the user to select from. - * - * @return A list of icons - */ - @SuppressWarnings("unchecked") - public List getIcons() - { - // return the various forums icons - if (this.forumsIcons == null) - { - this.forumsIcons = new ArrayList(1); - - UIListItem item = new UIListItem(); - item.setValue(FORUMS_ICON_DEFAULT); - item.getAttributes().put("image", "/images/icons/forums_large.gif"); - this.forumsIcons.add(item); - } - - return this.forumsIcons; } } diff --git a/source/java/org/alfresco/web/bean/wizard/NewSpaceWizard.java b/source/java/org/alfresco/web/bean/wizard/NewSpaceWizard.java index cdf122bd68..300f23478a 100644 --- a/source/java/org/alfresco/web/bean/wizard/NewSpaceWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/NewSpaceWizard.java @@ -33,7 +33,6 @@ import org.alfresco.config.Config; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigService; import org.alfresco.model.ContentModel; -import org.alfresco.model.ForumModel; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.model.FileExistsException; @@ -63,7 +62,6 @@ import org.springframework.web.jsf.FacesContextUtils; public class NewSpaceWizard extends AbstractWizardBean { public static final String SPACE_ICON_DEFAULT = "space-icon-default"; - public static final String FORUMS_ICON_DEFAULT = "forums_large"; private static Log logger = LogFactory.getLog(NewSpaceWizard.class); @@ -83,7 +81,9 @@ public class NewSpaceWizard extends AbstractWizardBean // new space wizard specific properties private SearchService searchService; + private NamespaceService namespaceService; private DictionaryService dictionaryService; + private ConfigService configService; protected String spaceType; protected String icon; @@ -97,8 +97,6 @@ public class NewSpaceWizard extends AbstractWizardBean protected boolean saveAsTemplate; protected List templates; protected List folderTypes; - protected List genericIcons; - protected List forumsIcons; protected List folderTypeDescriptions; // the NodeRef of the node created during finish @@ -683,72 +681,57 @@ public class NewSpaceWizard extends AbstractWizardBean @SuppressWarnings("unchecked") public List getIcons() { - // TODO: Drive the list of icons to show for each space type from the config - // this will then remove the dependency on forums from this generic - // class + // NOTE: we can't cache this list as it depends on the space type + // which the user can change during the advanced space wizard List icons = null; - if (this.spaceType.equals(ForumModel.TYPE_FORUMS.toString())) + QName type = QName.createQName(this.spaceType); + String typePrefixForm = type.toPrefixString(this.namespaceService); + + Config config = this.configService.getConfig(typePrefixForm); + if (config != null) { - // return the various forum icons - if (this.forumsIcons == null) + ConfigElement iconsCfg = config.getConfigElement("icons"); + if (iconsCfg != null) { - this.forumsIcons = new ArrayList(2); - - // change default icon to be forums - this.icon = FORUMS_ICON_DEFAULT; - - UIListItem item = new UIListItem(); - item.setValue(FORUMS_ICON_DEFAULT); - item.getAttributes().put("image", "/images/icons/forums_large.gif"); - this.forumsIcons.add(item); + boolean first = true; + for (ConfigElement icon : iconsCfg.getChildren()) + { + String iconName = icon.getAttribute("name"); + String iconPath = icon.getAttribute("path"); + + if (iconName != null && iconPath != null) + { + if (first) + { + // if this is the first icon create the list and make + // the first icon in the list the default + + icons = new ArrayList(iconsCfg.getChildCount()); + this.icon = iconName; + first = false; + } + + UIListItem item = new UIListItem(); + item.setValue(iconName); + item.getAttributes().put("image", iconPath); + icons.add(item); + } + } } - - icons = this.forumsIcons; } - else + + // if we didn't find any icons display one default choice + if (icons == null) { - // return the generic space icons - if (this.genericIcons == null) - { - this.genericIcons = new ArrayList(6); - - // change default icon - this.icon = SPACE_ICON_DEFAULT; - - UIListItem item = new UIListItem(); - item.setValue("space-icon-default"); - item.getAttributes().put("image", "/images/icons/space-icon-default.gif"); - this.genericIcons.add(item); - - item = new UIListItem(); - item.setValue("space-icon-star"); - item.getAttributes().put("image", "/images/icons/space-icon-star.gif"); - this.genericIcons.add(item); - - item = new UIListItem(); - item.setValue("space-icon-doc"); - item.getAttributes().put("image", "/images/icons/space-icon-doc.gif"); - this.genericIcons.add(item); - - item = new UIListItem(); - item.setValue("space-icon-pen"); - item.getAttributes().put("image", "/images/icons/space-icon-pen.gif"); - this.genericIcons.add(item); - - item = new UIListItem(); - item.setValue("space-icon-cd"); - item.getAttributes().put("image", "/images/icons/space-icon-cd.gif"); - this.genericIcons.add(item); - - item = new UIListItem(); - item.setValue("space-icon-image"); - item.getAttributes().put("image", "/images/icons/space-icon-image.gif"); - this.genericIcons.add(item); - } + icons = new ArrayList(1); + this.icon = SPACE_ICON_DEFAULT; - icons = this.genericIcons; + UIListItem item = new UIListItem(); + item.setValue("space-icon-default"); + item.getAttributes().put("image", "/images/icons/space-icon-default.gif"); + icons.add(item); } return icons; @@ -770,6 +753,14 @@ public class NewSpaceWizard extends AbstractWizardBean this.searchService = searchService; } + /** + * @param namespaceService The NamespaceService + */ + public void setNamespaceService(NamespaceService namespaceService) + { + this.namespaceService = namespaceService; + } + /** * Sets the dictionary service * @@ -780,6 +771,16 @@ public class NewSpaceWizard extends AbstractWizardBean this.dictionaryService = dictionaryService; } + /** + * Sets the config service + * + * @param configService The ConfigService + */ + public void setConfigService(ConfigService configService) + { + this.configService = configService; + } + /** * @return Returns the copyPolicy. */ diff --git a/source/java/org/alfresco/web/bean/wizard/NewTopicWizard.java b/source/java/org/alfresco/web/bean/wizard/NewTopicWizard.java index 562f8db323..42281ee6ae 100644 --- a/source/java/org/alfresco/web/bean/wizard/NewTopicWizard.java +++ b/source/java/org/alfresco/web/bean/wizard/NewTopicWizard.java @@ -47,8 +47,6 @@ import org.apache.commons.logging.LogFactory; */ public class NewTopicWizard extends NewSpaceWizard { - public static final String TOPIC_ICON_DEFAULT = "topic_large"; - private static final Log logger = LogFactory.getLog(NewTopicWizard.class); protected String message; @@ -134,32 +132,9 @@ public class NewTopicWizard extends NewSpaceWizard super.init(); this.spaceType = ForumModel.TYPE_TOPIC.toString(); - this.icon = TOPIC_ICON_DEFAULT; this.topicType = "0"; this.message = null; } - - /** - * Returns a list of icons to allow the user to select from. - * - * @return A list of icons - */ - @SuppressWarnings("unchecked") - public List getIcons() - { - // return the various forum icons - if (this.topicIcons == null) - { - this.topicIcons = new ArrayList(2); - - UIListItem item = new UIListItem(); - item.setValue(TOPIC_ICON_DEFAULT); - item.getAttributes().put("image", "/images/icons/topic_large.gif"); - this.topicIcons.add(item); - } - - return this.topicIcons; - } /** * @see org.alfresco.web.bean.wizard.NewSpaceWizard#performCustomProcessing(javax.faces.context.FacesContext) diff --git a/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java index 1dabf51ed6..2ab4b45603 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java @@ -26,6 +26,10 @@ import javax.faces.component.UIInput; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; +import org.alfresco.config.Config; +import org.alfresco.config.ConfigElement; +import org.alfresco.config.ConfigService; +import org.alfresco.web.app.Application; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIImagePicker; import org.alfresco.web.ui.common.component.UIListItem; @@ -101,6 +105,7 @@ public class ImagePickerRadioRenderer extends BaseRenderer /** * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent) */ + @SuppressWarnings("unchecked") public void encodeChildren(FacesContext context, UIComponent component) throws IOException { if (component.isRendered() == false) @@ -122,30 +127,64 @@ public class ImagePickerRadioRenderer extends BaseRenderer ResponseWriter out = context.getResponseWriter(); - // get the child components - for (Iterator i = imagePicker.getChildren().iterator(); i.hasNext(); /**/) + // determine whether the options should be pulled from config or + // from the child components + String configSection = (String)attrs.get("configSection"); + + if (configSection != null && configSection.length() > 0) { - UIComponent child = (UIComponent)i.next(); - if (child instanceof UIListItems) + // render all the icons from the list that appear in the given + // config section + ConfigService cfgService = Application.getConfigService(context); + Config cfg = cfgService.getConfig(configSection); + if (cfg != null) { - // get the value of the list items component and iterate - // through it's collection - Object listItems = ((UIListItems)child).getValue(); - if (listItems instanceof Collection) + ConfigElement iconsCfg = cfg.getConfigElement("icons"); + if (iconsCfg != null) { - Iterator iter = ((Collection)listItems).iterator(); - while (iter.hasNext()) + for (ConfigElement icon : iconsCfg.getChildren()) { - UIListItem item = (UIListItem)iter.next(); - renderItem(context, out, imagePicker, item, onclick); + String iconName = icon.getAttribute("name"); + String iconPath = icon.getAttribute("path"); + + if (iconName != null && iconPath != null) + { + UIListItem item = new UIListItem(); + item.setValue(iconName); + item.getAttributes().put("image", iconPath); + renderItem(context, out, imagePicker, item, onclick); + } } } } - else if (child instanceof UIListItem && child.isRendered() == true) + } + else + { + // get the child components + for (Iterator i = imagePicker.getChildren().iterator(); i.hasNext(); /**/) { - // found a valid UIListItem child to render - UIListItem item = (UIListItem)child; - renderItem(context, out, imagePicker, item, onclick); + UIComponent child = (UIComponent)i.next(); + if (child instanceof UIListItems) + { + // get the value of the list items component and iterate + // through it's collection + Object listItems = ((UIListItems)child).getValue(); + if (listItems instanceof Collection) + { + Iterator iter = ((Collection)listItems).iterator(); + while (iter.hasNext()) + { + UIListItem item = (UIListItem)iter.next(); + renderItem(context, out, imagePicker, item, onclick); + } + } + } + else if (child instanceof UIListItem && child.isRendered() == true) + { + // found a valid UIListItem child to render + UIListItem item = (UIListItem)child; + renderItem(context, out, imagePicker, item, onclick); + } } } diff --git a/source/java/org/alfresco/web/ui/common/tag/ImagePickerRadioTag.java b/source/java/org/alfresco/web/ui/common/tag/ImagePickerRadioTag.java index 6ec6905749..afebca5c4b 100644 --- a/source/java/org/alfresco/web/ui/common/tag/ImagePickerRadioTag.java +++ b/source/java/org/alfresco/web/ui/common/tag/ImagePickerRadioTag.java @@ -49,6 +49,9 @@ public class ImagePickerRadioTag extends HtmlComponentTag /** the onclick handler */ private String onclick; + /** the name of the config section to lookup to get the icons */ + private String configSection; + /** * @see javax.faces.webapp.UIComponentTag#getComponentType() */ @@ -77,6 +80,7 @@ public class ImagePickerRadioTag extends HtmlComponentTag setStringProperty(component, "value", this.value); setStringProperty(component, "image", this.image); setStringProperty(component, "onclick", this.onclick); + setStringProperty(component, "configSection", this.configSection); setIntProperty(component, "spacing", this.spacing); setIntProperty(component, "columns", this.columns); } @@ -95,6 +99,7 @@ public class ImagePickerRadioTag extends HtmlComponentTag this.image = null; this.columns = null; this.onclick = null; + this.configSection = null; } /** @@ -224,4 +229,20 @@ public class ImagePickerRadioTag extends HtmlComponentTag { this.onclick = onclick; } + + /** + * @return Returns the config section to lookup + */ + public String getConfigSection() + { + return this.configSection; + } + + /** + * @param configSection The config section to lookup + */ + public void setConfigSection(String configSection) + { + this.configSection = configSection; + } } diff --git a/source/web/WEB-INF/alfresco.tld b/source/web/WEB-INF/alfresco.tld index eb2da41822..0c77666ddc 100644 --- a/source/web/WEB-INF/alfresco.tld +++ b/source/web/WEB-INF/alfresco.tld @@ -1160,6 +1160,12 @@ false true + + + configSection + false + true + diff --git a/source/web/WEB-INF/faces-config.xml b/source/web/WEB-INF/faces-config.xml index 7e507e5b66..c64c87db83 100644 --- a/source/web/WEB-INF/faces-config.xml +++ b/source/web/WEB-INF/faces-config.xml @@ -262,6 +262,14 @@ dictionaryService #{DictionaryService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -291,6 +299,14 @@ browseBean #{BrowseBean} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -324,6 +340,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -926,6 +950,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -959,6 +991,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -992,6 +1032,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -1025,6 +1073,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -1062,6 +1118,14 @@ contentService #{ContentService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + @@ -1095,6 +1159,14 @@ searchService #{SearchService} + + configService + #{configService} + + + namespaceService + #{NamespaceService} + diff --git a/source/web/jsp/dialog/edit-space.jsp b/source/web/jsp/dialog/edit-space.jsp index 055e68c85d..ab935bf3b7 100644 --- a/source/web/jsp/dialog/edit-space.jsp +++ b/source/web/jsp/dialog/edit-space.jsp @@ -139,12 +139,7 @@
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> - - - - - - + <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>
diff --git a/source/web/jsp/dialog/new-space.jsp b/source/web/jsp/dialog/new-space.jsp index 5212390eb0..14a3468385 100644 --- a/source/web/jsp/dialog/new-space.jsp +++ b/source/web/jsp/dialog/new-space.jsp @@ -149,12 +149,7 @@
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "blue", "#D3E6FE"); %> - - - - - - + <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "blue"); %>