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

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

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

Table.setSelection介绍

[英]Selects the item at the given zero-relative index in the receiver. The current selection is first cleared, then the new item is selected, and if necessary the receiver is scrolled to make the new selection visible.
[中]选择接收器中给定零相对索引处的项目。首先清除当前选择,然后选择新项目,如有必要,滚动接收器,使新选择可见。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

@Override
 public void widgetSelected( SelectionEvent event ) {
  // Clear the preview step information for this step...
  //
  stepDebugMetaMap.remove( stepMeta );
  wSteps.table.setSelection( new int[]{} );
  previousIndex = -1;
  // refresh the steps list...
  //
  refreshStepList();
  showStepDebugInformation();
 }
} );

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

private void gotoField(String field){
  TableItem[] items = table.getItems();
  
  for(TableItem item: items){
    if(item.getText(0).equals(field)){
      table.setSelection(item);
      table.setSelection(-1);
    }
  }
}

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

private void gotoMember(String member){
  TableItem[] items = table.getItems();
  
  for(TableItem item : items){
    if(item.getText(1).equals(member)){
      table.setSelection(item);
      return;
    }
  }
}
@Override

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

private void refresh() {
  pageListener.setCount();
  table.clearAll();
  table.setSelection(0);
  table.setSelection(-1);
  currentData.setItem(null);
  status = Status.Normal;
  statusChanged();
}
@Override

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

@Override
  public void widgetSelected(SelectionEvent e) {
    if(channel.getText().length() > 0 && message.getText().length() > 0){
      publish.publish(id, channel.getText(), message.getText());
      TableItem item = new TableItem(table, SWT.None);
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.getDefault());
      String time = df.format(new Date());
      String[] str = new String[]{time, channel.getText(), message.getText()};
      item.setText(str);
      table.setSelection(item);
      channel.selectAll();
      message.selectAll();
      channel.setFocus();
    }
    
  }
});

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

private void refresh() {
  pageListener.setCount();
  table.clearAll();
  table.setSelection(-1);
  tableItemSelected();
}
@Override

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

@Override
  public void widgetSelected(SelectionEvent e) {
    service.removeLast(id, db, key);
    pageListener.setCount();
    table.getItem(table.getItemCount()-1);
    table.setSelection(table.getItemCount()-1);
    table.setSelection(-1);
    currentData.setItem(null);
    status = Status.Normal;
    statusChanged();
  }
});

代码示例来源:origin: pentaho/pentaho-kettle

public void setFilter() {
 if ( condition == null ) {
  condition = new Condition();
 }
 RowMetaInterface f = getRowWithoutValues();
 EnterConditionDialog ecd = new EnterConditionDialog( parent.getShell(), SWT.NONE, f, condition );
 Condition cond = ecd.open();
 if ( cond != null ) {
  ArrayList<Integer> tokeep = new ArrayList<Integer>();
  // Apply the condition to the TableView...
  int nr = table.getItemCount();
  for ( int i = nr - 1; i >= 0; i-- ) {
   RowMetaAndData r = getRow( i );
   boolean keep = cond.evaluate( r.getRowMeta(), r.getData() );
   if ( keep ) {
    tokeep.add( Integer.valueOf( i ) );
   }
  }
  int[] sels = new int[tokeep.size()];
  for ( int i = 0; i < sels.length; i++ ) {
   sels[i] = ( tokeep.get( i ) ).intValue();
  }
  table.setSelection( sels );
 }
}

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

private void add() {
  TableItem item = new TableItem(table, SWT.NONE, 0);
  table.setSelection(item);
  listener.clickRow(item, 0);
  currentStatus = Status.Add;
  currentData.setItem(item);
  addModifyTextListener();
  statusChanged();
}

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

@Override
  public void widgetSelected(SelectionEvent e) {
    InputDialog inputDialog = new InputDialog(
        (Shell) shell,
        RedisClient.i18nFile.getText(I18nFile.INPUTVALUES),
        RedisClient.i18nFile.getText(I18nFile.HASHINPUTFORMAT),
        "", null);
    if (inputDialog.open() == InputDialog.OK) {
      String values = inputDialog.getValue();
      String[] hashValues = values.split(";");
      TableItem item = null;
      for (String value : hashValues) {
        item = new TableItem(table, SWT.NONE);
        String[] zset = value.split(",");
        item.setText(zset);
      }
      
      if(item != null)
        table.setSelection(item);
    }
  }
});

代码示例来源: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

@Override
  public void widgetSelected(SelectionEvent e) {
    InputDialog inputDialog = new InputDialog((Shell) shell,
        RedisClient.i18nFile.getText(I18nFile.INPUTVALUES),
        RedisClient.i18nFile.getText(I18nFile.LISTINPUTFORMAT), "", null);
    if (inputDialog.open() == InputDialog.OK) {
      String values = inputDialog.getValue();
      String[] listValues = values.split(";");
      TableItem item = null;
      for (String value : listValues) {
        item = new TableItem(table, SWT.NONE);
        item.setText(value);
      }
      
      if(item != null)
        table.setSelection(item);
    }
  }
});

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

@Override
  public void widgetSelected(SelectionEvent e) {
    InputDialog inputDialog = new InputDialog((Shell) shell,
        RedisClient.i18nFile.getText(I18nFile.INPUTVALUES),
        RedisClient.i18nFile.getText(I18nFile.LISTINPUTFORMAT), "", null);
    if (inputDialog.open() == InputDialog.OK) {
      String values = inputDialog.getValue();
      String[] listValues = values.split(";");
      TableItem item = null;
      
      for (String value : listValues) {
        item = new TableItem(table, SWT.NONE);
        item.setText(value);
      }
      
      if(item != null)
        table.setSelection(item);
    }
  }
});

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

@Override
  public void widgetSelected(SelectionEvent e) {
    switch(status){
    case Normal:
      break;
    case Update:
      table.setSelection(-1);
      status = Status.Normal;
      currentData.setItem(null);
      statusChanged();
      break;
    case Updating:
      currentData.reset();
      status = Status.Update;
      listener.clickRow(currentData.getItem(), 0);
      addModifyTextListener();
      statusChanged();
      break;
    }
    
  }
});

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

@Override
  public void widgetSelected(SelectionEvent e) {
    InputDialog dialog = new InputDialog(shell.getParent().getShell(), RedisClient.i18nFile.getText(I18nFile.APPENDTAIL), RedisClient.i18nFile.getText(I18nFile.INPUTVALUES), "", null);
    if(dialog.open() == InputDialog.OK){
      String value = dialog.getValue();
      service.addTail(id, db, key, value);
      pageListener.setCount();
      table.clear(table.getItemCount()-1);
      table.setSelection(table.getItemCount()-1);
      table.setSelection(-1);
      currentData.setItem(null);
      status = Status.Normal;
      statusChanged();
    }
  }
});

代码示例来源: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

@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

private void refresh() {
  table.removeListener(SWT.MouseDown, editListener);
  table.addListener(SWT.MouseDown, new EditListener(table, false));
  
  table.removeListener(SWT.SetData, pageListener);
  pageListener = new PagingListener(table, new ZSetPage(id, db, key));
  table.addListener(SWT.SetData, pageListener);
  
  table.clearAll();
  table.setSelection(0);
  statusChanged();
  
}

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

@Override
  public void widgetSelected(SelectionEvent e) {
    table.addListener(SWT.MouseDown, editListener);
    
    table.removeListener(SWT.SetData, pageListener);
    pageListener = new PagingListener(table, new ZSetPage(id, db, key), true);
    table.addListener(SWT.SetData, pageListener);
    table.clearAll();
    
    TableItem item = table.getItem(0);
    
    table.setSelection(item);
    item.setText(new String[]{"", ""});
    editListener.clickRow(item, 0);
    addModifyTextListener();
    currentItem = item;
    status = Status.Add;
    statusChanged();
  }
});

相关文章

Table类方法