1
|
/**
|
2
|
* Copyright (C) 2014 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.ui.dialog.selection;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.swt.widgets.Shell;
|
14
|
|
15
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
16
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
17
|
import eu.etaxonomy.cdm.model.media.Media;
|
18
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
19
|
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
|
20
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
21
|
|
22
|
/**
|
23
|
* @author pplitzner
|
24
|
* @date 11.03.2014
|
25
|
*
|
26
|
*/
|
27
|
public class MediaSelectionDialog extends
|
28
|
AbstractFilteredCdmResourceSelectionDialog<Media> {
|
29
|
|
30
|
public static Media select(Shell shell, //ConversationHolder conversation,
|
31
|
Media media){
|
32
|
MediaSelectionDialog dialog = new MediaSelectionDialog(shell, //conversation,
|
33
|
"Choose Media", false, MediaSelectionDialog.class.getCanonicalName(), media);
|
34
|
return getSelectionFromDialog(dialog);
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p>
|
39
|
*/
|
40
|
protected MediaSelectionDialog(Shell shell, //ConversationHolder conversation,
|
41
|
String title,
|
42
|
boolean multi, String settings, Media cdmObject) {
|
43
|
super(shell, //conversation,
|
44
|
title, multi, settings, cdmObject);
|
45
|
}
|
46
|
|
47
|
/** {@inheritDoc} */
|
48
|
@Override
|
49
|
protected Media getPersistentObject(UUID uuid) {
|
50
|
Object object = CdmStore.getService(IMediaService.class).load(uuid);
|
51
|
|
52
|
Media media = (Media) HibernateProxyHelper.deproxy(object);
|
53
|
|
54
|
if(media != null){
|
55
|
return media;
|
56
|
}
|
57
|
MessagingUtils.error(this.getClass(), "Selected element is not media", null);
|
58
|
return null;
|
59
|
}
|
60
|
|
61
|
/** {@inheritDoc} */
|
62
|
@Override
|
63
|
protected void callService(String pattern) {
|
64
|
model = CdmStore.getService(IMediaService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
|
65
|
|
66
|
}
|
67
|
|
68
|
/* (non-Javadoc)
|
69
|
* @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#getTitle(eu.etaxonomy.cdm.model.common.ICdmBase)
|
70
|
*/
|
71
|
@Override
|
72
|
protected String getTitle(Media cdmObject) {
|
73
|
if(cdmObject!=null){
|
74
|
return cdmObject.getTitleCache();
|
75
|
}
|
76
|
return super.getTitle(cdmObject);
|
77
|
}
|
78
|
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
|
82
|
return null;
|
83
|
}
|
84
|
|
85
|
/** {@inheritDoc} */
|
86
|
@Override
|
87
|
protected String[] getNewWizardText() {
|
88
|
return null;
|
89
|
}
|
90
|
}
|