Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » CheckBoxCellEditor issue when editing large amount of cells
CheckBoxCellEditor issue when editing large amount of cells [message #1694868] Fri, 08 May 2015 14:40 Go to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
Hi,
I have a big problem when using the CheckBoxCellEditor in a NatTable with a couple of thousand rows. The Nattable is used in an RCP application. This is what happens:

I have a column that uses the CheckBoxCellEditor for editing. When I select the column (with a large number of rows about 9000 in my case) and press space to change the boolean value, the application freezes the next time the Nattable is refreshed. I have tackled down the problem to the activateCell method of the editor.

 protected Control activateCell(Composite parent,
            Object originalCanonicalValue) {
        // if this editor was activated by clicking a letter or digit key, do
        // nothing
        if (originalCanonicalValue instanceof Character) {
            return null;
        }

        setCanonicalValue(originalCanonicalValue);

        this.checked = !this.checked;

        this.canvas = createEditorControl(parent);

        commit(MoveDirectionEnum.NONE, false);

        if (this.editMode == EditModeEnum.INLINE) {
            // Close editor so will react to subsequent clicks on the cell
            if (this.canvas != null && !this.canvas.isDisposed()) {
                this.canvas.getDisplay().asyncExec(new Runnable() {
                    @Override
                    public void run() {
                        close();
                    }
                });
            }
        }

        return this.canvas;
    }


This code is called number of rows time from the edit controller. Each time an editor is created. In our case the editor is represented by a Canvas. So after setting the value to 9000 cells we have 9000 Canvases as children of the Nattable. The next time the table gets painted, the org.eclipse.e4.ui.css.swt.engine.CSSSWTEngine of Eclipse applies it's styles to the NatTable and all it's children. I am not sure but this might happen 9000 times for each canvas that was created and is then disposed in the async excec of the code shown above. In any case the application is not usable for a very long time.

A solution is to create the editor only once and reuse it for consecutive calls to activate.

protected Control activateCell(Composite parent,
            Object originalCanonicalValue) {
        // if this editor was activated by clicking a letter or digit key, do
        // nothing
        if (originalCanonicalValue instanceof Character) {
            return null;
        }

        setCanonicalValue(originalCanonicalValue);

        this.checked = !this.checked;

        if (canvas == null || canvas.isDisposed()) {
        	this.canvas = createEditorControl(parent);
            if (this.editMode == EditModeEnum.INLINE) {
                // Close editor so will react to subsequent clicks on the cell
                if (this.canvas != null && !this.canvas.isDisposed()) {
                    this.canvas.getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            close();
                        }
                    });
                }
            }
        }

        commit(MoveDirectionEnum.NONE, false);


        return this.canvas;
    }


This works but the question is if there are any obvious drawbacks with this solution which I might be missing here.

Thanks in advance
Thorsten
Re: CheckBoxCellEditor issue when editing large amount of cells [message #1694886 is a reply to message #1694868] Fri, 08 May 2015 17:34 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I'm not sure, but it sounds similar to https://bugs.eclipse.org/bugs/show_bug.cgi?id=463121

Because of the async disposal there is a memory leak. The logic is to create and immediately dispose the canvas. This is not happening correctly.

Please update to 1.3.0 where this is fixed to see if the issue still occurs.
Previous Topic:Create TreeView In Nat Table
Next Topic:TextSearch in a SpanningDataLayer
Goto Forum:
  


Current Time: Fri Apr 26 15:24:43 GMT 2024

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

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

Back to the top