Search in sources :

Example 66 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class BodyHoverStylingBindings method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    // apply a hover styling on moving the mouse over a NatTable
    uiBindingRegistry.registerFirstMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            return BodyHoverStylingBindings.this.layer.getClientAreaProvider().getClientArea().contains(event.x, event.y);
        }
    }, new HoverStylingAction(this.layer));
    // clear any hover styling if the mouse is moved out of the region area
    // uiBindingRegistry.registerMouseMoveBinding(
    // new IMouseEventMatcher() {
    // @Override
    // public boolean matches(NatTable natTable, MouseEvent event,
    // LabelStack regionLabels) {
    // return
    // (!layer.getClientAreaProvider().getClientArea().contains(event.x,
    // event.y));
    // }
    // 
    // }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of a NatTable
    // region
    uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            return (natTable != null && regionLabels == null);
        }
    }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of the NatTable
    // area
    uiBindingRegistry.registerMouseExitBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            // not necessary
            return true;
        }
    }, new ClearHoverStylingAction());
}
Also used : ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) MouseEvent(org.eclipse.swt.events.MouseEvent) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) HoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.HoverStylingAction)

Example 67 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class ColumnHeaderResizeHoverBindings method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    // Mouse move - Show resize cursor
    uiBindingRegistry.registerFirstMouseMoveBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 0), new ColumnResizeCursorAction());
    // apply a hover styling on moving the mouse over a NatTable and clear
    // the cursor
    uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(GridRegion.COLUMN_HEADER), new HoverStylingAction(this.layer));
    // clear any hover styling if the mouse is moved out of a NatTable
    // region
    uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            return ((natTable != null && regionLabels == null) || regionLabels != null && regionLabels.hasLabel(GridRegion.CORNER));
        }
    }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of the NatTable
    // area
    uiBindingRegistry.registerMouseExitBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            // not necessary
            return true;
        }
    }, new ClearHoverStylingAction());
    // Column resize
    uiBindingRegistry.registerFirstMouseDragMode(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new ColumnResizeDragMode());
    uiBindingRegistry.registerDoubleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new AutoResizeColumnAction());
    uiBindingRegistry.registerSingleClickBinding(new ColumnResizeEventMatcher(SWT.NONE, GridRegion.COLUMN_HEADER, 1), new NoOpMouseAction());
}
Also used : ColumnResizeCursorAction(org.eclipse.nebula.widgets.nattable.resize.action.ColumnResizeCursorAction) MouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) MouseEvent(org.eclipse.swt.events.MouseEvent) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) AutoResizeColumnAction(org.eclipse.nebula.widgets.nattable.resize.action.AutoResizeColumnAction) ColumnResizeEventMatcher(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEventMatcher) ColumnResizeDragMode(org.eclipse.nebula.widgets.nattable.resize.mode.ColumnResizeDragMode) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) NoOpMouseAction(org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) HoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.HoverStylingAction)

Example 68 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class RowHeaderResizeHoverBindings method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    // Mouse move - Show resize cursor
    uiBindingRegistry.registerFirstMouseMoveBinding(new RowResizeEventMatcher(SWT.NONE, 0), new RowResizeCursorAction());
    // apply a hover styling on moving the mouse over a NatTable and clear
    // the cursor
    uiBindingRegistry.registerMouseMoveBinding(new MouseEventMatcher(GridRegion.ROW_HEADER), new HoverStylingAction(this.layer));
    // clear any hover styling if the mouse is moved out of the region area
    // uiBindingRegistry.registerMouseMoveBinding(
    // new IMouseEventMatcher() {
    // @Override
    // public boolean matches(NatTable natTable, MouseEvent event,
    // LabelStack regionLabels) {
    // return (regionLabels != null &&
    // !regionLabels.hasLabel(GridRegion.ROW_HEADER));
    // }
    // 
    // }, new ClearHoverStylingAction(layer));
    // clear any hover styling if the mouse is moved out of a NatTable
    // region
    uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            return (natTable != null && regionLabels == null);
        }
    }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of the NatTable
    // area
    uiBindingRegistry.registerMouseExitBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            // not necessary
            return true;
        }
    }, new ClearHoverStylingAction());
    // Row resize
    uiBindingRegistry.registerFirstMouseDragMode(new RowResizeEventMatcher(SWT.NONE, 1), new RowResizeDragMode());
    uiBindingRegistry.registerDoubleClickBinding(new RowResizeEventMatcher(SWT.NONE, 1), new AutoResizeRowAction());
    uiBindingRegistry.registerSingleClickBinding(new RowResizeEventMatcher(SWT.NONE, 1), new NoOpMouseAction());
}
Also used : RowResizeCursorAction(org.eclipse.nebula.widgets.nattable.resize.action.RowResizeCursorAction) MouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) MouseEvent(org.eclipse.swt.events.MouseEvent) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) AutoResizeRowAction(org.eclipse.nebula.widgets.nattable.resize.action.AutoResizeRowAction) RowResizeDragMode(org.eclipse.nebula.widgets.nattable.resize.mode.RowResizeDragMode) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) RowResizeEventMatcher(org.eclipse.nebula.widgets.nattable.resize.event.RowResizeEventMatcher) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) NoOpMouseAction(org.eclipse.nebula.widgets.nattable.ui.action.NoOpMouseAction) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) HoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.HoverStylingAction)

Example 69 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class SimpleHoverStylingBindings method configureUiBindings.

@Override
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
    // apply a hover styling on moving the mouse over a NatTable
    uiBindingRegistry.registerFirstMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            int width = SimpleHoverStylingBindings.this.layer.getPreferredWidth();
            int height = SimpleHoverStylingBindings.this.layer.getPreferredHeight();
            return ((event.x > 0 && event.x < width) && (event.y > 0 && event.y < height));
        }
    }, new HoverStylingAction(this.layer));
    // clear any hover styling if the mouse is moved out of the region area
    uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            int width = SimpleHoverStylingBindings.this.layer.getPreferredWidth();
            int height = SimpleHoverStylingBindings.this.layer.getPreferredHeight();
            return ((event.x < 0 || event.x > width) || (event.y < 0 || event.y > height));
        }
    }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of a NatTable
    // region
    uiBindingRegistry.registerMouseMoveBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            return (natTable != null && regionLabels == null);
        }
    }, new ClearHoverStylingAction());
    // clear any hover styling if the mouse is moved out of the NatTable
    // area
    uiBindingRegistry.registerMouseExitBinding(new IMouseEventMatcher() {

        @Override
        public boolean matches(NatTable natTable, MouseEvent event, LabelStack regionLabels) {
            // not necessary
            return true;
        }
    }, new ClearHoverStylingAction());
}
Also used : ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) IMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.IMouseEventMatcher) MouseEvent(org.eclipse.swt.events.MouseEvent) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) ClearHoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.ClearHoverStylingAction) HoverStylingAction(org.eclipse.nebula.widgets.nattable.hover.action.HoverStylingAction)

Example 70 with LabelStack

use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.

the class GridLineCellLayerPainter method paintLayer.

@Override
public void paintLayer(ILayer natLayer, GC gc, int xOffset, int yOffset, Rectangle rectangle, IConfigRegistry configRegistry) {
    Boolean renderConfig = null;
    LabelStack stack = natLayer.getRegionLabelsByXY(xOffset, yOffset);
    List<String> labels = new ArrayList<String>();
    if (stack != null) {
        labels = stack.getLabels();
        // check if there is a configuration telling to not rendering grid
        // lines
        renderConfig = configRegistry.getConfigAttribute(CellConfigAttributes.RENDER_GRID_LINES, DisplayMode.NORMAL, labels);
    }
    this.renderGridLines = (renderConfig != null) ? renderConfig : true;
    // Draw GridLines
    if (this.renderGridLines) {
        // check if there is a configuration for the grid line width
        Integer width = configRegistry.getConfigAttribute(CellConfigAttributes.GRID_LINE_WIDTH, DisplayMode.NORMAL, labels);
        this.gridLineWidth = (width != null) ? width : 1;
        int oldLineWidth = gc.getLineWidth();
        gc.setLineWidth(this.gridLineWidth);
        drawGridLines(natLayer, gc, rectangle, configRegistry, labels);
        gc.setLineWidth(oldLineWidth);
    }
    super.paintLayer(natLayer, gc, xOffset, yOffset, rectangle, configRegistry);
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ArrayList(java.util.ArrayList)

Aggregations

LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)80 Test (org.junit.Test)30 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)14 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)11 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)10 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)10 HashMap (java.util.HashMap)9 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)8 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)8 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)8 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)8