Revision 6430b43e
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElement.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.ui.mvc.element; |
10 | 10 |
|
11 |
|
|
12 |
import java.util.Calendar; |
|
13 |
import java.util.ConcurrentModificationException; |
|
14 |
import java.util.List; |
|
15 |
|
|
16 |
import org.eclipse.core.runtime.Assert; |
|
17 |
import org.eclipse.jface.util.IPropertyChangeListener; |
|
11 | 18 |
import org.eclipse.swt.SWT; |
12 | 19 |
import org.eclipse.swt.events.DisposeEvent; |
13 | 20 |
import org.eclipse.swt.events.DisposeListener; |
21 |
import org.eclipse.swt.events.SelectionAdapter; |
|
22 |
import org.eclipse.swt.events.SelectionEvent; |
|
23 |
import org.eclipse.swt.graphics.Image; |
|
24 |
import org.eclipse.swt.layout.GridData; |
|
25 |
import org.eclipse.swt.layout.GridLayout; |
|
26 |
import org.eclipse.swt.widgets.Button; |
|
14 | 27 |
import org.eclipse.swt.widgets.Composite; |
28 |
import org.eclipse.swt.widgets.DateTime; |
|
15 | 29 |
import org.eclipse.swt.widgets.Display; |
30 |
import org.eclipse.swt.widgets.Label; |
|
31 |
import org.eclipse.swt.widgets.Shell; |
|
16 | 32 |
import org.eclipse.swt.widgets.Text; |
17 | 33 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
18 | 34 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
19 | 35 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
20 |
import org.joda.time.DateTime; |
|
36 |
//import org.joda.time.DateTime;
|
|
21 | 37 |
|
38 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
22 | 39 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
40 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
|
23 | 41 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
42 |
import eu.etaxonomy.taxeditor.ui.element.IPropertyChangeEmitter; |
|
24 | 43 |
import eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite; |
25 | 44 |
|
26 | 45 |
/** |
... | ... | |
28 | 47 |
* @date 16.06.2014 |
29 | 48 |
* |
30 | 49 |
*/ |
31 |
public class DateElement extends AbstractCdmComposite<DateElementController> { |
|
50 |
public class DateElement extends AbstractCdmComposite<DateElementController> {
|
|
32 | 51 |
|
33 | 52 |
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
34 |
private final DateTime initialDateTime; |
|
35 |
private final Text textDate; |
|
53 |
private org.joda.time.DateTime initialDateTime; |
|
54 |
private Text textDate; |
|
55 |
// private final Button openDateDialog; |
|
56 |
|
|
36 | 57 |
|
37 | 58 |
/** |
38 | 59 |
* Create the composite. |
39 | 60 |
* @param parent |
40 | 61 |
* @param style |
41 | 62 |
*/ |
42 |
public DateElement(Composite parent, DateTime initialDateTime, int style) { |
|
63 |
public DateElement(Composite parent, org.joda.time.DateTime initialDateTime, int style) {
|
|
43 | 64 |
super(parent, style); |
44 | 65 |
this.initialDateTime = initialDateTime; |
45 | 66 |
addDisposeListener(new DisposeListener() { |
... | ... | |
63 | 84 |
|
64 | 85 |
textDate = new Text(this, SWT.BORDER | SWT.WRAP); |
65 | 86 |
textDate.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
87 |
|
|
88 |
// openDateDialog = new Button (this, SWT.PUSH); |
|
89 |
// Image image = getDisplay().getSystemImage(SWT.DATE); |
|
90 |
// openDateDialog.setText ("Open Date Dialog"); |
|
91 |
// openDateDialog.addSelectionListener (new SelectionAdapter() { |
|
92 |
// @Override |
|
93 |
// public void widgetSelected(SelectionEvent e){ |
|
94 |
// final Shell dialog = new Shell (parent.getShell(), SWT.DIALOG_TRIM); |
|
95 |
// |
|
96 |
// dialog.setLayout (new GridLayout (3, false)); |
|
97 |
// |
|
98 |
// final DateTime calendar = new DateTime (dialog, SWT.CALENDAR | SWT.BORDER); |
|
99 |
// //final DateTime time = new DateTime (dialog, SWT.TIME | SWT.SHORT); |
|
100 |
// |
|
101 |
// new Label (dialog, SWT.NONE); |
|
102 |
// new Label (dialog, SWT.NONE); |
|
103 |
// Button ok = new Button (dialog, SWT.PUSH); |
|
104 |
// ok.setText ("OK"); |
|
105 |
// ok.setLayoutData(new GridData (SWT.FILL, SWT.CENTER, false, false)); |
|
106 |
// ok.addSelectionListener (new SelectionAdapter() { |
|
107 |
// @Override |
|
108 |
// public void widgetSelected(SelectionEvent e){ |
|
109 |
// setData(makeJodaFromSWT(calendar)); |
|
110 |
// setTextDate((calendar.getMonth () + 1) + "/" + calendar.getDay () + "/" + calendar.getYear ()); |
|
111 |
// System.out.println ("Calendar date selected (MM/DD/YYYY) = " + (calendar.getMonth () + 1) + "/" + calendar.getDay () + "/" + calendar.getYear ()); |
|
112 |
// // System.out.println ("Time selected (HH:MM) = " + time.getHours () + ":" + (time.getMinutes () < 10 ? "0" : "") + time.getMinutes ()); |
|
113 |
// dialog.close (); |
|
114 |
// } |
|
115 |
// }); |
|
116 |
// dialog.setDefaultButton (ok); |
|
117 |
// dialog.pack (); |
|
118 |
// dialog.open (); |
|
119 |
// } |
|
120 |
// }); |
|
121 |
|
|
66 | 122 |
toolkit.adapt(textDate, true, true); |
67 | 123 |
} |
68 | 124 |
|
... | ... | |
71 | 127 |
*/ |
72 | 128 |
@Override |
73 | 129 |
protected void initInternalController(CdmFormFactory formFactory, ICdmFormElement parentElement) { |
74 |
controller = new DateElementController(this, formFactory, parentElement, initialDateTime, SWT.NONE);
|
|
130 |
controller = new DateElementController(this, formFactory, parentElement, initialDateTime); |
|
75 | 131 |
formFactory.adapt(controller); |
76 | 132 |
} |
77 | 133 |
public Text getTextDate() { |
78 | 134 |
return textDate; |
79 | 135 |
} |
136 |
|
|
137 |
// public void setTextDate(String text){ |
|
138 |
// textDate.setText(text); |
|
139 |
// } |
|
140 |
// /** |
|
141 |
// * <p> |
|
142 |
// * Setter for the field <code>entity</code>. |
|
143 |
// * </p> |
|
144 |
// * |
|
145 |
// * @param selection |
|
146 |
// * a T object. |
|
147 |
// */ |
|
148 |
// public void setEntity(org.joda.time.DateTime time) { |
|
149 |
// this.initialDateTime = time; |
|
150 |
// |
|
151 |
// } |
|
152 |
// |
|
153 |
// |
|
154 |
// public static org.joda.time.DateTime makeJodaFromSWT( |
|
155 |
// org.eclipse.swt.widgets.DateTime widget) { |
|
156 |
// return new org.joda.time.DateTime(widget.getYear(), |
|
157 |
// widget.getMonth(), |
|
158 |
// widget.getDay(), |
|
159 |
// widget.getHours(), |
|
160 |
// widget.getMinutes(), |
|
161 |
// widget.getSeconds()); |
|
162 |
// } |
|
163 |
// |
|
164 |
// public static void updateSWTwithJoda( |
|
165 |
// org.eclipse.swt.widgets.DateTime widget, |
|
166 |
// org.joda.time.DateTime dateTime) { |
|
167 |
// widget.setYear(dateTime.getYear()); |
|
168 |
// widget.setMonth(dateTime.getMonthOfYear()); |
|
169 |
// widget.setDay(dateTime.getDayOfMonth()); |
|
170 |
// widget.setHours(dateTime.getHourOfDay()); |
|
171 |
// widget.setMinutes(dateTime.getMinuteOfHour()); |
|
172 |
// widget.setSeconds(dateTime.getSecondOfMinute()); |
|
173 |
// } |
|
174 |
// |
|
175 |
// public void setData (org.joda.time.DateTime data) { |
|
176 |
// this.initialDateTime = data; |
|
177 |
// |
|
178 |
// } |
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
80 | 185 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateElementController.java | ||
---|---|---|
13 | 13 |
import org.eclipse.swt.widgets.Text; |
14 | 14 |
import org.joda.time.DateTime; |
15 | 15 |
|
16 |
import com.sun.istack.logging.Logger; |
|
17 |
|
|
16 | 18 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement; |
17 | 19 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
18 | 20 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
... | ... | |
37 | 39 |
* @param initialDateTime |
38 | 40 |
* @param none |
39 | 41 |
*/ |
40 |
public DateElementController(DateElement dateTimeElement, CdmFormFactory formFactory, ICdmFormElement parentElement, DateTime initialDateTime, int none) {
|
|
42 |
public DateElementController(DateElement dateTimeElement, CdmFormFactory formFactory, ICdmFormElement parentElement, DateTime initialDateTime) { |
|
41 | 43 |
super(formFactory, parentElement); |
42 | 44 |
this.textDate = dateTimeElement.getTextDate(); |
43 | 45 |
this.textDate.setText(initialDateTime!=null?initialDateTime.toString("yyyy-MM-dd"):""); |
44 | 46 |
addControl(textDate); |
45 | 47 |
textDate.addModifyListener(this); |
46 | 48 |
} |
49 |
|
|
50 |
// public DateElementController(DateElementFormElement dateTimeElement, CdmFormFactory formFactory, DateTime initialDateTime) { |
|
51 |
// super(formFactory, dateTimeElement); |
|
52 |
// this.textDate = dateTimeElement.getTextDate(); |
|
53 |
// this.textDate.setText(initialDateTime!=null?initialDateTime.toString("yyyy-MM-dd"):""); |
|
54 |
// addControl(textDate); |
|
55 |
// textDate.addModifyListener(this); |
|
56 |
// } |
|
47 | 57 |
|
48 | 58 |
/* (non-Javadoc) |
49 | 59 |
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) |
... | ... | |
56 | 66 |
this.dateTime = parsedDateTime; |
57 | 67 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
58 | 68 |
} catch (IllegalArgumentException iae) { |
59 |
//nothing
|
|
69 |
System.err.println(iae.getMessage());
|
|
60 | 70 |
} |
61 | 71 |
} |
62 | 72 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement; |
34 | 34 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
35 | 35 |
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElement; |
36 |
import eu.etaxonomy.taxeditor.ui.mvc.element.DateElementFormElement; |
|
36 | 37 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
37 | 38 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement; |
38 | 39 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
... | ... | |
53 | 54 |
private LanguageStringWithLabelElement text_description; |
54 | 55 |
private LanguageStringWithLabelElement text_title; |
55 | 56 |
private MediaDetailElement mediaDetailElement; |
56 |
// private DateElement dateElement;
|
|
57 |
private DateElement mediaCreated;
|
|
57 | 58 |
private SelectionArbitrator selectionArbitrator; |
58 | 59 |
|
59 | 60 |
public MediaMetaElement(CdmFormFactory cdmFormFactory, |
... | ... | |
84 | 85 |
text_title = formFactory.createLanguageStringWithLabelElement(element, "Title", null, style); |
85 | 86 |
selection_artist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Artist", null, EntitySelectionElement.ALL, style); |
86 | 87 |
addElement(selection_artist); |
88 |
mediaCreated = formFactory.createDateElement(element, "Media Created", null, style); |
|
89 |
addElement(mediaCreated.getController()); |
|
87 | 90 |
text_description = formFactory.createLanguageStringWithLabelElement(element, "Description", null, 100, true, style); |
88 |
// dateElement = formFactory.createDateElement(element, "Media created", null, style); |
|
89 |
// addControl(dateElement); |
|
90 |
|
|
91 |
|
|
92 |
|
|
91 | 93 |
|
92 | 94 |
|
93 | 95 |
mediaDetailElement = formFactory.createMediaDetailElement(element); |
... | ... | |
119 | 121 |
} |
120 | 122 |
|
121 | 123 |
text_title.setLanguageString(title); |
122 |
// dateElement.setData(element.getMediaCreated());
|
|
124 |
mediaCreated.setData(element.getMediaCreated());
|
|
123 | 125 |
|
124 | 126 |
} |
125 | 127 |
|
... | ... | |
147 | 149 |
if (getParentElement() instanceof AbstractCdmDetailSection) { |
148 | 150 |
((AbstractCdmDetailSection<?>) getParentElement()).updateTitle(); |
149 | 151 |
} |
150 |
// } else if (eventSource == dateElement){
|
|
151 |
// org.joda.time.DateTime date = dateElement.getController().getDateTime();
|
|
152 |
// getEntity().setMediaCreated(date);
|
|
152 |
} else if (eventSource == mediaCreated.getController()){
|
|
153 |
org.joda.time.DateTime date = mediaCreated.getController().getDateTime();
|
|
154 |
getEntity().setMediaCreated(date); |
|
153 | 155 |
} |
154 | 156 |
} |
155 | 157 |
|
Also available in: Unified diff
fix #6658: add mediaCreated date field