Bug 379894 - Imported: Mouse : RIGHT CLICK : popup menu : Freeze
bindings

Change-Id: If12e1527f0fceb7c57b91ffeb33e20b4530f7169
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
diff --git a/org.eclipse.nebula.widgets.nattable.core/.settings/.api_filters b/org.eclipse.nebula.widgets.nattable.core/.settings/.api_filters
index 8815c74..7807aba 100644
--- a/org.eclipse.nebula.widgets.nattable.core/.settings/.api_filters
+++ b/org.eclipse.nebula.widgets.nattable.core/.settings/.api_filters
@@ -118,6 +118,24 @@
         <filter id="336658481">
             <message_arguments>
                 <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
+                <message_argument value="FREEZE_COLUMN_MENU_ITEM_ID"/>
+            </message_arguments>
+        </filter>
+        <filter id="336658481">
+            <message_arguments>
+                <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
+                <message_argument value="FREEZE_POSITION_MENU_ITEM_ID"/>
+            </message_arguments>
+        </filter>
+        <filter id="336658481">
+            <message_arguments>
+                <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
+                <message_argument value="FREEZE_ROW_MENU_ITEM_ID"/>
+            </message_arguments>
+        </filter>
+        <filter id="336658481">
+            <message_arguments>
+                <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
                 <message_argument value="REMOVE_ROW_GROUP_MENU_ITEM_ID"/>
             </message_arguments>
         </filter>
@@ -130,6 +148,12 @@
         <filter id="336658481">
             <message_arguments>
                 <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
+                <message_argument value="UNFREEZE_MENU_ITEM_ID"/>
+            </message_arguments>
+        </filter>
+        <filter id="336658481">
+            <message_arguments>
+                <message_argument value="org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder"/>
                 <message_argument value="UNGROUP_ROWS_MENU_ITEM_ID"/>
             </message_arguments>
         </filter>
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages.properties b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages.properties
index 890a0dd..ce0338f 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages.properties
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2012, 2016 Original authors and others.
+# Copyright (c) 2012, 2019 Original authors and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -132,6 +132,10 @@
 MenuItemProviders.exportToImage=Export to image
 MenuItemProviders.createRowGroup=Group selected rows
 MenuItemProviders.ungroupRows=Ungroup selected rows
+MenuItemProviders.freezeColumn=Freeze column
+MenuItemProviders.freezeRow=Freeze row
+MenuItemProviders.freezePosition=Freeze cell
+MenuItemProviders.unfreeze=Unfreeze
 
 NatExporter.exporting=Exporting.. please wait
 NatExporter.errorMessagePrefix=Error on export:\n{0}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages_de.properties b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages_de.properties
index a3b65f1..c4165b9 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages_de.properties
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/messages_de.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2012, 2016 Original authors and others.
+# Copyright (c) 2012, 2019 Original authors and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -132,6 +132,10 @@
 MenuItemProviders.exportToImage=Als Bild exportieren
 MenuItemProviders.createRowGroup=Gruppierung erzeugen
 MenuItemProviders.ungroupRows=Gruppierung aufheben
+MenuItemProviders.freezeColumn=Spalte fixieren
+MenuItemProviders.freezeRow=Zeile fixieren
+MenuItemProviders.freezePosition=Zelle fixieren
+MenuItemProviders.unfreeze=Fixierung aufheben
 
 NatExporter.exporting=Exportiere.. Bitte warten
 NatExporter.errorMessagePrefix=Fehler beim Exportieren:\n{0}
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
index d6d5582..91bbedd 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/MenuItemProviders.java
@@ -24,6 +24,10 @@
 import org.eclipse.nebula.widgets.nattable.export.image.ImageExporter;
 import org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand;
 import org.eclipse.nebula.widgets.nattable.filterrow.command.ToggleFilterRowCommand;
+import org.eclipse.nebula.widgets.nattable.freeze.command.FreezeColumnCommand;
+import org.eclipse.nebula.widgets.nattable.freeze.command.FreezePositionCommand;
+import org.eclipse.nebula.widgets.nattable.freeze.command.FreezeRowCommand;
+import org.eclipse.nebula.widgets.nattable.freeze.command.UnFreezeGridCommand;
 import org.eclipse.nebula.widgets.nattable.group.command.CreateColumnGroupCommand;
 import org.eclipse.nebula.widgets.nattable.group.command.CreateRowGroupCommand;
 import org.eclipse.nebula.widgets.nattable.group.command.DisplayColumnGroupRenameDialogCommand;
@@ -1260,10 +1264,8 @@
                 renameRowGroup.addSelectionListener(new SelectionAdapter() {
                     @Override
                     public void widgetSelected(SelectionEvent e) {
-                        NatEventData natEventData = MenuItemProviders.getNatEventData(e);
-                        int rowPosition = natEventData.getRowPosition();
-                        natTable.doCommand(
-                                new DisplayRowGroupRenameDialogCommand(natTable, rowPosition));
+                        int rowPosition = getNatEventData(e).getRowPosition();
+                        natTable.doCommand(new DisplayRowGroupRenameDialogCommand(natTable, rowPosition));
                     }
                 });
             }
@@ -1302,11 +1304,176 @@
                 menuItem.addSelectionListener(new SelectionAdapter() {
                     @Override
                     public void widgetSelected(SelectionEvent e) {
-                        NatEventData natEventData = MenuItemProviders.getNatEventData(e);
+                        NatEventData natEventData = getNatEventData(e);
                         int rowPosition = natEventData.getRowPosition();
                         int rowIndex = natEventData.getNatTable().getRowIndexByPosition(rowPosition);
+                        natTable.doCommand(new RemoveRowGroupCommand(rowIndex));
+                    }
+                });
+            }
+        };
+    }
+
+    /**
+     *
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         column.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezeColumnMenuItemProvider() {
+        return freezeColumnMenuItemProvider("%MenuItemProviders.freezeColumn"); //$NON-NLS-1$
+    }
+
+    /**
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         column.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezeColumnMenuItemProvider(final String menuLabel) {
+        return new IMenuItemProvider() {
+
+            @Override
+            public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
+                MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
+                menuItem.setText(Messages.getLocalizedMessage(menuLabel));
+                menuItem.setEnabled(true);
+
+                menuItem.addSelectionListener(new SelectionAdapter() {
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        int columnPosition = getNatEventData(e).getColumnPosition();
+                        natTable.doCommand(new FreezeColumnCommand(natTable, columnPosition, false, true));
+                    }
+                });
+            }
+        };
+    }
+
+    /**
+     *
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         row.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezeRowMenuItemProvider() {
+        return freezeRowMenuItemProvider("%MenuItemProviders.freezeRow"); //$NON-NLS-1$
+    }
+
+    /**
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         row.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezeRowMenuItemProvider(final String menuLabel) {
+        return new IMenuItemProvider() {
+
+            @Override
+            public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
+                MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
+                menuItem.setText(Messages.getLocalizedMessage(menuLabel));
+                menuItem.setEnabled(true);
+
+                menuItem.addSelectionListener(new SelectionAdapter() {
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        int rowPosition = getNatEventData(e).getRowPosition();
+                        natTable.doCommand(new FreezeRowCommand(natTable, rowPosition, false, true));
+                    }
+                });
+            }
+        };
+    }
+
+    /**
+     *
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         cell position.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezePositionMenuItemProvider(boolean include) {
+        return freezePositionMenuItemProvider("%MenuItemProviders.freezePosition", include); //$NON-NLS-1$
+    }
+
+    /**
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @param include
+     *            whether the selected cell should be included in the freeze
+     *            region or not. Include means the freeze borders will be to the
+     *            right and bottom, while exclude means the freeze borders are
+     *            to the left and top.
+     * @return The {@link IMenuItemProvider} for adding a menu item to freeze a
+     *         cell position.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider freezePositionMenuItemProvider(final String menuLabel, final boolean include) {
+        return new IMenuItemProvider() {
+
+            @Override
+            public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
+                MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
+                menuItem.setText(Messages.getLocalizedMessage(menuLabel));
+                menuItem.setEnabled(true);
+
+                menuItem.addSelectionListener(new SelectionAdapter() {
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        int columnPosition = getNatEventData(e).getColumnPosition();
+                        int rowPosition = getNatEventData(e).getRowPosition();
                         natTable.doCommand(
-                                new RemoveRowGroupCommand(rowIndex));
+                                new FreezePositionCommand(natTable, columnPosition, rowPosition, false, true, include));
+                    }
+                });
+            }
+        };
+    }
+
+    /**
+     *
+     * @return The {@link IMenuItemProvider} for adding a menu item to remove a
+     *         frozen state.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider unfreezeMenuItemProvider() {
+        return unfreezeMenuItemProvider("%MenuItemProviders.unfreeze"); //$NON-NLS-1$
+    }
+
+    /**
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return The {@link IMenuItemProvider} for adding a menu item to remove a
+     *         frozen state.
+     *
+     * @since 1.6
+     */
+    public static IMenuItemProvider unfreezeMenuItemProvider(final String menuLabel) {
+        return new IMenuItemProvider() {
+
+            @Override
+            public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
+                MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
+                menuItem.setText(Messages.getLocalizedMessage(menuLabel));
+                menuItem.setEnabled(true);
+
+                menuItem.addSelectionListener(new SelectionAdapter() {
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        natTable.doCommand(new UnFreezeGridCommand());
                     }
                 });
             }
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
index 7081a52..f12dcb5 100644
--- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
+++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/ui/menu/PopupMenuBuilder.java
@@ -77,6 +77,22 @@
      * @since 1.6
      */
     public static final String UNGROUP_ROWS_MENU_ITEM_ID = "ungroupRowsMenuItem"; //$NON-NLS-1$
+    /**
+     * @since 1.6
+     */
+    public static final String FREEZE_COLUMN_MENU_ITEM_ID = "freezeColumnMenuItem"; //$NON-NLS-1$
+    /**
+     * @since 1.6
+     */
+    public static final String FREEZE_ROW_MENU_ITEM_ID = "freezeRowMenuItem"; //$NON-NLS-1$
+    /**
+     * @since 1.6
+     */
+    public static final String FREEZE_POSITION_MENU_ITEM_ID = "freezePositionMenuItem"; //$NON-NLS-1$
+    /**
+     * @since 1.6
+     */
+    public static final String UNFREEZE_MENU_ITEM_ID = "unfreezeMenuItem"; //$NON-NLS-1$
 
     /**
      * The active NatTable instance the context menu should be added to. Needed
@@ -759,6 +775,130 @@
                 MenuItemProviders.removeRowGroupMenuItemProvider(menuLabel));
     }
 
+    /**
+     * Adds the menu item for for freezing a grid at a given column position.
+     *
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezeColumnMenuItem() {
+        return withMenuItemProvider(
+                FREEZE_COLUMN_MENU_ITEM_ID,
+                MenuItemProviders.freezeColumnMenuItemProvider());
+    }
+
+    /**
+     * Adds the menu item for for freezing a grid at a given column position.
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezeColumnMenuItem(String menuLabel) {
+        return withMenuItemProvider(
+                FREEZE_COLUMN_MENU_ITEM_ID,
+                MenuItemProviders.freezeColumnMenuItemProvider(menuLabel));
+    }
+
+    /**
+     * Adds the menu item for for freezing a grid at a given row position.
+     *
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezeRowMenuItem() {
+        return withMenuItemProvider(
+                FREEZE_ROW_MENU_ITEM_ID,
+                MenuItemProviders.freezeRowMenuItemProvider());
+    }
+
+    /**
+     * Adds the menu item for for freezing a grid at a given row position.
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezeRowMenuItem(String menuLabel) {
+        return withMenuItemProvider(
+                FREEZE_ROW_MENU_ITEM_ID,
+                MenuItemProviders.freezeRowMenuItemProvider(menuLabel));
+    }
+
+    /**
+     * Adds the menu item for freezing a grid at a given cell position. This
+     * menu item is intended to be used in a body menu.
+     *
+     * @param include
+     *            whether the selected cell should be included in the freeze
+     *            region or not. Include means the freeze borders will be to the
+     *            right and bottom, while exclude means the freeze borders are
+     *            to the left and top.
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezePositionMenuItem(boolean include) {
+        return withMenuItemProvider(
+                FREEZE_POSITION_MENU_ITEM_ID,
+                MenuItemProviders.freezePositionMenuItemProvider(include));
+    }
+
+    /**
+     * Adds the menu item for freezing a grid at a given cell position. This
+     * menu item is intended to be used in a body menu.
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @param include
+     *            whether the selected cell should be included in the freeze
+     *            region or not. Include means the freeze borders will be to the
+     *            right and bottom, while exclude means the freeze borders are
+     *            to the left and top.
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withFreezePositionMenuItem(String menuLabel, boolean include) {
+        return withMenuItemProvider(
+                FREEZE_POSITION_MENU_ITEM_ID,
+                MenuItemProviders.freezePositionMenuItemProvider(menuLabel, include));
+    }
+
+    /**
+     * Adds the menu item for removing a frozen state.
+     *
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withUnfreezeMenuItem() {
+        return withMenuItemProvider(
+                UNFREEZE_MENU_ITEM_ID,
+                MenuItemProviders.unfreezeMenuItemProvider());
+    }
+
+    /**
+     * Adds the menu item for removing a frozen state.
+     *
+     * @param menuLabel
+     *            The label to be used for showing the menu item.
+     * @return This PopupMenuBuilder.
+     *
+     * @since 1.6
+     */
+    public PopupMenuBuilder withUnfreezeMenuItem(String menuLabel) {
+        return withMenuItemProvider(
+                UNFREEZE_MENU_ITEM_ID,
+                MenuItemProviders.unfreezeMenuItemProvider(menuLabel));
+    }
+
     public PopupMenuBuilder withInspectLabelsMenuItem() {
         return withMenuItemProvider(
                 INSPECT_LABEL_MENU_ITEM_ID,
diff --git a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_513_FreezeExample.java b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_513_FreezeExample.java
index 11e73eb..06a3f38 100644
--- a/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_513_FreezeExample.java
+++ b/org.eclipse.nebula.widgets.nattable.examples/src/org/eclipse/nebula/widgets/nattable/examples/_500_Layers/_513_FreezeExample.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2015 Dirk Fauth and others.
+ * Copyright (c) 2013, 2019 Dirk Fauth and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -16,6 +16,7 @@
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.nebula.widgets.nattable.NatTable;
 import org.eclipse.nebula.widgets.nattable.columnChooser.command.DisplayColumnChooserCommandHandler;
+import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
 import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
 import org.eclipse.nebula.widgets.nattable.dataset.person.PersonService;
@@ -40,13 +41,19 @@
 import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
 import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
 import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.ui.NatEventData;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
 import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
+import org.eclipse.nebula.widgets.nattable.ui.menu.IMenuItemState;
+import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
 import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
 import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
 
 /**
  * Simple example showing how to add the functionality for freezing regions to a
@@ -152,15 +159,24 @@
         natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
         natTable.addConfiguration(new DefaultFreezeGridBindings());
 
-        // add the corner menu configuration for adding the view management
-        // action
+        // add the menu configuration
+        IMenuItemState freezeActiveState = new IMenuItemState() {
+
+            @Override
+            public boolean isActive(NatEventData natEventData) {
+                return freezeLayer.isFrozen();
+            }
+        };
         natTable.addConfiguration(new AbstractHeaderMenuConfiguration(natTable) {
             @Override
             protected PopupMenuBuilder createColumnHeaderMenu(NatTable natTable) {
                 return super.createColumnHeaderMenu(natTable)
                         .withHideColumnMenuItem()
                         .withShowAllColumnsMenuItem()
-                        .withColumnChooserMenuItem();
+                        .withColumnChooserMenuItem()
+                        .withFreezeColumnMenuItem()
+                        .withUnfreezeMenuItem()
+                        .withVisibleState(PopupMenuBuilder.UNFREEZE_MENU_ITEM_ID, freezeActiveState);
             }
 
             @Override
@@ -169,7 +185,34 @@
                         .withShowAllColumnsMenuItem()
                         .withStateManagerMenuItemProvider();
             }
+
+            @Override
+            protected PopupMenuBuilder createRowHeaderMenu(NatTable natTable) {
+                return super.createRowHeaderMenu(natTable)
+                        .withFreezeRowMenuItem()
+                        .withUnfreezeMenuItem()
+                        .withVisibleState(PopupMenuBuilder.UNFREEZE_MENU_ITEM_ID, freezeActiveState);
+            }
         });
+
+        natTable.addConfiguration(new AbstractUiBindingConfiguration() {
+
+            private final Menu bodyMenu = new PopupMenuBuilder(natTable)
+                    .withInspectLabelsMenuItem()
+                    .withFreezePositionMenuItem(true)
+                    .withUnfreezeMenuItem()
+                    .withVisibleState(PopupMenuBuilder.UNFREEZE_MENU_ITEM_ID, freezeActiveState)
+                    .build();
+
+            @Override
+            public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+                uiBindingRegistry.registerMouseDownBinding(
+                        new MouseEventMatcher(SWT.NONE, null, 3),
+                        new PopupMenuAction(this.bodyMenu));
+            }
+
+        });
+
         natTable.configure();
 
         panel.setLayout(new GridLayout());