net.karlmartens.ui.viewer.TableViewerColumn.java Source code

Java tutorial

Introduction

Here is the source code for net.karlmartens.ui.viewer.TableViewerColumn.java

Source

/**
 *   Copyright 2011 Karl Martens
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *       
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *   net.karlmartens.ui, is a library of UI widgets
 */
package net.karlmartens.ui.viewer;

import net.karlmartens.ui.widget.Table;
import net.karlmartens.ui.widget.TableColumn;

import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ViewerColumn;

public class TableViewerColumn extends ViewerColumn {

    private final TableColumn _column;
    private EditingSupport _editingSupport;

    public TableViewerColumn(TableViewer viewer, int style) {
        this(viewer, style, -1);
    }

    public TableViewerColumn(TableViewer viewer, int style, int index) {
        this(viewer, createColumn(viewer.getControl(), style, index));
    }

    TableViewerColumn(TableViewer viewer, TableColumn column) {
        super(viewer, column);
        _column = column;
    }

    public TableColumn getColumn() {
        return _column;
    }

    @Override
    public final void setEditingSupport(EditingSupport editingSupport) {
        super.setEditingSupport(editingSupport);
        _editingSupport = editingSupport;
    }

    final EditingSupport doGetEditingSupport() {
        return _editingSupport;
    }

    protected static TableColumn createColumn(Table table, int style, int index) {
        if (index >= 0)
            return new TableColumn(table, style, index);

        return new TableColumn(table, style);
    }
}