import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler;
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel;
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider;
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
+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.style.theme.ModernNatTableThemeConfiguration;
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
+import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData,
IPartContentHasSupplementalData, IPartContentHasMedia, IE4SavablePart, ITaxonEditor {
+ public static final String TARGET_LABEL = "target";
+ public static final String CANDIDATE_LABEL = "candidate";
+
public static final String TYPE_PROPERTY = Messages.BulkEditorE4_TYPE;
@Inject
dataLayer.registerCommandHandler(new VisualRefreshCommandHandler());
GlazedListsEventLayer<CdmBase> eventLayer = new GlazedListsEventLayer<>(dataLayer, input.getModel());
bodyLayer = new DefaultBodyLayerStack(eventLayer);
+
+ dataLayer.setColumnPercentageSizing(true);
+ dataLayer.setColumnWidthPercentageByPosition(0, 80);
+ dataLayer.setColumnWidthPercentageByPosition(1, 20);
+
//column
DataLayer columnHeaderDataLayer = new DataLayer(colHeaderDataProvider);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
bodyLayer, bodyLayer.getSelectionLayer());
- dataLayer.setColumnPercentageSizing(true);
- dataLayer.setColumnWidthPercentageByPosition(0, 80);
- dataLayer.setColumnWidthPercentageByPosition(1, 20);
//corner
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
return input.getModel().indexOf(rowObject);
}
}));
+
+ //add label to deduplication rows
+ dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
+
+ @Override
+ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
+ CdmBase rowObject = bodyDataProvider.getRowObject(rowPosition);
+ if(input.getMergeCandidates().contains(rowObject)){
+ configLabels.addLabel(CANDIDATE_LABEL);
+ }
+ else if(input.getMergeTarget()==rowObject){
+ configLabels.addLabel(TARGET_LABEL);
+ }
+ }
+ });
+
+ //add tooltip to table
+ new BulkEditorTooltip(natTable);
}
private void configureTable(){
//enable sorting
natTable.addConfiguration(new SingleClickSortConfiguration());
+
+ // Custom style for deduplication labels
+ natTable.addConfiguration(new AbstractRegistryConfiguration() {
+ @Override
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ Style cellStyle = new Style();
+ cellStyle.setAttributeValue(
+ CellStyleAttributes.BACKGROUND_COLOR,
+ GUIHelper.COLOR_YELLOW);
+ configRegistry.registerConfigAttribute(
+ CellConfigAttributes.CELL_STYLE, cellStyle,
+ DisplayMode.NORMAL, CANDIDATE_LABEL);
+
+ cellStyle = new Style();
+ cellStyle.setAttributeValue(
+ CellStyleAttributes.BACKGROUND_COLOR,
+ GUIHelper.COLOR_GREEN);
+ configRegistry.registerConfigAttribute(
+ CellConfigAttributes.CELL_STYLE, cellStyle,
+ DisplayMode.NORMAL, TARGET_LABEL);
+
+ }
+ });
+
//add default configuration because autoconfigure is set to false in constructor
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.configure();
--- /dev/null
+/**
+* Copyright (C) 2018 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.bulkeditor.e4;
+
+import org.eclipse.jface.window.DefaultToolTip;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.nebula.widgets.nattable.NatTable;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ * @author pplitzner
+ * @since Jul 6, 2018
+ *
+ */
+public class BulkEditorTooltip extends DefaultToolTip {
+
+ private NatTable natTable;
+
+ public BulkEditorTooltip(NatTable natTable) {
+ super(natTable, ToolTip.NO_RECREATE, false);
+ this.natTable = natTable;
+}
+
+ @Override
+ protected Object getToolTipArea(Event event) {
+ int col = this.natTable.getColumnPositionByX(event.x);
+ int row = this.natTable.getRowPositionByY(event.y);
+
+ return new Point(col, row);
+ }
+
+ @Override
+ protected String getText(Event event) {
+ int col = this.natTable.getColumnPositionByX(event.x);
+ int row = this.natTable.getRowPositionByY(event.y);
+
+ LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
+ if(configLabels.hasLabel(BulkEditorE4.TARGET_LABEL)){
+ return Messages.BulkEditorTooltip_TARGET;
+ }
+ else if(configLabels.hasLabel(BulkEditorE4.CANDIDATE_LABEL)){
+ return Messages.BulkEditorTooltip_CANDIDATE;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ protected Composite createToolTipContentArea(Event event,
+ Composite parent) {
+ return super.createToolTipContentArea(event, parent);
+ }
+
+ @Override
+ protected boolean shouldCreateToolTip(Event event) {
+ int col = this.natTable.getColumnPositionByX(event.x);
+ int row = this.natTable.getRowPositionByY(event.y);
+
+ LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row);
+ if(configLabels.hasLabel(BulkEditorE4.CANDIDATE_LABEL)
+ || configLabels.hasLabel(BulkEditorE4.TARGET_LABEL)){
+ return true;
+ }
+ return false;
+ }
+
+}