1

I am new in RCP. I have created one table and using TableEditor for some columns for putting Label and Progress bar.

But For some cases I want to clear the table. For textual content table.removeAll(); is working but its not clear the Label and Progress bar;

public void createPartControl(Composite parent) {
        toolkit = new FormToolkit(parent.getDisplay());
        compositeObj = toolkit.createComposite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        compositeObj.setLayout(layout);

        GridData gridData = new GridData();
        gridData.verticalAlignment = GridData.FILL;
        gridData.horizontalSpan = 4;
        gridData.grabExcessHorizontalSpace = true;
        gridData.grabExcessVerticalSpace = true;
        gridData.horizontalAlignment = GridData.FILL;

        myTable = new Table(compositeObj,
                SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.CHECK);
        myTable .setLayoutData(gridData);

        final int[] bounds = { 30, 80, 100, 80, 100, 50, 100, 50, 50, 70, 50, 50 };
        for (int i = 0; i < titles.length; i++) {
            TableColumn tblColumn = new TableColumn(btsTable, SWT.NONE);
            tblColumn.setText(titles[i]);
            tblColumn.setWidth(bounds[i]);
            tblColumn.setResizable(true);
            tblColumn.setMoveable(true);
            tblColumn.pack();
        }
        myTable.setHeaderVisible(true);
        myTable.setLinesVisible(true);
        
        for (int i = 0; i < receiverViewDataProvider.size(); i++) {
            items[i] = new TableItem(btsTable, SWT.NONE);
        }
       fillData();
}

Table Filling Method

{
        items[cntIndex].setText(1, sID); 
        
        items[cntIndex].setText(2, sName); 

        editor[cntIndex] = new TableEditor(myTable);
        signalStrengthLabel1[selCnt] = toolkit.createLabel(myTable, sText, SWT.CENTER);
        editor[cntIndex].grabHorizontal = true;
        if (bIsAllow == true)
            editor[cntIndex].setEditor(nameLabel1[selCnt], items[cntIndex], 3);
        
        
        editor[cntIndex] = new TableEditor(myTable);
        pbReverse[selCnt] = new ProgressBar(myTable, SWT.HORIZONTAL);
        pbReverse[selCnt].setMinimum(0);
        pbReverse[selCnt].setMaximum(30);
        signalStrengthLabel1[selCnt].setText("" + iLevel + "");
        pbReverse[selCnt].setSelection(iLevel);
        editor[cntIndex].grabHorizontal = editor[cntIndex].grabVertical = true;
        if (bAllow == true)
            editor[cntIndex].setEditor(pbReverse[selCnt], items[cntIndex], 4);
}

Tried

   for (int Index = 0; Index < Cnt; Index++) {
    nameLabel1[btsIndex].setText(""); 
pbReverse[selIndex].setMaximum(0);
    pbReverse[Index].setVisible(false);
    editor[Index].dispose();
}
myTable.removeAll();
      

I am getting below result but want to clear the whole table

enter image description here

Dum
  • 13
  • 3
  • You probably need to call `dispose` on the table editor and progress bar, or possibly `setVisible(false)` if want to reuse them. – greg-449 Apr 26 '21 at 07:47
  • No its not working i have used----for (int Index = 0; Index < Cnt; Index++) { nameLabel1[btsIndex].setText(""); pbReverse[selIndex].setMaximum(0); pbReverse[Index].setVisible(false); editor[Index].dispose(); } myTable.removeAll(); – Dum Apr 26 '21 at 11:08

0 Answers0