use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition 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.LayoutDefinition 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.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method getColumns.
/**
* @return the array of UI select items representing the columns that can be configured
*/
public SelectItem[] getColumns() {
FacesContext fc = FacesContext.getCurrentInstance();
LayoutDefinition layoutDef = DashboardManager.getDashboardConfig().getLayoutDefinition(getLayout());
SelectItem[] columns = new SelectItem[layoutDef.Columns];
for (int i = 0; i < layoutDef.Columns; i++) {
String label = Application.getMessage(fc, MSG_COLUMN) + " " + Integer.toString(i + 1);
columns[i] = new SelectItem(i, label);
}
return columns;
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method getColumnDashlets.
/**
* @return the List of SelectItem objects representing the dashlets displayed in the
* currently selected column.
*/
public List<SelectItem> getColumnDashlets() {
FacesContext fc = FacesContext.getCurrentInstance();
Column column = this.editConfig.getCurrentPage().getColumns().get(this.column);
// trim the max number of dashlets for this column
LayoutDefinition layoutDef = this.editConfig.getCurrentPage().getLayoutDefinition();
column.trimDashlets(layoutDef.ColumnLength);
List<SelectItem> dashlets = new ArrayList<SelectItem>(column.getDashlets().size());
for (DashletDefinition dashletDef : column.getDashlets()) {
String label = dashletDef.Label;
if (label == null) {
label = Application.getMessage(fc, dashletDef.LabelId);
}
dashlets.add(new SelectItem(dashletDef.Id, label));
}
return dashlets;
}
use of org.alfresco.web.config.DashboardsConfigElement.LayoutDefinition in project acs-community-packaging by Alfresco.
the class DashboardWizard method getSummary.
/**
* @return Returns the summary data for the wizard.
*/
public String getSummary() {
LayoutDefinition def = DashboardManager.getDashboardConfig().getLayoutDefinition(this.layout);
String label = def.Label;
if (label == null) {
label = Application.getMessage(FacesContext.getCurrentInstance(), def.LabelId);
}
return buildSummary(new String[] { Application.getMessage(FacesContext.getCurrentInstance(), "step_layout") }, new String[] { label });
}
Aggregations