Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Big Bug of EditingSupport with RAP 1.5 Release(Impossible to edit the right cell when a TableViewer needs a vertical scrollbar)
Big Bug of EditingSupport with RAP 1.5 Release [message #896380] Wed, 18 July 2012 08:42 Go to next message
Francis Delsinnes is currently offline Francis Delsinnes
Messages: 49
Registered: November 2011
Member
With the last release of June 2012 (RAP 1.5 Release),
I've got the following problem:

Impossible to edit the right cell when a TableViewer needs a vertical scrollbar.
Warning: This problem happens when the scroll bar is lowered to the maximum!
In this case: a bad cell is edited...


To try it, you can create a new RAP project with a basic view
and replace the "View" class by the following code:


An example of a correct edition:

I try to edit the cell with a number #8
I've edited the cell (OK)


An example of an incorrect edition (with the same code of course):
I scroll at the max...
I try to edit the last cell (with the number #34)
First problem: Why this cell displays "Value_33" ?
I modify the text...
=> Bad Result: The focus is on the cell #34 but it is not the edited cell...


import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.TextCellEditor;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

import org.eclipse.ui.part.ViewPart;


/**
 * Test.
 *
 * @author Internal Tools Team
 */
public final class View
  extends ViewPart {

  /**
   * A simple record.
   *
   * @author Internal Tools Team
   */
  private static class Record {

    /** A string. */
    public String key;

    /** A string. */
    public String value;

  }

  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  @Override public void createPartControl(Composite parent) {

    final TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    final Table table = viewer.getTable();
    final TableViewerColumn keyColumnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableViewerColumn valueColumnViewer = new TableViewerColumn(viewer, SWT.NONE);
    final TableColumn keyColumn = keyColumnViewer.getColumn();
    final TableColumn valueColumn = valueColumnViewer.getColumn();

    // widgets
    keyColumn.setText("Key");
    keyColumn.setWidth(100);
    valueColumn.setText("Value");
    valueColumn.setWidth(120);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    // viewers (label provider, editing support, content provider, input)
    keyColumnViewer.setLabelProvider(createKeyLabelProvider());
    valueColumnViewer.setLabelProvider(createValueLabelProvider());
    valueColumnViewer.setEditingSupport(createValueEditingSupport(viewer));
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setInput(createFakeRecords(35));

    setViewer(viewer);

  }

  /*
   * (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
   */
  @Override public void setFocus() {

    final TableViewer viewer = getViewer();
    viewer.getControl()
          .setFocus();

  }

  /**
   * Creates fake records.
   *
   * @param  nb - a number of records
   * @return a records array
   */
  private static Record[] createFakeRecords(final int nb) {

    final Record[] records = new Record[nb > 0 ? nb
                                               : 10];

    for (int i = 0; i < nb; i++) {

      final Record record = new Record();
      record.key = "Key_" + i;
      record.value = "Value_" + i;
      records[i] = record;

    }

    return records;

  }

  /**
   * Creates the corresponding label provider.
   *
   * @return a label provider
   */
  private static ColumnLabelProvider createKeyLabelProvider() {

    return new ColumnLabelProvider() {

      /** A string id. */
      private static final long serialVersionUID = 1547222513947003304L;

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
       */
      @Override public String getText(Object element) {

        return ((Record)element).key;

      }

    };

  }

  /**
   * Creates the corresponding editing support.
   *
   * @param  columnViewer - a viewer
   * @return an editing support
   */
  private static EditingSupport createValueEditingSupport(final ColumnViewer columnViewer) {

    return new EditingSupport(columnViewer) {

      /** A string id. */
      private static final long serialVersionUID = 893208682725506423L;

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
       */
      @Override protected void setValue(Object element,
                                        Object value) {

        ((Record)element).value = value.toString();
        getViewer().refresh(element, true);

      }

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
       */
      @Override protected Object getValue(Object element) {

        return ((Record)element).value;

      }

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
       */
      @Override protected CellEditor getCellEditor(Object element) {

        return new TextCellEditor((Composite)getViewer().getControl());

      }

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
       */
      @Override protected boolean canEdit(Object element) {

        return element instanceof Record;

      }

    };

  }

  /**
   * Creates the corresponding label provider.
   *
   * @return a label provider
   */
  private static ColumnLabelProvider createValueLabelProvider() {

    return new ColumnLabelProvider() {

      /** A string id. */
      private static final long serialVersionUID = -611412295225558699L;

      /*
       * (non-Javadoc)
       * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
       */
      @Override public String getText(Object element) {

        return ((Record)element).value;

      }

    };

  }

  /**
   * Gets the viewer.
   *
   * @return a viewer
   */
  private TableViewer getViewer() {

    return viewer;

  }

  /**
   * Sets the viewer.
   *
   * @param viewer - a viewer
   */
  private void setViewer(TableViewer viewer) {

    this.viewer = viewer;

  }

  /** String id. */
  public static final String ID = "Rap15ReleaseTest.view";

  /** viewer. */
  private TableViewer viewer;

}

Re: Big Bug of EditingSupport with RAP 1.5 Release [message #896385 is a reply to message #896380] Wed, 18 July 2012 08:51 Go to previous messageGo to next message
Francis Delsinnes is currently offline Francis Delsinnes
Messages: 49
Registered: November 2011
Member
I try the same code with a previous version of RAP (like RAP 1.5.0 M2).
No problem (normal use)!?

Note:
My Current version of Java JDK is: jdk1.6_0_27 (32 bits)

I tested it with Eclipse Indigo (32 bits) + RAP Targets (1.5.0 M2 and 1.5 Release)
And
I tested it also with the current Eclipse Juno (32 bits) + Same Targets

[Updated on: Wed, 18 July 2012 08:53]

Report message to a moderator

Re: Big Bug of EditingSupport with RAP 1.5 Release [message #896398 is a reply to message #896385] Wed, 18 July 2012 09:35 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1816
Registered: July 2009
Senior Member
Hi Francis,
this is a known problem and it's already fixed in Git master. See:
384589: [CellEditor] Wrong row is edited when last row is visible
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384589
You could try the latest nightly build [1]:
[1] http://www.eclipse.org/rap/downloads/
Best,
Ivan

On 7/18/2012 11:51 AM, Francis Delsinnes wrote:
> I try the same code with a previous version of RAP (like RAP 1.5.0 M2).
> Not problem (normal use)!?
>
> Note:
> My Current version of Java JDK is: jdk1.6_0_27 (32 bits)
>
> I tested it with Eclipse Indigo (32 bits) + RAP Targets (1.5.0 M2 and
> 1.5 Release)
> And
> I tested it also with the current Eclipse Juno (32 bits) + Same Targets

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Big Bug of EditingSupport with RAP 1.5 Release [message #896400 is a reply to message #896398] Wed, 18 July 2012 09:50 Go to previous message
Francis Delsinnes is currently offline Francis Delsinnes
Messages: 49
Registered: November 2011
Member
Thanks.
I saw the first bug reported into my mailbox.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=384589 (First Report)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=385387 (My Report)
Previous Topic:Nebula Grid in RWT Standalone?
Next Topic:Trouble with RAP & Spring
Goto Forum:
  


Current Time: Fri Sep 19 20:07:48 GMT 2014

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

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