org.eclipse.swt.widgets.Table.getSelection()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(264)

本文整理了Java中org.eclipse.swt.widgets.Table.getSelection()方法的一些代码示例,展示了Table.getSelection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Table.getSelection()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Table
类名称:Table
方法名:getSelection

Table.getSelection介绍

[英]Returns an array of TableItems that are currently selected in the receiver. The order of the items is unspecified. An empty array indicates that no items are selected.

Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
[中]

代码示例

代码示例来源:origin: caoxinyu/RedisClient

protected void tableItemSelected() {
    TableItem[] items = table.getSelection();
    if (items.length == 1) {
      btnDelete.setEnabled(true);
    } else if (items.length > 1) {
      btnDelete.setEnabled(true);
    } else {
      btnDelete.setEnabled(false);
    }
  }
}

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    if(table.getSelectionCount() > 0){
      String[] members = new String[table.getSelectionCount()];
      int i = 0;
      
      TableItem[] items = table.getSelection();
      for (TableItem item : items) {
        members[i++] = item.getText(1);
      }
      service.removeMembers(id, db, key, members);
      
      for (TableItem item : items) {
        item.dispose();
      }
      table.setSelection(-1);
      currentItem = null;
      btnDelete.setEnabled(false);
    }
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    service.setValue(id, db, key, table.getSelectionIndex(), items[0].getText());
    table.setSelection(-1);
    currentData.setItem(null);
    status = Status.Normal;
    statusChanged();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

protected void tableItemSelected() {
  TableItem[] items = table.getSelection();
  if (items.length == 1) {
    btnDelete.setEnabled(true);
  } else if (items.length > 1) {
    btnDelete.setEnabled(true);
  } else {
    btnDelete.setEnabled(false);
  }
}
public Table getTable() {

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getItems();
    TableItem[] selectedItems = table.getSelection();
    String selectedText = selectedItems[0].getText();
    int selected = table.getSelectionIndex();
    String upText = items[selected - 1].getText();
    items[selected].setText(upText);
    items[selected - 1].setText(selectedText);
    table.setSelection(selected - 1);
    if (selected == 1)
      tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

protected void tableItemSelected() {
    TableItem[] items = table.getSelection();
    if (items.length == 1) {
      btnDelete.setEnabled(true);
    } else if (items.length > 1) {
      btnDelete.setEnabled(true);
    } else {
      btnDelete.setEnabled(false);
    }
  }
}

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getItems();
    TableItem[] selectedItems = table.getSelection();
    String selectedText = selectedItems[0].getText();
    int selected = table.getSelectionIndex();
    String downText = items[selected + 1].getText();
    items[selected].setText(downText);
    items[selected + 1].setText(selectedText);
    table.setSelection(selected + 1);
    if (selected == table.getItemCount() - 2)
      tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

protected void tableItemSelected() {
  TableItem[] items = table.getSelection();
  if (items != null && items.length >= 1) {
    btnDelete.setEnabled(true);
    btnWatch.setEnabled(true);
  } else {
    btnDelete.setEnabled(false);
    btnWatch.setEnabled(false);
  }
}

代码示例来源:origin: caoxinyu/RedisClient

protected void tableItemSelected() {
    TableItem[] items = table.getSelection();
    if(items.length == 1){
      btnRenameButton.setEnabled(true);
      btnRemoveButton.setEnabled(true);
    } else if(items.length > 1){
      btnRemoveButton.setEnabled(true);
      btnRenameButton.setEnabled(false);
    } else {
      btnRemoveButton.setEnabled(false);
      btnRenameButton.setEnabled(false);
    }
  }
}

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    for (TableItem item : items) {
      item.dispose();
    }
    tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    for (TableItem item : items) {
      item.dispose();
    }
    tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    for (TableItem item : items) {
      item.dispose();
    }
    tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    for (TableItem item : items) {
      item.dispose();
    }
    tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    for(TableItem item : items){
      item.dispose();
    }
    tableItemSelected();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    Set<String> values = new HashSet<String>();
    
    TableItem[] items = table.getSelection();
    for (TableItem item : items) {
      values.add(item.getText());
    }
    service.remove(id, db, key, values);
    for (TableItem item : items) {
      item.dispose();
    }
    tableItemSelected();
    
  }
});

代码示例来源:origin: caoxinyu/RedisClient

private void delete() {
  TableItem[] items = table.getSelection();
  String[] fields  = new String[items.length];
  for(int i = 0; i < items.length; i ++){
    fields[i] = items[i].getText(0);
    items[i].dispose();
  }
  currentStatus = Status.Normal;
  statusChanged();
}

代码示例来源:origin: caoxinyu/RedisClient

private void deleteData(){
  TableItem[] items = table.getSelection();
  String[] fields  = new String[items.length];
  for(int i = 0; i < items.length; i ++){
    fields[i] = items[i].getText(0);
    items[i].dispose();
  }
  service.delField(id, db, key, fields);
  currentStatus = Status.Normal;
  statusChanged();
}

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    WatchDialog dialog = new WatchDialog(shell.getParent()
        .getShell(), image, items[0].getText(1));
    dialog.open();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    WatchDialog dialog = new WatchDialog(shell.getParent()
        .getShell(), image, items[0].getText());
    dialog.open();
  }
});

代码示例来源:origin: caoxinyu/RedisClient

@Override
  public void widgetSelected(SelectionEvent e) {
    TableItem[] items = table.getSelection();
    Favorite favorite = (Favorite) items[0].getData();
    RenameFavoriteDialog dialog = new RenameFavoriteDialog(shell, image, favorite);
    String name =  (String) dialog.open();
    if(name != null) {
      items[0].setText(new String[] { name, favorite.getFavorite() });
      favorite.setName(name);
      items[0].setData(favorite);
    }
  }
});

相关文章

Table类方法