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.dialog.selection;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.eclipse.swt.widgets.Shell;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
17
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
18
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
19
|
import eu.etaxonomy.cdm.model.media.Media;
|
20
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
21
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* @author pplitzner
|
26
|
* @date 11.03.2014
|
27
|
*
|
28
|
*/
|
29
|
public class MediaSelectionDialog extends
|
30
|
AbstractFilteredCdmResourceSelectionDialog<Media> {
|
31
|
|
32
|
public static Media select(Shell shell, ConversationHolder conversation, Media media){
|
33
|
MediaSelectionDialog dialog = new MediaSelectionDialog(shell, conversation,
|
34
|
"Choose Media", false, MediaSelectionDialog.class.getCanonicalName(), media);
|
35
|
return getSelectionFromDialog(dialog);
|
36
|
}
|
37
|
|
38
|
/**
|
39
|
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
|
40
|
*/
|
41
|
protected MediaSelectionDialog(Shell shell, ConversationHolder conversation, String title,
|
42
|
boolean multi, String settings, Media cdmObject) {
|
43
|
super(shell, conversation, title, multi, settings, cdmObject);
|
44
|
}
|
45
|
|
46
|
/** {@inheritDoc} */
|
47
|
@Override
|
48
|
protected Media getPersistentObject(UUID uuid) {
|
49
|
Object object = CdmStore.getService(IMediaService.class).load(uuid);
|
50
|
|
51
|
Media media = (Media) HibernateProxyHelper.deproxy(object);
|
52
|
|
53
|
if(media != null){
|
54
|
return media;
|
55
|
}
|
56
|
MessagingUtils.error(this.getClass(), "Selected element is not media", null);
|
57
|
return null;
|
58
|
}
|
59
|
|
60
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
protected void initModel() {
|
63
|
model = CdmStore.getService(IMediaService.class).getUuidAndTitleCache();
|
64
|
}
|
65
|
|
66
|
/* (non-Javadoc)
|
67
|
* @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#getTitle(eu.etaxonomy.cdm.model.common.ICdmBase)
|
68
|
*/
|
69
|
@Override
|
70
|
protected String getTitle(Media cdmObject) {
|
71
|
if(cdmObject!=null){
|
72
|
return cdmObject.getTitleCache();
|
73
|
}
|
74
|
return super.getTitle(cdmObject);
|
75
|
}
|
76
|
|
77
|
/** {@inheritDoc} */
|
78
|
@Override
|
79
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
80
|
return null;
|
81
|
}
|
82
|
|
83
|
/** {@inheritDoc} */
|
84
|
@Override
|
85
|
protected String getNewWizardLinkText() {
|
86
|
return "";
|
87
|
}
|
88
|
}
|