use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class CategoriesDialog method getViewItems.
public List<UIListItem> getViewItems() {
FacesContext context = FacesContext.getCurrentInstance();
List<UIListItem> items = new ArrayList<UIListItem>(2);
UIListItem item1 = new UIListItem();
item1.setValue(VIEW_ICONS);
item1.setLabel(Application.getMessage(context, LABEL_VIEW_ICONS));
items.add(item1);
UIListItem item2 = new UIListItem();
item2.setValue(VIEW_DETAILS);
item2.setLabel(Application.getMessage(context, LABEL_VIEW_DETAILS));
items.add(item2);
return items;
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class WizardManager method getStepItems.
/**
* Returns a list of UIListItems representing the steps of the wizard
*
* @return List of steps to display in UI
*/
public List<UIListItem> getStepItems() {
List<UIListItem> items = new ArrayList<UIListItem>(this.currentWizardState.getSteps().size());
for (int x = 0; x < this.currentWizardState.getSteps().size(); x++) {
String uiStepNumber = Integer.toString(x + 1);
StepConfig stepCfg = this.currentWizardState.getSteps().get(x);
UIListItem item = new UIListItem();
item.setValue(uiStepNumber);
// get the title for the step
String stepTitle = stepCfg.getTitleId();
if (stepTitle != null) {
stepTitle = Application.getMessage(FacesContext.getCurrentInstance(), stepTitle);
} else {
stepTitle = stepCfg.getTitle();
}
// get the tooltip for the step
String stepTooltip = stepCfg.getDescriptionId();
if (stepTooltip != null) {
stepTooltip = Application.getMessage(FacesContext.getCurrentInstance(), stepTooltip);
} else {
stepTooltip = stepCfg.getDescription();
}
// set the label and tooltip
item.setLabel(uiStepNumber + ". " + stepTitle);
item.setTooltip(stepTooltip);
items.add(item);
}
return items;
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class CreateSpaceWizard method getSummary.
/**
* @return Returns the summary data for the wizard.
*/
public String getSummary() {
String summaryCreateType = null;
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
if (this.createFrom.equals(CREATEFROM_SCRATCH)) {
summaryCreateType = bundle.getString(CREATEFROM_SCRATCH);
} else if (this.createFrom.equals(CREATEFROM_EXISTING)) {
summaryCreateType = bundle.getString("an_existing_space");
} else if (this.createFrom.equals(CREATEFROM_TEMPLATE)) {
summaryCreateType = bundle.getString("a_template");
}
// String summarySaveAsTemplate = this.saveAsTemplate ? bundle.getString("yes") : bundle.getString("no");
// bundle.getString("save_as_template"), bundle.getString("template_name")},
// summarySaveAsTemplate, this.templateName
String spaceTypeLabel = null;
for (UIListItem item : this.getFolderTypes()) {
if (item.getValue().equals(this.spaceType)) {
spaceTypeLabel = item.getLabel();
break;
}
}
return buildSummary(new String[] { bundle.getString("space_type"), bundle.getString("name"), bundle.getString("description"), bundle.getString("creating_from") }, new String[] { spaceTypeLabel, Utils.encode(this.name), Utils.encode(this.description), summaryCreateType });
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class CreateSpaceWizard method getFolderTypes.
/**
* Returns a list of UIListItem objects representing the folder types
* and also constructs the list of descriptions for each type
*
* @return List of UIListItem components
*/
@SuppressWarnings("unchecked")
public List<UIListItem> getFolderTypes() {
if ((this.folderTypes == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
this.folderTypes = new ArrayList<UIListItem>(2);
this.folderTypeDescriptions = new ArrayList<UIDescription>(2);
// add the well known 'container space' type to start with
UIListItem defaultItem = new UIListItem();
String defaultLabel = Application.getMessage(context, "container");
defaultItem.setValue(ContentModel.TYPE_FOLDER.toString());
defaultItem.setLabel(defaultLabel);
defaultItem.setTooltip(defaultLabel);
defaultItem.setImage(DEFAULT_SPACE_TYPE_ICON_PATH);
this.folderTypes.add(defaultItem);
UIDescription defaultDesc = new UIDescription();
defaultDesc.setControlValue(ContentModel.TYPE_FOLDER.toString());
defaultDesc.setText(Application.getMessage(context, "container_desc"));
this.folderTypeDescriptions.add(defaultDesc);
// add any configured content sub-types to the list
Config wizardCfg = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig("Space Wizards");
if (wizardCfg != null) {
ConfigElement typesCfg = wizardCfg.getConfigElement("folder-types");
if (typesCfg != null) {
for (ConfigElement child : typesCfg.getChildren()) {
QName idQName = Repository.resolveToQName(child.getAttribute("name"));
if (idQName != null) {
TypeDefinition typeDef = this.getDictionaryService().getType(idQName);
if (typeDef != null) {
if (this.getDictionaryService().isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER)) {
// try and get the label from config
String label = Utils.getDisplayLabel(context, child);
// if there wasn't a client based label try and get it from the dictionary
if (label == null) {
label = typeDef.getTitle(this.getDictionaryService());
}
// finally use the localname if we still haven't found a label
if (label == null) {
label = idQName.getLocalName();
}
// resolve a description string for the type
String description = Utils.getDescription(context, child);
// if we don't have a local description just use the label
if (description == null) {
description = label;
}
// extract the icon to use from the config
String icon = child.getAttribute("icon");
if (icon == null || icon.length() == 0) {
icon = DEFAULT_SPACE_TYPE_ICON_PATH;
}
UIListItem item = new UIListItem();
item.setValue(idQName.toString());
item.setLabel(label);
item.setTooltip(label);
item.setImage(icon);
this.folderTypes.add(item);
UIDescription desc = new UIDescription();
desc.setControlValue(idQName.toString());
desc.setText(description);
this.folderTypeDescriptions.add(desc);
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not a subtype of cm:folder");
}
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the type is not recognised");
}
} else {
logger.warn("Failed to add '" + child.getAttribute("name") + "' to the list of folder types as the prefix can not be resolved");
}
}
} else {
logger.warn("Could not find 'folder-types' configuration element");
}
} else {
logger.warn("Could not find 'Space Wizards' configuration section");
}
}
return this.folderTypes;
}
use of org.alfresco.web.ui.common.component.UIListItem in project acs-community-packaging by Alfresco.
the class CreateSpaceWizard method getIcons.
/**
* Returns a list of icons to allow the user to select from.
* The list can change according to the type of space being created.
*
* @return A list of icons
*/
@SuppressWarnings("unchecked")
public List<UIListItem> getIcons() {
// 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;
List<String> iconNames = new ArrayList<String>(8);
QName type = QName.createQName(this.spaceType);
String typePrefixForm = type.toPrefixString(this.getNamespaceService());
Config config = Application.getConfigService(FacesContext.getCurrentInstance()).getConfig(typePrefixForm + " icons");
if (config != null) {
ConfigElement iconsCfg = config.getConfigElement("icons");
if (iconsCfg != null) {
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());
if (this.icon == null) {
// set the default if it is not already
this.icon = iconName;
}
first = false;
}
UIListItem item = new UIListItem();
item.setValue(iconName);
item.setImage(iconPath);
icons.add(item);
iconNames.add(iconName);
}
}
}
}
// if we didn't find any icons display one default choice
if (icons == null) {
icons = new ArrayList<UIListItem>(1);
this.icon = DEFAULT_SPACE_ICON_NAME;
UIListItem item = new UIListItem();
item.setValue(DEFAULT_SPACE_ICON_NAME);
item.setImage("/images/icons/space-icon-default.gif");
icons.add(item);
iconNames.add(DEFAULT_SPACE_ICON_NAME);
}
// current list of icons about to be displayed
if (iconNames.contains(this.icon) == false) {
this.icon = iconNames.get(0);
}
return icons;
}
Aggregations