--- /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.nebula.widgets.nattable.data.ListDataProvider;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+
+/**
+ * @author pplitzner
+ * @since Jul 6, 2018
+ *
+ */
+public class BulkEditorConfigLabelAccumulator implements IConfigLabelAccumulator {
+ private ListDataProvider<CdmBase> dataProvider;
+ private AbstractBulkEditorInput input;
+
+ public BulkEditorConfigLabelAccumulator(ListDataProvider<CdmBase> dataProvider2,
+ AbstractBulkEditorInput input2) {
+ super();
+ this.dataProvider = dataProvider2;
+ this.input = input2;
+ }
+
+
+ @Override
+ public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
+ CdmBase rowObject = dataProvider.getRowObject(rowPosition);
+ if(input.getMergeCandidates().contains(rowObject)){
+ configLabels.addLabel(BulkEditorE4.CANDIDATE_LABEL);
+ }
+ else if(input.getMergeTarget()==rowObject){
+ configLabels.addLabel(BulkEditorE4.TARGET_LABEL);
+ }
+ }
+}
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;
}));
//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);
- }
- }
- });
+ dataLayer.setConfigLabelAccumulator(new BulkEditorConfigLabelAccumulator(bodyDataProvider, input));
//add tooltip to table
new BulkEditorTooltip(natTable);
//this configuration enables cell to be editable in general
//necessary because we disabled this beforehand by setting autoconfigure=false
- //in the GridLayer
+ //in the GridLayer constructor
((AbstractLayer) natTable.getLayer()).addConfiguration(new DefaultEditConfiguration());
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
}
});
+ //make cells editable to allow selecting the text
+ natTable.addConfiguration(new AbstractRegistryConfiguration() {
+ @Override
+ public void configureRegistry(IConfigRegistry configRegistry) {
+ //make cell editable
+ configRegistry.registerConfigAttribute(
+ EditConfigAttributes.CELL_EDITABLE_RULE,
+ IEditableRule.ALWAYS_EDITABLE,
+ DisplayMode.EDIT);
+ //register editor
+ TextCellEditor editor = new TextCellEditor();
+ editor.setEditable(false);
+ configRegistry.registerConfigAttribute(
+ EditConfigAttributes.CELL_EDITOR,
+ editor,
+ DisplayMode.NORMAL);
+ }
+ });
+
//+++CONTEXT MENU+++
menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$
// get the menu registered by EMenuService
}
});
- //make cells editable to allow selecting the text
- natTable.addConfiguration(new AbstractRegistryConfiguration() {
- @Override
- public void configureRegistry(IConfigRegistry configRegistry) {
- //make cell editable
- configRegistry.registerConfigAttribute(
- EditConfigAttributes.CELL_EDITABLE_RULE,
- IEditableRule.ALWAYS_EDITABLE,
- DisplayMode.EDIT);
- //register editor
- TextCellEditor editor = new TextCellEditor();
- editor.setEditable(false);
- configRegistry.registerConfigAttribute(
- EditConfigAttributes.CELL_EDITOR,
- editor,
- DisplayMode.NORMAL);
- }
- });
//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);
-
- }
- });
+ natTable.addConfiguration(new LabelStyleConfiguration());
//add default configuration because autoconfigure is set to false in constructor
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
@Optional
@Inject
private void updateAfterSearch(@UIEventTopic(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED)IStructuredSelection selection){
-
-
if(selection!=null){
setSelection(selection);
}
-// //auto resize columns
-// InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(
-// natTable, 2, natTable.getConfigRegistry(), new GCFactory(
-// natTable));
-// natTable.doCommand(command);
-// command = new InitializeAutoResizeColumnsCommand(
-// natTable, 1, natTable.getConfigRegistry(), new GCFactory(
-// natTable));
-// natTable.doCommand(command);
}
public void refresh(){
--- /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.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.style.CellStyleAttributes;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.style.Style;
+import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
+
+/**
+ * @author pplitzner
+ * @since Jul 6, 2018
+ *
+ */
+public final class LabelStyleConfiguration extends 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, BulkEditorE4.CANDIDATE_LABEL);
+
+ cellStyle = new Style();
+ cellStyle.setAttributeValue(
+ CellStyleAttributes.BACKGROUND_COLOR,
+ GUIHelper.COLOR_GREEN);
+ configRegistry.registerConfigAttribute(
+ CellConfigAttributes.CELL_STYLE, cellStyle,
+ DisplayMode.NORMAL, BulkEditorE4.TARGET_LABEL);
+
+ }
+}
\ No newline at end of file