| Summary: | Custom property source (date editor) | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] EMF | Reporter: | Krzysztof Daniel <krzysztof.daniel> | ||||||||
| Component: | Core | Assignee: | Ed Merks <Ed.Merks> | ||||||||
| Status: | CLOSED DUPLICATE | QA Contact: | |||||||||
| Severity: | enhancement | ||||||||||
| Priority: | P3 | CC: | ronbermejo | ||||||||
| Version: | unspecified | ||||||||||
| Target Milestone: | --- | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Windows Vista | ||||||||||
| URL: | http://eclipser-blog.blogspot.com/2007/10/custom-property-source-for-emf.html | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
Move out of doc so Ed will see it. Created attachment 79847 [details]
A patch that incorporates the design ideas...
Unfortunately a java.util.Date also includes a time, not just a calendar date and CALENDAR doesn't let you set that. The TIME and DATE dialogs are very crude and don't even appear to be formatted quite right, i.e., the text in the widget is too close to the bottom of the display field. So I'm not sure we can use this directly. It will require more thought.
Created attachment 80864 [details]
Proposal
Ed, and maybe somthing like that?
If this is to raw maybe it could be a good idea to add labels and position time belowe the date?
Yes, that seems nicer. One could even imagine launching a calendar control to set the date part of it. XML Schema dateTime even allows arbitrary precision fractional seconds... Created attachment 83229 [details]
Proposal 2
And what about this layout?
Ed, could you review this layout? Christopher, That's very nice! It's prefect for java.util.Date. To fully support XMLGregorianCalendar you'd somehow need to deal with fractional time and with timezones: http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/XMLGregorianCalendar.html#getFractionalSecond() http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/datatype/XMLGregorianCalendar.html#getTimezone() And of course there's a whole whack of similar XML Schema types like gYear. Dealing with date, dateTime, and time are the most important ones... It would be nice to have some type of registration mechanism for cell editors as described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=205432... In https://bugs.eclipse.org/bugs/show_bug.cgi?id=438123 I've implemented very flexible support that uses Nebula's CDateTime widget. *** This bug has been marked as a duplicate of bug 438123 *** |
Ed, as you said, I am putting bugzilla entry with code and link. public CellEditor createPropertyEditor(Composite composite) { CellEditor result = super.createPropertyEditor(composite); if(result == null) return result; EClassifier eType = ((EStructuralFeature)itemPropertyDescriptor.getFeature(object)).getEType(); if (eType instanceof EDataType) { EDataType eDataType = (EDataType) eType; if(eDataType.getInstanceClass() == Date.class){ result = new ExtendedDialogCellEditor(composite, getEditLabelProvider()){ protected Object openDialogBox(Control cellEditorWindow) { final DateTime dateTime[] = new DateTime[1]; final Date[] date = new Date[1]; Dialog d = new Dialog(cellEditorWindow.getShell()){ protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); dateTime[0] = new DateTime(dialogArea, SWT.CALENDAR); dateTime[0].addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { Date dateValue = new Date(); dateValue.setYear(dateTime[0].getYear()); dateValue.setMonth(dateTime[0].getMonth()); dateValue.setDate(dateTime[0].getDay()); date[0] = dateValue; super.widgetSelected(e); } }); return dialogArea; } }; d.setBlockOnOpen(true); d.open(); if(d.getReturnCode() == Dialog.OK){ return date[0]; } return null; } }; } } return result; }