use of com.vaadin.ui.TextField in project v-leaflet by mstahv.
the class PopupTest method setup.
@Override
protected void setup() {
super.setup();
final TextField lat = new TextField("Lat");
lat.setValue("" + 60.4525);
content.addComponentAsFirst(lat);
final TextField lon = new TextField("Lon");
lon.setValue("" + 22.301);
content.addComponentAsFirst(lon);
final TextField html = new TextField("html");
content.addComponentAsFirst(html);
final CheckBox closeButton = new CheckBox("Close button");
content.addComponentAsFirst(closeButton);
final CheckBox closeonclick = new CheckBox("Close on click");
content.addComponentAsFirst(closeonclick);
content.addComponentAsFirst(new Button("Open popup", new ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
Double lonValue = Double.valueOf(lon.getValue());
Double latValue = Double.valueOf(lat.getValue());
LPopup lPopup = new LPopup(latValue, lonValue).setContent(html.getValue());
lPopup.setCloseButton(closeButton.getValue());
lPopup.setCloseOnClick(closeonclick.getValue());
leafletMap.addComponent(lPopup);
leafletMap.zoomToContent();
popups.add(lPopup);
lPopup.addDetachListener(PopupTest.this);
}
}));
content.addComponentAsFirst(new Button("Remove first", new ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
popups.remove(0).close();
}
}));
}
use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.
the class FormHelper method bindTextField.
public <M> TextField bindTextField(String fieldLabel, SingularAttribute<E, M> member) {
TextField field = bindTextField(form, group, fieldLabel, member.getName());
this.fieldList.add(field);
return field;
}
use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.
the class ReportParameterTable method init.
protected void init(final String caption, final Class<T> tableClass, final SingularAttribute<T, String> displayField) {
JpaBaseDao.getGenericDao(tableClass).flushCache();
container = createContainer(tableClass, displayField);
UI ui = UI.getCurrent();
if (ui != null) {
Runnable runner = new Runnable() {
@Override
public void run() {
try (AutoCloseable closer = EntityManagerProvider.setThreadLocalEntityManagerTryWithResources()) {
ReportParameterTable.this.displayField = displayField;
layout.setSizeFull();
ReportParameterTable.this.caption = caption;
TextField searchText = new TextField();
searchText.setInputPrompt("Search");
searchText.setWidth("100%");
searchText.setImmediate(true);
searchText.setHeight("20");
searchText.addTextChangeListener(new TextChangeListener() {
private static final long serialVersionUID = 1315710313315289836L;
@Override
public void textChange(TextChangeEvent event) {
String value = event.getText();
removeAllContainerFilters();
if (value.length() > 0) {
container.addContainerFilter(new SimpleStringFilter(displayField.getName(), value, true, false));
}
}
});
grid = new Grid();
grid.setImmediate(true);
grid.setSizeFull();
// table.setHeight("150");
grid.setContainerDataSource(container);
new GridHeadingPropertySet.Builder<T>().createColumn(caption, displayField.getName()).setLockedState(true).build().applyToGrid(grid);
List<SortOrder> orders = new LinkedList<>();
orders.add(new SortOrder(displayField.getName(), SortDirection.ASCENDING));
grid.setSortOrder(orders);
final Label selectionCount = new Label("0 selected");
// removed for concertina
// layout.addComponent(new Label(caption));
layout.addComponent(searchText);
layout.addComponent(grid);
HorizontalLayout selectionLayout = new HorizontalLayout();
selectionLayout.setHeight("30");
selectionLayout.setWidth("100%");
selectionLayout.addComponent(selectionCount);
selectionLayout.setComponentAlignment(selectionCount, Alignment.MIDDLE_RIGHT);
layout.addComponent(selectionLayout);
grid.addSelectionListener(new SelectionListener() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public void select(SelectionEvent event) {
validate();
selectionCount.setValue("" + event.getSelected().size() + " selected");
}
});
layout.setExpandRatio(grid, 1);
// layout.setComponentAlignment(selectAll,
// Alignment.BOTTOM_RIGHT);
} catch (Exception e) {
ErrorWindow.showErrorWindow(e);
}
}
};
UI.getCurrent().accessSynchronously(runner);
} else {
logger.warn("No vaadin session available, not setting up UI");
}
}
use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.
the class DateTimePickerInline method buildUI.
@Override
protected void buildUI(String title) {
datePicker = new InlineDateField(title + " Date");
datePicker.setDateFormat("yyyy/MM/dd");
datePicker.setValue(new Date());
displayDate = createTextDateField();
datePicker.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(Property.ValueChangeEvent event) {
final Date date = (Date) event.getProperty().getValue();
displayDate.setValue(dateFormatter.format(date));
}
});
final Label midnightLabel = new Label();
midnightLabel.setContentMode(ContentMode.HTML);
field = new TextField();
field.setWidth("125");
field.setImmediate(true);
displayTime = field;
displayTime.addValidator(timeValidator);
field.addValidator(timeValidator);
field.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
DateTimePickerInline.this.valueChange(event);
@SuppressWarnings("deprecation") int hour = getValue().getHours();
if (hour == 0) {
midnightLabel.setValue("<font color='red'><b>Midnight</b></font>");
} else {
midnightLabel.setValue("");
}
try {
final Date parsedDate = parseDate((String) event.getProperty().getValue());
if (parsedDate != null) {
Calendar parsed = Calendar.getInstance();
parsed.setTime(parsedDate);
dateTime.set(Calendar.HOUR_OF_DAY, parsed.get(Calendar.HOUR_OF_DAY));
dateTime.set(Calendar.MINUTE, parsed.get(Calendar.MINUTE));
isSet = true;
setNewValue();
}
} catch (InvalidValueException e) {
logger.info(e);
// the validator will handle this
}
}
});
field.setCaption(null);
datePicker.setCaption(null);
VerticalLayout vl = new VerticalLayout();
HorizontalLayout dateLayout = new HorizontalLayout();
dateLayout.setWidth("210");
Button changeYearButton = new Button("Year");
changeYearButton.setDescription("Change the year");
changeYearButton.setStyleName(ValoTheme.BUTTON_TINY);
changeYearButton.addClickListener(getChangeYearClickListener());
dateLayout.addComponent(displayDate);
dateLayout.addComponent(changeYearButton);
dateLayout.setComponentAlignment(changeYearButton, Alignment.MIDDLE_RIGHT);
vl.addComponent(datePicker);
HorizontalLayout timeFieldLayout = new HorizontalLayout();
timeFieldLayout.setSpacing(true);
timeFieldLayout.addComponent(field);
timeFieldLayout.addComponent(midnightLabel);
timeFieldLayout.setComponentAlignment(midnightLabel, Alignment.MIDDLE_LEFT);
vl.addComponent(buildInline());
addComponent(vl);
vl.addComponent(timeFieldLayout);
vl.addComponent(dateLayout);
vl.setSpacing(true);
}
use of com.vaadin.ui.TextField in project VaadinUtils by rlsutton1.
the class TimePicker method buildUI.
protected void buildUI(String title) {
field = new TextField();
field.setWidth("125");
field.setImmediate(true);
displayTime.setImmediate(true);
displayTime.addValidator(timeValidator);
field.addValidator(timeValidator);
field.addValueChangeListener(new ValueChangeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("deprecation")
@Override
public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
try {
final Date parsedDate = parseDate((String) event.getProperty().getValue());
if (parsedDate != null) {
dateTime.set(Calendar.HOUR_OF_DAY, parsedDate.getHours());
dateTime.set(Calendar.MINUTE, parsedDate.getMinutes());
isSet = true;
setNewValue();
}
TimePicker.this.valueChange(event);
field.setComponentError(null);
} catch (final InvalidValueException e) {
field.setComponentError(new ErrorMessage() {
private static final long serialVersionUID = 1L;
@Override
public String getFormattedHtmlMessage() {
return e.getMessage();
}
@Override
public ErrorLevel getErrorLevel() {
return ErrorLevel.ERROR;
}
});
}
}
});
this.title = title;
CssLayout hl = new CssLayout();
hl.addStyleName("v-component-group");
hl.setWidth("100%");
hl.setHeight("35");
pickerButton = new Button();
pickerButton.setIcon(FontAwesome.CLOCK_O);
hl.addComponent(pickerButton);
hl.addComponent(field);
pickerButton.addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void buttonClick(ClickEvent event) {
showPopupTimePicker();
}
});
addComponent(hl);
}
Aggregations