Revision df947da5
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java | ||
---|---|---|
36 | 36 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
37 | 37 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
38 | 38 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
39 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
39 | 40 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
40 | 41 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
41 | 42 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
... | ... | |
45 | 46 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
46 | 47 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
47 | 48 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
49 |
import eu.etaxonomy.taxeditor.security.RequiredPermissions; |
|
48 | 50 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
49 | 51 |
import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4; |
50 | 52 |
import eu.etaxonomy.taxeditor.view.e4.details.DetailsViewerE4; |
... | ... | |
65 | 67 |
* If it is <code>true</code> then it is currently delaying a selection. |
66 | 68 |
*/ |
67 | 69 |
private boolean isInDelay; |
68 |
private boolean isEnabled; |
|
70 |
private boolean isEnabled = true;
|
|
69 | 71 |
private static final Logger logger = Logger.getLogger(AbstractCdmEditorPartE4.class); |
70 | 72 |
|
71 | 73 |
/** |
... | ... | |
193 | 195 |
return viewer; |
194 | 196 |
} |
195 | 197 |
|
198 |
public boolean isEnabled() { |
|
199 |
return isEnabled; |
|
200 |
} |
|
201 |
|
|
202 |
public void setEnabled(boolean isEnabled) { |
|
203 |
this.isEnabled = isEnabled; |
|
204 |
} |
|
205 |
|
|
196 | 206 |
protected void showViewer(IStructuredSelection selection, MPart activePart, Viewer viewer){ |
197 | 207 |
if(viewer!=null && viewer.getControl()!=null && !viewer.getControl().isDisposed()){ |
198 | 208 |
Object element = selection.getFirstElement(); |
... | ... | |
200 | 210 |
viewer.getControl().setEnabled(true); |
201 | 211 |
if(selection.getFirstElement()!=null){ |
202 | 212 |
if (element instanceof Taxon){ |
213 |
|
|
203 | 214 |
Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class); |
215 |
if (part instanceof ITaxonEditor){ |
|
216 |
TaxonNode node = ((ITaxonEditor) part).getTaxonNode(); |
|
217 |
if (node != null){ |
|
218 |
boolean doEnable = CdmStore.currentAuthentiationHasPermission(node, |
|
219 |
RequiredPermissions.TAXON_EDIT); |
|
220 |
this.isEnabled = doEnable; |
|
221 |
} |
|
222 |
|
|
223 |
|
|
224 |
} |
|
204 | 225 |
if (taxon.isMisapplication() || taxon.isProparteSynonym() || taxon.isInvalidDesignation()){ |
205 | 226 |
|
206 | 227 |
if(part instanceof ITaxonEditor){ |
207 | 228 |
Taxon accepted = ((ITaxonEditor) part).getTaxon(); |
229 |
|
|
208 | 230 |
Set<TaxonRelationship> rels = taxon.getTaxonRelations(accepted); |
209 | 231 |
|
210 | 232 |
if (rels != null && rels.iterator().hasNext() && !taxon.equals(accepted)){ |
... | ... | |
230 | 252 |
|
231 | 253 |
selectionProvidingPart = activePart; |
232 | 254 |
if (viewer instanceof DetailsViewerE4){ |
233 |
((DetailsViewerE4)viewer).setInput(element, part); |
|
255 |
|
|
234 | 256 |
if (!selectionProvidingPart.getElementId().equals("eu.etaxonomy.taxeditor.editor.view.checklist.e4.DistributionEditorPart")){ |
235 | 257 |
((DetailsViewerE4)viewer).setDetailsEnabled(true); |
236 | 258 |
} |
237 |
|
|
259 |
((DetailsViewerE4)viewer).setDetailsEnabled(isEnabled); |
|
260 |
((DetailsViewerE4)viewer).setInput(element, part); |
|
238 | 261 |
} |
239 | 262 |
|
240 | 263 |
else{ |
Also available in: Unified diff
ref #8239: disable details for missing rights