From 1f677abd3ea026eab1835f317828d8be5ad6bd65 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Thu, 4 Oct 2018 09:45:02 +0200
Subject: [PATCH 1/1] fix #7660 Add icons to bulk editor for deduplication
target/candidate
---
.../e4/BulkEditorConfigLabelAccumulator.java | 10 ++++-
.../bulkeditor/e4/BulkEditorE4Composite.java | 6 ++-
.../e4/BulkEditorLabelStyleConfiguration.java | 43 +++++++++++++++----
.../bulkeditor/e4/BulkEditorTooltip.java | 8 ++--
.../taxeditor/model/ImageResources.java | 3 ++
5 files changed, 54 insertions(+), 16 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java
index 13a0a4ba7..798d4b2d1 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java
@@ -42,10 +42,16 @@ public class BulkEditorConfigLabelAccumulator implements IConfigLabelAccumulator
}
CdmBase rowObject = dataProvider.getRowObject(rowPosition);
if(input.getMergeCandidates().contains(rowObject)){
- configLabels.addLabel(BulkEditorE4Composite.CANDIDATE_LABEL);
+ configLabels.addLabel(BulkEditorE4Composite.LABEL_CANDIDATE);
+ if(columnPosition==0){
+ configLabels.addLabel(BulkEditorE4Composite.LABEL_CANDIDATE_ICON);
+ }
}
else if(input.getMergeTarget()==rowObject){
- configLabels.addLabel(BulkEditorE4Composite.TARGET_LABEL);
+ configLabels.addLabel(BulkEditorE4Composite.LABEL_TARGET);
+ if(columnPosition==0){
+ configLabels.addLabel(BulkEditorE4Composite.LABEL_TARGET_ICON);
+ }
}
}
}
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
index 1476911c1..23a76a9c5 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java
@@ -95,9 +95,11 @@ public class BulkEditorE4Composite extends Composite {
public static final String UUID_PROPERTY = "Uuid"; //$NON-NLS-1$
- public static final String CANDIDATE_LABEL = "candidate"; //$NON-NLS-1$
+ public static final String LABEL_CANDIDATE = "LABEL_CANDIDATE"; //$NON-NLS-1$
+ public static final String LABEL_CANDIDATE_ICON = "LABEL_CANDIDATE_ICON"; //$NON-NLS-1$
- public static final String TARGET_LABEL = "target"; //$NON-NLS-1$
+ public static final String LABEL_TARGET = "LABEL_TARGET"; //$NON-NLS-1$
+ public static final String LABEL_TARGET_ICON = "LABEL_TARGET_ICON"; //$NON-NLS-1$
private final List columnList = new ArrayList<>();
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorLabelStyleConfiguration.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorLabelStyleConfiguration.java
index 9cd189f21..511f1b266 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorLabelStyleConfiguration.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorLabelStyleConfiguration.java
@@ -11,11 +11,16 @@ package eu.etaxonomy.taxeditor.bulkeditor.e4;
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter;
+import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
+import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator;
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.nebula.widgets.nattable.style.Style;
+import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum;
import eu.etaxonomy.taxeditor.model.ColorResources;
+import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.preference.Resources;
/**
@@ -26,21 +31,43 @@ import eu.etaxonomy.taxeditor.preference.Resources;
public final class BulkEditorLabelStyleConfiguration extends AbstractRegistryConfiguration {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
- Style cellStyle = new Style();
- cellStyle.setAttributeValue(
+ //deduplication candidate style
+ Style candidateCellStyle = new Style();
+ candidateCellStyle.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
ColorResources.getColor(Resources.COLOR_BULK_EDITOR_CANDIDATE));
configRegistry.registerConfigAttribute(
- CellConfigAttributes.CELL_STYLE, cellStyle,
- DisplayMode.NORMAL, BulkEditorE4Composite.CANDIDATE_LABEL);
+ CellConfigAttributes.CELL_STYLE,
+ candidateCellStyle,
+ DisplayMode.NORMAL,
+ BulkEditorE4Composite.LABEL_CANDIDATE);
+ configRegistry.registerConfigAttribute(
+ CellConfigAttributes.CELL_PAINTER,
+ new CellPainterDecorator(
+ new TextPainter(),
+ CellEdgeEnum.BOTTOM_RIGHT,
+ new ImagePainter(ImageResources.getImage(ImageResources.ACTIVE_DELETE_ICON)),
+ false),
+ DisplayMode.NORMAL,
+ BulkEditorE4Composite.LABEL_CANDIDATE_ICON);
- cellStyle = new Style();
- cellStyle.setAttributeValue(
+ //deduplication target style
+ Style targetCellStyle = new Style();
+ targetCellStyle.setAttributeValue(
CellStyleAttributes.BACKGROUND_COLOR,
ColorResources.getColor(Resources.COLOR_BULK_EDITOR_TARGET));
configRegistry.registerConfigAttribute(
- CellConfigAttributes.CELL_STYLE, cellStyle,
- DisplayMode.NORMAL, BulkEditorE4Composite.TARGET_LABEL);
+ CellConfigAttributes.CELL_STYLE, targetCellStyle,
+ DisplayMode.NORMAL, BulkEditorE4Composite.LABEL_TARGET);
+ configRegistry.registerConfigAttribute(
+ CellConfigAttributes.CELL_PAINTER,
+ new CellPainterDecorator(
+ new TextPainter(),
+ CellEdgeEnum.BOTTOM_RIGHT,
+ new ImagePainter(ImageResources.getImage(ImageResources.IMPORT)),
+ false),
+ DisplayMode.NORMAL,
+ BulkEditorE4Composite.LABEL_TARGET_ICON);
}
}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorTooltip.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorTooltip.java
index 6282dbf7f..172c47d50 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorTooltip.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorTooltip.java
@@ -46,10 +46,10 @@ public class BulkEditorTooltip extends DefaultToolTip {
int row = this.natTable.getRowPositionByY(event.y);
LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
- if(configLabels.hasLabel(BulkEditorE4Composite.TARGET_LABEL)){
+ if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_TARGET)){
return Messages.BulkEditorTooltip_TARGET;
}
- else if(configLabels.hasLabel(BulkEditorE4Composite.CANDIDATE_LABEL)){
+ else if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_CANDIDATE)){
return Messages.BulkEditorTooltip_CANDIDATE;
}
return ""; //$NON-NLS-1$
@@ -67,8 +67,8 @@ public class BulkEditorTooltip extends DefaultToolTip {
int row = this.natTable.getRowPositionByY(event.y);
LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
- if(configLabels.hasLabel(BulkEditorE4Composite.CANDIDATE_LABEL)
- || configLabels.hasLabel(BulkEditorE4Composite.TARGET_LABEL)){
+ if(configLabels.hasLabel(BulkEditorE4Composite.LABEL_CANDIDATE)
+ || configLabels.hasLabel(BulkEditorE4Composite.LABEL_TARGET)){
return true;
}
return false;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java
index 871bf041a..f0642dc57 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/ImageResources.java
@@ -147,6 +147,7 @@ public class ImageResources {
public static final String SWITCH_VIEW_TYPE = "switch_view_type";
public static final String SETTINGS = "settings";
public static final String EXPORT = "export";
+ public static final String IMPORT = "import";
//derivative icons
public static final String TISSUE_SAMPLE_DERIVATE = "tissue_sample_derivate";
@@ -423,6 +424,8 @@ public class ImageResources {
"default_derivate-16x16-32.png");
registerImage(registry, EXPORT,
"export.gif");
+ registerImage(registry, IMPORT,
+ "import_wiz.gif");
registerImage(registry, WEB,
"web.gif");
--
2.34.1