org.eclipse.swt.widgets.ScrollBar Java Examples
The following examples show how to use
org.eclipse.swt.widgets.ScrollBar.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParameterExpandBar.java From gama with GNU General Public License v3.0 | 6 votes |
void setScrollbar() { if (itemCount == 0) { return; } final ScrollBar verticalBar = getVerticalBar(); if (verticalBar == null) { return; } final int height = getClientArea().height; final ParameterExpandItem item = items[itemCount - 1]; int maxHeight = item.y + bandHeight + spacing; if (item.expanded) { maxHeight += item.height; } // claim bottom free space if (yCurrentScroll > 0 && height > maxHeight) { yCurrentScroll = Math.max(0, yCurrentScroll + maxHeight - height); layoutItems(0, false); } maxHeight += yCurrentScroll; final int selection = Math.min(yCurrentScroll, maxHeight); final int increment = verticalBar.getIncrement(); final int pageIncrement = verticalBar.getPageIncrement(); verticalBar.setValues(selection, 0, maxHeight, height, increment, pageIncrement); verticalBar.setVisible(maxHeight > height); }
Example #2
Source File: BaseSourceViewer.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override protected StyledText createTextWidget(Composite parent, int styles) { StyledTextWithoutVerticalBar styledText = new StyledTextWithoutVerticalBar(parent, styles); if (!MinimapOverviewRulerPreferencesPage.getShowVerticalScrollbar()) { ScrollBar verticalBar = styledText.getVerticalBar(); if (verticalBar != null) { verticalBar.setVisible(false); } } if (!MinimapOverviewRulerPreferencesPage.getShowHorizontalScrollbar()) { ScrollBar horizontalBar = styledText.getHorizontalBar(); if (horizontalBar != null) { horizontalBar.setVisible(false); } } return styledText; }
Example #3
Source File: SWTUtil.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) { return ((Control) widget).getShell(); } if (widget instanceof Caret) { return ((Caret) widget).getParent().getShell(); } if (widget instanceof DragSource) { return ((DragSource) widget).getControl().getShell(); } if (widget instanceof DropTarget) { return ((DropTarget) widget).getControl().getShell(); } if (widget instanceof Menu) { return ((Menu) widget).getParent().getShell(); } if (widget instanceof ScrollBar) { return ((ScrollBar) widget).getParent().getShell(); } return null; }
Example #4
Source File: ContextDialog.java From hop with Apache License 2.0 | 6 votes |
private Item findItem( int x, int y ) { ScrollBar verticalBar = wCanvas.getVerticalBar(); int startRow = verticalBar.getSelection(); int nrColumns = calculateNrColumns(); int nrRows = calculateNrRows(); int canvasRow = Math.min( Math.floorDiv( y, cellHeight ), nrRows ); int canvasColumn = Math.min( Math.floorDiv( x, cellWidth ), nrColumns ); int index = startRow * calculateNrColumns() + canvasRow * nrColumns + canvasColumn; if ( index < 0 || index >= filteredItems.size() ) { return null; } return filteredItems.get( index ); }
Example #5
Source File: Gallery.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Add internal scrollbars listeners to this gallery. */ private void _addScrollBarsListeners() { // Vertical bar ScrollBar verticalBar = getVerticalBar(); if (verticalBar != null) { verticalBar.addListener(SWT.Selection, event -> { if (vertical) scrollVertical(); }); } // Horizontal bar ScrollBar horizontalBar = getHorizontalBar(); if (horizontalBar != null) { horizontalBar.addListener(SWT.Selection, event -> { if (!vertical) scrollHorizontal(); }); } }
Example #6
Source File: BonitaContentProposalAdapter.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
void installListeners() { // Listeners on this popup's table and scroll bar proposalTable.addListener(SWT.FocusOut, this); final ScrollBar scrollbar = proposalTable.getVerticalBar(); if (scrollbar != null) { scrollbar.addListener(SWT.Selection, this); } // Listeners on this popup's shell getShell().addListener(SWT.Deactivate, this); getShell().addListener(SWT.Close, this); // Listeners on the target control control.addListener(SWT.MouseDoubleClick, this); control.addListener(SWT.MouseDown, this); control.addListener(SWT.Dispose, this); control.addListener(SWT.FocusOut, this); // Listeners on the target control's shell final Shell controlShell = control.getShell(); controlShell.addListener(SWT.Move, this); controlShell.addListener(SWT.Resize, this); }
Example #7
Source File: JaretTable.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Update the vertical scrollbar if present. */ public void updateYScrollBar() { if (Display.getCurrent() != null) { Display.getCurrent().syncExec(new Runnable() { public void run() { ScrollBar scroll = getVerticalBar(); // scroll may be null if (scroll != null) { _oldVerticalScroll = -1; // guarantee a clean repaint scroll.setMinimum(0); scroll.setMaximum(getTotalHeight() - getFixedRowsHeight()); int height = getHeight(); if (_tableRect != null) { height = _tableRect.height; } scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight()); scroll.setIncrement(50); // increment for arrows scroll.setPageIncrement(getHeight()); // page increment areas scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset + getFixedRowsHeight()); } } }); } }
Example #8
Source File: JaretTable.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Update the horiontal scrollbar. */ private void updateXScrollBar() { if (Display.getCurrent() != null) { Display.getCurrent().syncExec(new Runnable() { public void run() { ScrollBar scroll = getHorizontalBar(); // scroll may be null if (scroll != null) { _oldHorizontalScroll = -1; // make sure no optimization will be applied scroll.setMinimum(0); scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth()); scroll.setThumb(getWidth() - getFixedColumnsWidth()); scroll.setIncrement(50); // increment for arrows scroll.setPageIncrement(getWidth()); // page increment areas } } }); } }
Example #9
Source File: JaretTable.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Update the horiontal scrollbar. */ private void updateXScrollBar() { if (Display.getCurrent() != null) { Display.getCurrent().syncExec(new Runnable() { public void run() { ScrollBar scroll = getHorizontalBar(); // scroll may be null if (scroll != null) { _oldHorizontalScroll = -1; // make sure no optimization will be applied scroll.setMinimum(0); scroll.setMaximum(getTotalWidth() - getFixedColumnsWidth()); scroll.setThumb(getWidth() - getFixedColumnsWidth()); scroll.setIncrement(50); // increment for arrows scroll.setPageIncrement(getWidth()); // page increment areas } } }); } }
Example #10
Source File: BonitaContentProposalAdapter.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
void removeListeners() { if (isValid()) { proposalTable.removeListener(SWT.FocusOut, this); final ScrollBar scrollbar = proposalTable.getVerticalBar(); if (scrollbar != null) { scrollbar.removeListener(SWT.Selection, this); } getShell().removeListener(SWT.Deactivate, this); getShell().removeListener(SWT.Close, this); } if (control != null && !control.isDisposed()) { control.removeListener(SWT.MouseDoubleClick, this); control.removeListener(SWT.MouseDown, this); control.removeListener(SWT.Dispose, this); control.removeListener(SWT.FocusOut, this); final Shell controlShell = control.getShell(); controlShell.removeListener(SWT.Move, this); controlShell.removeListener(SWT.Resize, this); } }
Example #11
Source File: SWTUtil.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell, * <code>null</code> is returned. * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
Example #12
Source File: ConsoleAutoScrollPageParticipant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void dispose() { if (textWidget != null && !textWidget.isDisposed()) { textWidget.removeListener(SWT.MouseDown, listener); textWidget.removeListener(SWT.MouseMove, listener); textWidget.removeListener(SWT.MouseUp, listener); textWidget.removeListener(SWT.KeyDown, listener); textWidget.removeListener(SWT.KeyUp, listener); textWidget.removeListener(SWT.Resize, listener); ScrollBar vBar = textWidget.getVerticalBar(); if (vBar != null && !vBar.isDisposed()) { vBar.removeListener(SWT.Selection, listener); } } textWidget = null; listener = null; }
Example #13
Source File: SWTUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell, * <code>null</code> is returned. * * @param widget * the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control) widget).getShell(); if (widget instanceof Caret) return ((Caret) widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource) widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget) widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu) widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar) widget).getParent().getShell(); return null; }
Example #14
Source File: JaretTable.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Update the vertical scrollbar if present. */ public void updateYScrollBar() { if (Display.getCurrent() != null) { Display.getCurrent().syncExec(new Runnable() { public void run() { ScrollBar scroll = getVerticalBar(); // scroll may be null if (scroll != null) { _oldVerticalScroll = -1; // guarantee a clean repaint scroll.setMinimum(0); scroll.setMaximum(getTotalHeight() - getFixedRowsHeight()); int height = getHeight(); if (_tableRect != null) { height = _tableRect.height; } scroll.setThumb(height); // - getFixedRowsHeight() - getHeaderHeight()); scroll.setIncrement(50); // increment for arrows scroll.setPageIncrement(getHeight()); // page increment areas scroll.setSelection(getAbsBeginYForRowIdx(_firstRowIdx) + _firstRowPixelOffset + getFixedRowsHeight()); } } }); } }
Example #15
Source File: SWTUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the shell for the given widget. If the widget doesn't represent * a SWT object that manage a shell, <code>null</code> is returned. * @param widget the widget * * @return the shell for the given widget */ public static Shell getShell(Widget widget) { if (widget instanceof Control) return ((Control)widget).getShell(); if (widget instanceof Caret) return ((Caret)widget).getParent().getShell(); if (widget instanceof DragSource) return ((DragSource)widget).getControl().getShell(); if (widget instanceof DropTarget) return ((DropTarget)widget).getControl().getShell(); if (widget instanceof Menu) return ((Menu)widget).getParent().getShell(); if (widget instanceof ScrollBar) return ((ScrollBar)widget).getParent().getShell(); return null; }
Example #16
Source File: HorizontalViewportLayer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean doCommand(ILayerCommand command) { boolean b = super.doCommand(command); if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; final ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); // 垂直滚动条 Listener[] listeners = vBar.getListeners(SWT.Selection); for (Listener listener : listeners) { // 清除默认的 Selection 监听(在类 ScrollBarHandlerTemplate 中添加的) vBar.removeListener(SWT.Selection, listener); } vBar.addListener(SWT.Selection, new Listener() { private ViewportLayer viewportLayer = HorizontalViewportLayer.this; private IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer(); public void handleEvent(Event event) { // 滚动滚动条前提交当前处于编辑状态的文本段 if (TeActiveCellEditor.isValid()) TeActiveCellEditor.commit(); ScrollBar scrollBar = (ScrollBar) event.widget; int position = scrollableLayer.getRowPositionByY(scrollBar.getSelection()); viewportLayer.invalidateVerticalStructure(); viewportLayer.setOriginRowPosition(position); vBar.setIncrement(viewportLayer.getRowHeightByPosition(0)); } }); } return b; }
Example #17
Source File: ViewportLayer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean doCommand(ILayerCommand command) { if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; ScrollBar hBar = clientAreaResizeCommand.getScrollable().getHorizontalBar(); ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); if (hBarListener == null) { hBarListener = new HorizontalScrollBarHandler(this, hBar); } if (vBarListener == null) { vBarListener = new VerticalScrollBarHandler(this, vBar); } handleGridResize(); return true; } else if (command instanceof TurnViewportOffCommand) { viewportOffOriginCol = localToUnderlyingColumnPosition(0); viewportOnOriginRow = localToUnderlyingRowPosition(0); viewportOff = true; return true; } else if (command instanceof TurnViewportOnCommand) { viewportOff = false; setOriginColumnPosition(viewportOffOriginCol); setOriginRowPosition(viewportOnOriginRow); return true; } else if (command instanceof PrintEntireGridCommand) { moveCellPositionIntoViewport(0, 0, false); } return super.doCommand(command); }
Example #18
Source File: CustomPreviewTable.java From birt with Eclipse Public License 1.0 | 5 votes |
private void scrollTable( ScrollBar widget, KeyEvent event ) { int newSelectionValue = widget.getSelection( ); if ( event.keyCode == SWT.ARROW_LEFT ) { newSelectionValue -= TableCanvas.SCROLL_HORIZONTAL_STEP; } else if ( event.keyCode == SWT.ARROW_RIGHT ) { newSelectionValue += TableCanvas.SCROLL_HORIZONTAL_STEP; } else if ( event.keyCode == SWT.PAGE_UP || event.keyCode == SWT.ARROW_UP ) { newSelectionValue -= 1; } else if ( event.keyCode == SWT.PAGE_DOWN || event.keyCode == SWT.ARROW_DOWN ) { newSelectionValue += 1; } if ( newSelectionValue < widget.getMinimum( ) ) { newSelectionValue = widget.getMinimum( ); } else if ( newSelectionValue > widget.getMaximum( ) ) { newSelectionValue = widget.getMaximum( ); } widget.setSelection( newSelectionValue ); Event newEvent = new Event( ); newEvent.widget = widget; newEvent.type = SWT.Selection; newEvent.data = event.data; widget.notifyListeners( SWT.Selection, newEvent ); }
Example #19
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Updates the page scroll increment for given composite. * * @param scomp */ public static void updatePageIncrement( ScrolledComposite scomp ) { ScrollBar vbar = scomp.getVerticalBar( ); if ( vbar != null ) { Rectangle clientArea = scomp.getClientArea( ); int increment = clientArea.height - 5; vbar.setPageIncrement( increment ); } }
Example #20
Source File: ImageCanvas.java From birt with Eclipse Public License 1.0 | 5 votes |
private void scrollVertically( ScrollBar scrollBar ) { if ( sourceImage == null ) return; AffineTransform af = transform; double ty = af.getTranslateY( ); double select = -scrollBar.getSelection( ); af.preConcatenate( AffineTransform.getTranslateInstance( 0, select - ty ) ); transform = af; syncScrollBars( ); }
Example #21
Source File: HorizontalViewportLayer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean doCommand(ILayerCommand command) { boolean b = super.doCommand(command); if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; final ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); // 垂直滚动条 Listener[] listeners = vBar.getListeners(SWT.Selection); for (Listener listener : listeners) { // 清除默认的 Selection 监听(在类 ScrollBarHandlerTemplate 中添加的) vBar.removeListener(SWT.Selection, listener); } vBar.addListener(SWT.Selection, new Listener() { private ViewportLayer viewportLayer = HorizontalViewportLayer.this; private IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer(); public void handleEvent(Event event) { // 滚动滚动条前提交当前处于编辑状态的文本段 HsMultiActiveCellEditor.commit(true); ScrollBar scrollBar = (ScrollBar) event.widget; int position = scrollableLayer.getRowPositionByY(scrollBar.getSelection()); viewportLayer.invalidateVerticalStructure(); viewportLayer.setOriginRowPosition(position); vBar.setIncrement(viewportLayer.getRowHeightByPosition(0)); HsMultiCellEditorControl.activeSourceAndTargetCell(XLIFFEditorImplWithNatTable.getCurrent()); } }); } return b; }
Example #22
Source File: ImageCanvas.java From birt with Eclipse Public License 1.0 | 5 votes |
private void scrollHorizontally( ScrollBar scrollBar ) { if ( sourceImage == null ) return; AffineTransform af = transform; double tx = af.getTranslateX( ); double select = -scrollBar.getSelection( ); af.preConcatenate( AffineTransform.getTranslateInstance( select - tx, 0 ) ); transform = af; syncScrollBars( ); }
Example #23
Source File: ViewportLayer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean doCommand(ILayerCommand command) { if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; ScrollBar hBar = clientAreaResizeCommand.getScrollable().getHorizontalBar(); ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); if (hBarListener == null) { hBarListener = new HorizontalScrollBarHandler(this, hBar); } if (vBarListener == null) { vBarListener = new VerticalScrollBarHandler(this, vBar); } handleGridResize(); return true; } else if (command instanceof TurnViewportOffCommand) { viewportOffOriginCol = localToUnderlyingColumnPosition(0); viewportOnOriginRow = localToUnderlyingRowPosition(0); viewportOff = true; return true; } else if (command instanceof TurnViewportOnCommand) { viewportOff = false; setOriginColumnPosition(viewportOffOriginCol); setOriginRowPosition(viewportOnOriginRow); return true; } else if (command instanceof PrintEntireGridCommand) { moveCellPositionIntoViewport(0, 0, false); } return super.doCommand(command); }
Example #24
Source File: LineSeriesMarkerSheet.java From birt with Eclipse Public License 1.0 | 5 votes |
private void updateScrollBar( ) { ScrollBar vsb = cnvMarkers.getVerticalBar( ); vsb.setValues( iStartRow, 0, Math.max( 0, ( getMarkers( ).size( ) - 1 ) / MARKER_ROW_MAX_NUMBER + 2 - MARKER_COLUMN_MAX_NUMBER ), 1, 1, 1 ); }
Example #25
Source File: HorizontalViewportLayer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean doCommand(ILayerCommand command) { boolean b = super.doCommand(command); if (command instanceof ClientAreaResizeCommand && command.convertToTargetLayer(this)) { ClientAreaResizeCommand clientAreaResizeCommand = (ClientAreaResizeCommand) command; final ScrollBar vBar = clientAreaResizeCommand.getScrollable().getVerticalBar(); // 垂直滚动条 Listener[] listeners = vBar.getListeners(SWT.Selection); for (Listener listener : listeners) { // 清除默认的 Selection 监听(在类 ScrollBarHandlerTemplate 中添加的) vBar.removeListener(SWT.Selection, listener); } vBar.addListener(SWT.Selection, new Listener() { private ViewportLayer viewportLayer = HorizontalViewportLayer.this; private IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer(); public void handleEvent(Event event) { // 滚动滚动条前提交当前处于编辑状态的文本段 HsMultiActiveCellEditor.commit(true); ScrollBar scrollBar = (ScrollBar) event.widget; int position = scrollableLayer.getRowPositionByY(scrollBar.getSelection()); viewportLayer.invalidateVerticalStructure(); viewportLayer.setOriginRowPosition(position); vBar.setIncrement(viewportLayer.getRowHeightByPosition(0)); // HsMultiCellEditorControl.activeSourceAndTargetCell(XLIFFEditorImplWithNatTable.getCurrent()); } }); } return b; }
Example #26
Source File: JsonTreeViewer.java From olca-app with Mozilla Public License 2.0 | 5 votes |
public void setCounterpart(JsonTreeViewer counterpart) { TreeViewer viewer = counterpart.getViewer(); getViewer().addTreeListener(new ExpansionListener(viewer)); getViewer().addSelectionChangedListener(new SelectionChangedListener(viewer)); ScrollBar vBar = getViewer().getTree().getVerticalBar(); vBar.addSelectionListener(new ScrollListener(viewer)); }
Example #27
Source File: MethodsViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Saves the state of the filter actions * @param memento the memento */ public void saveState(IMemento memento) { fMemberFilterActionGroup.saveState(memento); memento.putString(TAG_SHOWINHERITED, String.valueOf(isShowInheritedMethods())); memento.putString(TAG_SORTBYDEFININGTYPE, String.valueOf(isShowDefiningTypes())); ScrollBar bar= getTable().getVerticalBar(); int position= bar != null ? bar.getSelection() : 0; memento.putString(TAG_VERTICAL_SCROLL, String.valueOf(position)); }
Example #28
Source File: TypeHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void saveState(IMemento memento) { if (fPagebook == null) { // part has not been created if (fMemento != null) { //Keep the old state; memento.putMemento(fMemento); } return; } if (fInputElements != null) { memento.putString(TAG_INPUT, fInputElements[0].getHandleIdentifier()); for (int i= 1; i < fInputElements.length; i++) { IJavaElement element= fInputElements[i]; memento.putString(TAG_INPUT + i, element.getHandleIdentifier()); } } memento.putInteger(TAG_VIEW, getHierarchyMode()); memento.putInteger(TAG_LAYOUT, getViewLayout()); memento.putInteger(TAG_QUALIFIED_NAMES, isQualifiedTypeNamesEnabled() ? 1 : 0); memento.putInteger(TAG_EDITOR_LINKING, isLinkingEnabled() ? 1 : 0); int weigths[]= fTypeMethodsSplitter.getWeights(); int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]); memento.putInteger(TAG_RATIO, ratio); ScrollBar bar= getCurrentViewer().getTree().getVerticalBar(); int position= bar != null ? bar.getSelection() : 0; memento.putInteger(TAG_VERTICAL_SCROLL, position); IJavaElement selection= (IJavaElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement(); if (selection != null) { memento.putString(TAG_SELECTION, selection.getHandleIdentifier()); } fWorkingSetActionGroup.saveState(memento); fMethodsViewer.saveState(memento); }
Example #29
Source File: ContextDialog.java From hop with Apache License 2.0 | 5 votes |
private void selectItem( Item item ) { if ( this.selectedItem == item ) { return; } this.selectedItem = item; int nrColumns = calculateNrColumns(); int index = filteredItems.indexOf( item ); if ( item == null ) { wlTooltip.setText( "" ); } else { wlTooltip.setText( Const.NVL( item.getAction().getTooltip(), "" ) ); ScrollBar bar = wCanvas.getVerticalBar(); int row = Math.floorDiv( index, nrColumns ); // if ( row >= bar.getSelection()+bar.getPageIncrement() ) { // // We scrolled down and need to scroll the scrollbar // // // bar.setSelection( Math.min(row, bar.getMaximum() ) ); // } if ( row < bar.getSelection() ) { // We scrolled up and need to scroll the scrollbar up // bar.setSelection( Math.max( row, bar.getMinimum() ) ); } } wCanvas.redraw(); }
Example #30
Source File: ParameterExpandBar.java From gama with GNU General Public License v3.0 | 5 votes |
public void onScroll(final Event event) { final ScrollBar verticalBar = getVerticalBar(); if (verticalBar != null) { yCurrentScroll = verticalBar.getSelection(); layoutItems(0, false); } }