use of org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher in project nebula.widgets.nattable by eclipse.
the class MouseEventMatcherTest method testFullConstructorEquals.
@Test
public void testFullConstructorEquals() {
IMouseEventMatcher matcher1 = new MouseEventMatcher(5, "Test_Region", 1);
IMouseEventMatcher matcher2 = new MouseEventMatcher(5, "Test_Region", 1);
Assert.assertEquals(matcher1, matcher2);
}
use of org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher in project nebula.widgets.nattable by eclipse.
the class DefaultSortConfiguration method configureUiBindings.
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerSingleClickBinding(new MouseEventMatcher(SWT.MOD3, GridRegion.COLUMN_HEADER.toString(), 1), new SortColumnAction(false));
uiBindingRegistry.registerSingleClickBinding(new MouseEventMatcher(SWT.MOD3 | SWT.MOD2, GridRegion.COLUMN_HEADER.toString(), 1), new SortColumnAction(true));
}
use of org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher in project nebula.widgets.nattable by eclipse.
the class _5064_GridHeaderHoverStylingExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// property names of the Person class
String[] propertyNames = { "firstName", "lastName", "gender", "married", "birthday" };
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("firstName", "Firstname");
propertyToLabelMap.put("lastName", "Lastname");
propertyToLabelMap.put("gender", "Gender");
propertyToLabelMap.put("married", "Married");
propertyToLabelMap.put("birthday", "Birthday");
// build the body layer stack
// Usually you would create a new layer stack by extending
// AbstractIndexLayerTransform and setting the ViewportLayer
// as underlying layer. But in this case using the ViewportLayer
// directly as body layer is also working.
IDataProvider bodyDataProvider = new DefaultBodyDataProvider<>(PersonService.getPersons(10), propertyNames);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
SelectionLayer selectionLayer = new SelectionLayer(bodyDataLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(columnHeaderDataProvider);
HoverLayer columnHoverLayer = new HoverLayer(columnHeaderDataLayer, false);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHoverLayer, viewportLayer, selectionLayer, false);
// add ColumnHeaderHoverLayerConfiguration to ensure that hover styling
// and resizing is working together
columnHeaderLayer.addConfiguration(new ColumnHeaderHoverLayerConfiguration(columnHoverLayer));
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(rowHeaderDataProvider);
HoverLayer rowHoverLayer = new HoverLayer(rowHeaderDataLayer, false);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHoverLayer, viewportLayer, selectionLayer, false);
// add RowHeaderHoverLayerConfiguration to ensure that hover styling and
// resizing is working together
rowHeaderLayer.addConfiguration(new RowHeaderHoverLayerConfiguration(rowHoverLayer));
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer, columnHeaderLayer);
// build the grid layer
GridLayer gridLayer = new GridLayer(viewportLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
// turn the auto configuration off as we want to add our header menu
// configuration
NatTable natTable = new NatTable(parent, gridLayer, false);
// as the autoconfiguration of the NatTable is turned off, we have to
// add the DefaultNatTableStyleConfiguration manually
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(GridRegion.BODY), new ClearHoverStylingAction());
}
});
// add the style configuration for hover
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
Style style = new Style();
style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.COLOR_RED);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.HOVER, GridRegion.ROW_HEADER);
Image bgImage = GUIHelper.getImageByURL("columnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/column_header_bg.png"));
Image hoverBgImage = GUIHelper.getImageByURL("hoverColumnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/hovered_column_header_bg.png"));
Image selectedBgImage = GUIHelper.getImageByURL("selectedColumnHeaderBg", getClass().getResource("/org/eclipse/nebula/widgets/nattable/examples/resources/selected_column_header_bg.png"));
TextPainter txtPainter = new TextPainter(false, false);
ICellPainter bgImagePainter = new BackgroundImagePainter(txtPainter, bgImage, GUIHelper.getColor(192, 192, 192));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bgImagePainter, DisplayMode.NORMAL, GridRegion.COLUMN_HEADER);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, bgImagePainter, DisplayMode.NORMAL, GridRegion.CORNER);
ICellPainter hoveredHeaderPainter = new BackgroundImagePainter(txtPainter, hoverBgImage, GUIHelper.getColor(192, 192, 192));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, hoveredHeaderPainter, DisplayMode.HOVER, GridRegion.COLUMN_HEADER);
ICellPainter selectedHeaderPainter = new BackgroundImagePainter(txtPainter, selectedBgImage, GUIHelper.getColor(192, 192, 192));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, selectedHeaderPainter, DisplayMode.SELECT, GridRegion.COLUMN_HEADER);
}
});
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher in project nebula.widgets.nattable by eclipse.
the class MouseEventMatcherTest method testNotEqual.
@Test
public void testNotEqual() {
IMouseEventMatcher matcher = new MouseEventMatcher(5, "Test_Region", 1);
Assert.assertFalse(matcher.equals(new MouseEventMatcher(4, "Test_Region", 1)));
Assert.assertFalse(matcher.equals(new MouseEventMatcher(5, "X_Region", 1)));
Assert.assertFalse(matcher.equals(new MouseEventMatcher(5, "Test_Region", 2)));
Assert.assertFalse(matcher.equals(new MouseEventMatcher(4, "X_Region", 2)));
}
use of org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher in project nebula.widgets.nattable by eclipse.
the class MouseEventMatcherTest method testMap.
@Test
public void testMap() {
Map<IMouseEventMatcher, String> map = new HashMap<IMouseEventMatcher, String>();
map.put(new MouseEventMatcher(), "ABC");
Assert.assertEquals(1, map.size());
map.remove(new MouseEventMatcher());
Assert.assertEquals(0, map.size());
}
Aggregations