mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
All icon choices when creating spaces are config driven
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2016 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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<UIListItem> 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<UIListItem> getIcons()
|
||||
{
|
||||
// return the various forum icons
|
||||
if (this.forumIcons == null)
|
||||
{
|
||||
this.forumIcons = new ArrayList<UIListItem>(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)
|
||||
|
@@ -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<UIListItem> 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<UIListItem> getIcons()
|
||||
{
|
||||
// return the various forums icons
|
||||
if (this.forumsIcons == null)
|
||||
{
|
||||
this.forumsIcons = new ArrayList<UIListItem>(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;
|
||||
}
|
||||
}
|
||||
|
@@ -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<SelectItem> templates;
|
||||
protected List<UIListItem> folderTypes;
|
||||
protected List<UIListItem> genericIcons;
|
||||
protected List<UIListItem> forumsIcons;
|
||||
protected List<UIDescription> folderTypeDescriptions;
|
||||
|
||||
// the NodeRef of the node created during finish
|
||||
@@ -683,72 +681,57 @@ public class NewSpaceWizard extends AbstractWizardBean
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<UIListItem> 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<UIListItem> 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<UIListItem>(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<UIListItem>(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<UIListItem>(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<UIListItem>(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.
|
||||
*/
|
||||
|
@@ -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<UIListItem> getIcons()
|
||||
{
|
||||
// return the various forum icons
|
||||
if (this.topicIcons == null)
|
||||
{
|
||||
this.topicIcons = new ArrayList<UIListItem>(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)
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user