Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Grid item resize
Grid item resize [message #19350] Mon, 04 December 2006 11:54 Go to next message
Eclipse UserFriend
Originally posted by: swetha.atc.tcs.co.in

Hi All,

I am facing two problems in Nebula Grid,

1. How can we set the height of the grid Item... I want to increase the
size of the grid item vertically..

I can able set the size of the grid Item in terms of Width...(i.e;
horizontally)..
I am displaying image in a cell, as the image is bigger, the image is
not completely visible in a Grid.

Please help in this regard.


2. Another requirement is based on the size of the grid(I perform
resizing of grid) and size of the image, it will automatically calculate
the number of grid columns...
Problem is suppose there are 2 columns in the grid.. and after
performing the resizing operation, the calculated number of cells is
5...these 5 columns were appended to the already existing 2 columns...

I want to set the number of columns to zero and then adding the newly
cal no of cols...

Please help me ...
Re: Grid item resize [message #19444 is a reply to message #19350] Mon, 04 December 2006 15:12 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Re 1.) The row height is determined by the height of the first cell of
the first row in the grid. If you put an image of the size you want the
row to be in the first row/first cell then you should get the size you
want. Otherwise, you could write a custom cell renderer and that can
determine the size (but thats not easy).

Re 2.) To remove a column use GridColumn#dispose. Surely though you
could do a delta between the number of current columns and the number
you need added.

Swetha wrote:
> Hi All,
>
> I am facing two problems in Nebula Grid,
>
> 1. How can we set the height of the grid Item... I want to increase the
> size of the grid item vertically..
>
> I can able set the size of the grid Item in terms of Width...(i.e;
> horizontally)..
> I am displaying image in a cell, as the image is bigger, the image
> is not completely visible in a Grid.
>
> Please help in this regard.
>
>
> 2. Another requirement is based on the size of the grid(I perform
> resizing of grid) and size of the image, it will automatically calculate
> the number of grid columns...
> Problem is suppose there are 2 columns in the grid.. and after
> performing the resizing operation, the calculated number of cells is
> 5...these 5 columns were appended to the already existing 2 columns...
>
> I want to set the number of columns to zero and then adding the newly
> cal no of cols...
>
> Please help me ...
>
>
Re: Grid item resize [message #19625 is a reply to message #19444] Tue, 05 December 2006 04:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sujji_minnu.yahoo.co.in

Hi Chris,

Thanks for the reply,

For the Reply 2):


I already tried with gridColumn#dispose.... but its not disposing.
Instead whenever I perform resizing operation, number of cols increased as
well as the data is displayed in some random order...not in continuous
cols starting with the first one....

The following is the code I am using,

public void reConstructGrid(){

grid.removeAll();
for(int i1=0;i1<grid.getColumnCount();i1++){

grid.getColumn(i1).dispose();
}


for(int i=0;i<GlobalVariablesClass.cols;i++){
GridColumn column=new GridColumn(grid,SWT.NONE);
column.setResizeable(true);
column.setWidth(100);

}

}


And for the reply 1):

I am placing only only one icon...in the grid in the first row and
first col only....Still its not totally visible..

grid = new Grid(sash_form,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

gridItem = new GridItem(grid, SWT.NONE);
gridItem.setImage(0, Util.getImageRegistry().get("file"));

I am placing only the image in the first item first col... still its not
showing complete image...

Do I need to set any option for the grid...?
Re: Grid item resize [message #19715 is a reply to message #19625] Tue, 05 December 2006 22:21 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
1.) Turns out I was incorrect. The grid is calculating the row height
based on the first column and item but thats before you have a chance to
set the image. I am investigating a simple setItemHeight method. I'll
respond back when I'm finished.

2.) Your loop construct to remove the columns is incorrect.

Swetha wrote:
> Hi Chris,
>
> Thanks for the reply,
>
> For the Reply 2):
>
>
> I already tried with gridColumn#dispose.... but its not disposing.
> Instead whenever I perform resizing operation, number of cols increased
> as well as the data is displayed in some random order...not in
> continuous cols starting with the first one....
>
> The following is the code I am using,
>
> public void reConstructGrid(){
> grid.removeAll();
> for(int i1=0;i1<grid.getColumnCount();i1++){
> grid.getColumn(i1).dispose();
> }
> for(int i=0;i<GlobalVariablesClass.cols;i++){
> GridColumn column=new GridColumn(grid,SWT.NONE);
> column.setResizeable(true);
> column.setWidth(100);
> }
> }
>
>
> And for the reply 1):
>
> I am placing only only one icon...in the grid in the first row and
> first col only....Still its not totally visible..
>
> grid = new Grid(sash_form,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
>
> gridItem = new GridItem(grid, SWT.NONE);
> gridItem.setImage(0, Util.getImageRegistry().get("file"));
>
> I am placing only the image in the first item first col... still its not
> showing complete image...
>
> Do I need to set any option for the grid...?
>
>
>
>
>
>
>
>
>
>
>
Re: Grid item resize [message #19752 is a reply to message #19715] Wed, 06 December 2006 05:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sujji_minnu.yahoo.co.in

Hi,

Thanks for the response....

2) What is the wrong with the loop for disposing the number of existing
cols...

I am just removing the existing number of cols in the first loop and
then adding the required number of cols in the second loop...

Please throw a light on this... I didn't get what is the wrong with it..


1) When can I expect setItemHeight to be available....Mean while..is
there any other way other than writing our own custom cell renderer...

Once again Thanks lot..
Re: Grid item resize [message #19790 is a reply to message #19752] Wed, 06 December 2006 09:57 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Swetha schrieb:
> Hi,
>
> Thanks for the response....
>
> 2) What is the wrong with the loop for disposing the number of existing
> cols...
>
> I am just removing the existing number of cols in the first loop and
> then adding the required number of cols in the second loop...
>
> Please throw a light on this... I didn't get what is the wrong with it..
>

You always have to remove the column with the index 0 and not with the
incremented index think short about it and it should be clear why this
needs to be done ;-)

while( grid.getColumnCount() > 0 ) {
grid.getColumn(0).dispose();
}

Doesn't your current code produce NPEs?

Tom
Re: Grid item resize [message #19834 is a reply to message #19790] Wed, 06 December 2006 11:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Tom Schindl schrieb:
> Swetha schrieb:
>> Hi,
>>
>> Thanks for the response....
>>
>> 2) What is the wrong with the loop for disposing the number of existing
>> cols...
>>
>> I am just removing the existing number of cols in the first loop and
>> then adding the required number of cols in the second loop...
>>
>> Please throw a light on this... I didn't get what is the wrong with it..
>>
>
> You always have to remove the column with the index 0 and not with the
> incremented index think short about it and it should be clear why this
> needs to be done ;-)
>
> while( grid.getColumnCount() > 0 ) {
> grid.getColumn(0).dispose();
> }
>
> Doesn't your current code produce NPEs?
>

Wrong your old code was not able to produce Exceptions but it simply
stopped to early as you might have discovered.

Tom
Re: Grid item resize [message #20038 is a reply to message #19834] Thu, 07 December 2006 04:01 Go to previous message
Eclipse UserFriend
Originally posted by: sujji_minnu.yahoo.co.in

Hi,

Thanks Tom, while loop for grid cols disposing worked....

one more question which I already mentioned is, how to set the grid Item
Height,

do u have any idea other than custom cell renderer.....
Re: Grid item resize [message #571360 is a reply to message #19350] Mon, 04 December 2006 15:12 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Re 1.) The row height is determined by the height of the first cell of
the first row in the grid. If you put an image of the size you want the
row to be in the first row/first cell then you should get the size you
want. Otherwise, you could write a custom cell renderer and that can
determine the size (but thats not easy).

Re 2.) To remove a column use GridColumn#dispose. Surely though you
could do a delta between the number of current columns and the number
you need added.

Swetha wrote:
> Hi All,
>
> I am facing two problems in Nebula Grid,
>
> 1. How can we set the height of the grid Item... I want to increase the
> size of the grid item vertically..
>
> I can able set the size of the grid Item in terms of Width...(i.e;
> horizontally)..
> I am displaying image in a cell, as the image is bigger, the image
> is not completely visible in a Grid.
>
> Please help in this regard.
>
>
> 2. Another requirement is based on the size of the grid(I perform
> resizing of grid) and size of the image, it will automatically calculate
> the number of grid columns...
> Problem is suppose there are 2 columns in the grid.. and after
> performing the resizing operation, the calculated number of cells is
> 5...these 5 columns were appended to the already existing 2 columns...
>
> I want to set the number of columns to zero and then adding the newly
> cal no of cols...
>
> Please help me ...
>
>
Re: Grid item resize [message #571485 is a reply to message #19444] Tue, 05 December 2006 04:42 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi Chris,

Thanks for the reply,

For the Reply 2):


I already tried with gridColumn#dispose.... but its not disposing.
Instead whenever I perform resizing operation, number of cols increased as
well as the data is displayed in some random order...not in continuous
cols starting with the first one....

The following is the code I am using,

public void reConstructGrid(){

grid.removeAll();
for(int i1=0;i1<grid.getColumnCount();i1++){

grid.getColumn(i1).dispose();
}


for(int i=0;i<GlobalVariablesClass.cols;i++){
GridColumn column=new GridColumn(grid,SWT.NONE);
column.setResizeable(true);
column.setWidth(100);

}

}


And for the reply 1):

I am placing only only one icon...in the grid in the first row and
first col only....Still its not totally visible..

grid = new Grid(sash_form,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

gridItem = new GridItem(grid, SWT.NONE);
gridItem.setImage(0, Util.getImageRegistry().get("file"));

I am placing only the image in the first item first col... still its not
showing complete image...

Do I need to set any option for the grid...?
Re: Grid item resize [message #571556 is a reply to message #19625] Tue, 05 December 2006 22:21 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
1.) Turns out I was incorrect. The grid is calculating the row height
based on the first column and item but thats before you have a chance to
set the image. I am investigating a simple setItemHeight method. I'll
respond back when I'm finished.

2.) Your loop construct to remove the columns is incorrect.

Swetha wrote:
> Hi Chris,
>
> Thanks for the reply,
>
> For the Reply 2):
>
>
> I already tried with gridColumn#dispose.... but its not disposing.
> Instead whenever I perform resizing operation, number of cols increased
> as well as the data is displayed in some random order...not in
> continuous cols starting with the first one....
>
> The following is the code I am using,
>
> public void reConstructGrid(){
> grid.removeAll();
> for(int i1=0;i1<grid.getColumnCount();i1++){
> grid.getColumn(i1).dispose();
> }
> for(int i=0;i<GlobalVariablesClass.cols;i++){
> GridColumn column=new GridColumn(grid,SWT.NONE);
> column.setResizeable(true);
> column.setWidth(100);
> }
> }
>
>
> And for the reply 1):
>
> I am placing only only one icon...in the grid in the first row and
> first col only....Still its not totally visible..
>
> grid = new Grid(sash_form,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
>
> gridItem = new GridItem(grid, SWT.NONE);
> gridItem.setImage(0, Util.getImageRegistry().get("file"));
>
> I am placing only the image in the first item first col... still its not
> showing complete image...
>
> Do I need to set any option for the grid...?
>
>
>
>
>
>
>
>
>
>
>
Re: Grid item resize [message #571592 is a reply to message #19715] Wed, 06 December 2006 05:05 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

Thanks for the response....

2) What is the wrong with the loop for disposing the number of existing
cols...

I am just removing the existing number of cols in the first loop and
then adding the required number of cols in the second loop...

Please throw a light on this... I didn't get what is the wrong with it..


1) When can I expect setItemHeight to be available....Mean while..is
there any other way other than writing our own custom cell renderer...

Once again Thanks lot..
Re: Grid item resize [message #571625 is a reply to message #19752] Wed, 06 December 2006 09:57 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Swetha schrieb:
> Hi,
>
> Thanks for the response....
>
> 2) What is the wrong with the loop for disposing the number of existing
> cols...
>
> I am just removing the existing number of cols in the first loop and
> then adding the required number of cols in the second loop...
>
> Please throw a light on this... I didn't get what is the wrong with it..
>

You always have to remove the column with the index 0 and not with the
incremented index think short about it and it should be clear why this
needs to be done ;-)

while( grid.getColumnCount() > 0 ) {
grid.getColumn(0).dispose();
}

Doesn't your current code produce NPEs?

Tom
Re: Grid item resize [message #571652 is a reply to message #19790] Wed, 06 December 2006 11:15 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Tom Schindl schrieb:
> Swetha schrieb:
>> Hi,
>>
>> Thanks for the response....
>>
>> 2) What is the wrong with the loop for disposing the number of existing
>> cols...
>>
>> I am just removing the existing number of cols in the first loop and
>> then adding the required number of cols in the second loop...
>>
>> Please throw a light on this... I didn't get what is the wrong with it..
>>
>
> You always have to remove the column with the index 0 and not with the
> incremented index think short about it and it should be clear why this
> needs to be done ;-)
>
> while( grid.getColumnCount() > 0 ) {
> grid.getColumn(0).dispose();
> }
>
> Doesn't your current code produce NPEs?
>

Wrong your old code was not able to produce Exceptions but it simply
stopped to early as you might have discovered.

Tom
Re: Grid item resize [message #571831 is a reply to message #19834] Thu, 07 December 2006 04:01 Go to previous message
Swetha is currently offline SwethaFriend
Messages: 68
Registered: July 2009
Member
Hi,

Thanks Tom, while loop for grid cols disposing worked....

one more question which I already mentioned is, how to set the grid Item
Height,

do u have any idea other than custom cell renderer.....
Previous Topic:Compiler error in org.eclipse.swt.nebula.examples
Next Topic:setItemHeight
Goto Forum:
  


Current Time: Tue Mar 19 05:49:50 GMT 2024

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

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

Back to the top