Skip to main content



      Home
Home » Eclipse Projects » NatTable » Row header layer not converting position to index
Row header layer not converting position to index [message #1775723] Fri, 03 November 2017 21:57 Go to next message
Eclipse UserFriend
Hello, I have a grid layer with a custom row header data provider that allows for editing of the row headers. However, if the table is scrolled down so that some of the rows aren't visible, upon editing a row header, an earlier row header is actually updated. With some debugging I think it's because the row header data provider is being supplied with the row position instead of the row index, and doesn't do a conversion.

I think I'm doing something wrong. Here's my default grid layer construction.
    DefaultGridLayer gridLayer = new DefaultGridLayer(bodyDataProvider,
        new DefaultColumnHeaderDataProvider(columnNames, columnToLabelMap),
        new RequirementsRowHeaderDataProvider(bodyDataProvider, requirementsList), false);


and here's my row header data provider.

public class RequirementsRowHeaderDataProvider implements IDataProvider {
  
  /**
   * The body data provider of the NatTable.
   */
  private final IDataProvider bodyDataProvider;
  
  /**
   * The list of elements that the row header will represent.
   */
  private EList<? extends NamedElement> elementList;
  
  /**
   * Data provider for the row labels of a NatTable.
   * @param bodyDataProvider
   *         The bodyDataProvider for the NatTableCreator.
   * @param elementList
   *         The list of elements that will be displayed in the NatTable.
   */
  public RequirementsRowHeaderDataProvider(
      IDataProvider bodyDataProvider, EList<? extends NamedElement> elementList) {
    this.bodyDataProvider = bodyDataProvider;
    this.elementList = elementList;
  }
  
  @Override
  public int getColumnCount() {
    return 1;
  }
  
  @Override
  public int getRowCount() {
    return this.bodyDataProvider.getRowCount();
  }

  @Override
  public Object getDataValue(int columnIndex, int rowIndex) {
    return getRowHeaderLabel(rowIndex);
  }
  
  /**
   * Gets the label for a given row header cell.
   * @param rowIndex
   *            The index of the row of the row header cell requested.
   * @return
   *             The name of the requirement associated with the given row.
   */
  public String getRowHeaderLabel(int rowIndex) {
    return elementList.get(rowIndex).getName();
  }

  @Override
  public void setDataValue(int columnIndex, int rowIndex, Object newValue) {
    //Gets the element associated with the given row.
    NamedElement element = elementList.get(rowIndex);
    
    //If no changes were made, simply return
    if (element.getName() != null && element.getName().equals(newValue)) {
      return;
    }
    
    OperationsUtil.performOperation(new EditName(element, newValue));
  }
  
}


Any idea what I'm missing/doing wrong to get the row header editing to work?

Thanks.

[Updated on: Fri, 03 November 2017 23:48] by Moderator

Re: Row header layer not converting position to index [message #1775766 is a reply to message #1775723] Mon, 06 November 2017 02:32 Go to previous messageGo to next message
Eclipse UserFriend
I think you are right. This is currently an issue in the DimensionalDependentUniqueIndexLayer IIRC. There only the row/column positions are retrieved via the dependent layer. But the index-position-transformation is done via underlying layer. This is incorrect for the RowHeaderLayer but necessary for the FreezeLayer for example.

Please create a ticket and once I have time I will have a look at this. Until then you need to perform the necessary transformation via LayerUtil yourself.
Re: Row header layer not converting position to index [message #1775809 is a reply to message #1775766] Mon, 06 November 2017 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Ok will do. What would the source/target layers be in this case?

Thanks.
Re: Row header layer not converting position to index [message #1775810 is a reply to message #1775809] Mon, 06 November 2017 12:44 Go to previous messageGo to next message
Eclipse UserFriend
Bug ticket link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=526905
Re: Row header layer not converting position to index [message #1775818 is a reply to message #1775809] Mon, 06 November 2017 13:59 Go to previous messageGo to next message
Eclipse UserFriend
To rephrase my earlier question, how would I get access to the source/target layers in the row header data provider if the grid layer has not been made yet when the row header data provider is created, as it is created in the construction of the grid layer?
Re: Row header layer not converting position to index [message #1775825 is a reply to message #1775818] Mon, 06 November 2017 15:23 Go to previous message
Eclipse UserFriend
Nevermind I figured it out. This post was helpful.

https://www.eclipse.org/forums/index.php/t/596168/
Previous Topic:Some strange behavior with multiselect checkbox combobox dropdown
Next Topic:Losing focus on DateCellEditor
Goto Forum:
  


Current Time: Sun Jul 13 08:09:35 EDT 2025

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

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

Back to the top