Skip to main content



      Home
Home » Eclipse Projects » NatTable » Cell Combo,Checkbox editor
Cell Combo,Checkbox editor [message #1702011] Fri, 17 July 2015 08:35 Go to next message
Eclipse UserFriend
Hi,

How can I define different widget for different cells. For example
column 1 - Row 1 Text
column 1 - Row 2 Combobox
column 1 - Row 3 Checkbox

What is the solution for this. Is there any example.

Thankyou
Re: Cell Combo,Checkbox editor [message #1702012 is a reply to message #1702011] Fri, 17 July 2015 08:45 Go to previous messageGo to next message
Eclipse UserFriend
Register different labels for different cells. The same mechanism as always. You just need a custom label provider that adds labels on special conditions per cell instead of the column label provider.
Re: Cell Combo,Checkbox editor [message #1702108 is a reply to message #1702012] Sun, 19 July 2015 14:50 Go to previous messageGo to next message
Eclipse UserFriend
Thankyou for your help. I can implement the custom label provider. And it is ok. I can be defined below like.

column 1 - Row 1 Text
column 1 - Row 2 Integer

When I sorted for column 0, Editors that defined for column 1 not sorted. Text editor is still on Row1 and Integer Editor is still on Row2. What is the problem. How can I fixed it.

Sorted code is below.

Thank you.

return new SortableTreeComparator<EditTableBaseRowData>(
                    GlazedLists.beanPropertyComparator(EditTableBaseRowData.class, "name"),
                    this.sortModel);
Re: Cell Combo,Checkbox editor [message #1702109 is a reply to message #1702108] Sun, 19 July 2015 15:40 Go to previous messageGo to next message
Eclipse UserFriend
The problem is not the sorting. The problem is your custom label provider that seems to be not content related. Are you applying labels via column / row positions?
Re: Cell Combo,Checkbox editor [message #1702110 is a reply to message #1702109] Sun, 19 July 2015 16:32 Go to previous messageGo to next message
Eclipse UserFriend
Yes. I realized it after sent mail. But I cannot find a solution. My code is below.
package view.nattablebase.editable;

import java.io.Serializable;
import java.util.List;

import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider;
import org.eclipse.nebula.widgets.nattable.layer.ILayer;
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
import org.eclipse.nebula.widgets.nattable.layer.cell.AbstractOverrider;

public class CellIndexOverrideLabelAccumulator<T> extends AbstractOverrider {
    private ILayer dataProvider;

    public CellIndexOverrideLabelAccumulator(ILayer dataProvider) {
        this.dataProvider = dataProvider;
    }

    @Override
    public void accumulateConfigLabels(LabelStack configLabels,
            int columnPosition, int rowPosition) {
        List<String> cellLabels = getConfigLabels(
               rowPosition,
                columnPosition);
        if (cellLabels == null) {
            return;
        }
        for (String configLabel : cellLabels) {
            configLabels.addLabel(configLabel);
        }
    }

    protected List<String> getConfigLabels(Integer row, int col) {
        CellIndexOverrideKey key = new CellIndexOverrideKey(row, col);
        return getOverrides(key);
    }

   
    public void registerOverride(Integer row, int col, String configLabel) {
        registerOverrides(new CellIndexOverrideKey(row, col), configLabel);
    }
}


class CellIndexOverrideKey implements Serializable {
    private static final long serialVersionUID = 1L;
    Integer cellIndex;
    int col;

    CellIndexOverrideKey(Integer cellIndex, int col) {
        this.cellIndex = cellIndex;
        this.col = col;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        CellIndexOverrideKey other = (CellIndexOverrideKey) obj;
        if (this.cellIndex == null) {
            if (other.cellIndex != null)
                return false;
        } else if (!this.cellIndex.equals(other.cellIndex))
            return false;
        if (this.col != other.col)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((this.cellIndex == null) ? 0 : this.cellIndex.hashCode());
        result = prime * result + this.col;
        return result;
    }

    public String getComposite() {
        return this.cellIndex + String.valueOf(this.col);
    }
}


Re: Cell Combo,Checkbox editor [message #1702119 is a reply to message #1702110] Mon, 20 July 2015 02:33 Go to previous message
Eclipse UserFriend
You need to register you label for the editor for the content, not the position. I would implement the interface IConfigLabelAccumulator directly instead of extending AbstractOverrider.

http://www.vogella.com/tutorials/NatTable/article.html#architecture_labels
Previous Topic:NatTableBorderOverlayPainter border overdrawn by editor
Next Topic:How to make GroupBy and Summary layer work together
Goto Forum:
  


Current Time: Sun Jun 15 19:27:22 EDT 2025

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

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

Back to the top