public String getName(Locale l) { // Get name in specified locale. String name = (String) nameI18nMap.get(l); if (name != null) return name; // Get name in default locale. LocaleManager lm = LocaleManager.lookup(); name = (String) lm.localize(nameI18nMap); if (name != null) return name; // Use formatter to get the name. DataPropertyFormatter df = DataFormatterRegistry.lookup().getPropertyFormatter(id); if (df != null) return df.formatName(this, l); return id; }
protected String formatForDisplay(String propertyId, Object value) { DataPropertyFormatter formatter = DataFormatterRegistry.lookup().getPropertyFormatter(propertyId); return formatter.formatValue(propertyId, value, LocaleManager.currentLocale()); }
public String getDescription(Locale l) { DataFormatterRegistry dfr = DataFormatterRegistry.lookup(); DataProperty property = getDomain().getProperty(); if (property == null) return getLabel(); DataPropertyFormatter dpf = dfr.getPropertyFormatter(property.getPropertyId()); return dpf.formatValue(property, getLabel(), l); }
public static String generateKPIValuesArray(KPI kpi) { DataSet dataSet = KPIHelper.getDataSet(kpi); if (dataSet == null) return null; DataFormatterRegistry dataFormatterRegistry = DataFormatterRegistry.lookup(); StringBuffer buf = new StringBuffer(); buf.append("new String[][] {"); for (int i = 0; i < dataSet.getRowCount(); i++) { buf.append("\n{"); for (int j = 0; j < dataSet.getProperties().length; j++) { Object dataSetValue = dataSet.getValueAt(i, j); DataProperty prop = dataSet.getPropertyByColumn(j); DataPropertyFormatter propFormatter = dataFormatterRegistry.getPropertyFormatter(prop.getPropertyId()); String displayedValue = propFormatter.formatValue(prop, dataSetValue, Locale.ENGLISH); if (j > 0) buf.append(","); buf.append("\"" + displayedValue + "\""); } buf.append("}"); if (i < dataSet.getRowCount()-1) buf.append(","); } buf.append("}"); return buf.toString(); }
/** * Check if some data set rows match a given result. * @param dataSet The data set to validate. * @param x The x position of the cell to check (starting at 0). * @param y The y position of the cell to check (starting at 0). * @param expected The expected value in the given cell. */ public static void assertDataSetValue(DataSet dataSet, int x, int y, String expected) { Locale locale = Locale.ENGLISH; DataFormatterRegistry dataFormatterRegistry = DataFormatterRegistry.lookup(); Object value = dataSet.getValueAt(x,y); DataProperty prop = dataSet.getPropertyByColumn(y); DataPropertyFormatter propFormatter = dataFormatterRegistry.getPropertyFormatter(prop.getPropertyId()); String displayedValue = propFormatter.formatValue(prop, value, locale); if (!displayedValue.equals(expected)) { fail("Data set value [" + x + "," + y + "] is different. " + "Column=\"" + prop.getPropertyId() + "\" " + "Actual=\"" + displayedValue + "\" Expected=\"" + expected + "\""); } }
DataPropertyFormatter propFormatter = dataFormatterRegistry.getPropertyFormatter(prop.getPropertyId()); String displayedValue = propFormatter.formatValue(prop, dataSetValue, locale); if (!displayedValue.equals(expectedValue)) {