
Moderator: JIDE Support
DateComboBox dateComboBox = new DateComboBox() {
@Override
public PopupPanel createPopupComponent() {
final DateChooserPanel dateChooserPanel = new DateChooserPanel(getDateModel(), isShowTodayButton(), isShowNoneButton(), isShowWeekNumbers(), getLocale());
dateChooserPanel.setTimeDisplayed(isTimeDisplayed());
dateChooserPanel.setShowOKButton(isShowOKButton());
dateChooserPanel.getSelectionModel().addDateSelectionListener(new DateSelectionListener() {
public void valueChanged(DateSelectionEvent e) {
Date date = dateChooserPanel.getSelectionModel().getSelectedDate();
Object dateInEditor = getEditor().getItem();
if (!((dateInEditor instanceof Date && dateInEditor.equals(date)) || (dateInEditor instanceof Calendar && ((Calendar) dateInEditor).getTime().equals(date)))) {
getEditor().setItem(date);
setSelectedItem(date, false);
getEditor().selectAll();
}
}
});
return dateChooserPanel;
}
};
DateComboBox dateComboBox = new DateComboBox() {
@Override
public PopupPanel createPopupComponent() {
final DateChooserPanel dateChooserPanel = new DateChooserPanel(getDateModel(), isShowTodayButton(), isShowNoneButton(), isShowWeekNumbers(), getLocale()) {
@Override
protected String getResourceString(String key, Locale locale) {
if ("Date.ok".equals(key)) {
return "Test OK";
}
else if ("Date.today".equals(key)) {
return "Test Today";
}
return super.getResourceString(key, locale);
}
};
dateChooserPanel.setTimeDisplayed(isTimeDisplayed());
dateChooserPanel.setShowOKButton(isShowOKButton());
dateChooserPanel.getSelectionModel().addDateSelectionListener(new DateSelectionListener() {
public void valueChanged(DateSelectionEvent e) {
Date date = dateChooserPanel.getSelectionModel().getSelectedDate();
Object dateInEditor = getEditor().getItem();
if (!((dateInEditor instanceof Date && dateInEditor.equals(date)) || (dateInEditor instanceof Calendar && ((Calendar) dateInEditor).getTime().equals(date)))) {
getEditor().setItem(date);
setSelectedItem(date, false);
getEditor().selectAll();
}
}
});
return dateChooserPanel;
}
};
public class CustomizeDateExComboBox extends DateExComboBox {
public CustomizeDateExComboBox() {
super();
}
public CustomizeDateExComboBox(DateModel model) {
super(model);
}
@Override
public PopupPanel createPopupComponent() {
final DateChooserPanel dateChooserPanel = new DateChooserPanel(getDateModel(), isShowTodayButton(), isShowNoneButton(), isShowWeekNumbers(), getLocale()) {
// override here to hide the button as you did in plain DateChooserPanel
};
dateChooserPanel.setTimeDisplayed(isTimeDisplayed());
dateChooserPanel.setShowOKButton(isShowOKButton());
dateChooserPanel.getSelectionModel().addDateSelectionListener(new DateSelectionListener() {
public void valueChanged(DateSelectionEvent e) {
Object old = getSelectedItem();
Date date = dateChooserPanel.getSelectedDate();
setSelectedItem(date, false);
CustomizeDateExComboBox.this.fireItemStateChanged(new ItemEvent(CustomizeDateExComboBox.this, ItemEvent.ITEM_STATE_CHANGED, old, ItemEvent.DESELECTED));
CustomizeDateExComboBox.this.fireItemStateChanged(new ItemEvent(CustomizeDateExComboBox.this, ItemEvent.ITEM_STATE_CHANGED, date, ItemEvent.SELECTED));
}
});
return dateChooserPanel;
}
}
Return to JIDE Common Layer Open Source Project Discussion (Community Driven)
Users browsing this forum: No registered users and 12 guests