Grid Widget refresh Problem [message #41305] |
Wed, 24 October 2007 10:11 |
Eclipse User |
|
|
|
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 #41784 is a reply to message #41630] |
Thu, 25 October 2007 05:46 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #585651 is a reply to message #41630] |
Thu, 25 October 2007 05:46 |
swetha 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04916 seconds