Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to make cell editable programmatically
how to make cell editable programmatically [message #633301] Sat, 16 October 2010 06:54 Go to next message
MohanVaradharajan Mising name is currently offline MohanVaradharajan Mising nameFriend
Messages: 8
Registered: October 2010
Junior Member
hi all,

i have a table with 3 columns and three buttons edit, apply, cancel.

initially all three columns are not editable.

when i press edit button, i want to allow user to edit only 2nd, 3rd columns.

how it is possible to make cell editable/uneditable programmatically ?
Re: how to make cell editable programmatically [message #633307 is a reply to message #633301] Sat, 16 October 2010 07:56 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

Use cell editors and modifiers.This might help you.
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Demonstrat esCellEditors.htm


To disable editing on property you need to do something like this in the above example..


  public boolean canModify(Object element, String property) {
      if (PersonEditor.NAME.equals(property)) {
             return false;
      }
      return true;
  }
 



Re: how to make cell editable programmatically [message #633568 is a reply to message #633307] Mon, 18 October 2010 12:38 Go to previous messageGo to next message
MohanVaradharajan Mising name is currently offline MohanVaradharajan Mising nameFriend
Messages: 8
Registered: October 2010
Junior Member
hi prasad,

thanks. i have gone thru those links. but my issue is,

based on user button selection, i need to enable / disable the cells. [Edit button, Apply button]

for example, when user press edit button, table cells should be editable, when user press apply button, the table cells become uneditable.
Re: how to make cell editable programmatically [message #633597 is a reply to message #633301] Mon, 18 October 2010 14:04 Go to previous messageGo to next message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

If i got your question right i guess that should be simple just have a variable say 'editable' and update the variable in the buttons selection listener. Use the variable in can modify method and return false if the 'editable' field is false.





Re: how to make cell editable programmatically [message #633771 is a reply to message #633568] Tue, 19 October 2010 11:28 Go to previous message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
On 18.10.2010 14:38, MohanVaradharajan wrote:
> hi prasad,
>
> thanks. i have gone thru those links. but my issue is,
>
> based on user button selection, i need to enable / disable the cells.
> [Edit button, Apply button]
>
> for example, when user press edit button, table cells should be
> editable, when user press apply button, the table cells become
> uneditable.

As Prasad already explained you need to implement the canModify method
of your ICellModifier implementation. The snippet

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet009CellEditors.java?view=markup

shows how to use this Eclipse 3.2 Viewer editing API.

If you are using the new Eclipse 3.3. Viewer API you probably will use
EditingSupport implementations. In this case you have to implement its
canEdit method as shown in

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.s nippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippet s/viewers/Snippet024TableViewerExploreNewAPI.java?view=marku p

In principle both approaches are equivalent, but I would use the new
API whenever possible, because it is much more flexible.

It is *your* decision how to bind the button-click event to the return
value of either of these methods. You could use jface databinding or
you could simple do that manually by listening to the selection change
event of the button, changing a corresponding state variable that is
read in the method. It would also be possible to directly read the
button states for radio buttons, check buttons, or toggle buttons.

HTH & Greetings from Bremen,

Daniel Krügler
Previous Topic:Product export: org.eclipse.emf.edit.ui not found
Next Topic:Errors about invalid charsets
Goto Forum:
  


Current Time: Wed Apr 24 21:58:58 GMT 2024

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

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

Back to the top