import eu.etaxonomy.cdm.model.term.TermType;
import eu.etaxonomy.cdm.model.term.TermVocabulary;
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
-import eu.etaxonomy.taxeditor.editor.IDistributionEditor;
+import eu.etaxonomy.taxeditor.editor.IDistributionEditorPart;
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
private ISelection selection;
private boolean detailsEnabled = true;
+ private Object activePart;
public boolean isDetailsEnabled() {
return detailsEnabled;
}
public void setInput(Object input, Object activePart) {
- if (activePart instanceof IDistributionEditor){
- detailsEnabled = false;
- }else{
- detailsEnabled = true;
- }
+ this.activePart = activePart;
setInput(input);
}
if (isUseDescription == true && input instanceof CategoricalData) {
createUseRecordSection(rootElement);
} else {
- createDescriptionElementSection(rootElement);
+ createDescriptionElementSection(rootElement, activePart);
}
} else if (input instanceof Media) {
private void createTaxonSections(RootElement parent) {
NameDetailsConfigurator config = PreferencesUtil.getPreferredNameDetailsConfiguration();
+// EnumSet<CRUD> requiredCrud;
+// if(getInput() == null || StoreUtil.getCdmEntity(getInput()).getId() == 0) {
+// // new entity, not yet saved
+// requiredCrud = EnumSet.of(CRUD.CREATE);
+// } else {
+// requiredCrud = EnumSet.of(CRUD.UPDATE);
+// }
+// boolean hasPermission = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getInput()), requiredCrud);
+ // detailsEnabled = hasPermission;
ParsingMessagesSection parsingMessagesSection = formFactory.createParsingMessagesSection(getConversationHolder(), parent, this,
StoreUtil.getSectionStyle(ParsingMessagesSection.class, getInput().getClass().getCanonicalName(), true));
- if (!config.isSimpleDetailsViewActivated()){
+ if (config == null){
TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
StoreUtil.getSectionStyle(TaxonBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+ // boolean hasPermission = CdmStore.currentAuthentiationHasPermission(getInput(), Operation.UPDATE);
+ taxonBaseDetailSection.setEnabled(detailsEnabled);
addPart(taxonBaseDetailSection);
}else{
if (config.isTaxonSectionActivated()){
TaxonBaseDetailSection taxonBaseDetailSection = formFactory.createTaxonBaseDetailSection(getConversationHolder(), parent, this,
StoreUtil.getSectionStyle(TaxonBaseDetailSection.class, getInput().getClass().getCanonicalName(), true));
+ taxonBaseDetailSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(taxonBaseDetailSection);
}
.createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
StoreUtil.getSectionStyle(NonViralNameDetailSection.class, getInput().getClass().getCanonicalName(), true));
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
- if (!config.isSimpleDetailsViewActivated() || (config.isSimpleDetailsViewActivated() && config.isNomenclaturalReferenceSectionActivated())){
+ nonViralNameSection.setEnabled(detailsEnabled);
+ if (config == null || config.isNomenclaturalReferenceSectionActivated()){
NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
StoreUtil.getSectionStyle(NomenclaturalReferenceDetailSection.class, getInput().getClass().getCanonicalName(), true));
+ referenceDetailSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(referenceDetailSection);
}
- if ( !config.isSimpleDetailsViewActivated() || (config.isSimpleDetailsViewActivated() && config.isNomenclaturalStatusSectionActivated())){
+ if ( config == null || config.isNomenclaturalStatusSectionActivated()){
NomenclaturalStatusSection nomenclaturalStatusSection = formFactory.createNomenclaturalStatusSection(getConversationHolder(), parent,
StoreUtil.getSectionStyle(NomenclaturalStatusSection.class, getInput().getClass().getCanonicalName(), true));
+ nomenclaturalStatusSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(nomenclaturalStatusSection);
}
- if ( !config.isSimpleDetailsViewActivated() || (config.isSimpleDetailsViewActivated() && config.isProtologueActivated())){
+ if ( config == null || config.isProtologueActivated()){
ProtologueSection protologSection = formFactory.createProtologueSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(ProtologueSection.class, getInput().getClass().getCanonicalName()));
+ protologSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(protologSection);
}
- if (!config.isSimpleDetailsViewActivated() || (config.isSimpleDetailsViewActivated() && config.isTypeDesignationSectionActivated())){
+ if (config == null || config.isTypeDesignationSectionActivated()){
TypeDesignationSection typeDesignationSection = formFactory.createTypeDesignationSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(TypeDesignationSection.class, getInput().getClass().getCanonicalName()));
+ typeDesignationSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(typeDesignationSection);
}
- if (!config.isSimpleDetailsViewActivated() || (config.isSimpleDetailsViewActivated() &&config.isNameRelationsSectionActivated())){
+ if (config == null || config.isNameRelationsSectionActivated()){
NameRelationshipDetailSection nameRelationshipSection = formFactory.createNameRelationshipDetailSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(NameRelationshipDetailSection.class, getInput().getClass().getCanonicalName()));
+ nameRelationshipSection.setEnabled(detailsEnabled);
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
addPart(nameRelationshipSection);
}
}
private void createDescriptionElementSection(RootElement parent) {
+ createDescriptionElementSection(parent, null);
+ }
+
+ private void createDescriptionElementSection(RootElement parent, Object activePart) {
DescriptionElementDetailSection descriptionElementDetailSection = formFactory.createDescriptionElementDetailSection(getConversationHolder(), parent, this, StoreUtil.getSectionStyle(DescriptionElementDetailSection.class, getInput().getClass().getCanonicalName(), true));
descriptionElementDetailSection.setEnabled(this.detailsEnabled);
// IntextReferenceSection intextReferenceSection = formFactory.createIntextReferenceSection(getConversationHolder(), parent, getSectionStyle(.class, getInput().getClass().getCanonicalName()));
formFactory.createHorizontalSeparator(parent, SWT.BORDER);
+ DescriptionElementSourceSection descriptionElementSourceSection;
+ if (activePart != null && activePart instanceof IDistributionEditorPart){
+ Reference defaultSource =((IDistributionEditorPart)activePart).getEditor().getDefaultSource();
+ descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, defaultSource, StoreUtil.getSectionStyle(DescriptionElementSourceSection.class, getInput().getClass().getCanonicalName()));
+ }else{
+ descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionElementSourceSection.class, getInput().getClass().getCanonicalName()) );
+ }
- DescriptionElementSourceSection descriptionElementSourceSection = formFactory.createDescriptionElementSourceSection(getConversationHolder(), parent, StoreUtil.getSectionStyle(DescriptionElementSourceSection.class, getInput().getClass().getCanonicalName()));
formFactory.createHorizontalSeparator(parent, SWT.BORDER);