Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Row index concept(Row index concept)
Row index concept [message #774242] Tue, 03 January 2012 15:20 Go to next message
jlmueller5 is currently offline jlmueller5Friend
Messages: 8
Registered: November 2011
Junior Member

Hello All,

I am working in Eclipse RCP, Windows7 platform.

I am getting following issues :

With mouse click the column editor (which is TextCellEditor) of an empty Table should be activated. Till now i am able to know in which column the mouse is clicked but i am not
able to get the row index since the table is empty.
 
Is it possible to do that ? and if yes, any hints about how it should be done?

Thanks in anticipation.

Best Regards,
Julia
Re: Row index concept [message #774249 is a reply to message #774242] Tue, 03 January 2012 15:32 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
So you would create all rows until "row" the user clicked? You can
calculate the row using the rowHeight provided by the Table-Control but
I'm not sure I got you right.

Tom

Am 03.01.12 16:20, schrieb jlmueller5:
>
> Hello All,
>
> I am working in Eclipse RCP, Windows7 platform.
>
> I am getting following issues :
>
> With mouse click the column editor (which is TextCellEditor) of an empty
> Table should be activated. Till now i am able to know in which column
> the mouse is clicked but i am not
> able to get the row index since the table is empty.
>
> Is it possible to do that ? and if yes, any hints about how it should be
> done?
> Thanks in anticipation.
>
> Best Regards,
> Julia
Re: Row index concept [message #774610 is a reply to message #774249] Wed, 04 January 2012 09:28 Go to previous messageGo to next message
jlmueller5 is currently offline jlmueller5Friend
Messages: 8
Registered: November 2011
Junior Member

Hi Tom,

Many thanks for your reply.

I will explain my problem once again.

I am working to add a few functionalities in oneTable, in this Table, I have added cell editors(TextCellEditor) .
When the rows of the table contains object and if I click on any cell of that rows then the Editors are working fine.

But now My need is if I click on any empty cell of the rows, i.e. the cell which does not contain any objects, then also the cell Editors should be activated. And i should be able to edit it. How should I proceed to add this functinality ?"

If I browse the table with TAB and Arrows keys , this is working. I implemented this functionality in first phase and now in second phase i will have to do with mouse click.

I think if somehow i can find Row Index then this can be done. Whats your thought ?
Please let me know if you have understood my problem ?

Any hint will be highly appreciated.

Best Regards,
Julia
Re: Row index concept [message #774656 is a reply to message #774610] Wed, 04 January 2012 10:51 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
Hi,

I still don't get that if there's no row-object how did you manage to go
there with TAB/Arrow-Keys, if there's no row-object there's no TableItem
so you can't navigate to it.

I'm a little bit lost because I'm not sure what you are doing because
you are once talking about cells, then rows, ... .

I think it is best you create a small self-contained snippet which we
can run locally and describe exactly what one has to expect in which
situation. A good starting point of such a snippet is the collection in
http://wiki.eclipse.org/JFaceSnippets.

As outline before you can calculate the row-index from the event.x/y and:
a) Using the TableItem#getBounds(), TableItem#getBounds(int)
b) Using the RowHeight provided by the Table-Control itself and
TableColumn#getWidth().

Tom

Am 04.01.12 10:28, schrieb jlmueller5:
>
> Hi Tom,
>
> Many thanks for your reply.
>
> I will explain my problem once again.
>
> I am working to add a few functionalities in oneTable, in this Table, I
> have added cell editors(TextCellEditor) .
> When the rows of the table contains object and if I click on any cell of
> that rows then the Editors are working fine.
> But now My need is if I click on any empty cell of the rows, i.e. the
> cell which does not contain any objects, then also the cell Editors
> should be activated. And i should be able to edit it. How should I
> proceed to add this functinality ?"
>
> If I browse the table with TAB and Arrows keys , this is working. I
> implemented this functionality in first phase and now in second phase i
> will have to do with mouse click.
>
> I think if somehow i can find Row Index then this can be done. Whats
> your thought ?
> Please let me know if you have understood my problem ?
>
> Any hint will be highly appreciated.
>
> Best Regards,
> Julia
Re: Row index concept [message #774687 is a reply to message #774656] Wed, 04 January 2012 12:06 Go to previous messageGo to next message
jlmueller5 is currently offline jlmueller5Friend
Messages: 8
Registered: November 2011
Junior Member
Hi Tom,

Thanking you once again for your detailed reply. I will check what you suggested.
In between , i would like describe my task once again :

When the rows of the table contains object then only I am able to traverse its cells with TAB/Arrow-Keys and also can edit them.
 
My task is, "if  a row does not contain objects then also if I click on its cells, then the corresponding cell Editor should be activated."
 
With this code I am able to get in which column I clicked(i.e 1st column or 2nd column etc) but I am not able to get the corresponding Row.
Or is there  any other way to do that?
 
viewer.getTable().addMouseListener(new MouseAdapter() {
 
                  public void mouseDown(MouseEvent e) {
                        int x = 0;
                        int activeColumn = -1;
                        // TableItem item = new TableItem(table, SWT.NONE);
 
                        for (int i = 0; i < viewer.getTable().getColumnCount(); i++) {
                             x += viewer.getTable().getColumn(i).getWidth();
                             if (e.x <= x) {
                                   activeColumn = i;
                                   break;
                             }
                        }
                        CellEditor[] editor = viewer.getCellEditors();
                        switch (activeColumn) {
                        case 1:
                        case 2:
                        case 3:
                        case 4:
 
                             // item.setText(activeColumn, "column");
                             editor[activeColumn].activate();
                 
                        }
                  }
            });
 
 Please let me hear from you.

Regards,
Julia
Re: Row index concept [message #774704 is a reply to message #774687] Wed, 04 January 2012 12:31 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
Hi,

Ok we are approaching it slowly. You can not activate a celleditor
unless you have created Row-Objects (wha are represented as
TableItem-Instances in the SWT) for it.

Beside that you CellEditor activation has to be done using the viewer
API by calling editElement(Object,int).

Given all those facts the only thing that makes sense is that if say the
table contains 5 rows and the user clicks in the 6th that you create a
row object, call viewer.add() and then viewer.editElement(Object,int).

You code could like this then (totally untested braindump):

viewer.getTable().addMouseListener(new MouseAdapter {
public void mouseDown(MouseEvent e) {
int count = viewer.getTable().getItemCount();
if( count > 0 ) {
TableItem last = viewer.getTable().getItem(count-1);
Rectangle rect = last.getBounds();
if( rect.y + rect.height < e.y ) {
createRowAndActivate(e);
}
} else {
createRowAndActivate(e);
}

}

void createRowAndActivate(MouseEvent e) {
MyRow m = new MyRow();
viewer.add(m);
viewer.editElement(m,getColumnIndex(e));
}

int getColumnIndex(MouseEvent e) {
for (int i = 0; i < viewer.getTable().getColumnCount(); i++)
{
x += viewer.getTable().getColumn(i).getWidth();

if (e.x <= x) {
rerturn i;
}
}
return 0;
}
}

Tom

Am 04.01.12 13:06, schrieb jlmueller5:
> Hi Tom,
>
> Thanking you once again for your detailed reply. I will check what you
> suggested.
> In between , i would like describe my task once again :
>
> When the rows of the table contains object then only I am able to
> traverse its cells with TAB/Arrow-Keys and also can edit them.
>
> My task is, "if a row does not contain objects then also if I click on
> its cells, then the corresponding cell Editor should be activated."
>
> With this code I am able to get in which column I clicked(i.e 1st column
> or 2nd column etc) but I am not able to get the corresponding Row.
> Or is there any other way to do that?
>
> viewer.getTable().addMouseListener(new MouseAdapter() {
>
> public void mouseDown(MouseEvent e) {
> int x = 0;
> int activeColumn = -1;
> // TableItem item = new TableItem(table, SWT.NONE);
>
> for (int i = 0; i <
> viewer.getTable().getColumnCount(); i++) {
> x +=
> viewer.getTable().getColumn(i).getWidth();
> if (e.x <= x) {
> activeColumn = i;
> break;
> }
> }
> CellEditor[] editor = viewer.getCellEditors();
> switch (activeColumn) {
> case 1:
> case 2:
> case 3:
> case 4:
>
> // item.setText(activeColumn, "column");
> editor[activeColumn].activate();
>
> }
> }
> });
>
> Please let me hear from you.
>
> Regards,
> Julia
Re: Row index concept [message #776417 is a reply to message #774704] Sun, 08 January 2012 10:27 Go to previous messageGo to next message
jlmueller5 is currently offline jlmueller5Friend
Messages: 8
Registered: November 2011
Junior Member

Hi Tom,

Many thanks for your time and reply. Your post was very helpful.
I implemented this functionality by filling objects with null values. So may be its not a wonderful idea but requrement was full filled with everybody's knowledge. As this can not be done in anyother way.

Thanking you once again.

Best Regards,
Julia
Re: Row index concept [message #776431 is a reply to message #776417] Sun, 08 January 2012 11:17 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
Hi,

null is NOT a good idea in viewers you should create NullObject.

Tom

Am 08.01.12 11:27, schrieb jlmueller5:
>
> Hi Tom,
>
> Many thanks for your time and reply. Your post was very helpful.
> I implemented this functionality by filling objects with null values. So
> may be its not a wonderful idea but requrement was full filled with
> everybody's knowledge. As this can not be done in anyother way.
>
> Thanking you once again.
>
> Best Regards,
> Julia
Re: Row index concept [message #777642 is a reply to message #776431] Tue, 10 January 2012 21:17 Go to previous message
jlmueller5 is currently offline jlmueller5Friend
Messages: 8
Registered: November 2011
Junior Member
Hi Tom,

It was typo, i have also used NullObject.

Thanks,
Julia
Previous Topic:SSL through RCP application
Next Topic:Install plugins dynamically
Goto Forum:
  


Current Time: Wed Nov 26 08:05:41 GMT 2014

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

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