title: Adding a remove button to a column in a table
body: <p>Is it possible to add a <em>Remove</em> button to a cell in a table?</p>
  
  <p>I have a table with 5 columns, I would like to add a 6th column.  I want the 6th column to have a remove button in each row.</p>
  
  <p>Example Row:</p>
  
  <blockquote>
    <p>|  10002  |  part  |  Metal  |  001  |  Yes  |  <kbd>Remove</kbd>  |</p>
  </blockquote>
  
  <p>That way the user can remove any unwanted rows by just clicking the button. </p>
  
  <p>I have a markup column in the table and it is <code>ComboBox</code>.  I created a class that extends <code>EditingSupport</code>.  </p>
  
  <p>Would I need to make a another class extending <code>EditingSupport</code>, but creating a button instead of <code>ComboBox</code>?</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>public class AplotDataTableViewer extends TableViewer
  {
  
      public AplotDataTableViewer(Composite parent, int style) 
      {
          super(parent, style);
  
          Table table = getTable();
          GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
          table.setLayoutData(gridData);
          createColumns();
          table.setHeaderVisible(true);
          table.setLinesVisible(true);
          setContentProvider(new ArrayContentProvider());
      }
  
      private void createColumns() {
  
        String[] titles = { "ItemId", "RevId", "PRL", "Dataset Name", "EC Markup" };
        int[] bounds = { 150, 150, 100, 150, 100 };
  
        TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
        col.setLabelProvider(new ColumnLabelProvider() {
           public String getText(Object element) {
              if(element instanceof AplotDataModel.AplotDatasetData)
                 return ((AplotDataModel.AplotDatasetData)element).getDataset().toString();
              return super.getText(element); 
              }
           }); 
  
        col = createTableViewerColumn(titles[1], bounds[1], 1);
        col.setLabelProvider(new ColumnLabelProvider() {
           public String getText(Object element) {
              if(element instanceof AplotDataModel.AplotDatasetData)
                 return ((AplotDataModel.AplotDatasetData)element).getRev().toString();
              return super.getText(element); 
              }
           });
  
        col = createTableViewerColumn(titles[2], bounds[2], 2);
        col.setLabelProvider(new ColumnLabelProvider() {
           public String getText(Object element) {
              if(element instanceof AplotDataModel.AplotDatasetData)
                 return ((AplotDataModel.AplotDatasetData)element).getPRLValue().toString();
              return super.getText(element); 
              }
           });
        col = createTableViewerColumn(titles[3], bounds[3], 3);
        col.setLabelProvider(new ColumnLabelProvider() {
           public String getText(Object element) {
              if(element instanceof AplotDataModel.AplotDatasetData)
                 return ((AplotDataModel.AplotDatasetData)element).getDatasetName().toString();
              return super.getText(element); 
              }
           });
  
         col = createTableViewerColumn(titles[4], bounds[4], 4);
         col.setLabelProvider(new ColumnLabelProvider() {
            public String getText(Object element) {
               if(element instanceof AplotDataModel.AplotDatasetData)
                  return ((AplotDataModel.AplotDatasetData)element).getMarkupValue();
               return super.getText(element); 
               }
            });
  
         col.setEditingSupport(new OptionEditingSupport(this));
  
      }
  
      private TableViewerColumn createTableViewerColumn(String header, int width, int idx) 
      {
          TableViewerColumn column = new TableViewerColumn(this, SWT.LEFT, idx);
          column.getColumn().setText(header);
          column.getColumn().setWidth(width);
          column.getColumn().setResizable(true);
          column.getColumn().setMoveable(true);
  
          return column;
      }
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>col = createTableViewerColumn(titles[5], bounds[5], 5);
     col.setLabelProvider(new ColumnLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
           TableItem item = new TableItem(getTable(),SWT.NONE);
           Button button = new Button(getTable(),SWT.NONE);
           button.setText("X");
           getControl().setBackground(item.getBackground());
           TableEditor editor = new TableEditor(getTable());
           editor.grabHorizontal  = true;
           editor.grabVertical = true;
           editor.setEditor(button , item, columnIndex);
           editor.layout();
           }
        });
  </code></pre>