Search in sources :

Example 1 with STDisposeListener

use of org.eclipse.linuxtools.dataviewers.listeners.STDisposeListener in project linuxtools by eclipse.

the class AbstractSTViewer method init.

/*
     * Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the
     * views state from a previous session. Where possible, the view should try to recreate that state within the part
     * controls. <p> This implementation will ignore the memento and initialize the view in a fresh state. Subclasses
     * may override the implementation to perform any state restoration as needed.
     */
/**
 * Initializes the viewers. It sets: the columns of the viewers, a viewer setting (similar to memento) a column
 * manager a viewer comparator ColumnViewerToolTipSupport an OpenListener a KeyListener a PaintListener a
 * DisposeListener the input the content provider
 * @param parent The parent composite.
 * @param style  SWT style to be used.
 */
private void init(Composite parent, int style) {
    viewer = createViewer(parent, style);
    viewerSettings = createSTAbstractDataViewersSettings();
    fields = getAllFields();
    createColumns();
    restoreColumnOrder();
    // building columns manager
    // (needs the columns to be created first)
    STDataViewersHideShowManager manager = new STDataViewersHideShowManager(this);
    manager.restoreState(viewerSettings);
    setHideShowManager(manager);
    // building the column comparator
    // (needs the columns to be created first)
    STDataViewersComparator comparator = new STDataViewersComparator(getColumns());
    comparator.restoreState(viewerSettings);
    setComparator(comparator);
    setSortIndicators();
    IContentProvider cp = createContentProvider();
    viewer.setContentProvider(cp);
    viewer.setUseHashlookup(true);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    viewer.getControl().setLayoutData(data);
    viewer.setInput(null);
    ColumnViewerToolTipSupport.enableFor(viewer);
    Scrollable scrollable = (Scrollable) viewer.getControl();
    ScrollBar bar = scrollable.getVerticalBar();
    if (bar != null) {
        bar.setSelection(restoreVerticalScrollBarPosition());
    }
    bar = scrollable.getHorizontalBar();
    if (bar != null) {
        bar.setSelection(restoreHorizontalScrollBarPosition());
    }
    viewer.addOpenListener(event -> handleOpenEvent(event));
    viewer.getControl().addDisposeListener(new STDisposeListener(this));
}
Also used : STDisposeListener(org.eclipse.linuxtools.dataviewers.listeners.STDisposeListener) IContentProvider(org.eclipse.jface.viewers.IContentProvider) GridData(org.eclipse.swt.layout.GridData) Scrollable(org.eclipse.swt.widgets.Scrollable) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

IContentProvider (org.eclipse.jface.viewers.IContentProvider)1 STDisposeListener (org.eclipse.linuxtools.dataviewers.listeners.STDisposeListener)1 GridData (org.eclipse.swt.layout.GridData)1 ScrollBar (org.eclipse.swt.widgets.ScrollBar)1 Scrollable (org.eclipse.swt.widgets.Scrollable)1