Help Edit DateComboBox

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Help Edit DateComboBox

Postby eramirezj » Mon Jan 02, 2012 7:01 am

Hello, I am using a DateComboBox and I want to rename buttons, specifically where it says "TODAY" and "NONE" any suggestions to make this possible, thank you. :)
eramirezj
 
Posts: 12
Joined: Mon Jan 02, 2012 6:43 am

Re: Help Edit DateComboBox

Postby JIDE Support » Mon Jan 02, 2012 8:31 am

Please override DateComboBox#createDateChooserPanel() then override DateChooserPanel#getResourceString(). You could return a different string for keys like "Date.ok" and "Date.today".

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Help Edit DateComboBox

Postby eramirezj » Mon Jan 02, 2012 11:18 am

sorry, my version of the jide is 2.9.5, where not exist the method CreateDateChooserPanel(),any other suggestions, i can not change version, thanks.
:(
eramirezj
 
Posts: 12
Joined: Mon Jan 02, 2012 6:43 am

Re: Help Edit DateComboBox

Postby JIDE Support » Mon Jan 02, 2012 11:30 am

Please try to use the following code to create a customized DateChooserPanel.
Code: Select all
        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;
            }
        };

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Help Edit DateComboBox

Postby eramirezj » Mon Jan 02, 2012 12:11 pm

when attempting to assign a button text to "NONE" and "TODAY" she says protected objects that are, thanks. :(
eramirezj
 
Posts: 12
Joined: Mon Jan 02, 2012 6:43 am

Re: Help Edit DateComboBox

Postby JIDE Support » Mon Jan 02, 2012 12:25 pm

Sorry that I can't quite get where your problem is now. The following code works fine for me in 2.9.6 in JIDE ComboBoxDemo.
Code: Select all
        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;
            }
        };

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: Help Edit DateComboBox

Postby eramirezj » Mon Jan 02, 2012 1:07 pm

thank you very much, topic resolved

:D
eramirezj
 
Posts: 12
Joined: Mon Jan 02, 2012 6:43 am

Re: Help Edit DateComboBox

Postby Kalyani » Tue Jan 03, 2012 12:55 am

Could you please guide me with the DateExComboBox.
I do not want the previous year button to be displayed.
I could do it in a simple DateChoosePanel but not in a DateExComboBox,even though it opens up a DateChooserPanel.

Could you please provide me with the sample Code
Kalyani
 
Posts: 10
Joined: Fri Nov 11, 2011 12:59 am

Re: Help Edit DateComboBox

Postby JIDE Support » Tue Jan 03, 2012 10:04 am

Please give the following code a try.
Code: Select all
    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;
        }
    }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 15 guests