use of org.alfresco.web.config.DashboardsConfigElement.DashletDefinition in project acs-community-packaging by Alfresco.
the class DashboardManager method getDashletDefinitionByIndex.
/**
* Helper to get the DashDefinition as the zero based index, working from the left most column
* top-bottom then working left-right.
*
* @param index Zero based index from the left most column working top-bottom then left-right
*
* @return DashletDefinition if found or null if no dashlet at the specified index
*/
private static DashletDefinition getDashletDefinitionByIndex(PageConfig config, int index) {
DashletDefinition def = null;
LayoutDefinition layoutDef = config.getCurrentPage().getLayoutDefinition();
List<Column> columns = config.getCurrentPage().getColumns();
int columnCount = columns.size();
int selectedColumn = index / layoutDef.ColumnLength;
if (selectedColumn < columnCount) {
List<DashletDefinition> dashlets = columns.get(selectedColumn).getDashlets();
if (index % layoutDef.ColumnLength < dashlets.size()) {
def = dashlets.get(index % layoutDef.ColumnLength);
}
}
if (logger.isDebugEnabled())
logger.debug("Searching for dashlet at index: " + index + " and found " + (def != null ? def.JSPPage : null));
return def;
}
use of org.alfresco.web.config.DashboardsConfigElement.DashletDefinition 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.DashletDefinition 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.DashletDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method dashletDown.
/**
* Action event called to move a dashlet down the column list
*/
public void dashletDown(ActionEvent event) {
UISelectOne dashletColumn = (UISelectOne) event.getComponent().findComponent(COMPONENT_COLUMNDASHLETS);
// get the ID of the selected Dashlet definition
String dashletId = (String) dashletColumn.getValue();
if (dashletId != null) {
Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
// find the dashlet in the list
for (int i = 0; i < column.getDashlets().size(); i++) {
if (column.getDashlets().get(i).Id.equals(dashletId)) {
if (i != column.getDashlets().size() - 1) {
DashletDefinition dashletDef = column.getDashlets().get(i);
column.getDashlets().remove(i);
if (i + 1 < column.getDashlets().size()) {
column.getDashlets().add(i + 1, dashletDef);
} else {
column.getDashlets().add(dashletDef);
}
}
break;
}
}
}
}
use of org.alfresco.web.config.DashboardsConfigElement.DashletDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method dashletUp.
/**
* Action event called to move a dashlet up the column list
*/
public void dashletUp(ActionEvent event) {
UISelectOne dashletColumn = (UISelectOne) event.getComponent().findComponent(COMPONENT_COLUMNDASHLETS);
// get the ID of the selected Dashlet definition
String dashletId = (String) dashletColumn.getValue();
if (dashletId != null) {
Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
// find the dashlet in the list
for (int i = 0; i < column.getDashlets().size(); i++) {
if (column.getDashlets().get(i).Id.equals(dashletId)) {
if (i != 0) {
DashletDefinition dashletDef = column.getDashlets().get(i);
column.getDashlets().remove(i);
column.getDashlets().add(i - 1, dashletDef);
}
break;
}
}
}
}
Aggregations