use of org.apache.pivot.wtk.CalendarButton in project pivot by apache.
the class ComponentInspectorSkin method updateCalendarDateControl.
private void updateCalendarDateControl(Dictionary<String, Object> dictionary, String key) {
CalendarButton calendarButton = (CalendarButton) controls.get(key);
if (calendarButton != null) {
CalendarDate value = (CalendarDate) dictionary.get(key);
calendarButton.setSelectedDate(value);
}
}
use of org.apache.pivot.wtk.CalendarButton in project pivot by apache.
the class ComponentInspectorSkin method addCalendarDateControl.
private static Component addCalendarDateControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
CalendarDate calendarDate = (CalendarDate) dictionary.get(key);
CalendarButton calendarButton = new CalendarButton();
calendarButton.setMinimumWidth(75);
calendarButton.setSelectedDate(calendarDate);
section.add(calendarButton);
Form.setLabel(calendarButton, key);
calendarButton.getCalendarButtonSelectionListeners().add(new CalendarButtonSelectionListener() {
@Override
public void selectedDateChanged(CalendarButton calendarButtonArgument, CalendarDate previousSelectedDate) {
try {
dictionary.put(key, calendarButtonArgument.getSelectedDate());
} catch (Exception exception) {
displayErrorMessage(exception, calendarButtonArgument.getWindow());
dictionary.put(key, previousSelectedDate);
}
}
});
return calendarButton;
}
use of org.apache.pivot.wtk.CalendarButton in project pivot by apache.
the class CalendarButtonDataRenderer method render.
@Override
public void render(final Object data, final Button button, boolean highlight) {
Object dataMutable = data;
CalendarButton calendarButton = (CalendarButton) button;
Locale locale = calendarButton.getLocale();
if (dataMutable == null) {
dataMutable = "";
} else {
if (dataMutable instanceof CalendarDate) {
CalendarDate date = (CalendarDate) dataMutable;
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
dataMutable = dateFormat.format(date.toCalendar().getTime());
}
}
super.render(dataMutable, button, highlight);
}
use of org.apache.pivot.wtk.CalendarButton in project pivot by apache.
the class CalendarButtonSkin method install.
@Override
public void install(Component component) {
super.install(component);
CalendarButton calendarButton = (CalendarButton) component;
calendarButton.getCalendarButtonListeners().add(this);
calendarButton.getCalendarButtonSelectionListeners().add(this);
calendar.setLocale(calendarButton.getLocale());
}
use of org.apache.pivot.wtk.CalendarButton in project pivot by apache.
the class CalendarTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BXMLSerializer bxmlSerializer = new BXMLSerializer();
window = (Window) bxmlSerializer.readObject(CalendarTest.class, "calendar_test.bxml");
bxmlSerializer.bind(this, CalendarTest.class);
Filter<CalendarDate> todayFilter = new Filter<CalendarDate>() {
@Override
public boolean include(CalendarDate date) {
CalendarDate today = new CalendarDate();
return (!date.equals(today));
}
};
calendar.setDisabledDateFilter(todayFilter);
calendarButton.getCalendarButtonListeners().add(new CalendarButtonListener() {
@Override
public void yearChanged(CalendarButton calendarButtonArgument, int previousYear) {
disable();
}
@Override
public void monthChanged(CalendarButton calendarButtonArgument, int previousMonth) {
disable();
}
private void disable() {
calendarButton.setDisabledDateFilter(new Filter<CalendarDate>() {
@Override
public boolean include(CalendarDate date) {
return true;
}
});
Task<Void> task = new Task<Void>() {
@Override
public Void execute() {
try {
Thread.sleep(500);
} catch (InterruptedException exception) {
// ignore exception
}
return null;
}
};
System.out.println("STARTING TASK");
task.execute(new TaskAdapter<>(new TaskListener<Void>() {
@Override
public void taskExecuted(Task<Void> taskArgument) {
System.out.println("EXECUTED");
calendarButton.setDisabledDateFilter(null);
}
@Override
public void executeFailed(Task<Void> taskArgument) {
System.out.println("FAILED");
calendarButton.setDisabledDateFilter(null);
}
}));
}
});
window.open(display);
}
Aggregations