Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Pressing "Arrow Down" key right after focusing and selection of some cell in Grid programm
Pressing "Arrow Down" key right after focusing and selection of some cell in Grid programm [message #45188] Thu, 27 December 2007 10:30 Go to next message
Eclipse UserFriend
Originally posted by: vye.maconomy.dk

Hi guys,

When I try to focus and select some cell (using Grid API)
in a grid and right after this to press “Arrow Down” key, I have
got NullPointerException.

I have used the first snippet of grid (and changed it a little bit :))
to reproduce the problem. Here is the snippet:

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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
* Creates a simple grid and a button for focusing and selection
* of the first cell of the grid.
*/
public class MxSnippet001GridCellFocusingAndSelection {

/**
* Main entry.
* @param args command line arguments
*/
public static void main(final String [] args) {
final Display display = new Display ();
final Shell shell = new Shell (display);
// shell.setLayout(new FillLayout());
// The following code line was inserted instead
// of the line commented out above in
// order to be able to add a button below the grid.
shell.setLayout(new GridLayout(1, false));

final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL);
grid.setHeaderVisible(true);
final GridColumn column = new GridColumn(grid, SWT.NONE);
column.setTree(true);
column.setText("Column 1");
column.setWidth(100);
final GridItem item1 = new GridItem(grid, SWT.NONE);
item1.setText("Root Item");
// final GridItem item2 = new GridItem(item1, SWT.NONE);
// The following code line was inserted instead
// of the line commented out above.
final GridItem item2 = new GridItem(grid, SWT.NONE);
item2.setText("Second item");
// final GridItem item3 = new GridItem(item2, SWT.NONE);
// The following code line was inserted instead
// of the line commented out above.
final GridItem item3 = new GridItem(grid, SWT.NONE);
item3.setText("Third Item");

// The following code is added to demonstrate the defect
// with the grid cell focusing and selection.
grid.setCellSelectionEnabled(true);
// The following button is used to focus and select
// the first cell of the grid. Try to press "Arrow Down"
// key right after clicking on this button.
final Button button = new Button(shell, SWT.BORDER);
button.addSelectionListener(new SelectionAdapter() {
/** {@inheritDoc} */
@Override
public void widgetSelected(final SelectionEvent e) {
grid.forceFocus();
// We tried to use the following three code lines
// in order to both focus and select some cell of
// the grid, but as it was found, the third code line
//leads to the NullPointerException. If we do not use
// the third line, the cell is in fact selected, but
// NOT FOCUSED (and focusing is what we need).
grid.setCellSelection(new Point(0, 0));
grid.setFocusItem(grid.getItem(0));
// When you comment out the following code line the first
// cell will be selected but NOT FOCUSED. You will see
// that the first cell of the grid being not focused is
//indicated by the fact that the border of the cell is
// not present. If you do not comment the line the first
// cell will be both focused and selected, but pressing
// "Arrow Down" key leads to NullPointerException.
grid.setFocusColumn(grid.getColumn(0));
}
});
button.setText("Click this button to select and focus the "
+ "first cell of the grid. Right after clicking this "
+ "button press \"Arrow Down\" key.");

//shell.setSize(200,200);
// The following code line was inserted instead
// of the line commented out above.
shell.pack();
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

Does somebody know why it might be a problem?

Best regards,

Vadym Yepishov
Re: Pressing "Arrow Down" key right after focusing and selection of some cell in Grid prog [message #45282 is a reply to message #45188] Fri, 04 January 2008 21:02 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 253
Registered: July 2009
Senior Member
Already responded on the mailing list but for anyone else who may also
have encounterd this... this was an old bug thats fixed with any recent
Grid build.

-Chris

Vadym Yepishov wrote:
> Hi guys,
>
> When I try to focus and select some cell (using Grid API)
> in a grid and right after this to press “Arrow Down” key, I have
> got NullPointerException.
>
> I have used the first snippet of grid (and changed it a little bit :))
> to reproduce the problem. Here is the snippet:
>
> 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.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> /**
> * Creates a simple grid and a button for focusing and selection
> * of the first cell of the grid.
> */
> public class MxSnippet001GridCellFocusingAndSelection {
>
> /**
> * Main entry.
> * @param args command line arguments
> */
> public static void main(final String [] args) {
> final Display display = new Display ();
> final Shell shell = new Shell (display);
> // shell.setLayout(new FillLayout());
> // The following code line was inserted instead
> // of the line commented out above in
> // order to be able to add a button below the grid.
> shell.setLayout(new GridLayout(1, false));
>
> final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL
> | SWT.H_SCROLL);
> grid.setHeaderVisible(true);
> final GridColumn column = new GridColumn(grid, SWT.NONE);
> column.setTree(true);
> column.setText("Column 1");
> column.setWidth(100);
> final GridItem item1 = new GridItem(grid, SWT.NONE);
> item1.setText("Root Item");
> // final GridItem item2 = new GridItem(item1, SWT.NONE);
> // The following code line was inserted instead
> // of the line commented out above.
> final GridItem item2 = new GridItem(grid, SWT.NONE);
> item2.setText("Second item");
> // final GridItem item3 = new GridItem(item2, SWT.NONE);
> // The following code line was inserted instead
> // of the line commented out above.
> final GridItem item3 = new GridItem(grid, SWT.NONE);
> item3.setText("Third Item");
>
> // The following code is added to demonstrate the defect
> // with the grid cell focusing and selection.
> grid.setCellSelectionEnabled(true);
> // The following button is used to focus and select
> // the first cell of the grid. Try to press "Arrow Down"
> // key right after clicking on this button.
> final Button button = new Button(shell, SWT.BORDER);
> button.addSelectionListener(new SelectionAdapter() {
> /** {@inheritDoc} */
> @Override
> public void widgetSelected(final SelectionEvent e) {
> grid.forceFocus();
> // We tried to use the following three code lines
> // in order to both focus and select some cell of
> // the grid, but as it was found, the third code line
> //leads to the NullPointerException. If we do not use
> // the third line, the cell is in fact selected, but
> // NOT FOCUSED (and focusing is what we need).
> grid.setCellSelection(new Point(0, 0));
> grid.setFocusItem(grid.getItem(0));
> // When you comment out the following code line the first
> // cell will be selected but NOT FOCUSED. You will see
> // that the first cell of the grid being not focused is
> //indicated by the fact that the border of the cell is
> // not present. If you do not comment the line the first
> // cell will be both focused and selected, but pressing
> // "Arrow Down" key leads to NullPointerException.
> grid.setFocusColumn(grid.getColumn(0));
> }
> });
> button.setText("Click this button to select and focus the "
> + "first cell of the grid. Right after clicking this "
> + "button press \"Arrow Down\" key.");
>
> //shell.setSize(200,200);
> // The following code line was inserted instead
> // of the line commented out above.
> shell.pack();
> shell.open ();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> Does somebody know why it might be a problem?
>
> Best regards,
>
> Vadym Yepishov
Re: Pressing "Arrow Down" key right after focusing and selection of some cell in Grid prog [message #587131 is a reply to message #45188] Fri, 04 January 2008 21:02 Go to previous message
Chris Gross is currently offline Chris GrossFriend
Messages: 471
Registered: July 2009
Senior Member
Already responded on the mailing list but for anyone else who may also
have encounterd this... this was an old bug thats fixed with any recent
Grid build.

-Chris

Vadym Yepishov wrote:
> Hi guys,
>
> When I try to focus and select some cell (using Grid API)
> in a grid and right after this to press “Arrow Down” key, I have
> got NullPointerException.
>
> I have used the first snippet of grid (and changed it a little bit :))
> to reproduce the problem. Here is the snippet:
>
> 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.SelectionAdapter;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.graphics.Point;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> /**
> * Creates a simple grid and a button for focusing and selection
> * of the first cell of the grid.
> */
> public class MxSnippet001GridCellFocusingAndSelection {
>
> /**
> * Main entry.
> * @param args command line arguments
> */
> public static void main(final String [] args) {
> final Display display = new Display ();
> final Shell shell = new Shell (display);
> // shell.setLayout(new FillLayout());
> // The following code line was inserted instead
> // of the line commented out above in
> // order to be able to add a button below the grid.
> shell.setLayout(new GridLayout(1, false));
>
> final Grid grid = new Grid(shell, SWT.BORDER | SWT.V_SCROLL
> | SWT.H_SCROLL);
> grid.setHeaderVisible(true);
> final GridColumn column = new GridColumn(grid, SWT.NONE);
> column.setTree(true);
> column.setText("Column 1");
> column.setWidth(100);
> final GridItem item1 = new GridItem(grid, SWT.NONE);
> item1.setText("Root Item");
> // final GridItem item2 = new GridItem(item1, SWT.NONE);
> // The following code line was inserted instead
> // of the line commented out above.
> final GridItem item2 = new GridItem(grid, SWT.NONE);
> item2.setText("Second item");
> // final GridItem item3 = new GridItem(item2, SWT.NONE);
> // The following code line was inserted instead
> // of the line commented out above.
> final GridItem item3 = new GridItem(grid, SWT.NONE);
> item3.setText("Third Item");
>
> // The following code is added to demonstrate the defect
> // with the grid cell focusing and selection.
> grid.setCellSelectionEnabled(true);
> // The following button is used to focus and select
> // the first cell of the grid. Try to press "Arrow Down"
> // key right after clicking on this button.
> final Button button = new Button(shell, SWT.BORDER);
> button.addSelectionListener(new SelectionAdapter() {
> /** {@inheritDoc} */
> @Override
> public void widgetSelected(final SelectionEvent e) {
> grid.forceFocus();
> // We tried to use the following three code lines
> // in order to both focus and select some cell of
> // the grid, but as it was found, the third code line
> //leads to the NullPointerException. If we do not use
> // the third line, the cell is in fact selected, but
> // NOT FOCUSED (and focusing is what we need).
> grid.setCellSelection(new Point(0, 0));
> grid.setFocusItem(grid.getItem(0));
> // When you comment out the following code line the first
> // cell will be selected but NOT FOCUSED. You will see
> // that the first cell of the grid being not focused is
> //indicated by the fact that the border of the cell is
> // not present. If you do not comment the line the first
> // cell will be both focused and selected, but pressing
> // "Arrow Down" key leads to NullPointerException.
> grid.setFocusColumn(grid.getColumn(0));
> }
> });
> button.setText("Click this button to select and focus the "
> + "first cell of the grid. Right after clicking this "
> + "button press \"Arrow Down\" key.");
>
> //shell.setSize(200,200);
> // The following code line was inserted instead
> // of the line commented out above.
> shell.pack();
> shell.open ();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
> Does somebody know why it might be a problem?
>
> Best regards,
>
> Vadym Yepishov
Previous Topic:Horisontal scrolling during column draging
Next Topic:fix for cosmetic painting problem in PGroup
Goto Forum:
  


Current Time: Thu Apr 25 22:48:36 GMT 2024

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

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

Back to the top