Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Multi edit in Menu options (Multi edit in Menu options )
Multi edit in Menu options [message #1565830] Thu, 15 January 2015 14:09 Go to next message
ambuj bhargava is currently offline ambuj bhargavaFriend
Messages: 19
Registered: July 2014
Junior Member
Hi

I have placed the Multi Edit on Menu options that we get when we right click on the column of the nat table.

It works correctly, my question is:

How shall I grey out the menu option for Multi edit on the basis of whether the cells are editable or not.

I have gone through the code of Nat Table and there is an iterator that calculates the cell Size

for (Iterator<ILayerCell> iterator = editCells.iterator(); iterator.hasNext(); ) {
ILayerCell layerCell = iterator.next();
LabelStack labelStack = layerCell.getConfigLabels();
IEditableRule editableRule = configRegistry.getConfigAttribute(
EditConfigAttributes.CELL_EDITABLE_RULE,
DisplayMode.EDIT, labelStack.getLabels());
if (!editableRule.isEditable(layerCell, configRegistry)) {
iterator.remove();
}
}



But the problem is how can I invoke this before pressing F2 or how can I get to know that the Multi Edit will not be invoked so that on right click I can grey out the Multi Edit option.


Regards
Ambuj
Re: Multi edit in Menu options [message #1565899 is a reply to message #1565830] Thu, 15 January 2015 14:56 Go to previous messageGo to next message
Arye Shemesh is currently offline Arye ShemeshFriend
Messages: 37
Registered: November 2012
Member
Hi Ambuj,

If you use NatTable IMenuItemProvider to add the multi-edit menu item to the menu, you can use the following code:


new IMenuItemProvider() {

   @Override
   public void addMenuItem(NatTable natTable, Menu popupMenu) {
		
      final MenuItem myMenuItem = new MenuItem(popupMenu, SWT.PUSH);
      myMenuItem.setText("Some Text");
      myMenuItem.addSelectionListener(new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent event){

            //Do your stuff

         }
      });
								
      popupMenu.addMenuListener(new MenuAdapter() {
         @Override
         public void menuShown(MenuEvent e) {

            myMenuItem.setEnabled(condition);
         }
      });
}


Hope it Helps
Re: Multi edit in Menu options [message #1565950 is a reply to message #1565899] Thu, 15 January 2015 15:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
With the current version of NatTable the solution above is a way to solve your requirement.

With NatTable 1.2.0 you will be able to register an IMenuItemState to grey out or hide menu items.
Re: Multi edit in Menu options [message #1567136 is a reply to message #1565899] Fri, 16 January 2015 07:15 Go to previous message
ambuj bhargava is currently offline ambuj bhargavaFriend
Messages: 19
Registered: July 2014
Junior Member
Thanks Sheemesh and Dirk for providing the solution

[Updated on: Fri, 16 January 2015 07:28]

Report message to a moderator

Previous Topic:Editable NatTable for GlazedLists?
Next Topic:How to get live updates while maintaining a sorted tree
Goto Forum:
  


Current Time: Wed Apr 24 13:30:28 GMT 2024

Powered by FUDForum. Page generated in 0.03584 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top