use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.
the class DashboardManager method getDashboardConfig.
/**
* @return The externally configured WebClient config element for the Dashboards
*/
public static DashboardsConfigElement getDashboardConfig() {
ConfigService service = Application.getConfigService(FacesContext.getCurrentInstance());
DashboardsConfigElement config = (DashboardsConfigElement) service.getConfig("Dashboards").getConfigElement(DashboardsConfigElement.CONFIG_ELEMENT_ID);
return config;
}
use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.
the class DashboardManager method getPageConfig.
/**
* @return the PageConfig for the current My Alfresco dashboard page
*/
public PageConfig getPageConfig() {
if (this.pageConfig == null) {
PageConfig pageConfig;
DashboardsConfigElement config = getDashboardConfig();
// read the config for this user from the Preferences
String xml = (String) PreferencesService.getPreferences().getValue(PREF_DASHBOARD);
if (xml != null && xml.length() != 0) {
if (logger.isDebugEnabled())
logger.debug("PageConfig found: " + xml);
// process the XML config and convert into a PageConfig object
pageConfig = new PageConfig();
pageConfig.fromXML(config, xml);
} else {
if (logger.isDebugEnabled())
logger.debug("No PageConfig found, creating default instance.");
// create default config for the first access for a user
pageConfig = new PageConfig();
LayoutDefinition layout = config.getLayoutDefinition(LAYOUT_DEFAULT);
if (layout != null) {
Page page = new Page("default", layout);
Column defaultColumn = new Column();
// add the default dashlet(s) to the column as specified in the config
if (config.getDefaultDashlets() != null) {
for (String id : config.getDefaultDashlets()) {
DashletDefinition dashlet = config.getDashletDefinition(id);
if (dashlet != null) {
defaultColumn.addDashlet(dashlet);
}
}
}
// add the column to the page and we are done
page.addColumn(defaultColumn);
pageConfig.addPage(page);
}
}
this.pageConfig = pageConfig;
}
return this.pageConfig;
}
use of org.alfresco.web.config.DashboardsConfigElement in project acs-community-packaging by Alfresco.
the class DashboardWizard method getAllDashlets.
/**
* @return The SelectItem List of all available dashlets
*/
public List<SelectItem> getAllDashlets() {
if ((this.dashlets == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext fc = FacesContext.getCurrentInstance();
DashboardsConfigElement config = DashboardManager.getDashboardConfig();
Collection<DashletDefinition> dashletDefs = config.getDashlets();
List<SelectItem> dashlets = new ArrayList<SelectItem>(dashletDefs.size());
for (DashletDefinition dashletDef : dashletDefs) {
String label = dashletDef.Label;
if (label == null) {
label = Application.getMessage(fc, dashletDef.LabelId);
}
String description = dashletDef.Description;
if (description == null) {
description = Application.getMessage(fc, dashletDef.DescriptionId);
}
if (description != null) {
// append description of the dashlet if set
label = label + " (" + description + ')';
}
SelectItem item = new SelectItem(dashletDef.Id, label);
dashlets.add(item);
}
this.dashlets = dashlets;
}
return this.dashlets;
}
use of org.alfresco.web.config.DashboardsConfigElement 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 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));
}
}
}
}
Aggregations