您的位置:首页 > 其它

TableViewer使用

2015-08-28 17:35 316 查看
1.自定义编辑器激活方式

/**
* Create a customized editor whose activation process is customized
*
* @param viewer
* the viewer the editor is created for
* @param editorActivationStrategy
* activation strategy to control if an editor activated
* @param feature
* bit mask controlling the editor
* <ul>
* <li>{@link ColumnViewerEditor#DEFAULT}</li>
* <li>{@link ColumnViewerEditor#TABBING_CYCLE_IN_ROW}</li>
* <li>{@link ColumnViewerEditor#TABBING_HORIZONTAL}</li>
* <li>{@link ColumnViewerEditor#TABBING_MOVE_TO_ROW_NEIGHBOR}</li>
* <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
* </ul>
*/
public static void create(TableViewer viewer,
ColumnViewerEditorActivationStrategy editorActivationStrategy,
int feature) {

}

附例子:

TableViewerEditor .create(viewer,
new DoubleClickColumnViewerEditorActivationStrategy(
viewer), ColumnViewerEditor.DEFAULT);

/**
* 双击编辑策略
*
* @author pang
*
*/
public class DoubleClickColumnViewerEditorActivationStrategy extends
ColumnViewerEditorActivationStrategy implements CommonUse {

public DoubleClickColumnViewerEditorActivationStrategy(TableViewer viewer) {
super(viewer);
}

/**
* 設置編輯器觸發方式
*/
@Override
protected boolean isEditorActivationEvent(
ColumnViewerEditorActivationEvent event) {

boolean singleSelect = ((IStructuredSelection) getViewer()
.getSelection()).size() == 1;
return singleSelect
&& (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: