List of usage examples for com.google.gwt.i18n.client NumberFormat getFormat
public static NumberFormat getFormat(String pattern)
NumberFormat
instance for the default locale using the specified pattern and the default currencyCode. From source file:org.sigmah.shared.dto.element.TextAreaElementDTO.java
License:Open Source License
/** * Creates a new <code>NumberField</code> for this element. * // w ww. j a v a 2s . co m * @param valueResult * Initial value to set. * @return A new <code>NumberField</code>. */ private TextField<Number> createNumberField(final ValueResult valueResult) { final NumberField numberField = new NumberField(); final boolean isDecimal = Boolean.TRUE.equals(getIsDecimal()); numberField.setAllowDecimals(isDecimal); numberField.setAllowNegative(true); preferredWidth = FlexibleElementDTO.NUMBER_FIELD_WIDTH; // Decimal value if (isDecimal) { numberField.setFormat(NumberFormat.getDecimalFormat()); // Sets the value to the field. if (valueResult != null && valueResult.isValueDefined()) { numberField.setValue(Double.parseDouble(valueResult.getValueObject())); } } // Non-decimal value else { numberField.setFormat(NumberFormat.getFormat("#")); // Sets the value to the field. if (valueResult != null && valueResult.isValueDefined()) { numberField.setValue(Long.parseLong(valueResult.getValueObject())); } } // Sets the min value. final Long minValue = getMinValue(); if (minValue != null) { numberField.setMinValue(minValue); } // Sets the min value. final Long maxValue = getMaxValue(); if (maxValue != null) { numberField.setMaxValue(maxValue); } // Sets tooltip. numberField.setToolTip(I18N.MESSAGES.flexibleElementTextAreaNumberRange( isDecimal ? I18N.CONSTANTS.flexibleElementDecimalValue() : I18N.CONSTANTS.flexibleElementNonDecimalValue(), minValue != null ? String.valueOf(minValue) : "-", maxValue != null ? String.valueOf(maxValue) : "-")); // Adds listeners. numberField.addListener(Events.OnKeyUp, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { onNumberFieldChange(numberField, isDecimal); } }); numberField.addListener(Events.OnBlur, new Listener<BaseEvent>() { @Override public void handleEvent(BaseEvent be) { onNumberFieldChange(numberField, isDecimal); } }); return numberField; }
From source file:org.sonar.api.web.gwt.client.Utils.java
License:Open Source License
public static String formatPercent(double percentage) { return NumberFormat.getFormat("0.0").format(percentage) + "%"; }
From source file:org.ssgwt.client.ui.datagrid.SSPager.java
License:Apache License
/** * Get the text to display in the pager that reflects the state of the * pager. This will show the range of records that are displayed * /*from www .java 2 s.c o m*/ * @return the text */ protected String createText() { // Default text is 1 based. NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay(); Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); return formatter.format(pageStart) + "-" + formatter.format(endIndex); }
From source file:org.ssgwt.client.ui.datagrid.SSPager.java
License:Apache License
/** * Get the text to display in the pager that reflects the state of the * pager. This will show the total amount of records * /*from w ww . j a va2 s .co m*/ * @return the text */ protected String createTextOf() { // Default text is 1 based. NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay(); Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); boolean exact = display.isRowCountExact(); return (exact ? " of " : " of over ") + formatter.format(dataSize); }
From source file:org.talend.mdm.webapp.browserecords.client.rest.ExplainRestServiceHandler.java
License:Open Source License
private String getScoreValue(JSONValue jsonValue) { String value = null;/* ww w . jav a 2s .c o m*/ if (jsonValue != null && jsonValue.isNumber() != null) { NumberFormat numberFormat = NumberFormat.getFormat("0.00"); //$NON-NLS-1$ value = numberFormat.format(jsonValue.isNumber().doubleValue() * 100) + "%"; //$NON-NLS-1$ } return value; }
From source file:org.talend.mdm.webapp.browserecords.client.util.FormatUtil.java
License:Open Source License
public static String changeNumberToFormatedValue(String value) { StringBuilder pattern = new StringBuilder("###0."); if (value == null || value.equals("")) { return ""; }/*from www. java 2s .c om*/ if (value.contains(",")) { value = value.replace(",", "."); } int fractionDigits = 0; if (value.contains(".")) { fractionDigits = value.trim().split("\\.")[1].length(); } if (fractionDigits == 0) { pattern.append("######"); } for (int i = 0; i < fractionDigits; i++) { pattern.append("0"); } NumberFormat nf = NumberFormat.getFormat(pattern.toString()); return nf.format(Double.valueOf(value)); }
From source file:org.talend.mdm.webapp.stagingarea.control.client.view.StagingContainerSummaryView.java
License:Open Source License
@Override public void onModelEvent(ModelEvent e) { GwtEvent.Type<ModelEventHandler> type = e.getAssociatedType(); if (type == ModelEvent.Types.CONTAINER_MODEL_CHANGED.getType()) { StagingContainerModel stagingContainerModel = e.getModel(); // Updates summary int waiting = stagingContainerModel.getWaitingValidationRecords(); int valid = stagingContainerModel.getValidRecords(); int invalid = stagingContainerModel.getInvalidRecords(); Element titleEl = detailPanel.getElementById(STAGING_AREA_TITLE); titleEl.setInnerHTML(messages.total_desc("<b>" + stagingContainerModel.getTotalRecords() + "</b>")); //$NON-NLS-1$ //$NON-NLS-2$ Element waitingEl = detailPanel.getElementById(STAGING_AREA_WAITING); waitingEl.setInnerHTML(messages.waiting_desc("<b>" + waiting + "</b>")); //$NON-NLS-1$ //$NON-NLS-2$ Element invalidEl = detailPanel.getElementById(STAGING_AREA_INVALID); invalidEl.setInnerHTML(messages.invalid_desc( "<span id=\"open_invalid_record\" style=\"color:red; text-decoration:underline; cursor:pointer;\">", //$NON-NLS-1$ "<b>" + invalid + "</b>", "</span>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Element open_invalid_record = detailPanel.getElementById("open_invalid_record"); //$NON-NLS-1$ addClickForRecord(2, open_invalid_record); Element validEl = detailPanel.getElementById(STAGING_AREA_VALID); validEl.setInnerHTML(messages.valid_desc( "<span id=\"open_valid_record\" style=\"color:green; text-decoration:underline; cursor:pointer;\">", //$NON-NLS-1$ "<b>" + valid + "</b>", "</span>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Element open_valid_record = detailPanel.getElementById("open_valid_record"); //$NON-NLS-1$ addClickForRecord(3, open_valid_record); // Update gauge bar int total = valid + invalid + waiting; if (total == 0) { gaugeBar.reset();//from w w w. j a v a 2s .c o m return; } double percentage = valid * 1D / total; NumberFormat format = NumberFormat.getFormat("#0.00"); //$NON-NLS-1$ final double validPercentage = format.parse(format.format(valid * 100D / total)); if (gaugeBar.getValue() < 1.0 || totalRecordCount != total) { gaugeBar.updateProgress(percentage, messages.percentage(valid, total, validPercentage)); } totalRecordCount = total; } else if (type == ModelEvent.Types.VALIDATION_END.getType() || type == ModelEvent.Types.VALIDATION_CANCEL.getType()) { startValidate.enable(); } else if (type == ModelEvent.Types.VALIDATION_START.getType()) { startValidate.disable(); } }
From source file:org.uberfire.ext.widgets.table.client.UberfireSimplePager.java
License:Apache License
protected String createText() { NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay();//from ww w. ja v a2 s .c o m Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); boolean exact = display.isRowCountExact(); if (dataSize == 0) { return "0 " + of() + " 0"; } else if (pageStart == endIndex) { return formatter.format(pageStart) + " " + of() + " " + formatter.format(dataSize); } return formatter.format(pageStart) + "-" + formatter.format(endIndex) + (exact ? " " + of() + " " : " " + of() + " " + over() + " ") + formatter.format(dataSize); }
From source file:org.unitime.timetable.gwt.client.instructor.InstructorsTable.java
License:Apache License
protected Widget getCell(final InstructorInterface instructor, final InstructorsColumn column, final int idx) { switch (column) { case ID:// w w w. ja va 2s .c o m if (instructor.getExternalId() == null) { Image warning = new Image(RESOURCES.warning()); warning.setTitle(MESSAGES.warnInstructorHasNoExternalId(instructor.getFormattedName())); return warning; } else { return new Label(instructor.getExternalId()); } case NAME: return new Label(instructor.getFormattedName()); case POSITION: return new Label(instructor.getPosition() == null ? "" : instructor.getPosition().getLabel()); case TEACHING_PREF: if (instructor.getTeachingPreference() == null) { return new Label(""); } else { Label pref = new Label(instructor.getTeachingPreference().getName()); if (instructor.getTeachingPreference().getColor() != null) pref.getElement().getStyle().setColor(instructor.getTeachingPreference().getColor()); return pref; } case MAX_LOAD: return new Label(instructor.hasMaxLoad() ? NumberFormat.getFormat(CONSTANTS.teachingLoadFormat()).format(instructor.getMaxLoad()) : ""); case SELECTION: return new SelectableCell(instructor); case ATTRIBUTES: AttributeTypeInterface type = iProperties.getAttributeTypes().get(idx); List<AttributeInterface> attributes = instructor.getAttributes(type); if (!attributes.isEmpty() && !isColumnVisible(getCellIndex(column) + idx)) { setColumnVisible(getCellIndex(column) + idx, true); } return new AttributesCell(attributes); default: return null; } }
From source file:org.unitime.timetable.gwt.client.sectioning.StudentSchedule.java
License:Apache License
protected void fillInRequests() { ArrayList<WebTable.Row> rows = new ArrayList<WebTable.Row>(); boolean hasPref = false, hasWarn = false, hasWait = false, hasStat = false, hasCrit = false; NumberFormat df = NumberFormat.getFormat("0.#"); if (iAssignment.hasRequest()) { CheckCoursesResponse check = new CheckCoursesResponse(iAssignment.getRequest().getConfirmations()); hasWarn = iAssignment.getRequest().hasConfirmations(); int priority = 1; for (Request request : iAssignment.getRequest().getCourses()) { if (!request.hasRequestedCourse()) continue; boolean first = true; if (request.isWaitList()) hasWait = true;/*w w w . ja v a 2s . c o m*/ if (request.isCritical()) hasCrit = true; for (RequestedCourse rc : request.getRequestedCourse()) { if (rc.isCourse()) { ImageResource icon = null; String iconText = null; String msg = check.getMessage(rc.getCourseName(), "\n"); if (check.isError(rc.getCourseName()) && (rc.getStatus() == null || rc.getStatus() != RequestedCourseStatus.OVERRIDE_REJECTED)) { icon = RESOURCES.requestError(); iconText = (msg); } else if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: icon = RESOURCES.requestEnrolled(); iconText = (MESSAGES.enrolled(rc.getCourseName())); break; case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); iconText = (MESSAGES.overrideNeeded(msg)); break; case SAVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.requested(rc.getCourseName())); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestRejected(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideRejected(rc.getCourseName())); break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overridePending(rc.getCourseName())); break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestCancelled(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideCancelled(rc.getCourseName())); break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideApproved(rc.getCourseName())); break; default: if (check.isError(rc.getCourseName())) icon = RESOURCES.requestError(); iconText = (msg); } } if (rc.hasStatusNote()) iconText += "\n" + MESSAGES.overrideNote(rc.getStatusNote()); Collection<Preference> prefs = null; if (rc.hasSelectedIntructionalMethods()) { if (rc.hasSelectedClasses()) { prefs = new ArrayList<Preference>(rc.getSelectedIntructionalMethods().size() + rc.getSelectedClasses().size()); prefs.addAll(new TreeSet<Preference>(rc.getSelectedIntructionalMethods())); prefs.addAll(new TreeSet<Preference>(rc.getSelectedClasses())); } else { prefs = new TreeSet<Preference>(rc.getSelectedIntructionalMethods()); } } else if (rc.hasSelectedClasses()) { prefs = new TreeSet<Preference>(rc.getSelectedClasses()); } String status = ""; if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: status = MESSAGES.reqStatusEnrolled(); break; case OVERRIDE_APPROVED: status = MESSAGES.reqStatusApproved(); hasStat = true; break; case OVERRIDE_CANCELLED: status = MESSAGES.reqStatusCancelled(); hasStat = true; break; case OVERRIDE_PENDING: status = MESSAGES.reqStatusPending(); hasStat = true; break; case OVERRIDE_REJECTED: status = MESSAGES.reqStatusRejected(); hasStat = true; break; } } if (status.isEmpty()) status = MESSAGES.reqStatusRegistered(); if (prefs != null) hasPref = true; WebTable.Cell credit = new WebTable.Cell( rc.hasCredit() ? (rc.getCreditMin().equals(rc.getCreditMax()) ? df.format(rc.getCreditMin()) : df.format(rc.getCreditMin()) + " - " + df.format(rc.getCreditMax())) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); String note = null, noteTitle = null; if (check != null) { note = check.getMessageWithColor(rc.getCourseName(), "<br>", "CREDIT"); noteTitle = check.getMessage(rc.getCourseName(), "\n", "CREDIT"); } if (rc.hasStatusNote()) { note = (note == null ? "" : note + "<br>") + rc.getStatusNote(); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + rc.getStatusNote(); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(rc.getCourseName()), new WebTable.Cell(rc.hasCourseTitle() ? rc.getCourseTitle() : ""), credit, new WebTable.Cell(ToolBox.toString(prefs)), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), (first && request.isCritical() ? new WebTable.IconCell(RESOURCES.requestsCritical(), MESSAGES.descriptionRequestCritical(), "") : new WebTable.Cell("")), (first && request.isWaitList() ? new WebTable.IconCell(RESOURCES.requestsWaitList(), MESSAGES.descriptionRequestWaitListed(), "") : new WebTable.Cell("")), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (priority > 1 && first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-dashed"); rows.add(row); } else if (rc.isFreeTime()) { String free = ""; for (FreeTime ft : rc.getFreeTime()) { if (!free.isEmpty()) free += ", "; free += ft.toString(CONSTANTS.shortDays(), CONSTANTS.useAmPm()); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(CONSTANTS.freePrefix() + free, 3, null), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.IconCell(RESOURCES.requestSaved(), MESSAGES.requested(free), MESSAGES.reqStatusRegistered()), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (priority > 1 && first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-dashed"); rows.add(row); } first = false; } priority++; } priority = 1; for (Request request : iAssignment.getRequest().getAlternatives()) { if (!request.hasRequestedCourse()) continue; boolean first = true; if (request.isWaitList()) hasWait = true; if (request.isCritical()) hasCrit = true; for (RequestedCourse rc : request.getRequestedCourse()) { if (rc.isCourse()) { ImageResource icon = null; String iconText = null; String msg = check.getMessage(rc.getCourseName(), "\n"); if (check.isError(rc.getCourseName()) && (rc.getStatus() == null || rc.getStatus() != RequestedCourseStatus.OVERRIDE_REJECTED)) { icon = RESOURCES.requestError(); iconText = (msg); } else if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: icon = RESOURCES.requestEnrolled(); iconText = (MESSAGES.enrolled(rc.getCourseName())); break; case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); iconText = (MESSAGES.overrideNeeded(msg)); break; case SAVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.requested(rc.getCourseName())); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestRejected(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideRejected(rc.getCourseName())); break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overridePending(rc.getCourseName())); break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestCancelled(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideCancelled(rc.getCourseName())); break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideApproved(rc.getCourseName())); break; default: if (check.isError(rc.getCourseName())) icon = RESOURCES.requestError(); iconText = (msg); } } if (rc.hasStatusNote()) iconText += "\n" + MESSAGES.overrideNote(rc.getStatusNote()); Collection<Preference> prefs = null; if (rc.hasSelectedIntructionalMethods()) { if (rc.hasSelectedClasses()) { prefs = new ArrayList<Preference>(rc.getSelectedIntructionalMethods().size() + rc.getSelectedClasses().size()); prefs.addAll(new TreeSet<Preference>(rc.getSelectedIntructionalMethods())); prefs.addAll(new TreeSet<Preference>(rc.getSelectedClasses())); } else { prefs = new TreeSet<Preference>(rc.getSelectedIntructionalMethods()); } } else if (rc.hasSelectedClasses()) { prefs = new TreeSet<Preference>(rc.getSelectedClasses()); } if (prefs != null) hasPref = true; String status = ""; if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: status = MESSAGES.reqStatusEnrolled(); break; case OVERRIDE_APPROVED: status = MESSAGES.reqStatusApproved(); hasStat = true; break; case OVERRIDE_CANCELLED: status = MESSAGES.reqStatusCancelled(); hasStat = true; break; case OVERRIDE_PENDING: status = MESSAGES.reqStatusPending(); hasStat = true; break; case OVERRIDE_REJECTED: status = MESSAGES.reqStatusRejected(); hasStat = true; break; } } if (status.isEmpty()) status = MESSAGES.reqStatusRegistered(); WebTable.Cell credit = new WebTable.Cell( rc.hasCredit() ? (rc.getCreditMin().equals(rc.getCreditMax()) ? df.format(rc.getCreditMin()) : df.format(rc.getCreditMin()) + " - " + df.format(rc.getCreditMax())) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); String note = null, noteTitle = null; if (check != null) { note = check.getMessageWithColor(rc.getCourseName(), "<br>", "CREDIT"); noteTitle = check.getMessage(rc.getCourseName(), "\n", "CREDIT"); } if (rc.hasStatusNote()) { note = (note == null ? "" : note + "<br>") + rc.getStatusNote(); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + rc.getStatusNote(); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsAlternative(priority) : ""), new WebTable.Cell(rc.getCourseName()), new WebTable.Cell(rc.hasCourseTitle() ? rc.getCourseTitle() : ""), credit, new WebTable.Cell(ToolBox.toString(prefs)), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), (first && request.isCritical() ? new WebTable.IconCell(RESOURCES.requestsCritical(), MESSAGES.descriptionRequestCritical(), "") : new WebTable.Cell("")), (first && request.isWaitList() ? new WebTable.IconCell(RESOURCES.requestsWaitList(), MESSAGES.descriptionRequestWaitListed(), "") : new WebTable.Cell("")), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName(priority == 1 ? "top-border-solid" : "top-border-dashed"); rows.add(row); } else if (rc.isFreeTime()) { String free = ""; for (FreeTime ft : rc.getFreeTime()) { if (!free.isEmpty()) free += ", "; free += ft.toString(CONSTANTS.shortDays(), CONSTANTS.useAmPm()); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(CONSTANTS.freePrefix() + free, 3, null), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.IconCell(RESOURCES.requestSaved(), MESSAGES.requested(free), MESSAGES.reqStatusRegistered()), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName(priority == 1 ? "top-border-solid" : "top-border-dashed"); rows.add(row); } first = false; } priority++; } } if (iAssignment.getRequest().getMaxCreditOverrideStatus() != null) { ImageResource icon = null; String status = ""; String note = null, noteTitle = null; String iconText = null; if (iAssignment.getRequest().hasCreditWarning()) { note = iAssignment.getRequest().getCreditWarning().replace("\n", "<br>"); noteTitle = iAssignment.getRequest().getCreditWarning(); iconText = iAssignment.getRequest().getCreditWarning(); hasWarn = true; } else if (iAssignment.getRequest().getMaxCreditOverrideStatus() != RequestedCourseStatus.SAVED) { note = noteTitle = iconText = MESSAGES.creditWarning(iAssignment.getRequest().getCredit()); } switch (iAssignment.getRequest().getMaxCreditOverrideStatus()) { case CREDIT_HIGH: icon = RESOURCES.requestError(); status = MESSAGES.reqStatusRejected(); note = "<span class='text-red'>" + note + "</span>"; iconText += "\n" + MESSAGES.creditStatusTooHigh(); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestError(); status = MESSAGES.reqStatusRejected(); note = "<span class='text-red'>" + note + "</span>"; iconText += "\n" + MESSAGES.creditStatusDenied(); break; case CREDIT_LOW: case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); status = MESSAGES.reqStatusWarning(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestNeeded(); status = MESSAGES.reqStatusCancelled(); iconText += "\n" + MESSAGES.creditStatusCancelled(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); status = MESSAGES.reqStatusPending(); iconText += "\n" + MESSAGES.creditStatusPending(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); status = MESSAGES.reqStatusApproved(); iconText += (iconText == null ? "" : iconText + "\n") + MESSAGES.creditStatusApproved(); break; case SAVED: icon = RESOURCES.requestSaved(); status = MESSAGES.reqStatusRegistered(); break; } if (!status.isEmpty()) hasStat = true; if (iAssignment.getRequest().hasCreditNote()) { note = (note == null ? "" : note + "<br>") + iAssignment.getRequest().getCreditNote().replace("\n", "<br>"); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + MESSAGES.overrideNote(iAssignment.getRequest().getCreditNote()); iconText = (iconText == null ? "" : iconText + "\n") + iAssignment.getRequest().getCreditNote(); hasWarn = true; } float[] range = iAssignment.getRequest().getCreditRange(); WebTable.Cell credit = new WebTable.Cell(range != null ? range[0] < range[1] ? df.format(range[0]) + " - " + df.format(range[1]) : df.format(range[0]) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); WebTable.Row row = new WebTable.Row(new WebTable.Cell(MESSAGES.rowRequestedCredit(), 2, null), new WebTable.Cell(""), credit, new WebTable.Cell(""), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), new WebTable.Cell(""), new WebTable.Cell("")); for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-solid"); row.getCell(0).setStyleName("top-border-solid text-bold"); rows.add(row); } WebTable.Row[] rowArray = new WebTable.Row[rows.size()]; int idx = 0; for (WebTable.Row row : rows) rowArray[idx++] = row; iRequests.setData(rowArray); iRequests.setColumnVisible(4, hasPref); iRequests.setColumnVisible(5, hasWarn); iRequests.setColumnVisible(6, hasStat); iRequests.setColumnVisible(7, hasCrit); iRequests.setColumnVisible(8, hasWait); }