Revision aaed1c42
Added by Patrick Plitzner over 9 years ago
- added missing parameters to MediaSpecimen DetailsView (#4239)
.gitattributes | ||
---|---|---|
1397 | 1397 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/GeographicPointElement.java -text |
1398 | 1398 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/combo/EnumTermCombo.java -text |
1399 | 1399 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/combo/EnumTermComboController.java -text |
1400 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateTimeController.java -text |
|
1401 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateTimeElement.java -text |
|
1400 | 1402 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextWithLabelElementController.java -text |
1401 | 1403 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/TextWithLabelElementMVC.java -text |
1402 | 1404 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/interfaces/CdmCompositeController.java -text |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateTimeController.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.mvc.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.events.SelectionEvent; |
|
13 |
import org.eclipse.swt.events.SelectionListener; |
|
14 |
import org.eclipse.swt.widgets.DateTime; |
|
15 |
|
|
16 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement; |
|
17 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
18 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
|
19 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
20 |
import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement; |
|
21 |
import eu.etaxonomy.taxeditor.ui.element.ISelectable; |
|
22 |
import eu.etaxonomy.taxeditor.ui.mvc.interfaces.CdmCompositeController; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author pplitzner |
|
26 |
* @date 16.06.2014 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class DateTimeController extends AbstractCdmFormElement implements IEnableableFormElement, |
|
30 |
ISelectable, CdmCompositeController, SelectionListener{ |
|
31 |
|
|
32 |
private final DateTime dateTime; |
|
33 |
|
|
34 |
/** |
|
35 |
* @param dateTimeElement |
|
36 |
* @param formFactory |
|
37 |
* @param parentElement |
|
38 |
* @param initialDateTime |
|
39 |
* @param none |
|
40 |
*/ |
|
41 |
public DateTimeController(DateTimeElement dateTimeElement, CdmFormFactory formFactory, ICdmFormElement parentElement, org.joda.time.DateTime initialDateTime, int none) { |
|
42 |
super(formFactory, parentElement); |
|
43 |
this.dateTime = dateTimeElement.getDateTime(); |
|
44 |
// this.dateTime.setDate(initialDateTime.getYear(), initialDateTime.getMonthOfYear(), initialDateTime.getDayOfMonth()); |
|
45 |
addControl(dateTime); |
|
46 |
dateTime.addSelectionListener(this); |
|
47 |
} |
|
48 |
|
|
49 |
/* (non-Javadoc) |
|
50 |
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) |
|
51 |
*/ |
|
52 |
/** {@inheritDoc} */ |
|
53 |
@Override |
|
54 |
public void widgetSelected(SelectionEvent e) { |
|
55 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e)); |
|
56 |
} |
|
57 |
|
|
58 |
/** {@inheritDoc} */ |
|
59 |
@Override |
|
60 |
public void widgetDefaultSelected(SelectionEvent e) {} |
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see eu.etaxonomy.taxeditor.ui.element.IRelevantFormElement#setIrrelevant(boolean) |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
public void setIrrelevant(boolean irrelevant) { |
|
67 |
// TODO Auto-generated method stub |
|
68 |
|
|
69 |
} |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see eu.etaxonomy.taxeditor.ui.element.ISelectable#setSelected(boolean) |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public void setSelected(boolean selected) { |
|
76 |
// TODO Auto-generated method stub |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#setEnabled(boolean) |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public void setEnabled(boolean enabled) { |
|
85 |
dateTime.setEnabled(enabled); |
|
86 |
} |
|
87 |
|
|
88 |
/* (non-Javadoc) |
|
89 |
* @see eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement#isEnabled() |
|
90 |
*/ |
|
91 |
@Override |
|
92 |
public boolean isEnabled() { |
|
93 |
return dateTime.isEnabled(); |
|
94 |
} |
|
95 |
|
|
96 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/mvc/element/DateTimeElement.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2014 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.taxeditor.ui.mvc.element; |
|
11 |
|
|
12 |
import org.eclipse.swt.SWT; |
|
13 |
import org.eclipse.swt.events.DisposeEvent; |
|
14 |
import org.eclipse.swt.events.DisposeListener; |
|
15 |
import org.eclipse.swt.widgets.Composite; |
|
16 |
import org.eclipse.swt.widgets.DateTime; |
|
17 |
import org.eclipse.swt.widgets.Display; |
|
18 |
import org.eclipse.ui.forms.widgets.FormToolkit; |
|
19 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
|
20 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
|
21 |
|
|
22 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
|
23 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
|
24 |
import eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite; |
|
25 |
|
|
26 |
/** |
|
27 |
* @author pplitzner |
|
28 |
* @date 16.06.2014 |
|
29 |
* |
|
30 |
*/ |
|
31 |
public class DateTimeElement extends AbstractCdmComposite { |
|
32 |
|
|
33 |
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
|
34 |
private final DateTime dateTime; |
|
35 |
private final org.joda.time.DateTime initialDateTime; |
|
36 |
|
|
37 |
/** |
|
38 |
* Create the composite. |
|
39 |
* @param parent |
|
40 |
* @param style |
|
41 |
*/ |
|
42 |
public DateTimeElement(Composite parent, org.joda.time.DateTime initialDateTime, int style) { |
|
43 |
super(parent, style); |
|
44 |
this.initialDateTime = initialDateTime; |
|
45 |
addDisposeListener(new DisposeListener() { |
|
46 |
@Override |
|
47 |
public void widgetDisposed(DisposeEvent e) { |
|
48 |
toolkit.dispose(); |
|
49 |
} |
|
50 |
}); |
|
51 |
toolkit.adapt(this); |
|
52 |
toolkit.paintBordersFor(this); |
|
53 |
{ |
|
54 |
TableWrapLayout tableWrapLayout = new TableWrapLayout(); |
|
55 |
tableWrapLayout.verticalSpacing = 0; |
|
56 |
tableWrapLayout.topMargin = 0; |
|
57 |
tableWrapLayout.rightMargin = 0; |
|
58 |
tableWrapLayout.leftMargin = 0; |
|
59 |
tableWrapLayout.horizontalSpacing = 0; |
|
60 |
tableWrapLayout.bottomMargin = 0; |
|
61 |
tableWrapLayout.numColumns = 1; |
|
62 |
setLayout(tableWrapLayout); |
|
63 |
} |
|
64 |
|
|
65 |
dateTime = new DateTime(this, SWT.BORDER | SWT.DROP_DOWN); |
|
66 |
dateTime.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1)); |
|
67 |
toolkit.adapt(dateTime); |
|
68 |
toolkit.paintBordersFor(dateTime); |
|
69 |
} |
|
70 |
|
|
71 |
public DateTime getDateTime() { |
|
72 |
return dateTime; |
|
73 |
} |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 |
* @see eu.etaxonomy.taxeditor.ui.mvc.AbstractCdmComposite#initInternalController(eu.etaxonomy.taxeditor.ui.element.CdmFormFactory, eu.etaxonomy.taxeditor.ui.element.ICdmFormElement) |
|
77 |
*/ |
|
78 |
@Override |
|
79 |
protected void initInternalController(CdmFormFactory formFactory, ICdmFormElement parentElement) { |
|
80 |
controller = new DateTimeController(this, formFactory, parentElement, initialDateTime, SWT.NONE); |
|
81 |
formFactory.adapt(controller); |
|
82 |
} |
|
83 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/media/MediaSpecimenGeneralDetailElement.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.ui.section.occurrence.media; |
11 | 11 |
|
12 |
import org.eclipse.swt.widgets.Label; |
|
12 | 13 |
import org.eclipse.ui.forms.widgets.ExpandableComposite; |
14 |
import org.joda.time.DateTime; |
|
13 | 15 |
|
14 | 16 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
17 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
18 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
15 | 19 |
import eu.etaxonomy.cdm.model.common.Language; |
16 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
|
20 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
21 |
import eu.etaxonomy.cdm.model.common.TermType; |
|
17 | 22 |
import eu.etaxonomy.cdm.model.media.Media; |
23 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
|
18 | 24 |
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen; |
25 |
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement; |
|
19 | 26 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
20 | 27 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
21 | 28 |
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement; |
22 | 29 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
23 |
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement; |
|
30 |
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement; |
|
31 |
import eu.etaxonomy.taxeditor.ui.mvc.element.DateTimeElement; |
|
24 | 32 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; |
25 | 33 |
import eu.etaxonomy.taxeditor.ui.section.media.MediaRepresentationSection; |
26 | 34 |
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement; |
... | ... | |
32 | 40 |
*/ |
33 | 41 |
public class MediaSpecimenGeneralDetailElement extends AbstractCdmDetailElement<MediaSpecimen> { |
34 | 42 |
|
43 |
private TermComboElement<DefinedTerm> comboKindOfUnit; |
|
35 | 44 |
private LanguageStringWithLabelElement textTitleLanguageString; |
36 | 45 |
private EntitySelectionElement<AgentBase> selectionArtist; |
37 |
private TimePeriodElement date; |
|
38 |
private LanguageStringWithLabelElement textDescriptionLanguageString; |
|
46 |
private DateTimeElement date; |
|
47 |
private LanguageStringWithLabelElement textMethodLanguageString; |
|
48 |
private EntitySelectionElement<Collection> selection_collection; |
|
49 |
private TextWithLabelElement text_accessionNumber; |
|
50 |
private EntitySelectionElement<IdentifiableSource> selection_publishedIn; |
|
39 | 51 |
|
40 | 52 |
private MediaRepresentationSection mediaRepresentationSection; |
41 | 53 |
/** |
... | ... | |
55 | 67 |
*/ |
56 | 68 |
@Override |
57 | 69 |
protected void createControls(ICdmFormElement formElement, MediaSpecimen entity, int style) { |
58 |
LanguageString title; |
|
59 |
AgentBase artist; |
|
60 |
LanguageString description; |
|
61 |
|
|
62 | 70 |
Media media = entity.getMediaSpecimen(); |
63 | 71 |
if(media==null){ |
64 | 72 |
formFactory.createLabel(formElement, "No media attached to this MediaSpecimen!"); |
65 |
title = null; |
|
66 |
artist = null; |
|
67 |
description = null; |
|
68 | 73 |
} |
69 | 74 |
else{ |
70 |
title = media.getTitle(); |
|
71 |
artist = media.getArtist(); |
|
72 |
description = media.getDescription(Language.DEFAULT()); |
|
73 |
textTitleLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Title", title, style); |
|
74 |
selectionArtist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Artist", artist, EntitySelectionElement.ALL, style); |
|
75 |
textDescriptionLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Description", description, style); |
|
75 |
comboKindOfUnit = formFactory.createDefinedTermComboElement(TermType.KindOfUnit, formElement, "Kind of Media", entity.getKindOfUnit(), style); |
|
76 |
textTitleLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Motif", media.getTitle(), style); |
|
77 |
selectionArtist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), formElement, "Prepared by", media.getArtist(), EntitySelectionElement.ALL, style); |
|
78 |
|
|
79 |
Label label = new Label(getLayoutComposite(), style); |
|
80 |
label.setText("Preparation Date"); |
|
81 |
date = new DateTimeElement(formElement.getLayoutComposite(), entity.getMediaSpecimen().getMediaCreated(), style); |
|
82 |
date.initController(formFactory, formElement); |
|
83 |
|
|
84 |
textMethodLanguageString = formFactory.createLanguageStringWithLabelElement(formElement, "Method", media.getDescription(Language.DEFAULT()), style); |
|
85 |
selection_collection = formFactory.createSelectionElement(Collection.class, getConversationHolder(), formElement, "Collection", entity.getCollection(), EntitySelectionElement.ALL, style); |
|
86 |
text_accessionNumber = formFactory.createTextWithLabelElement(formElement, "Accession Number", entity.getAccessionNumber(), style); |
|
87 |
IdentifiableSource publishedIn = null; |
|
88 |
for(IdentifiableSource source:entity.getSources()){ |
|
89 |
if(source.getType()==OriginalSourceType.PrimaryMediaSource){ |
|
90 |
publishedIn = source; |
|
91 |
break; |
|
92 |
} |
|
93 |
} |
|
94 |
selection_publishedIn = formFactory.createSelectionElement(IdentifiableSource.class, getConversationHolder(), formElement, "Published in", publishedIn, EntitySelectionElement.ALL, style); |
|
76 | 95 |
|
77 | 96 |
mediaRepresentationSection = formFactory.createMediaRepresentationSection(getConversationHolder(), formElement, ExpandableComposite.TWISTIE); |
78 | 97 |
mediaRepresentationSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
... | ... | |
92 | 111 |
Media media = getEntity().getMediaSpecimen(); |
93 | 112 |
if(media==null){ |
94 | 113 |
media = Media.NewInstance(); |
114 |
getEntity().setMediaSpecimen(media); |
|
95 | 115 |
} |
96 |
|
|
97 |
if(eventSource==selectionArtist){ |
|
116 |
if(eventSource==textTitleLanguageString){ |
|
117 |
media.putTitle(textTitleLanguageString.getLanguageString()); |
|
118 |
} |
|
119 |
else if(eventSource==date.getController()){ |
|
120 |
int year = date.getDateTime().getYear(); |
|
121 |
int month = date.getDateTime().getMonth(); |
|
122 |
int day = date.getDateTime().getDay(); |
|
123 |
DateTime dateTime = new DateTime(year, month, day, 0, 0); |
|
124 |
media.setMediaCreated(dateTime); |
|
125 |
} |
|
126 |
else if(eventSource==selectionArtist){ |
|
98 | 127 |
media.setArtist(selectionArtist.getSelection()); |
99 | 128 |
} |
100 |
else if(eventSource==textDescriptionLanguageString){ |
|
101 |
media.addDescription(textDescriptionLanguageString.getLanguageString()); |
|
129 |
else if(eventSource==textMethodLanguageString){ |
|
130 |
media.addDescription(textMethodLanguageString.getLanguageString()); |
|
131 |
} |
|
132 |
else if (eventSource == selection_collection) { |
|
133 |
getEntity().setCollection(selection_collection.getSelection()); |
|
134 |
} |
|
135 |
else if (eventSource == text_accessionNumber) { |
|
136 |
getEntity().setAccessionNumber(text_accessionNumber.getText()); |
|
137 |
} |
|
138 |
else if(eventSource==selection_publishedIn){ |
|
139 |
getEntity().addSource(selection_publishedIn.getSelection()); |
|
102 | 140 |
} |
103 | 141 |
} |
104 | 142 |
} |
Also available in: Unified diff