Revision 6328df3b
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
41 | 41 |
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler; |
42 | 42 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; |
43 | 43 |
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration; |
44 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; |
|
44 | 45 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry; |
45 | 46 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration; |
46 | 47 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
... | ... | |
63 | 64 |
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer; |
64 | 65 |
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer; |
65 | 66 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; |
67 |
import org.eclipse.nebula.widgets.nattable.layer.LabelStack; |
|
68 |
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; |
|
66 | 69 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack; |
67 | 70 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel; |
68 | 71 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider; |
69 | 72 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
70 | 73 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration; |
74 |
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes; |
|
71 | 75 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
76 |
import org.eclipse.nebula.widgets.nattable.style.Style; |
|
72 | 77 |
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration; |
73 | 78 |
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry; |
74 | 79 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher; |
75 | 80 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher; |
76 | 81 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction; |
77 | 82 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder; |
83 |
import org.eclipse.nebula.widgets.nattable.util.GUIHelper; |
|
78 | 84 |
import org.eclipse.swt.SWT; |
79 | 85 |
import org.eclipse.swt.dnd.Clipboard; |
80 | 86 |
import org.eclipse.swt.dnd.TextTransfer; |
... | ... | |
119 | 125 |
IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData, |
120 | 126 |
IPartContentHasSupplementalData, IPartContentHasMedia, IE4SavablePart, ITaxonEditor { |
121 | 127 |
|
128 |
public static final String TARGET_LABEL = "target"; |
|
129 |
public static final String CANDIDATE_LABEL = "candidate"; |
|
130 |
|
|
122 | 131 |
public static final String TYPE_PROPERTY = Messages.BulkEditorE4_TYPE; |
123 | 132 |
|
124 | 133 |
@Inject |
... | ... | |
214 | 223 |
dataLayer.registerCommandHandler(new VisualRefreshCommandHandler()); |
215 | 224 |
GlazedListsEventLayer<CdmBase> eventLayer = new GlazedListsEventLayer<>(dataLayer, input.getModel()); |
216 | 225 |
bodyLayer = new DefaultBodyLayerStack(eventLayer); |
226 |
|
|
227 |
dataLayer.setColumnPercentageSizing(true); |
|
228 |
dataLayer.setColumnWidthPercentageByPosition(0, 80); |
|
229 |
dataLayer.setColumnWidthPercentageByPosition(1, 20); |
|
230 |
|
|
217 | 231 |
//column |
218 | 232 |
DataLayer columnHeaderDataLayer = new DataLayer(colHeaderDataProvider); |
219 | 233 |
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer( |
... | ... | |
233 | 247 |
DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider); |
234 | 248 |
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, |
235 | 249 |
bodyLayer, bodyLayer.getSelectionLayer()); |
236 |
dataLayer.setColumnPercentageSizing(true); |
|
237 |
dataLayer.setColumnWidthPercentageByPosition(0, 80); |
|
238 |
dataLayer.setColumnWidthPercentageByPosition(1, 20); |
|
239 | 250 |
|
240 | 251 |
//corner |
241 | 252 |
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider( |
... | ... | |
255 | 266 |
return input.getModel().indexOf(rowObject); |
256 | 267 |
} |
257 | 268 |
})); |
269 |
|
|
270 |
//add label to deduplication rows |
|
271 |
dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() { |
|
272 |
|
|
273 |
@Override |
|
274 |
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { |
|
275 |
CdmBase rowObject = bodyDataProvider.getRowObject(rowPosition); |
|
276 |
if(input.getMergeCandidates().contains(rowObject)){ |
|
277 |
configLabels.addLabel(CANDIDATE_LABEL); |
|
278 |
} |
|
279 |
else if(input.getMergeTarget()==rowObject){ |
|
280 |
configLabels.addLabel(TARGET_LABEL); |
|
281 |
} |
|
282 |
} |
|
283 |
}); |
|
284 |
|
|
285 |
//add tooltip to table |
|
286 |
new BulkEditorTooltip(natTable); |
|
258 | 287 |
} |
259 | 288 |
|
260 | 289 |
private void configureTable(){ |
... | ... | |
318 | 347 |
|
319 | 348 |
//enable sorting |
320 | 349 |
natTable.addConfiguration(new SingleClickSortConfiguration()); |
350 |
|
|
351 |
// Custom style for deduplication labels |
|
352 |
natTable.addConfiguration(new AbstractRegistryConfiguration() { |
|
353 |
@Override |
|
354 |
public void configureRegistry(IConfigRegistry configRegistry) { |
|
355 |
Style cellStyle = new Style(); |
|
356 |
cellStyle.setAttributeValue( |
|
357 |
CellStyleAttributes.BACKGROUND_COLOR, |
|
358 |
GUIHelper.COLOR_YELLOW); |
|
359 |
configRegistry.registerConfigAttribute( |
|
360 |
CellConfigAttributes.CELL_STYLE, cellStyle, |
|
361 |
DisplayMode.NORMAL, CANDIDATE_LABEL); |
|
362 |
|
|
363 |
cellStyle = new Style(); |
|
364 |
cellStyle.setAttributeValue( |
|
365 |
CellStyleAttributes.BACKGROUND_COLOR, |
|
366 |
GUIHelper.COLOR_GREEN); |
|
367 |
configRegistry.registerConfigAttribute( |
|
368 |
CellConfigAttributes.CELL_STYLE, cellStyle, |
|
369 |
DisplayMode.NORMAL, TARGET_LABEL); |
|
370 |
|
|
371 |
} |
|
372 |
}); |
|
373 |
|
|
321 | 374 |
//add default configuration because autoconfigure is set to false in constructor |
322 | 375 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); |
323 | 376 |
natTable.configure(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorTooltip.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.bulkeditor.e4; |
|
10 |
|
|
11 |
import org.eclipse.jface.window.DefaultToolTip; |
|
12 |
import org.eclipse.jface.window.ToolTip; |
|
13 |
import org.eclipse.nebula.widgets.nattable.NatTable; |
|
14 |
import org.eclipse.nebula.widgets.nattable.layer.LabelStack; |
|
15 |
import org.eclipse.swt.graphics.Point; |
|
16 |
import org.eclipse.swt.widgets.Composite; |
|
17 |
import org.eclipse.swt.widgets.Event; |
|
18 |
|
|
19 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author pplitzner |
|
23 |
* @since Jul 6, 2018 |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class BulkEditorTooltip extends DefaultToolTip { |
|
27 |
|
|
28 |
private NatTable natTable; |
|
29 |
|
|
30 |
public BulkEditorTooltip(NatTable natTable) { |
|
31 |
super(natTable, ToolTip.NO_RECREATE, false); |
|
32 |
this.natTable = natTable; |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected Object getToolTipArea(Event event) { |
|
37 |
int col = this.natTable.getColumnPositionByX(event.x); |
|
38 |
int row = this.natTable.getRowPositionByY(event.y); |
|
39 |
|
|
40 |
return new Point(col, row); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
protected String getText(Event event) { |
|
45 |
int col = this.natTable.getColumnPositionByX(event.x); |
|
46 |
int row = this.natTable.getRowPositionByY(event.y); |
|
47 |
|
|
48 |
LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row); |
|
49 |
if(configLabels.hasLabel(BulkEditorE4.TARGET_LABEL)){ |
|
50 |
return Messages.BulkEditorTooltip_TARGET; |
|
51 |
} |
|
52 |
else if(configLabels.hasLabel(BulkEditorE4.CANDIDATE_LABEL)){ |
|
53 |
return Messages.BulkEditorTooltip_CANDIDATE; |
|
54 |
} |
|
55 |
return ""; //$NON-NLS-1$ |
|
56 |
} |
|
57 |
|
|
58 |
@Override |
|
59 |
protected Composite createToolTipContentArea(Event event, |
|
60 |
Composite parent) { |
|
61 |
return super.createToolTipContentArea(event, parent); |
|
62 |
} |
|
63 |
|
|
64 |
@Override |
|
65 |
protected boolean shouldCreateToolTip(Event event) { |
|
66 |
int col = this.natTable.getColumnPositionByX(event.x); |
|
67 |
int row = this.natTable.getRowPositionByY(event.y); |
|
68 |
|
|
69 |
LabelStack configLabels = natTable.getConfigLabelsByPosition(col, row); |
|
70 |
if(configLabels.hasLabel(BulkEditorE4.CANDIDATE_LABEL) |
|
71 |
|| configLabels.hasLabel(BulkEditorE4.TARGET_LABEL)){ |
|
72 |
return true; |
|
73 |
} |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java | ||
---|---|---|
30 | 30 |
public static String BulkEditorSearchE4_SEARCH; |
31 | 31 |
public static String BulkEditorSearchE4_TITLE_CACHE; |
32 | 32 |
public static String BulkEditorSearchE4_WILDCARD; |
33 |
public static String ReferencingObjectsLabelProvider_No_description_available; |
|
33 |
public static String BulkEditorTooltip_CANDIDATE; |
|
34 |
public static String BulkEditorTooltip_TARGET; |
|
35 |
public static String ReferencingObjectsLabelProvider_No_description_available; |
|
34 | 36 |
public static String ConvertPerson2TeamHandler_warning; |
35 | 37 |
public static String ConvertPerson2TeamHandler_lable; |
36 | 38 |
public static String DeleteHandler_CAN_BE_DELETED; |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties | ||
---|---|---|
22 | 22 |
BulkEditorSearchE4_SEARCH=Search |
23 | 23 |
BulkEditorSearchE4_TITLE_CACHE=Title Cache |
24 | 24 |
BulkEditorSearchE4_WILDCARD=Use '%s' for wildcard searching |
25 |
BulkEditorTooltip_CANDIDATE=Candidate for duplicate removal |
|
26 |
BulkEditorTooltip_TARGET=Target for duplicate removal |
|
25 | 27 |
|
26 | 28 |
USER_CREATOR_user_exists_title=The user already exists |
27 | 29 |
USER_CREATOR_user_exists=The user already exists in database |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties | ||
---|---|---|
22 | 22 |
BulkEditorSearchE4_SEARCH=Suche |
23 | 23 |
BulkEditorSearchE4_TITLE_CACHE=Title-Cache |
24 | 24 |
BulkEditorSearchE4_WILDCARD='%s' f\u00FCr Platzhalter-Suche benutzen |
25 |
BulkEditorTooltip_CANDIDATE= Kandidat f?r Duplikatenentfernung |
|
26 |
BulkEditorTooltip_TARGET=Ziel f?r Duplikatenentfernung |
|
25 | 27 |
|
26 | 28 |
USER_CREATOR_user_exists_title=Der Benutzer existiert bereits |
27 | 29 |
USER_CREATOR_user_exists=Der Benutzer existiert bereits in der Datenbank. |
Also available in: Unified diff
ref #7518 Colorize deduplication rows + tooltip