Revision 8dbcbc43
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/RightsSelectionDialog.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2017 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.Control; |
|
14 |
import org.eclipse.swt.widgets.Shell; |
|
15 |
import org.eclipse.swt.widgets.Text; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
18 |
import eu.etaxonomy.cdm.api.service.IRightsService; |
|
19 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
|
20 |
import eu.etaxonomy.cdm.model.media.Rights; |
|
21 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
22 |
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard; |
|
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
24 |
|
|
25 |
/** |
|
26 |
* @author k.luther |
|
27 |
* @date 15.02.2017 |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class RightsSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<Rights> { |
|
31 |
|
|
32 |
|
|
33 |
public static Rights select(Shell shell, ConversationHolder conversation, Rights rights){ |
|
34 |
RightsSelectionDialog dialog = new RightsSelectionDialog(shell, conversation, |
|
35 |
"Choose Rights", false, RightsSelectionDialog.class.getCanonicalName(), rights); |
|
36 |
return getSelectionFromDialog(dialog); |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* <p>Constructor for FilteredDerivedUnitSelectionDialog.</p> |
|
41 |
*/ |
|
42 |
protected RightsSelectionDialog(Shell shell, ConversationHolder conversation, String title, |
|
43 |
boolean multi, String settings, Rights rights) { |
|
44 |
super(shell, conversation, title, multi, settings, rights); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* {@inheritDoc} |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
protected Rights getPersistentObject(UUID uuid) { |
|
52 |
Object object = CdmStore.getService(IRightsService.class).load(uuid); |
|
53 |
|
|
54 |
Rights rights= (Rights) HibernateProxyHelper.deproxy(object); |
|
55 |
|
|
56 |
if(rights != null){ |
|
57 |
return rights; |
|
58 |
} |
|
59 |
MessagingUtils.error(this.getClass(), "Selected element is not rights", null); |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* {@inheritDoc} |
|
65 |
*/ |
|
66 |
@Override |
|
67 |
protected String getNewWizardLinkText() { |
|
68 |
// TODO Auto-generated method stub |
|
69 |
return null; |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* {@inheritDoc} |
|
74 |
*/ |
|
75 |
@Override |
|
76 |
protected AbstractNewEntityWizard getNewEntityWizard(String parameter) { |
|
77 |
// TODO Auto-generated method stub |
|
78 |
return null; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* {@inheritDoc} |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
protected void initModel() { |
|
86 |
Control control = getPatternControl(); |
|
87 |
String pattern = null; |
|
88 |
if (control != null){ |
|
89 |
pattern = ((Text)control).getText(); |
|
90 |
} |
|
91 |
|
|
92 |
if (pattern == null || pattern.equals("?")){ |
|
93 |
model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(null,null); |
|
94 |
|
|
95 |
}else{ |
|
96 |
|
|
97 |
model = CdmStore.getService(IRightsService.class).getUuidAndLabelText(limitOfInitialElements,pattern); |
|
98 |
|
|
99 |
} |
|
100 |
|
|
101 |
} |
|
102 |
|
|
103 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.model.location.Country; |
29 | 29 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
30 | 30 |
import eu.etaxonomy.cdm.model.media.Media; |
31 |
import eu.etaxonomy.cdm.model.media.Rights; |
|
31 | 32 |
import eu.etaxonomy.cdm.model.molecular.Amplification; |
32 | 33 |
import eu.etaxonomy.cdm.model.molecular.Primer; |
33 | 34 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
... | ... | |
163 | 164 |
if(clazz.equals(Media.class)){ |
164 | 165 |
return (T) MediaSelectionDialog.select(shell, conversation, (Media) currentSelection); |
165 | 166 |
} |
167 |
if(clazz.equals(Rights.class)){ |
|
168 |
return (T) RightsSelectionDialog.select(shell, conversation, (Rights) currentSelection); |
|
169 |
} |
|
166 | 170 |
|
167 | 171 |
return null; |
168 | 172 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/RightsSection.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.ui.section.supplemental; |
5 | 5 |
|
... | ... | |
8 | 8 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
9 | 9 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
10 | 10 |
import eu.etaxonomy.cdm.model.media.Rights; |
11 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.RightsSelectionDialog; |
|
11 | 12 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
12 | 13 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
13 | 14 |
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection; |
... | ... | |
74 | 75 |
*/ |
75 | 76 |
@Override |
76 | 77 |
public Rights addExisting() { |
77 |
// TODO Auto-generated method stub |
|
78 |
return null; |
|
78 |
return RightsSelectionDialog.select(getShell(), getConversationHolder(), null); |
|
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
/** |
... | ... | |
83 | 83 |
*/ |
84 | 84 |
@Override |
85 | 85 |
public boolean allowAddExisting() { |
86 |
// TODO Auto-generated method stub |
|
87 |
return false; |
|
86 |
return true; |
|
88 | 87 |
} |
89 | 88 |
|
89 |
|
|
90 |
|
|
91 |
|
|
90 | 92 |
} |
Also available in: Unified diff
fix #6262: add possibility to reuse rights in editor