Merge branch 'release/5.11.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescriptionElementDetailSection.java
index 01c6ef29689d846234eee2a22a207383fe0781be..064904c26819cb063d86f3e91553d33b1a86d50c 100644 (file)
@@ -9,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;
@@ -19,6 +22,7 @@ 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;
@@ -27,6 +31,7 @@ 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;
 
 /**
  * <p>DescriptionElementDetailSection class.</p>
@@ -38,6 +43,8 @@ import eu.etaxonomy.taxeditor.ui.section.description.operation.ChangeDescription
 public class DescriptionElementDetailSection extends
                AbstractCdmDetailSection<DescriptionElementBase> {
 
+
+
        /**
         * <p>Constructor for DescriptionElementDetailSection.</p>
         *
@@ -62,7 +69,7 @@ public class DescriptionElementDetailSection extends
 
                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()
                         */
@@ -71,10 +78,11 @@ public class DescriptionElementDetailSection extends
                                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));
                                }
                        }
                };
@@ -103,7 +111,8 @@ public class DescriptionElementDetailSection extends
        /** {@inheritDoc} */
        @Override
        protected void setSectionTitle() {
-               this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));
+               this.setText(getHeading() + ": " + getEntity().getFeature().getPreferredRepresentation(CdmStore.getDefaultLanguage()));
+                       //getLabel(CdmStore.getDefaultLanguage()));
 
         if(IsMoreThanOneTypeSupported()){
             setTextClient(createToolbar());
@@ -130,4 +139,6 @@ public class DescriptionElementDetailSection extends
        protected AbstractCdmDetailElement<DescriptionElementBase> createCdmDetailElement(AbstractCdmDetailSection<DescriptionElementBase> parentElement, int style) {
            return formFactory.createDescriptionElementDetailElement(parentElement, style);
        }
+
+
 }