public CommandResponse actionChangeEditingLanguage(Panel panel, CommandRequest request) throws Exception { String currentText = request.getRequestObject().getParameter(PARAMETER_HTML); Map text = (Map) SessionManager.getPanelSession(panel).getAttribute(ATTR_TEXT); if (text == null) { text = toEditableObject(load(panel.getInstance())); SessionManager.getPanelSession(panel).setAttribute(ATTR_TEXT, text); } text.put(getEditingLanguage(panel), currentText); SessionManager.getPanelSession(panel).setAttribute(ATTR_TEXT, text); String paramLang = request.getRequestObject().getParameter(PARAMETER_EDITING_LANG); SessionManager.getPanelSession(panel).setAttribute(ATTR_EDITING_LANGUAGE, paramLang); return new ShowPanelPage(); }
public boolean execute(CommandRequest cmdReq) throws Exception { if (log.isDebugEnabled()) log.debug("ShowJSPAjaxResponse: " + jsp); cmdReq.getResponseObject().setHeader("Content-Encoding", HTTPSettings.lookup().getEncoding()); cmdReq .getResponseObject() .setContentType("text/html;charset=" + HTTPSettings.lookup().getEncoding()); if (region != null) { cmdReq.getRequestObject().setAttribute(Parameters.RENDER_IDREGION, region.getId()); } cmdReq .getRequestObject() .getRequestDispatcher(jsp) .include(cmdReq.getRequestObject(), cmdReq.getResponseObject()); return true; }
public CommandResponse actionApplyLink(CommandRequest request) throws Exception { AbstractChartDisplayer abstractChartDisplayer = (AbstractChartDisplayer) getDataDisplayer(); DataProperty property = abstractChartDisplayer.getDomainProperty(); Integer series = Integer.decode(request.getRequestObject().getParameter(PARAM_NSERIE)); DataSet dataSet = abstractChartDisplayer.buildXYDataSet(); Interval interval = (Interval) dataSet.getValueAt(series, 0); Dashboard dashboard = DashboardHandler.lookup().getCurrentDashboard(); if (dashboard.filter(property.getPropertyId(), interval, FilterByCriteria.ALLOW_ANY)) { return new ShowCurrentScreenResponse(); } return null; }
public CommandResponse actionSaveChanges(Panel panel, CommandRequest request) throws Exception { String currentText = request.getRequestObject().getParameter(PARAMETER_HTML); Map m = (Map) SessionManager.getPanelSession(panel).getAttribute(ATTR_TEXT); HTMLText text = load(panel.getInstance()); for (Iterator it = m.keySet().iterator(); it.hasNext(); ) { String lang = (String) it.next(); String val = (String) m.get(lang); text.setText(lang, val); } text.setText(getEditingLanguage(panel), currentText); text.save(); activateNormalMode(panel, request); return new ShowPanelPage(); }
public CommandResponse actionDeleteFilteredProperty(CommandRequest request) { String propertyToDelete = request.getRequestObject().getParameter("filteredPropertyToDelete"); if (propertyToDelete == null || propertyToDelete.trim().length() == 0) return null; try { Dashboard dashboard = getDashboard(); if (dashboard.unfilter(propertyToDelete)) { return new ShowCurrentScreenResponse(); } } catch (Exception e) { log.error("Cannot remove filter property.", e); } return null; }
public void actionRefresh(CommandRequest request) { try { String timeOutValue = request.getRequestObject().getParameter("refreshTimeOut"); if (!StringUtils.isBlank(timeOutValue)) { try { autoRefreshTimeout = Integer.decode(timeOutValue).intValue(); } catch (NumberFormatException e) { log.warn("Cannot parse auto refresh value as a number."); } } getDashboard().refresh(); } catch (Exception e) { log.error("Cannot refresh dashboard.", e); } }
protected Panel getPanel() { RequestContext reqCtx = RequestContext.getCurrentContext(); CommandRequest request = reqCtx.getRequest(); return (Panel) request.getRequestObject().getAttribute(Parameters.RENDER_PANEL); }
public CommandResponse actionFilter(CommandRequest request) { try { // Init attributes for start applying the filter. filterPropertyErrors.clear(); // Parse parameters and set the filter. Iterator visiblePropertiesIt = properties.iterator(); while (visiblePropertiesIt.hasNext()) { DashboardFilterProperty dashboardFilterProperty = (DashboardFilterProperty) visiblePropertiesIt.next(); // Is property already in the dashboard filter?. Then is not possible to filter by this // property, it's already added to dashboard filter. if (dashboardFilterProperty.isBeingFiltered()) continue; if (!dashboardFilterProperty.isPropertyAlive()) { log.warn( "Trying to filter by " + dashboardFilterProperty.getPropertyId() + ". This property is not in any dataset."); continue; } if (!dashboardFilterProperty.isVisible()) continue; Object[] result; try { result = requestProcessor.parseDashboardProperty( request.getRequestObject(), dashboardFilterProperty); } catch (Exception e) { log.error("Error parsing property " + dashboardFilterProperty.getPropertyId() + ".", e); continue; } if (result.length != 3) { log.error( "Error parsing property: '" + dashboardFilterProperty.getPropertyId() + "' for dataProvider: '" + dashboardFilterProperty.getDataProviderCode() + "'"); continue; } Collection allowedValues = (Collection) result[0]; Object minValue = result[1]; Object maxValue = result[2]; if (allowedValues == null && minValue == null && maxValue == null) continue; // Set the filter with this property. Dashboard currentDashboard = DashboardHandler.lookup().getCurrentDashboard(); if (currentDashboard.filter( dashboardFilterProperty.getPropertyId(), minValue, true, maxValue, true, allowedValues, FilterByCriteria.ALLOW_ANY)) { return new ShowCurrentScreenResponse(); } } } catch (Exception e) { log.error("Error trying to filter properties for dashboard", e); } return null; }
public void actionStore(CommandRequest request) { Map parameters = request.getRequestObject().getParameterMap(); // Initialize parameters and properties to default. showPropertyNames = false; showRefreshButton = false; showApplyButton = false; showClearButton = false; showSubmitOnChange = false; isShortMode = false; showLegend = false; showAutoRefresh = false; properties.clear(); notAllowedProperties.clear(); // Component options. if (parameters.containsKey(PARAM_SHOW_REFRESH_BUTTON)) showRefreshButton = true; if (parameters.containsKey(PARAM_SHOW_PROPERTY_NAMES)) showPropertyNames = true; if (parameters.containsKey(PARAM_SHOW_CLEAR_BUTTON)) showClearButton = true; if (parameters.containsKey(PARAM_SHOW_APPLY_BUTTON)) showApplyButton = true; if (parameters.containsKey(PARAM_SHOW_SUBMIT_ON_CHANGE)) showSubmitOnChange = true; if (parameters.containsKey(PARAM_SHORT_MODE)) isShortMode = true; if (parameters.containsKey(PARAM_SHOW_LEGEND)) showLegend = true; if (parameters.containsKey(PARAM_SHOW_AUTO_REFRESH)) showAutoRefresh = true; // Component properties. DashboardFilterProperty[] allProperties = getAllPropertiesForCurrentFilter(); for (int i = 0; i < allProperties.length; i++) { DashboardFilterProperty property = allProperties[i]; String dataProviderCode = property.getDataProviderCode(); String propertyId = property.getPropertyId(); String visibleParamKey = new StringBuffer() .append(PARAM_VISIBLE) .append("/") .append(dataProviderCode) .append("/") .append(propertyId) .toString(); String drillDownParamKey = new StringBuffer() .append(PARAM_SECTION) .append("/") .append(dataProviderCode) .append("/") .append(propertyId) .toString(); boolean isVisible = parameters.containsKey(visibleParamKey); Long sectionId = null; if (parameters.containsKey(drillDownParamKey)) { String sectionIdStr = ((String[]) parameters.get(drillDownParamKey))[0]; if (!PARAM_DRILLDOWN_DISABLED.equals(sectionIdStr)) sectionId = Long.decode(sectionIdStr); } if (!isVisible && sectionId == null) continue; // Property must be added? DashboardFilterProperty prop = getDashboardFilterPropertyForCurrentFilter(dataProviderCode, propertyId); if (prop == null) prop = new DashboardFilterProperty(dataProviderCode, propertyId, getFilter(), null, false); // Check if another property with same identifier. if (getDashboardFilterProperty(propertyId) != null) { // Another property with same id is already set to the filter. // Filter cannot use two properties with same property id., so show warning. notAllowedProperties.add(prop); continue; } // Add property to this component. properties.add(prop); // Set property parameters prop.setBeignFiltered(false); prop.setVisible(isVisible); prop.setSectionId(sectionId); } }