ref #7674 Allow editing descriptions in details view
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 19 Sep 2018 10:28:13 +0000 (12:28 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 19 Sep 2018 10:28:13 +0000 (12:28 +0200)
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CellSelectionListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixPart.java

index 57ed6d104f4e35d80320d51d4d5e16fd2d70415a..825c874c3c81762c5b107eb3586ded754402b413 100644 (file)
@@ -41,7 +41,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.e4.core.contexts,
  org.eclipse.nebula.widgets.nattable.core,
  org.eclipse.nebula.widgets.nattable.extension.glazedlists,
- ca.odell.glazedlists
+ ca.odell.glazedlists,
+ org.eclipse.nebula.widgets.nattable.extension.e4;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
index 1e3a10c30371f6f098fbe9d1dea1db9f2c76f050..f343237b5764c1d449dd65370cae8d43ab3e84ef 100644 (file)
@@ -11,23 +11,33 @@ package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
 
 import java.util.Collection;
 
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.nebula.widgets.nattable.layer.ILayerListener;
+import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider;
+import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
 import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
 import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
 import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
+import org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent;
+
+import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
 
 /**
  * @author pplitzner
  * @date 09.07.2018
  *
  */
-final class CellSelectionListener implements ILayerListener {
+final class CellSelectionListener extends E4SelectionListener<Object> {
 
     private CharacterMatrixPart part;
 
-    public CellSelectionListener(CharacterMatrixPart part) {
-        super();
+    public CellSelectionListener(
+            ESelectionService service,
+            SelectionLayer selectionLayer,
+            IRowDataProvider<Object> rowDataProvider,
+            CharacterMatrixPart part) {
+        super(service, selectionLayer, rowDataProvider);
         this.part = part;
     }
 
@@ -36,18 +46,29 @@ final class CellSelectionListener implements ILayerListener {
         if(event instanceof CellSelectionEvent){
             CellSelectionEvent cellSelectionEvent = (CellSelectionEvent)event;
             int columnPosition = cellSelectionEvent.getColumnPosition();
-            if(columnPosition>CharacterMatrix.LEADING_COLUMN_COUNT){
+            if(columnPosition>=CharacterMatrix.LEADING_COLUMN_COUNT){
                 Collection<ILayerCell> selectedCells = cellSelectionEvent.getSelectionLayer().getSelectedCells();
-                StructuredSelection selection = new StructuredSelection();
                 if(selectedCells.size()==1){
                     ILayerCell cell = selectedCells.iterator().next();
                     Object dataValue = cell.getDataValue();
                     if(dataValue!=null){
-                        selection = new StructuredSelection(dataValue);
+                        part.getSelectionService().setSelection(new StructuredSelection(dataValue));
                     }
                 }
-                part.getSelectionService().setSelection(selection);
             }
         }
+        else if(event instanceof RowSelectionEvent){
+            RowSelectionEvent rowSelectionEvent = (RowSelectionEvent) event;
+            int[] fullySelectedRowPositions = rowSelectionEvent.getSelectionLayer().getFullySelectedRowPositions();
+            if(fullySelectedRowPositions.length==1){
+                Object rowObject = part.getMatrix().getBodyDataProvider().getRowObject(fullySelectedRowPositions[0]);
+                if(rowObject instanceof RowWrapperDTO){
+                    part.getSelectionService().setSelection(new StructuredSelection(((RowWrapperDTO) rowObject).getDescription()));
+                }
+            }
+        }
+        else{
+            super.handleLayerEvent(event);
+        }
     }
 }
index d5faf4756c6cf2c07b9c041a675dcf49943f52c4..6ccc563f6b48419677a37eabfcc2882c349f1aba 100644 (file)
@@ -20,6 +20,7 @@ import java.util.UUID;
 import java.util.stream.Collectors;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 
 import org.apache.commons.collections4.map.LinkedMap;
 import org.eclipse.core.runtime.ICoreRunnable;
@@ -28,8 +29,10 @@ import org.eclipse.core.runtime.SubMonitor;
 import org.eclipse.core.runtime.jobs.IJobChangeEvent;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.e4.core.di.annotations.Optional;
 import org.eclipse.e4.ui.di.UISynchronize;
 import org.eclipse.e4.ui.services.EMenuService;
+import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.viewers.ComboViewer;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -43,6 +46,7 @@ import org.eclipse.nebula.widgets.nattable.coordinate.Range;
 import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
 import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
 import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
+import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
@@ -446,8 +450,11 @@ public class CharacterMatrix extends Composite {
         // exporting work
         topMostLayer.registerCommandHandler(new ExportCommandHandler(topMostLayer));
 
-        //propagate single cell selection
-        natTable.addLayerListener(new CellSelectionListener(part));
+        //selection listener
+        E4SelectionListener selectionListener = new CellSelectionListener(part.getSelectionService(),
+                bodyLayer.getSelectionLayer(), bodyDataProvider, part);
+        bodyLayer.getSelectionLayer().addLayerListener(selectionListener);
+        selectionListener.setFullySelectedRowsOnly(false);
 
         //register handler for view configuration menu
         natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
index 50f62ef96b3bc7f4f4b52cfb9370e8585e1f6a32..3843f54f92dc38338187e03ba2dfbc60b3996aad 100644 (file)
@@ -50,6 +50,8 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
@@ -64,7 +66,7 @@ import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
  *
  */
 public class CharacterMatrixPart implements IE4SavablePart, IConversationEnabled, IDirtyMarkable,
-ICdmEntitySessionEnabled{
+ICdmEntitySessionEnabled, IPartContentHasSupplementalData, IPartContentHasDetails{
 
     private static final List<String> WS_PROPERTY_PATH = Arrays.asList(new String[] {
             "descriptions", //$NON-NLS-1$