List of usage examples for com.google.gwt.i18n.client DateTimeFormat getFormat
public static DateTimeFormat getFormat(String pattern)
From source file:accelerator.client.ui.TaskDialogBox.java
License:Open Source License
/** * /* w ww .j a v a2 s . com*/ */ public TaskDialogBox() { setWidget(uiBinder.createAndBindUi(this)); projectListBox.addItem("(??)", ""); List<HasCell<Tag, ?>> hasCells = CollectionUtil.createArrayList(); hasCells.add(new HasCell<Tag, Boolean>() { private final CheckboxCell cell = new CheckboxCell(); public Cell<Boolean> getCell() { return cell; } public FieldUpdater<Tag, Boolean> getFieldUpdater() { return null; } public Boolean getValue(Tag object) { return selectionModel.isSelected(object); } }); hasCells.add(new HasCell<Tag, Tag>() { private final TagCell cell = new TagCell(); public Cell<Tag> getCell() { return cell; } public FieldUpdater<Tag, Tag> getFieldUpdater() { return null; } public Tag getValue(Tag object) { return object; } }); CompositeCell<Tag> tagCell = new CompositeCell<Tag>(hasCells); tagCellList = new CellList<Tag>(tagCell); tagCellList.setSelectionModel(selectionModel, selectionManager); scrollPanel.add(tagCellList); nameErrorLabel.setVisible(false); setText("??"); setHandler(null); // DateBox ?? dueDateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("yyyy/MM/dd"))); }
From source file:accelerator.client.view.desktop.DesktopTaskListView.java
License:Open Source License
/** * CompositCell ? HasCell ?????/*from w w w . j a v a 2 s. com*/ * * @param handler * ???????? * @return HasCell ? */ private List<HasCell<Task, ?>> createHasCellList() { List<HasCell<Task, ?>> hasCellList = CollectionUtil.createArrayList(); // ?? hasCellList.add(new HasCell<Task, Boolean>() { private final CheckboxCell cell = new CheckboxCell(); public Cell<Boolean> getCell() { return cell; } public FieldUpdater<Task, Boolean> getFieldUpdater() { return new FieldUpdater<Task, Boolean>() { public void update(int index, Task object, Boolean value) { object.setCompleted(value); DesktopTaskListView.this.presenter.updateTask(object); } }; } public Boolean getValue(Task object) { return object.getCompleted(); } }); // ? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); // ???????????? if (presenter instanceof InboxPresenter) { return sb.toSafeHtml(); } else if (presenter instanceof ProjectPresenter) { return sb.toSafeHtml(); } Key projectKey = object.getProject(); if ((projectKey != null) && projectList.containsKey(projectKey)) { Project p = projectList.get(projectKey); sb.appendHtmlConstant("<span class=\"project\">"); sb.appendEscaped(p.getName()); sb.appendEscaped(":"); sb.appendHtmlConstant("</span>"); } return sb.toSafeHtml(); } }); // ??? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (object.getCompleted()) { sb.appendHtmlConstant("<s>"); sb.appendEscaped(object.getName()); sb.appendHtmlConstant("</s>"); } else { sb.appendEscaped(object.getName()); } return sb.toSafeHtml(); } }); // ? hasCellList.add(new HasCell<Task, String>() { private final IconButtonCell cell = new IconButtonCell(); public Cell<String> getCell() { cell.setIcon(JQueryUI.UI_ICON_CLOSE); return cell; } public FieldUpdater<Task, String> getFieldUpdater() { return new FieldUpdater<Task, String>() { public void update(int index, Task object, String value) { List<Task> tasks = CollectionUtil.createArrayList(); tasks.add(object); DesktopTaskListView.this.presenter.deleteTask(tasks); } }; } public String getValue(Task object) { return "?"; } }); // ? hasCellList.add(new HasCell<Task, String>() { private final IconButtonCell cell = new IconButtonCell(); public Cell<String> getCell() { cell.setIcon(JQueryUI.UI_ICON_PENCIL); return cell; } public FieldUpdater<Task, String> getFieldUpdater() { return new FieldUpdater<Task, String>() { public void update(int index, Task object, String value) { DesktopTaskListView.this.editTask(object); } }; } public String getValue(Task object) { return "?"; } }); // ?? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); private final DateTimeFormat format = DateTimeFormat.getFormat("yyyyMMdd"); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); Date d = object.getDueDate(); if (d != null) { sb.appendHtmlConstant("<span class=\"duedate\">"); sb.appendEscaped(format.format(d)); sb.appendHtmlConstant("</span>"); } return sb.toSafeHtml(); } }); // ?? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (DesktopTaskListView.this.tagMap != null) { List<Key> tagKeys = object.getTags(); for (Key tagKey : tagKeys) { if (DesktopTaskListView.this.tagMap.containsKey(tagKey)) { Tag tag = DesktopTaskListView.this.tagMap.get(tagKey); sb.appendHtmlConstant("<span class=\"tag\">"); sb.appendEscaped(tag.getName()); sb.appendHtmlConstant("</span>"); } } } return sb.toSafeHtml(); } }); return hasCellList; }
From source file:ar.com.kyol.jet.client.wrappers.DateBoxWrapper.java
License:Open Source License
/** * Instantiates a new date box wrapper.//from ww w . j a va 2 s.c o m * * @param date the date * @param objSetter the obj setter * @param dateBox the date box * @param useValueAsString the use value as string */ public DateBoxWrapper(Date date, ObjectSetter objSetter, final DateBox dateBox, boolean useValueAsString) { super(useValueAsString); this.dateBox = dateBox; this.date = date; this.objSetter = objSetter; dateBox.setValue(this.date); String format = "dd/MM/yyyy"; if (objSetter.getFormat() != null && !objSetter.getFormat().equals("")) { format = objSetter.getFormat(); } dateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(format))); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override @SuppressWarnings("rawtypes") public void onValueChange(ValueChangeEvent<Date> arg0) { if (DateBoxWrapper.this.date == null) { ClassType cType = TypeOracle.Instance .getClassType(DateBoxWrapper.this.objSetter.getObj().getClass()); DateBoxWrapper.this.date = new Date(); cType.invoke(DateBoxWrapper.this.objSetter.getObj(), DateBoxWrapper.this.objSetter.getSetter(), new Object[] { DateBoxWrapper.this.date }); } if (DateBoxWrapper.this.dateBox.getValue() != null) { DateBoxWrapper.this.date.setTime(DateBoxWrapper.this.dateBox.getValue().getTime()); } else { DateBoxWrapper.this.date = null; ClassType cType = TypeOracle.Instance .getClassType(DateBoxWrapper.this.objSetter.getObj().getClass()); cType.invoke(DateBoxWrapper.this.objSetter.getObj(), DateBoxWrapper.this.objSetter.getSetter(), new Object[] { DateBoxWrapper.this.date }); } } }); //gwt issue 4084 (Fixed in version 2.5) dateBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if ("".equals(event.getValue()) || null == event.getValue()) { ValueChangeEvent.fire(dateBox, null); } } }); initWidget(dateBox); }
From source file:ar.com.kyol.jet.client.wrappers.HTMLWrapper.java
License:Open Source License
/** * Instantiates a new hTML wrapper.// ww w .j av a 2s .co m * * @param objSetter the obj setter * @param html the html */ public HTMLWrapper(ObjectSetter objSetter, HTML html) { super(false); this.objSetter = objSetter; this.html = html; if (objSetter.getValue() == null) { html.setText(""); } else { NumberFormat.setForcedLatinDigits(true); if (objSetter.getValue() instanceof Float) { NumberFormat nf = NumberFormat.getFormat(getFormat("0.00")); Float valor = (Float) objSetter.getValue(); html.setText(nf.format(valor)); } else if (objSetter.getValue() instanceof Double) { NumberFormat nf = NumberFormat.getFormat(getFormat("0.00")); Double valor = (Double) objSetter.getValue(); html.setText(nf.format(valor)); } else if (objSetter.getValue() instanceof Long) { NumberFormat nf = NumberFormat.getFormat(getFormat("0")); Long valor = (Long) objSetter.getValue(); html.setText(nf.format(valor)); } else if (objSetter.getValue() instanceof Integer) { NumberFormat nf = NumberFormat.getFormat(getFormat("0")); Integer valor = (Integer) objSetter.getValue(); html.setText(nf.format(valor)); } else if (objSetter.getValue() instanceof java.util.Date) { java.util.Date utilDate = (java.util.Date) objSetter.getValue(); html.setText(DateTimeFormat.getFormat(getFormat("dd/MM/yyyy")).format(utilDate)); } else if (objSetter.getValue() instanceof java.sql.Date) { java.sql.Date sqlDate = (java.sql.Date) objSetter.getValue(); html.setText(DateTimeFormat.getFormat(getFormat("dd/MM/yyyy")).format(sqlDate)); } else if (objSetter.getValue() instanceof Timestamp) { Timestamp ts = (Timestamp) objSetter.getValue(); html.setText(DateTimeFormat.getFormat(getFormat("dd/MM/yyyy")).format(ts)); } else { html.setText(objSetter.getValue().toString()); } } initWidget(html); }
From source file:ar.com.kyol.jet.client.wrappers.SqlDateBoxWrapper.java
License:Open Source License
/** * Instantiates a new sql date box wrapper. * * @param date the date/*from w w w. j a v a 2s.c om*/ * @param dateBox the date box * @param useValueAsString the use value as string */ public SqlDateBoxWrapper(java.sql.Date date, DateBox dateBox, boolean useValueAsString, ObjectSetter objSetter) { super(useValueAsString); this.dateBox = dateBox; this.objSetter = objSetter; if (date != null) { this.date = new java.sql.Date(date.getTime()); } dateBox.setValue(this.date); String format = "dd/MM/yyyy"; if (objSetter.getFormat() != null && !objSetter.getFormat().equals("")) { format = objSetter.getFormat(); } dateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(format))); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> arg0) { java.util.Date date = SqlDateBoxWrapper.this.dateBox.getValue(); setProperty(new java.sql.Date(date.getTime())); } }); initWidget(dateBox); }
From source file:ar.com.kyol.jet.client.wrappers.TimestampBoxWrapper.java
License:Open Source License
private void initDateWidget() { if (this.originalTimestamp != null) { dateBox.setValue(new Date(this.timestamp.getTime())); }//from ww w . j av a 2 s . com String format = "dd/MM/yyyy"; if (objSetter.getFormat() != null && !objSetter.getFormat().equals("")) { format = objSetter.getFormat(); } dateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(format))); dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() { @Override public void onValueChange(ValueChangeEvent<Date> arg0) { refreshTimestamp(); Date inputDate = TimestampBoxWrapper.this.dateBox.getValue(); TimestampBoxWrapper.this.timestamp.setYear(inputDate.getYear()); TimestampBoxWrapper.this.timestamp.setMonth(inputDate.getMonth()); TimestampBoxWrapper.this.timestamp.setDate(inputDate.getDate()); setProperty(TimestampBoxWrapper.this.timestamp); } }); dateBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> arg0) { if ("".equals(arg0.getValue())) { cleanDate(); } } }); initWidget(dateBox); }
From source file:at.ait.dme.yuma.suite.apps.image.core.client.treeview.ImageAnnotationTreeNode.java
License:EUPL
protected HorizontalPanel createHeader() { HorizontalPanel headerPanel = new HorizontalPanel(); headerPanel.setStyleName("imageAnnotation-header"); Image avatar = new Image(annotation.getCreatedBy().getGravatarURL()); avatar.setStyleName("imageAnnotation-header-avatar"); headerPanel.add(avatar);//from w w w. jav a2 s .c o m Label userLabel = new Label(annotation.getCreatedBy().getUsername()); userLabel.setStyleName("imageAnnotation-header-user"); userLabel.getElement().setAttribute("property", "dc:creator"); headerPanel.add(userLabel); Label dateLabel = new Label("(" + DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT) .format(annotation.getLastModified()) + ")"); dateLabel.setStyleName("imageAnnotation-header-date"); headerPanel.add(dateLabel); PushButton feedIcon = new PushButton(new Image("images/feed-icon-14x14.png")); feedIcon.setStyleName("imageAnnotation-header-feedicon"); feedIcon.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.open(YUMACoreProperties.getFeedUrl() + "replies/" + annotation.getId(), "_self", ""); } }); headerPanel.add(feedIcon); return headerPanel; }
From source file:br.com.pegasus.solutions.smartgwt.lib.client.view.impl.formatter.HourCellFormater.java
License:Apache License
/** * format//from w w w.j a va2 s .c o m * * @param value * {@link Object} * @param record * {@link ListGridRecord} * @param rowNum * int * @param colNum * int * @return {@link String} */ public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value != null) { try { if (value instanceof Date) { Date date = (Date) value; return DateTimeFormat.getFormat("HH:mm").format(date); } return ""; } catch (Exception e) { return value.toString(); } } return ""; }
From source file:br.org.olimpiabarbacena.client.formulario.Membro.java
License:Apache License
public Membro(Principal principal, DialogBox dialogo) { this.principal = principal; this.dialogo = dialogo; initWidget(uiBinder.createAndBindUi(this)); dateboxNascimento.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("dd/MM/yyyy"))); // Let's disallow non-numeric entry in the normal text box. textboxCPF.addKeyPressHandler(new KeyPressHandler() { @Override/* w ww .ja v a 2 s . c om*/ public void onKeyPress(KeyPressEvent event) { if (!InputValidator.isInteger(event.getCharCode())) { // TextBox.cancelKey() suppresses the current keyboard ((TextBox) event.getSource()).cancelKey(); } } }); // Let's disallow non-numeric entry in the normal text box. textboxCEP.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (!InputValidator.isInteger(event.getCharCode())) { // TextBox.cancelKey() suppresses the current keyboard ((TextBox) event.getSource()).cancelKey(); } } }); // adiciona a lista dos estados brasileiros comboEstado.addItem("AC"); comboEstado.addItem("AL"); comboEstado.addItem("AP"); comboEstado.addItem("AM"); comboEstado.addItem("BA"); comboEstado.addItem("CE"); comboEstado.addItem("DF"); comboEstado.addItem("ES"); comboEstado.addItem("GO"); comboEstado.addItem("MA"); comboEstado.addItem("MT"); comboEstado.addItem("MS"); comboEstado.addItem("MG"); comboEstado.addItem("PA"); comboEstado.addItem("PB"); comboEstado.addItem("PR"); comboEstado.addItem("PE"); comboEstado.addItem("PI"); comboEstado.addItem("RJ"); comboEstado.addItem("RN"); comboEstado.addItem("RS"); comboEstado.addItem("RO"); comboEstado.addItem("RR"); comboEstado.addItem("SC"); comboEstado.addItem("SP"); comboEstado.addItem("SE"); comboEstado.addItem("TO"); }
From source file:bz.davide.dmweb.shared.view.DMDateBoxFactory.java
License:Open Source License
@Override public Widget create() { DatePicker datePicker = new DatePicker(); DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(this.dmDateBox.format); DateBox dateBox = new DateBox(datePicker, new Date(this.dmDateBox.timestamp), new DateBox.DefaultFormat(dateTimeFormat)); this.dmDateBox.dateBox = dateBox; this.dmDateBox.timestamp = 0; return dateBox; }