use of org.eclipse.swt.widgets.Scrollable in project linuxtools by eclipse.
the class AbstractSTViewer method saveState.
/**
* Used to save the state of the viewer before its disposal
*/
public void saveState() {
if (viewerSettings == null) {
viewerSettings = getDialogSettings().getSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
}
if (viewerSettings == null) {
viewerSettings = getDialogSettings().addNewSection(STDataViewersSettings.TAG_SECTION_VIEWER_STATE);
}
// save column order
int[] columnOrder = getColumnOrder();
String[] columnOrderStrings = new String[columnOrder.length];
for (int i = 0; i < columnOrder.length; i++) {
columnOrderStrings[i] = columnOrder[i] + "";
}
viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_COLUMN_ORDER, columnOrderStrings);
// save hide show manager
if (getHideShowManager() != null) {
getHideShowManager().saveState(viewerSettings);
}
// save sort
if (getTableSorter() != null) {
getTableSorter().saveState(viewerSettings);
}
// save vertical position
Scrollable scrollable = (Scrollable) viewer.getControl();
ScrollBar bar = scrollable.getVerticalBar();
int position = (bar != null) ? bar.getSelection() : 0;
viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_VERTICAL_POSITION, position);
// save horizontal position
bar = scrollable.getHorizontalBar();
position = (bar != null) ? bar.getSelection() : 0;
viewerSettings.put(STDataViewersSettings.TAG_VIEWER_STATE_HORIZONTAL_POSITION, position);
}
use of org.eclipse.swt.widgets.Scrollable 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));
}
Aggregations