SWT / JFace: disabled in table column

Calmly create Tableusing a flag column, for example using a flag SWT.CHECK. But how to make flags in certain rows of a table inaccessible for editing, while other rows remain editable?

+3
source share
3 answers

I do not know an easy way to do this.

But I see two possible solutions: there is JFace Snippet, which makes a rather extreme hack to emulate the desired flags in the tables with images here .

And then you can put your own flags in a regular table, for example this . Thus, you can independently control the status of each flag.

.

+3

:

table.addListener(SWT.Selection, new Listener() {
   public void handleEvent(Event event) {
       if( event.detail == SWT.CHECK ) {
           event.detail = SWT.NONE;
           event.type   = SWT.None;
           event.doIt   = false;
           ((TableItem)event.item).setChecked(false);
       }
   }
});
+2

, SWT.check. :

TableItem[] item = table.getItems();

for(int j=0; j<item.length;j++)
        {
            TableItem tblItem = item[j];
            if (tblItem.getChecked())
            {
                table.setSelection(j);
                 if(codition for the checkbox to be non-Editable written here)
                 {
                     item[table.getSelectionIndex()].setChecked(false);
                 }
            }
        }

In the above code, after filling in the table and when the user tries to check an element in the table, the above code should be called. If you click the checkmark, if the condition is valid for the checkBox, so that it is not editable, the flag is not selected, otherwise it will be selected. Thus, in the table, some rows may be editable, while others may not be editable in accordance with the required condition.

+2
source

All Articles