如何在Eclipse视图中对齐表

时间:2015-08-28 12:15:41

标签: eclipse tree swt jface

使用SWT和JFace我在第一列中创建了一个带有树视图的表,并将其放在视图中。 该表显示在视图的右半部分,即使我已将其所有设计功能保留为默认设置。

    private FormToolkit toolKit =null; 
    private ScrolledForm form = null;
    private TreeViewer viewer;
    private FeatureForm viewform;
    private Layout layout;
    // ^^^ these were declared outside of the function that creates the table 
    toolKit =   new FormToolkit (parent.getDisplay());
    viewform=   new FeatureForm(parent, toolKit,this);
    viewer  =   viewform.getTreeViewer();
    form    =   viewform.getForm();
    layout = form.getLayout();
    final TreeViewer viewer = new TreeViewer(parent, SWT.BORDER| SWT.FULL_SELECTION );
    viewer.getTree().setLinesVisible(true);
    viewer.getTree().setHeaderVisible(true);
    final TreeViewerFocusCellManager manager = new TreeViewerFocusCellManager(viewer,new FocusCellOwnerDrawHighlighter(viewer));    
    ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {
        @Override
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
        return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
            || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
            || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && ( event.keyCode == SWT.CR || event.character == ' ' ))
            || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        }
    };
    TreeViewerEditor.create(viewer, manager, actSupport, ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR| ColumnViewerEditor.TABBING_HORIZONTAL|  ColumnViewerEditor.TABBING_VERTICAL);    
    final TextCellEditor textCellEditor = new TextCellEditor(viewer.getTree());
    final CheckboxCellEditor checkboxCellEditor = new CheckboxCellEditor(viewer.getTree());

        TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.NONE);
        column.getColumn().setWidth(200);
        column.getColumn().setMoveable(false);
        column.getColumn().setText("RSI");
    //the other columns are generated the same way, only the label and content provider differs

我在控制台上打印了所有对齐和树的坐标,第一列,查看器,表单和结果都是{0,0},列的对齐是SWT.LEFT,显然。 我在这个项目中使用Eclipse Juno和JavaSE-1.7。

我该如何解决?

0 个答案:

没有答案