Exemple #1
0
  public static void sortTable(Table table, Comparator<TableItem> comparator) {
    int columnCount = table.getColumnCount();
    String[] values = new String[columnCount];
    TableItem[] items = table.getItems();
    for (int i = 1; i < items.length; i++) {
      for (int j = 0; j < i; j++) {
        TableItem item = items[i];
        if (comparator.compare(item, items[j]) < 0) {
          for (int k = 0; k < columnCount; k++) {
            values[k] = item.getText(k);
          }
          Object data = item.getData();
          boolean checked = item.getChecked();
          item.dispose();

          item = new TableItem(table, SWT.NONE, j);
          item.setText(values);
          item.setData(data);
          item.setChecked(checked);
          items = table.getItems();
          break;
        }
      }
    }
  }
 private void deleteProfile() {
   if (profilesTable.getSelectionCount() != 1) {
     return;
   }
   TableItem item = profilesTable.getSelection()[0];
   TeaVMProfile profile = (TeaVMProfile) item.getData();
   if (!profile.getExternalToolId().isEmpty()) {
     return;
   }
   boolean confirmed =
       MessageDialog.openConfirm(
           getShell(),
           "Deletion confirmation",
           "Are you sure to delete profile " + item.getText(0) + "?");
   if (!confirmed) {
     return;
   }
   settings.deleteProfile((TeaVMProfile) item.getData());
   item.dispose();
 }