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

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

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

Tree.getColumnCount介绍

[英]Returns the number of columns contained in the receiver. If no TreeColumns were created by the programmer, this value is zero, despite the fact that visually, one column of items may be visible. This occurs when the programmer uses the tree like a list, adding items but never creating a column.
[中]返回接收器中包含的列数。如果程序员没有创建TreeColumns,则该值为零,尽管在视觉上,一列项目可能是可见的。当程序员像列表一样使用树,添加项目,但从不创建列时,就会发生这种情况。

代码示例

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

public static final void setOptimalWidthOnColumns( Tree tree ) {
 int nrCols = tree.getColumnCount();
 int[] max = new int[nrCols];
 Image image = new Image( tree.getDisplay(), 10, 10 );
 GC gc = new GC( image );
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  Point point = gc.textExtent( treeColumn.getText() );
  max[i] = point.x;
 }
 getMaxWidths( tree.getItems(), max, gc );
 gc.dispose();
 image.dispose();
 for ( int i = 0; i < max.length; i++ ) {
  TreeColumn treeColumn = tree.getColumn( i );
  treeColumn.setWidth( max[i] + 30 );
 }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * {@inheritDoc}
 *
 * @since 3.5
 */
@Override
protected int getColumnCount(Scrollable tree) {
  return ((Tree) tree).getColumnCount();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private boolean isValidColumn( int index ) {
 int columnCount = parent.getColumnCount();
 return ( columnCount == 0 && index == 0 ) || ( index >= 0 && index < columnCount );
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
protected int doGetColumnCount() {
  return tree.getColumnCount();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

void setPreferredWidthBuffer( int index, int preferredWidthBuffer ) {
 int count = Math.max( 1, parent.getColumnCount() );
 ensureData( index, count );
 data[ index ].preferredWidthBuffer = preferredWidthBuffer;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
public int getColumnCount() {
  return item.getParent().getColumnCount();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
protected Widget getColumnViewerOwner(int columnIndex) {
  if (columnIndex < 0 || ( columnIndex > 0 && columnIndex >= getTree().getColumnCount() ) ) {
    return null;
  }
  if (getTree().getColumnCount() == 0)// Hang it off the table if it
    return getTree();
  return getTree().getColumn(columnIndex);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

protected Widget getColumnViewerOwner(int columnIndex) {
  if (columnIndex < 0 || ( columnIndex > 0 && columnIndex >= getTree().getColumnCount() ) ) {
    return null;
  }
  if (getTree().getColumnCount() == 0)// Hang it off the table if it
    return getTree();
  return getTree().getColumn(columnIndex);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
protected Widget getColumnViewerOwner(int columnIndex) {
  if (columnIndex < 0 || ( columnIndex > 0 && columnIndex >= getTree().getColumnCount() ) ) {
    return null;
  }
  if (getTree().getColumnCount() == 0)// Hang it off the table if it
    return getTree();
  return getTree().getColumn(columnIndex);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

void setRowColumn(int row, int column, boolean notify) {
  TreeItem item = row == -1 ? null : tree.getItem(row);
  TreeColumn col = column == -1 || tree.getColumnCount() == 0 ? null : tree.getColumn(column);
  setRowColumn(item, col, notify);
}

代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64

void setRowColumn(int row, int column, boolean notify) {
  TreeItem item = row == -1 ? null : tree.getItem(row);
  TreeColumn col = column == -1 || tree.getColumnCount() == 0 ? null : tree.getColumn(column);
  setRowColumn(item, col, notify);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

@Override
public void layout () {
  if (tree == null || tree.isDisposed()) return;
  if (item == null || item.isDisposed()) return;
  int columnCount = tree.getColumnCount();
  if (columnCount == 0 && column != 0) return;
  if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
  super.layout();
}
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

void setRowColumn(int row, int column, boolean notify) {
  TreeItem item = row == -1 ? null : tree.getItem(row);
  TreeColumn col = column == -1 || tree.getColumnCount() == 0 ? null : tree.getColumn(column);
  setRowColumn(item, col, notify);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private int getCellWidth( int index ) {
 return   getColumnCount() == 0 && index == 0
     ? getMaxInnerWidth( items, 0, 1, false )
     : getColumn( index ).getWidth();
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

public void layout() {
  if( tree == null || tree.isDisposed() )
   return;
  if( item == null || item.isDisposed() )
   return;
  int columnCount = tree.getColumnCount();
  if( columnCount == 0 && column != 0 )
   return;
  if( columnCount > 0 && ( column < 0 || column >= columnCount ) )
   return;
  super.layout();
 }
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

String _getText (int index) {
  int count = Math.max (1, parent.getColumnCount ());
  if (0 > index || index > count - 1) return "";
  int /*long*/ [] ptr = new int /*long*/ [1];
  int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
  OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, ptr, -1);
  if (ptr [0] == 0) return ""; //$NON-NLS-1$
  int length = OS.strlen (ptr [0]);
  byte[] buffer = new byte [length];
  OS.memmove (buffer, ptr [0], length);
  OS.g_free (ptr [0]);
  return new String (Converter.mbcsToWcs (null, buffer));
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

Image _getImage (int index) {
  int count = Math.max (1, parent.getColumnCount ());
  if (0 > index || index > count - 1) return null;
  int /*long*/ [] ptr = new int /*long*/ [1];
  int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
  OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, ptr, -1);
  if (ptr [0] == 0) return null;
  ImageList imageList = parent.imageList;
  int imageIndex = imageList.indexOf (ptr [0]);
  OS.g_object_unref (ptr [0]);
  if (imageIndex == -1) return null;
  return imageList.get (imageIndex);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc

Image _getImage (int index) {
  int count = Math.max (1, parent.getColumnCount ());
  if (0 > index || index > count - 1) return null;
  int /*long*/ [] ptr = new int /*long*/ [1];
  int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
  OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, ptr, -1);
  if (ptr [0] == 0) return null;
  ImageList imageList = parent.imageList;
  int imageIndex = imageList.indexOf (ptr [0]);
  OS.g_object_unref (ptr [0]);
  if (imageIndex == -1) return null;
  return imageList.get (imageIndex);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
protected Item getItemAt(Point p) {
  TreeItem[] selection = tree.getSelection();
  if( selection.length == 1 ) {
    int columnCount = tree.getColumnCount();
    for( int i = 0; i < columnCount; i++ ) {
      if( selection[0].getBounds(i).contains(p) ) {
        return selection[0];
      }
    }
  }
  return getTree().getItem(p);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
protected Item getItemAt(Point p) {
  TreeItem[] selection = tree.getSelection();
  if( selection.length == 1 ) {
    int columnCount = tree.getColumnCount();
    for( int i = 0; i < columnCount; i++ ) {
      if( selection[0].getBounds(i).contains(p) ) {
        return selection[0];
      }
    }
  }
  return getTree().getItem(p);
}

相关文章

Tree类方法