Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to know if cell was changed in tableviewer

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to know if cell was changed in tableviewer

    I created tableviewer ( jface ).

    All the columns are editable ( using EditingSupport )

    I want to know when cell is changed and then

    to raise a flag in other column. meaning that you start to write any data in the cell

    I know that I need to create event of key changed listener to the cells. ( or there is different way )

    How I can have access to the cell ? where do I need to add the event

    public class MyGridViewer extends TableViewer {
    public MyGridViewer (Composite parent) {
    super(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);

    final Table table = this.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    this.setContentProvider(new MyModelProvider());

    @Override
    protected void inputChanged(Object input, Object oldInput) {

    removeColumn();



    tableCol = new TableViewerColumn(this, SWT.NONE);
    column = tableCol.getColumn();
    column.setText(dataColumnHeader.getName());
    column.setWidth(100);
    column.setResizable(true);
    column.setMoveable(true);
    tableCol.setLabelProvider(new ColumnLabelProvider() {
    @Override
    public String getText(Object element) {
    DataRow r = (DataRow) element;
    DataCell c = r.getDataCellByName(dataColumnHeader.getName());
    if (c != null && c.getValue() != null) {
    return c.getValue().toString();
    }
    return null;
    }
    });


    editingSupport = new StringCellEditingSupport(this, dataColumnHeader);
    tableCol.setEditingSupport(editingSupport);
    super.inputChanged(input, oldInput);
    }


  2. #2
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get the right value in tableviewer?

    I created tableviewer ( jface ).

    All the columns are editable ( using EditingSupport )

    I want to save the changes in the table.

    I Added a button of save.

    The issue that I tried change the value in the cell ( the focus is still on the cell ) I press save and I want to read the value that changed.The issue that I always see the old value and not the new value.

    If I changed the focus of the cell then it is working.

    Do I need to add event for the editing in the cell ?

    The button is above the table

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,469
    My Mood
    Mellow
    Thanks
    151
    Thanked 609 Times in 596 Posts

    Default Re: how to know if cell was changed in tableviewer

    Threads merged.

    Welcome to the forum! Please don't post duplicate threads/topics. It's confusing and doesn't increase either the likelihood of getting help or the quality of help you'll get.

    Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers, including a few "house rules" that you'd try to follow when visiting someplace new.

Similar Threads

  1. JTable with JButton in a cell
    By kpat in forum AWT / Java Swing
    Replies: 0
    Last Post: April 9th, 2012, 12:17 PM
  2. Table cell renderer
    By dibyayan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 17th, 2011, 07:34 AM
  3. My path is changed...
    By Oryan Dallal in forum Member Introductions
    Replies: 1
    Last Post: July 24th, 2011, 07:16 AM
  4. [SOLVED] find first empty cell?
    By prettynew in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 15th, 2011, 11:52 AM
  5. What must be changed in the following code
    By kulk_dm in forum Member Introductions
    Replies: 2
    Last Post: February 3rd, 2011, 01:34 AM