java限制表格区大小,swt表对单元格中的文本长度有限制吗?

I use JFace TableViewer and databinding to display data of a database table, some columns have very long text, I found the text is cut out. if I activate the text editor associated with that cell, I can see the full text.

Does swt table has limitation on text length in a cell ? or the OS has such limitation ?(I am using eclipse 3.6 and windows 7 32 bit)

/*******************************************************************************

* Copyright (c) 2006 Tom Schindl and others.

* All rights reserved. This program and the accompanying materials

* are made available under the terms of the Eclipse Public License v1.0

* which accompanies this distribution, and is available at

* http://www.eclipse.org/legal/epl-v10.html

*

* Contributors:

* Tom Schindl - initial API and implementation

*******************************************************************************/

package org.eclipse.jface.snippets.viewers;

import org.eclipse.jface.viewers.IStructuredContentProvider;

import org.eclipse.jface.viewers.LabelProvider;

import org.eclipse.jface.viewers.TableViewer;

import org.eclipse.jface.viewers.Viewer;

import org.eclipse.swt.layout.FillLayout;

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

/**

* A simple TableViewer to demonstrate usage

*

* @author Tom Schindl

*

*/

public class Snippet001TableViewer {

private class MyContentProvider implements IStructuredContentProvider {

/* (non-Javadoc)

* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)

*/

public Object[] getElements(Object inputElement) {

return (MyModel[])inputElement;

}

/* (non-Javadoc)

* @see org.eclipse.jface.viewers.IContentProvider#dispose()

*/

public void dispose() {

}

/* (non-Javadoc)

* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)

*/

public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {

}

}

public class MyModel {

public int counter;

public MyModel(int counter) {

this.counter = counter;

}

public String toString() {

**return "very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooog text" + this.counter;**

}

}

public Snippet001TableViewer(Shell shell) {

final TableViewer v = new TableViewer(shell);

v.setLabelProvider(new LabelProvider());

v.setContentProvider(new MyContentProvider());

MyModel[] model = createModel();

v.setInput(model);

v.getTable().setLinesVisible(true);

}

private MyModel[] createModel() {

MyModel[] elements = new MyModel[10];

for( int i = 0; i < 10; i++ ) {

elements[i] = new MyModel(i);

}

return elements;

}

/**

* @param args

*/

public static void main(String[] args) {

Display display = new Display ();

Shell shell = new Shell(display);

shell.setLayout(new FillLayout());

new Snippet001TableViewer(shell);

shell.open ();

while (!shell.isDisposed ()) {

if (!display.readAndDispatch ()) display.sleep ();

}

display.dispose ();

}

}

f98cn.png

解决方案

It's windows bug/feature (see bugzilla for details), here is the proof (linux screenshot of your code)

lpkxa.png

I may be possible to workaround this bug/feature by self cell rendering (see Custom Drawing Table and Tree Items tutorial).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值