X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/7d0ff89c0c3153d4ea623b463715fe172c03806a..bd05baf38855e3f5b5c988db8bbc527b8e3f9aea:/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java index 6414310fd..6c0148712 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.java @@ -1,4 +1,3 @@ -// $Id$ /** * Copyright (C) 2007 EDIT * European Distributed Institute of Taxonomy @@ -10,7 +9,10 @@ package eu.etaxonomy.taxeditor.ui.section.description; +import org.eclipse.e4.ui.di.UISynchronize; +import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.ToolBarManager; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.swt.SWT; @@ -18,14 +20,18 @@ import org.eclipse.swt.widgets.Control; import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.model.description.DescriptionElementBase; +import eu.etaxonomy.cdm.model.description.Feature; import eu.etaxonomy.cdm.model.description.TextData; +import eu.etaxonomy.taxeditor.model.AbstractUtility; +import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.store.CdmStore; import eu.etaxonomy.taxeditor.store.StoreUtil; -import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; +import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement; import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; import eu.etaxonomy.taxeditor.ui.section.description.operation.ChangeDescriptionElementType; +import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4; /** *

DescriptionElementDetailSection class.

@@ -54,33 +60,32 @@ public class DescriptionElementDetailSection extends @Override protected Control createToolbar() { - if(! hasSpecificElement()){ - return null; - } ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); - final String destinationString = (getEntity() instanceof TextData) ? "the specific element" : "free text"; + final String destinationString = (getEntity().isInstanceOf(TextData.class)) ? "the specific element" : "free text"; final String label = "Change to " + destinationString; - Action addAction = new Action("Change Type", Action.AS_PUSH_BUTTON) { + Action addAction = new Action("Change Type", IAction.AS_PUSH_BUTTON) { /* (non-Javadoc) * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { - boolean confirmed = StoreUtil.confirmDialog("Confirmation", "Do you really want to change to " + boolean confirmed = MessagingUtils.confirmDialog("Confirmation", "Do you really want to change to " + destinationString + "? Current data will be lost."); if (confirmed) { - // FIXME - ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label, - getEntity(), StoreUtil.getDetailsView(), StoreUtil.getUndoContext()); - StoreUtil.executeOperation(operation); + EPartService partService = formFactory.getContext().get(EPartService.class); + DetailsPartE4 detailsView = AbstractUtility.getDetailsView(partService); + ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label, + getEntity(), detailsView, StoreUtil.getUndoContext()); + AbstractUtility.executeOperation(operation, formFactory.getContext().get(UISynchronize.class)); } } }; // TODO enable this once a proper icon has been found + // ticket #5043 // addAction.setImageDescriptor(new ImageDescriptor() { // // @Override @@ -104,17 +109,25 @@ public class DescriptionElementDetailSection extends /** {@inheritDoc} */ @Override protected void setSectionTitle() { - this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage())); - setTextClient(createToolbar()); + this.setText(getHeading() + ": " + getEntity().getFeature().getPreferredRepresentation(CdmStore.getDefaultLanguage())); + //getLabel(CdmStore.getDefaultLanguage())); + + if(IsMoreThanOneTypeSupported()){ + setTextClient(createToolbar()); + } } - private boolean hasSpecificElement(){ - return getEntity().getFeature().isSupportsCategoricalData() - || getEntity().getFeature().isSupportsCommonTaxonName() - || getEntity().getFeature().isSupportsDistribution() - || getEntity().getFeature().isSupportsIndividualAssociation() - || getEntity().getFeature().isSupportsQuantitativeData() - || getEntity().getFeature().isSupportsTaxonInteraction(); + private boolean IsMoreThanOneTypeSupported(){ + int count = 0; + Feature feature = getEntity().getFeature(); + if(feature.isSupportsCategoricalData()){count++;} + if(feature.isSupportsCommonTaxonName()){count++;} + if(feature.isSupportsDistribution()){count++;} + if(feature.isSupportsIndividualAssociation()){count++;} + if(feature.isSupportsQuantitativeData()){count++;} + if(feature.isSupportsTaxonInteraction()){count++;} + if(feature.isSupportsTextData()){count++;} + return count > 1; } /* (non-Javadoc)