Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » dynamic cell editors in one cell in NatTable(dynamic cell editors in one cell in NatTable)
dynamic cell editors in one cell in NatTable [message #1403867] Mon, 28 July 2014 10:41 Go to next message
Alex Dong is currently offline Alex DongFriend
Messages: 5
Registered: July 2014
Junior Member
Hi,

i have read some documentions and tried some edit examples for natTable.

I registed the editors and painters for every column of my table,all work well after

i implements my columnPropertyAccessor.

but now i want to custom two cell editors in one cell.

for example,there are two columns in my table,one is "type" ,

and another is "value".by default the type is String and the value of the cell

is a TextCellEditor.but there has many types,if i select "File" ,i prefer the value

cell has a button appeared. after i click the button can open a

FileDialog.the code just like this:

 if (type != null) {
            if (isFile(type)) {
                cellEditor = createFileCellEditor(table, defalutDataValue);
            } else if (isDate(type)) {
                cellEditor = createDateCellEditor(table, para);
                ((CustomCellEditor) cellEditor).getDefaultLabel().setEditable(false);
            } else if (isDirectory(type)) {
                cellEditor = createDirectoryCellEditor(table, defalutDataValue);
            } else if (isList(type)) {
                cellEditor = createListCellEditor(table, para);
                defalutDataValue = para.getDisplayValue();
            }
        }

        if (cellEditor == null) {
            cellEditor = createDefaultTextCellEditor(table);
 }


Is there any way to achive the target by NatTable?

Thanks a lot for the help.
Re: dynamic cell editors in one cell in NatTable [message #1403964 is a reply to message #1403867] Mon, 28 July 2014 18:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2525
Registered: July 2012
Senior Member
yes it is possible. you need to implement a mechanism that sets a label to the value cell corresponding to the value in your type column.

you should also notice that it is possible to implement dialog editors in NatTable like a FileDialogCellEditor that opens the file dialog on opening the editor. You can see this in the examples.
Re: dynamic cell editors in one cell in NatTable [message #1403993 is a reply to message #1403964] Tue, 29 July 2014 03:16 Go to previous messageGo to next message
Alex Dong is currently offline Alex DongFriend
Messages: 5
Registered: July 2014
Junior Member
Hi,Dirk

Thanks very much for your reply.

Quote:
implement a mechanism that sets a label to the value cell corresponding to the value in your type column.


for the "mechaism" here i am not very understand.Is there already exist a mechanism in natTable to support this such as a configuration or mouseMatcher to corresponding two columns?

And i get another question is : i am not sure how to wrapped a button into a exist TextCellEditor cell since i already registed the while "value" column as TextCellEditor.

Do i need to override the function paintCell() of the TextPainter to implement this or other ways?

Regards,
Alex
Re: dynamic cell editors in one cell in NatTable [message #1404005 is a reply to message #1403993] Tue, 29 July 2014 06:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2525
Registered: July 2012
Senior Member
As I said before, you need to use the label mechanism. As your the content of your type column should be part of your model, you should be able to inspect it within your label accumulator by operating on (columnPosition-1) in case you registered it on the DataLayer.

We have a ButtonCellPainter, maybe that helps. But I also said before that we have a FileDialogCellEditor that directly opens the FileDialog if you click in the cell to start editing. IMHO it is not necessary to render a special button for it. But rendering is done via painters, so check that if you really need a button.
As I also said before, check the examples. In the EditorExample there is a file dialog registered for the last column.

Quote:
Do i need to override the function paintCell() of the TextPainter to implement this or other ways?


NatTable is a quite open framework, so you can do whatever you want. But instead of overriding working functionality, I would suggest to implement something special or check if NatTable already has something working.
Re: dynamic cell editors in one cell in NatTable [message #1404053 is a reply to message #1404005] Tue, 29 July 2014 11:02 Go to previous messageGo to next message
Alex Dong is currently offline Alex DongFriend
Messages: 5
Registered: July 2014
Junior Member
Hi,Dirk

Thanks for the informations.Yes,use the label mechanism and my data model,i can get the value column by the value of type column now after i add the UiBindingRegistry to caculate.

For the button here,maybe you are right,it is not necessary to add this.But after i checked the source code of NatTable, i found there is a NatCombo.class which also customized the cell

contains two controls.If later i still need the button,maybe i can do like this to custom a CellEditor which contains the text and button,right?

Regards,
Alex
Re: dynamic cell editors in one cell in NatTable [message #1404054 is a reply to message #1404053] Tue, 29 July 2014 11:16 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2525
Registered: July 2012
Senior Member
Quote:
If later i still need the button,maybe i can do like this to custom a CellEditor which contains the text and button,right?


You could do this, although that means to introduce a new combination that has an editor and a button that opens a dialog.
Previous Topic:Dynamic cell editors for one cell in NatTable
Next Topic:Disposing of group by table with glazed lists
Goto Forum:
  


Current Time: Tue Nov 21 04:38:30 GMT 2017

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

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