本文整理了Java中org.eclipse.swt.widgets.Tree.getItemHeight()
方法的一些代码示例,展示了Tree.getItemHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.getItemHeight()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.Tree
类名称:Tree
方法名:getItemHeight
[英]Returns the height of the area which would be used to display one of the items in the tree.
[中]返回用于显示树中一个项的区域的高度。
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private void ensureImageSize() {
if (imageSize == -1) {
imageSize = tree.getViewer().getTree().getItemHeight();
usableImageSize = Math.max(1, imageSize - 4);
}
}
代码示例来源:origin: kiegroup/droolsjbpm-tools
public IUTreeViewer(Composite parent, int style) {
super(parent, style);
final Tree tree = getTree();
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 3 * tree.getItemHeight();
tree.setLayoutData(gd);
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
int getInnerHeight() {
int innerHeight = itemCount * parent.getItemHeight();
for( int i = 0; i < itemCount; i++ ) {
TreeItem item = items[ i ];
if( item != null && item.getExpanded() ) {
innerHeight += item.getInnerHeight();
}
}
return innerHeight;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
final int getVisibleRowCount( boolean includePartlyVisible ) {
int clientHeight = getClientArea().height - getHeaderHeight();
int result = 0;
if( clientHeight >= 0 ) {
int itemHeight = getItemHeight();
result = clientHeight / itemHeight;
if( includePartlyVisible && clientHeight % itemHeight != 0 ) {
result++;
}
}
return result;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
private static void writeItemHeight( final Tree tree ) throws IOException {
JSWriter writer = JSWriter.getWriterFor( tree );
Integer newValue = new Integer( tree.getItemHeight( ) );
if( WidgetLCAUtil.hasChanged( tree, PROP_ITEM_HEIGHT, newValue ) ) {
writer.set( PROP_ITEM_HEIGHT, "itemHeight", newValue, new Integer( 16 ) );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
int getItemTop() {
int headerHeight = parent.getHeaderHeight();
int itemHeight = parent.getItemHeight();
return headerHeight + ( getFlatIndex() - parent.getTopItemIndex() ) * itemHeight;
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
boolean needsVScrollBar() {
int availableHeight = getClientArea().height;
int height = getHeaderHeight();
height += itemCount * getItemHeight();
for( int i = 0; i < itemCount; i++ ) {
TreeItem item = items[ i ];
if( item != null && item.getExpanded() ) {
height += item.getInnerHeight();
}
}
return height > availableHeight;
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.debug.ui
/**
* Creates a runtime classpath viewer with the given parent.
*
* @param parent the parent control
*/
public RuntimeClasspathViewer(Composite parent) {
super(parent);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
data.heightHint = getTree().getItemHeight();
getTree().setLayoutData(data);
getTree().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (updateSelection(RuntimeClasspathAction.REMOVE, (IStructuredSelection)getSelection()) && event.character == SWT.DEL && event.stateMask == 0) {
List selection= getSelectionFromWidget();
getClasspathContentProvider().removeAll(selection);
notifyChanged();
}
}
});
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
public void handleSetTopItemIndex( Tree tree, JsonObject properties ) {
JsonValue value = properties.get( PROP_TOP_ITEM_INDEX );
if( value != null ) {
int topItemIndex = value.asInt();
getTreeAdapter( tree ).setTopItemIndex( topItemIndex );
int scrollTop = topItemIndex * tree.getItemHeight();
setScrollBarSelection( tree.getVerticalBar(), scrollTop );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
private static void readTopItemIndex( final Tree tree ) {
String topItemIndex = WidgetLCAUtil.readPropertyValue( tree, "topItemIndex" );
if( topItemIndex != null ) {
final ITreeAdapter treeAdapter = getTreeAdapter( tree );
int newIndex = parsePosition( topItemIndex );
int topOffset = newIndex * tree.getItemHeight();
treeAdapter.setTopItemIndex( newIndex );
processScrollBarSelection( tree.getVerticalBar(), topOffset );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
public void preserveValues( Widget widget ) {
Tree tree = ( Tree )widget;
ControlLCAUtil.preserveValues( ( Control )widget );
IWidgetAdapter adapter = WidgetUtil.getAdapter( tree );
adapter.preserve( PROP_SELECTION_LISTENERS,
Boolean.valueOf( SelectionEvent.hasListener( tree ) ) );
adapter.preserve( PROP_HEADER_HEIGHT, new Integer( tree.getHeaderHeight() ) );
adapter.preserve( PROP_HEADER_VISIBLE, Boolean.valueOf( tree.getHeaderVisible() ) );
adapter.preserve( PROP_LINES_VISIBLE, Boolean.valueOf( tree.getLinesVisible() ) );
preserveItemMetrics( tree );
adapter.preserve( PROP_COLUMN_COUNT, new Integer( tree.getColumnCount() ) );
adapter.preserve( PROP_TREE_COLUMN, getTreeColumn( tree ) );
adapter.preserve( PROP_ITEM_HEIGHT, new Integer( tree.getItemHeight() ) );
adapter.preserve( PROP_ITEM_COUNT, new Integer( tree.getItemCount() ) );
adapter.preserve( PROP_SCROLL_LEFT, getScrollLeft( tree ) );
adapter.preserve( PROP_TOP_ITEM_INDEX, new Integer( getTopItemIndex( tree ) ) );
adapter.preserve( PROP_HAS_H_SCROLL_BAR, hasHScrollBar( tree ) );
adapter.preserve( PROP_HAS_V_SCROLL_BAR, hasVScrollBar( tree ) );
adapter.preserve( PROP_SCROLLBARS_SELECTION_LISTENER, hasScrollBarsSelectionListener( tree ) );
adapter.preserve( PROP_ENABLE_CELL_TOOLTIP,
new Boolean( CellToolTipUtil.isEnabledFor( tree ) ) );
WidgetLCAUtil.preserveCustomVariant( tree );
}
代码示例来源:origin: org.eclipse.xtext/ui
protected TreeViewer createTreeViewer(Composite parent, int style) {
Tree tree = new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = tree.getItemHeight() * 12;
tree.setLayoutData(gd);
final TreeViewer treeViewer = new TreeViewer(tree);
treeViewer.addFilter(new NamePatternFilter());
treeViewer.setContentProvider(contentProvider);
filterAndSorter.setComparator(comparator);
contentProvider.setFilterAndSorter(filterAndSorter);
treeViewer.setLabelProvider(labelProvider);
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
IOutlineNode rootNode = document.readOnly(new IUnitOfWork<IOutlineNode, XtextResource>() {
public IOutlineNode exec(XtextResource state) throws Exception {
IOutlineNode rootNode = treeProvider.createRoot(document);
createChildrenRecursively(rootNode.getChildren());
return rootNode;
}
protected void createChildrenRecursively(List<IOutlineNode> nodes) {
for (IOutlineNode node : nodes) {
createChildrenRecursively(node.getChildren());
}
}
});
treeViewer.setInput(rootNode);
return treeViewer;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
int findIndex(TreeItem[] items, TreeItem treeItem) {
if (items == null || treeItem == null) return -1;
Rectangle rect = treeItem.getBounds();
int index = 0;
for (int i = 0; i < items.length; i++) {
TreeItem previousItem = null;
TreeItem currentItem = items[i];
if (i > 0) previousItem = items[i - 1];
Rectangle rect1 = currentItem.getBounds();
if (rect.y == rect1.y) return index;
if (rect.y < rect1.y) {
return index - 1 + findIndex(previousItem.getItems(), treeItem);
}
if (rect.y > rect1.y && i == items.length - 1) {
return index + findIndex(currentItem.getItems(), treeItem);
}
if (rect.y >= rect1.y + (1 + currentItem.getItemCount()) * tree.getItemHeight() && currentItem.getExpanded()) {
index += countSubTreePages(currentItem);
continue;
}
index++;
}
return -1;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
int findIndex(TreeItem[] items, TreeItem treeItem) {
if (items == null || treeItem == null) return -1;
Rectangle rect = treeItem.getBounds();
int index = 0;
for (int i = 0; i < items.length; i++) {
TreeItem previousItem = null;
TreeItem currentItem = items[i];
if (i > 0) previousItem = items[i - 1];
Rectangle rect1 = currentItem.getBounds();
if (rect.y == rect1.y) return index;
if (rect.y < rect1.y) {
return index - 1 + findIndex(previousItem.getItems(), treeItem);
}
if (rect.y > rect1.y && i == items.length - 1) {
return index + findIndex(currentItem.getItems(), treeItem);
}
if (rect.y >= rect1.y + (1 + currentItem.getItemCount()) * tree.getItemHeight() && currentItem.getExpanded()) {
index += countSubTreePages(currentItem);
continue;
}
index++;
}
return -1;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
int findIndex(TreeItem[] items, TreeItem treeItem) {
if (items == null || treeItem == null) return -1;
Rectangle rect = treeItem.getBounds();
int index = 0;
for (int i = 0; i < items.length; i++) {
TreeItem previousItem = null;
TreeItem currentItem = items[i];
if (i > 0) previousItem = items[i - 1];
Rectangle rect1 = currentItem.getBounds();
if (rect.y == rect1.y) return index;
if (rect.y < rect1.y) {
return index - 1 + findIndex(previousItem.getItems(), treeItem);
}
if (rect.y > rect1.y && i == items.length - 1) {
return index + findIndex(currentItem.getItems(), treeItem);
}
if (rect.y >= rect1.y + (1 + currentItem.getItemCount()) * tree.getItemHeight() && currentItem.getExpanded()) {
index += countSubTreePages(currentItem);
continue;
}
index++;
}
return -1;
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
int findIndex(TreeItem[] items, TreeItem treeItem) {
if (items == null || treeItem == null) return -1;
Rectangle rect = treeItem.getBounds();
int index = 0;
for (int i = 0; i < items.length; i++) {
TreeItem previousItem = null;
TreeItem currentItem = items[i];
if (i > 0) previousItem = items[i - 1];
Rectangle rect1 = currentItem.getBounds();
if (rect.y == rect1.y) return index;
if (rect.y < rect1.y) {
return index - 1 + findIndex(previousItem.getItems(), treeItem);
}
if (rect.y > rect1.y && i == items.length - 1) {
return index + findIndex(currentItem.getItems(), treeItem);
}
if (rect.y >= rect1.y + (1 + currentItem.getItemCount()) * tree.getItemHeight() && currentItem.getExpanded()) {
index += countSubTreePages(currentItem);
continue;
}
index++;
}
return -1;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* Tree-viewer that shows the allowable types in a tree view.
* @param parent the parent
*/
private void addTreeComponent(Composite parent) {
fTreeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
GridData gd= new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace= true;
gd.grabExcessVerticalSpace= true;
Tree tree= fTreeViewer.getTree();
Dialog.applyDialogFont(tree);
gd.heightHint= tree.getItemHeight() * 12;
tree.setLayoutData(gd);
fTreeViewer.setContentProvider(new ChangeTypeContentProvider(((ChangeTypeRefactoring)getRefactoring())));
fLabelProvider= new ChangeTypeLabelProvider();
fTreeViewer.setLabelProvider(fLabelProvider);
ISelectionChangedListener listener= new ISelectionChangedListener(){
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection= (IStructuredSelection)event.getSelection();
typeSelected((ITypeBinding)selection.getFirstElement());
}
};
fTreeViewer.addSelectionChangedListener(listener);
fTreeViewer.setInput(new ChangeTypeContentProvider.RootType(getGeneralizeTypeRefactoring().getOriginalType()));
fTreeViewer.expandToLevel(10);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
/**
* Tree-viewer that shows the allowable types in a tree view.
* @param parent the parent
*/
private void addTreeComponent(Composite parent) {
fTreeViewer= new TreeViewer(parent, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
GridData gd= new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace= true;
gd.grabExcessVerticalSpace= true;
Tree tree= fTreeViewer.getTree();
Dialog.applyDialogFont(tree);
gd.heightHint= tree.getItemHeight() * 12;
tree.setLayoutData(gd);
fTreeViewer.setContentProvider(new ChangeTypeContentProvider(((ChangeTypeRefactoring)getRefactoring())));
fLabelProvider= new ChangeTypeLabelProvider();
fTreeViewer.setLabelProvider(fLabelProvider);
ISelectionChangedListener listener= new ISelectionChangedListener(){
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection= (IStructuredSelection)event.getSelection();
typeSelected((ITypeBinding)selection.getFirstElement());
}
};
fTreeViewer.addSelectionChangedListener(listener);
fTreeViewer.setInput(new ChangeTypeContentProvider.RootType(getGeneralizeTypeRefactoring().getOriginalType()));
fTreeViewer.expandToLevel(10);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
protected TreeViewer createTreeViewer(Composite parent, int style) {
Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
GridData gd= new GridData(GridData.FILL_BOTH);
gd.heightHint= tree.getItemHeight() * 12;
tree.setLayoutData(gd);
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
public void preserveValues( Tree tree ) {
preserveProperty( tree, PROP_ITEM_COUNT, tree.getItemCount() );
preserveProperty( tree, PROP_ITEM_HEIGHT, tree.getItemHeight() );
preserveProperty( tree, PROP_ITEM_METRICS, getItemMetrics( tree ) );
preserveProperty( tree, PROP_COLUMN_COUNT, tree.getColumnCount() );
preserveProperty( tree, PROP_COLUMN_ORDER, getColumnOrder( tree ) );
preserveProperty( tree, PROP_FIXED_COLUMNS, getFixedColumns( tree ) );
preserveProperty( tree, PROP_TREE_COLUMN, getTreeColumn( tree ) );
preserveProperty( tree, PROP_HEADER_HEIGHT, tree.getHeaderHeight() );
preserveProperty( tree, PROP_HEADER_VISIBLE, tree.getHeaderVisible() );
preserveProperty( tree, PROP_HEADER_FOREGROUND, tree.getHeaderForeground() );
preserveProperty( tree, PROP_HEADER_BACKGROUND, tree.getHeaderBackground() );
preserveProperty( tree, PROP_LINES_VISIBLE, tree.getLinesVisible() );
preserveProperty( tree, PROP_TOP_ITEM_INDEX, getTopItemIndex( tree ) );
preserveProperty( tree, PROP_FOCUS_ITEM, getFocusItem( tree ) );
preserveProperty( tree, PROP_SCROLL_LEFT, getScrollLeft( tree ) );
preserveProperty( tree, PROP_SELECTION, getSelection( tree ) );
preserveProperty( tree, PROP_SORT_DIRECTION, getSortDirection( tree ) );
preserveProperty( tree, PROP_SORT_COLUMN, tree.getSortColumn() );
preserveProperty( tree, PROP_ENABLE_CELL_TOOLTIP, CellToolTipUtil.isEnabledFor( tree ) );
preserveProperty( tree, PROP_CELL_TOOLTIP_TEXT, null );
}
内容来源于网络,如有侵权,请联系作者删除!