Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Grid Widget refresh Problem
Grid Widget refresh Problem [message #41305] Wed, 24 October 2007 10:11 Go to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.com

Hi

I have created a grid with 4 columns and 3 griditems initially.Now I am
adding a new item to the grid in response to selection of a context menu
item.

Problem is that the item is getting added to the grid, ie the itemcount
increases but the newly added item is not visible in the grid.

grid.redraw() doesnt seem to solve the problem.....

Can anybody tell what should be done

Thanks
Swetha
Re: Grid Widget refresh Problem [message #41630 is a reply to message #41305] Wed, 24 October 2007 15:25 Go to previous messageGo to next message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Hi Swetha,

Can you attach a sample snippet that demonstrates the problem?

Regards
-Chris

swetha wrote:
> Hi
>
> I have created a grid with 4 columns and 3 griditems initially.Now I am
> adding a new item to the grid in response to selection of a context menu
> item.
>
> Problem is that the item is getting added to the grid, ie the itemcount
> increases but the newly added item is not visible in the grid.
>
> grid.redraw() doesnt seem to solve the problem.....
>
> Can anybody tell what should be done
> Thanks
> Swetha
>
Re: Grid Widget refresh Problem [message #41784 is a reply to message #41630] Thu, 25 October 2007 05:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.com

Hi Chris

Here is a snippet that demonstrates the problem..
Initially I am creating a grid with 4 columns and 3 items...

I have added a MouseListener to the Grid which adds the 4th item to the
Grid when the First grid Item is selected. After execution of this
mouselistener , the itemcount on the Grid is 4 but the newly added item is
not visible in the Grid.

package gridexamples;

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class GridRefereshSnippet extends ApplicationWindow
{

private Grid expectedPeaksGrid;


public GridRefereshSnippet()
{
super(null);
}

private void run()
{
GridRefereshSnippet details = new GridRefereshSnippet();
details.setBlockOnOpen(true);
details.open();
Display.getCurrent().dispose();
}

public void configureShell(Shell shell)
{
super.configureShell(shell);
// Set the title bar text and the size
shell.setText("Grid Referesh ");

shell.setSize(500, 300);
}

public Composite createContents(Composite parent)
{
Composite compositemain = new Composite(parent, SWT.NONE);
compositemain.setLayout(new GridLayout());

GridData gridData;

expectedPeaksGrid = new Grid(compositemain, SWT.MULTI |
SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
expectedPeaksGrid.setLayoutData(gridData);
expectedPeaksGrid.setLinesVisible(true);
expectedPeaksGrid.setHeaderVisible(true);
expectedPeaksGrid.setRowHeaderVisible(true);
expectedPeaksGrid.setCellSelectionEnabled(true);
expectedPeaksGrid.setColumnScrolling(true);
expectedPeaksGrid.setRedraw(true);

GridColumn column1 = new GridColumn(expectedPeaksGrid, 0);
column1.setText("COLUMN1");
column1.setWidth(100);
GridColumn column2 = new GridColumn(expectedPeaksGrid, 0);
column2.setText("COLUMN2");
column2.setWidth(100);
GridColumn column3 = new GridColumn(expectedPeaksGrid, 0);
column3.setText("COLUMN3");
column3.setWidth(100);
GridColumn column4 = new GridColumn(expectedPeaksGrid, 0);
column4.setText("COLUMN4");
column4.setWidth(100);
GridItem item1 = new GridItem(expectedPeaksGrid, SWT.NONE);
item1.setHeaderText("GRIDITEM1");
GridItem item2 = new GridItem(expectedPeaksGrid, SWT.NONE);
item2.setHeaderText("GRIDITEM2");
GridItem item3 = new GridItem(expectedPeaksGrid, SWT.NONE);
item3.setHeaderText("GRIDITEM3");

expectedPeaksGrid.addMouseListener(new MouseAdapter()
{
public void mouseDown(MouseEvent r)
{
System.out.println("In handle event context menu");

Point p = new Point(r.x, r.y);
GridItem item = expectedPeaksGrid.getItem(p);
if (item != null)
{
System.out
.println("In handle event context menu item
selected is " +
item.getHeaderText());
if (item.getHeaderText().equals("GRIDITEM1"))
{
GridItem item1=new
GridItem(expectedPeaksGrid,SWT.NONE);
item1.setHeaderText("NEWGRIDITEM");
System.out.println("Number of GridItems immediately
after adding " + expectedPeaksGrid.getItemCount());
}
}
}
});

return compositemain;
}

public static void main(String args[])
{
new GridRefereshSnippet().run();
}

}


Thanks
Swetha
Re: Grid Widget refresh Problem [message #41871 is a reply to message #41784] Thu, 25 October 2007 10:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: swetha.yahoo.com

Hi

When I run this code, the new GridItem is created for sure but the
problem is its not visible in the Grid...
May be I should resize the Grid or something???

Thanks
Swetha
Re: Grid Widget refresh Problem [message #42058 is a reply to message #41871] Thu, 25 October 2007 14:42 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
The item is created but its not in the visible area, and the Grid was
created without a V_SCROLL so you can't scroll to it. You need to
create the Grid with scrollbars.

Regards,
-Chris

swetha wrote:
> Hi
>
> When I run this code, the new GridItem is created for sure but the
> problem is its not visible in the Grid...
> May be I should resize the Grid or something???
>
> Thanks
> Swetha
>
Re: Grid Widget refresh Problem [message #585565 is a reply to message #41305] Wed, 24 October 2007 15:25 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Hi Swetha,

Can you attach a sample snippet that demonstrates the problem?

Regards
-Chris

swetha wrote:
> Hi
>
> I have created a grid with 4 columns and 3 griditems initially.Now I am
> adding a new item to the grid in response to selection of a context menu
> item.
>
> Problem is that the item is getting added to the grid, ie the itemcount
> increases but the newly added item is not visible in the grid.
>
> grid.redraw() doesnt seem to solve the problem.....
>
> Can anybody tell what should be done
> Thanks
> Swetha
>
Re: Grid Widget refresh Problem [message #585651 is a reply to message #41630] Thu, 25 October 2007 05:46 Go to previous message
swetha  is currently offline swetha Friend
Messages: 10
Registered: July 2009
Junior Member
Hi Chris

Here is a snippet that demonstrates the problem..
Initially I am creating a grid with 4 columns and 3 items...

I have added a MouseListener to the Grid which adds the 4th item to the
Grid when the First grid Item is selected. After execution of this
mouselistener , the itemcount on the Grid is 4 but the newly added item is
not visible in the Grid.

package gridexamples;

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.nebula.widgets.grid.Grid;
import org.eclipse.nebula.widgets.grid.GridColumn;
import org.eclipse.nebula.widgets.grid.GridItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class GridRefereshSnippet extends ApplicationWindow
{

private Grid expectedPeaksGrid;


public GridRefereshSnippet()
{
super(null);
}

private void run()
{
GridRefereshSnippet details = new GridRefereshSnippet();
details.setBlockOnOpen(true);
details.open();
Display.getCurrent().dispose();
}

public void configureShell(Shell shell)
{
super.configureShell(shell);
// Set the title bar text and the size
shell.setText("Grid Referesh ");

shell.setSize(500, 300);
}

public Composite createContents(Composite parent)
{
Composite compositemain = new Composite(parent, SWT.NONE);
compositemain.setLayout(new GridLayout());

GridData gridData;

expectedPeaksGrid = new Grid(compositemain, SWT.MULTI |
SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
expectedPeaksGrid.setLayoutData(gridData);
expectedPeaksGrid.setLinesVisible(true);
expectedPeaksGrid.setHeaderVisible(true);
expectedPeaksGrid.setRowHeaderVisible(true);
expectedPeaksGrid.setCellSelectionEnabled(true);
expectedPeaksGrid.setColumnScrolling(true);
expectedPeaksGrid.setRedraw(true);

GridColumn column1 = new GridColumn(expectedPeaksGrid, 0);
column1.setText("COLUMN1");
column1.setWidth(100);
GridColumn column2 = new GridColumn(expectedPeaksGrid, 0);
column2.setText("COLUMN2");
column2.setWidth(100);
GridColumn column3 = new GridColumn(expectedPeaksGrid, 0);
column3.setText("COLUMN3");
column3.setWidth(100);
GridColumn column4 = new GridColumn(expectedPeaksGrid, 0);
column4.setText("COLUMN4");
column4.setWidth(100);
GridItem item1 = new GridItem(expectedPeaksGrid, SWT.NONE);
item1.setHeaderText("GRIDITEM1");
GridItem item2 = new GridItem(expectedPeaksGrid, SWT.NONE);
item2.setHeaderText("GRIDITEM2");
GridItem item3 = new GridItem(expectedPeaksGrid, SWT.NONE);
item3.setHeaderText("GRIDITEM3");

expectedPeaksGrid.addMouseListener(new MouseAdapter()
{
public void mouseDown(MouseEvent r)
{
System.out.println("In handle event context menu");

Point p = new Point(r.x, r.y);
GridItem item = expectedPeaksGrid.getItem(p);
if (item != null)
{
System.out
.println("In handle event context menu item
selected is " +
item.getHeaderText());
if (item.getHeaderText().equals("GRIDITEM1"))
{
GridItem item1=new
GridItem(expectedPeaksGrid,SWT.NONE);
item1.setHeaderText("NEWGRIDITEM");
System.out.println("Number of GridItems immediately
after adding " + expectedPeaksGrid.getItemCount());
}
}
}
});

return compositemain;
}

public static void main(String args[])
{
new GridRefereshSnippet().run();
}

}


Thanks
Swetha
Re: Grid Widget refresh Problem [message #585699 is a reply to message #41784] Thu, 25 October 2007 10:32 Go to previous message
swetha  is currently offline swetha Friend
Messages: 10
Registered: July 2009
Junior Member
Hi

When I run this code, the new GridItem is created for sure but the
problem is its not visible in the Grid...
May be I should resize the Grid or something???

Thanks
Swetha
Re: Grid Widget refresh Problem [message #585781 is a reply to message #41871] Thu, 25 October 2007 14:42 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
The item is created but its not in the visible area, and the Grid was
created without a V_SCROLL so you can't scroll to it. You need to
create the Grid with scrollbars.

Regards,
-Chris

swetha wrote:
> Hi
>
> When I run this code, the new GridItem is created for sure but the
> problem is its not visible in the Grid...
> May be I should resize the Grid or something???
>
> Thanks
> Swetha
>
Previous Topic:Grid: How can I find out if the row or column is selected?
Next Topic:How GridViewerEditor deactivates a cell editor with save value?
Goto Forum:
  


Current Time: Thu Dec 26 13:19:22 GMT 2024

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

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

Back to the top