javaeclipseeclipse-pluginnebula

How to create user input field in Eclipse plugin using Eclipse Nebula Grid?


I am simply trying to create a Grid plugin that can have each cell be edited by a user. I found Eclipse Nebula and it seems pretty close to what I want to do except I can't figure out a way to make the cells editable. So far I have something simple like this:

public class SampleView2 extends ViewPart {
  public SampleView2() {
  }
  public void createPartControl(Composite parent) {

      // create Grid
      Grid grid = new Grid(parent,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
      grid.setHeaderVisible(true);

      // create column
      GridColumn col = new GridColumn(grid, 0);
      col.setText("First Column");
      col.setWidth(140);      

      // write text in row
      GridItem item = new GridItem(grid, 0);
      item.setText("This is my first cell"); // <--- I want the user to be able to edit this
  }

This code produces this:

enter image description here

As you can see, I can manually set the text in the cell but I want the user to be able to edit it.


Solution

  • In Eclipse Nebula Grid the GridEditor is for editable cells.

    This code snippet gives an example of how to use the GridEditor.