use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method setLayout.
/**
* Set the currently selected layout ID
*/
public void setLayout(String layout) {
this.layout = layout;
LayoutDefinition def = DashboardManager.getDashboardConfig().getLayoutDefinition(layout);
this.editConfig.getCurrentPage().setLayoutDefinition(def);
if (this.column >= def.Columns) {
this.column = def.Columns - 1;
}
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method buildLayoutValueLists.
/**
* Build the cached list of values for the layout page. The lists are used by the
* image radio picker and dynamic description components.
*/
private void buildLayoutValueLists() {
List<UIListItem> icons = new ArrayList<UIListItem>(4);
List<UIDescription> descriptions = new ArrayList<UIDescription>(4);
FacesContext context = FacesContext.getCurrentInstance();
DashboardsConfigElement config = DashboardManager.getDashboardConfig();
Iterator<LayoutDefinition> layoutItr = config.getLayouts().iterator();
while (layoutItr.hasNext()) {
LayoutDefinition layoutDef = layoutItr.next();
// build UIListItem to represent the layout image
String label = layoutDef.Label;
if (label == null) {
label = Application.getMessage(context, layoutDef.LabelId);
}
String desc = layoutDef.Description;
if (desc == null) {
desc = Application.getMessage(context, layoutDef.DescriptionId);
}
UIListItem item = new UIListItem();
item.setLabel(label);
item.setTooltip(desc);
item.setValue(layoutDef.Id);
item.setImage(layoutDef.Image);
icons.add(item);
// build UIDescription to represent the layout description text
UIDescription description = new UIDescription();
description.setControlValue(layoutDef.Id);
description.setText(desc);
descriptions.add(description);
}
this.layoutIcons = icons;
this.layoutDescriptions = descriptions;
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method addDashlets.
/**
* Action event handler called to Add dashlets to the selection for a column
*/
public void addDashlets(ActionEvent event) {
UISelectMany dashletPicker = (UISelectMany) event.getComponent().findComponent(COMPONENT_ALLDASHLETS);
UISelectOne dashletColumn = (UISelectOne) event.getComponent().findComponent(COMPONENT_COLUMNDASHLETS);
// get the IDs of the selected Dashlet definitions
Object[] selected = dashletPicker.getSelectedValues();
if (selected.length != 0) {
// get the column to add the dashlets too
DashboardsConfigElement config = DashboardManager.getDashboardConfig();
LayoutDefinition layoutDef = this.editConfig.getCurrentPage().getLayoutDefinition();
Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
// add each selected dashlet to the column
for (int i = 0; i < selected.length && column.getDashlets().size() < layoutDef.ColumnLength; i++) {
String dashletId = (String) selected[i];
// don't add if already present in the list
boolean found = false;
for (int x = 0; x < column.getDashlets().size(); x++) {
if (column.getDashlets().get(x).Id.equals(dashletId)) {
found = true;
break;
}
}
if (found == false) {
column.addDashlet(config.getDashletDefinition(dashletId));
}
}
}
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class Column method fromXML.
/**
* Deserialise this PageConfig instance from the specified XML stream.
*
* @param xml
*/
public void fromXML(DashboardsConfigElement config, String xml) {
try {
SAXReader reader = new SAXReader();
Document document = reader.read(new StringReader(xml));
Element rootElement = document.getRootElement();
// walk the pages found in xml
Iterator itrPages = rootElement.elementIterator(ELEMENT_PAGE);
while (itrPages.hasNext()) {
Element pageElement = (Element) itrPages.next();
String layoutId = pageElement.attributeValue(ATTR_LAYOUTID);
LayoutDefinition layoutDef = config.getLayoutDefinition(layoutId);
if (layoutDef != null) {
// found the layout now build the page and read the columns
Page page = new Page(pageElement.attributeValue(ATTR_ID), layoutDef);
Iterator itrColumns = pageElement.elementIterator(ELEMENT_COLUMN);
while (itrColumns.hasNext()) {
Column column = new Column();
// read and resolve the dashlet definitions for this column
Element columnElement = (Element) itrColumns.next();
Iterator itrDashlets = columnElement.elementIterator(ELEMENT_DASHLET);
while (itrDashlets.hasNext()) {
String dashletId = ((Element) itrDashlets.next()).attributeValue(ATTR_REFID);
DashletDefinition dashletDef = config.getDashletDefinition(dashletId);
if (dashletDef != null) {
column.addDashlet(dashletDef);
} else if (logger.isWarnEnabled()) {
logger.warn("Failed to resolve Dashboard Dashlet Definition ID: " + dashletId);
}
}
// add the column of dashlets to the page
page.addColumn(column);
}
// add the page to this config instance
this.addPage(page);
} else if (logger.isWarnEnabled()) {
logger.warn("Failed to resolve Dashboard Layout Definition ID: " + layoutId);
}
}
} catch (DocumentException docErr) {
// if we cannot parse, then we simply revert to default
}
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardsElementReader method parseLayoutDefinition.
/**
* Parse a single Layout definition from config.
*
* @param config Element
*
* @return LayoutDefinition for the specified config element.
*/
private static LayoutDefinition parseLayoutDefinition(Element config) {
String id = getMandatoryLayoutAttributeValue(config, ATTR_ID);
LayoutDefinition def = new LayoutDefinition(id);
String columns = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNS);
def.Columns = Integer.parseInt(columns);
String columnLength = getMandatoryLayoutAttributeValue(config, ATTR_COLUMNLENGTH);
def.ColumnLength = Integer.parseInt(columnLength);
def.Image = getMandatoryLayoutAttributeValue(config, ATTR_IMAGE);
def.JSPPage = getMandatoryLayoutAttributeValue(config, ATTR_JSP);
String label = config.attributeValue(ATTR_LABEL);
String labelId = config.attributeValue(ATTR_LABELID);
if ((label == null || label.length() == 0) && (labelId == null || labelId.length() == 0)) {
throw new ConfigException("Either 'label' or 'label-id' attribute must be specified for Dashboard 'layout' configuration element.");
}
def.Label = label;
def.LabelId = labelId;
String description = config.attributeValue(ATTR_DESCRIPTION);
String descriptionId = config.attributeValue(ATTR_DESCRIPTIONID);
if ((description == null || description.length() == 0) && (descriptionId == null || descriptionId.length() == 0)) {
throw new ConfigException("Either 'description' or 'description-id' attribute must be specified for Dashboard 'layout' configuration element.");
}
def.Description = description;
def.DescriptionId = descriptionId;
return def;
}
Aggregations