Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 242231 - [Viewers] TableViewer#applyEditorValue() should be public
Summary: [Viewers] TableViewer#applyEditorValue() should be public
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 enhancement with 1 vote (vote)
Target Milestone: 4.5 M2   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-28 09:05 EDT by David Pérez CLA
Modified: 2014-09-16 03:21 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Pérez CLA 2008-07-28 09:05:15 EDT
As I have already commented on the forum:
http://www.eclipse.org/newsportal/article.php?id=76737&group=eclipse.platform#76737

When I press a button in a toolbar, I need to be able to take into account the possible edited new cell values in a TableViewer.

The right API for this is:
       TableViewer#applyEditorValue()
but it is protected, not public.

I have tried to find any other public API unsuccessfully.

The solutions I have found are:

1) Calling applyEditorValue() with reflection
2) Deriving TableViewr for making applyEditorValue() visible

public class MyTableViewer extends TableViewer {
    public TableViewer(Composite parent, int style) {
        super(parent, style);
    }

    @Override public void applyEditorValue() {
        super.applyEditorValue();
    }
}

Both of these solutions do work, but I don't like to use a back door for solving this.

The best solution for me would be to make this API public.
Comment 1 Thomas Schindl CLA 2008-08-04 04:44:46 EDT
because cancleEditor is also public I'd like to see this happen
Comment 2 David Pérez CLA 2008-08-05 05:04:34 EDT
Another need I have:

Access to save the current editor value, without deactivating the current cell, i.e., ColumnViewerEditor#saveEditorValue()

I have developed a database-oriented CRUD framework on top of JFace and SWT, specially on TableViewer, and these are nearly the only non-public methods I have needed.
Comment 3 Thomas Schindl CLA 2010-01-28 17:12:51 EST
multi change because of intenion of stepping back as platform-ui committer
Comment 4 Henno Vermeulen CLA 2013-01-18 04:39:51 EST
This has my vote! I run into the same problem in my "forms CRUD framework": it uses databinding to show validation errors and enable/disable the save command when the model changes taking into account these validation errors.

When the user runs the save command while a cell editor is active the value is not yet applied to the model and this may result in the current value not being saved. 

(But even worse in my case: some forms show a dialog before doing the actual save. The save handler does another check for validation errors, when the command executes the model is still in the old valid state. While the dialog is open the cell editor loses focus and commits it value to the model. At the time the user presses OK the server suddenly throws a validation exception that should have been already caught in the UI.)
Comment 5 Henno Vermeulen CLA 2013-01-18 05:12:44 EST
Can also cause problems with other actions such as closing an editor. It may think that it is not dirty and don't prompt for save. Such a problem was reported in bug 125827.
Comment 6 Stefan Winkler CLA 2014-03-31 16:40:09 EDT
I came across this rather old bug today because I need this as well, and since no one has objected that applyEditorValue() should not be public, I went ahead and created a changeset in Gerrit.

see https://git.eclipse.org/r/24230
Comment 7 Lars Vogel CLA 2014-04-01 12:00:57 EDT
(In reply to Stefan Winkler from comment #6)
> I came across this rather old bug today because I need this as well, and
> since no one has objected that applyEditorValue() should not be public, I
> went ahead and created a changeset in Gerrit.
> 
> see https://git.eclipse.org/r/24230

Thanks, for Luna we already have API freeze, I mark this one for early Mars. Please feel free to remind me after the Luna release.
Comment 8 Lars Vogel CLA 2014-08-18 11:19:53 EDT
Thanks Stefan for this contribution and sorry for the delay in the review from my side.
Comment 10 David Pérez CLA 2014-08-19 02:34:54 EDT
Thanks.  It is better late (6 years) that never.
Comment 11 Lars Vogel CLA 2014-09-16 03:21:25 EDT
Validated by running the corresponding tests.