use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by serge-rider.
the class PlainTextPresentation method performHorizontalScroll.
@Override
protected void performHorizontalScroll(int scrollCount) {
ScrollBar hsb = text.getHorizontalBar();
if (hsb != null && hsb.isVisible()) {
int curPosition = text.getHorizontalPixel();
int pageIncrement = UIUtils.getFontHeight(text.getFont()) * 10;
if (scrollCount > 0) {
if (curPosition > 0) {
curPosition -= pageIncrement;
}
} else {
curPosition += pageIncrement;
}
if (curPosition < 0)
curPosition = 0;
text.setHorizontalPixel(curPosition);
// text.setHorizontalIndex();
}
}
use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by serge-rider.
the class StatisticsNavigatorNodeRenderer method getActionButtonFor.
private INavigatorNodeActionHandler getActionButtonFor(DBNNode element, Tree tree, Event event) {
List<INavigatorNodeActionHandler> nodeActions = NavigatorExtensionsRegistry.getInstance().getNodeActions(getView(), element);
ScrollBar horizontalScrollBar = tree.getHorizontalBar();
if (horizontalScrollBar != null && horizontalScrollBar.isVisible()) {
return null;
}
int widthOccupied = 0;
for (INavigatorNodeActionHandler nah : nodeActions) {
if (!nah.isSticky(view, element)) {
// Non-sticky buttons are active only for selected or hovered items
boolean isSelected = (event.stateMask & SWT.SELECTED) != 0;
boolean isHover = false;
if (!isSelected && !isHover) {
return null;
}
}
// Margin
widthOccupied += 2;
DBPImage icon = nah.getNodeActionIcon(getView(), element);
if (icon != null) {
Image image = DBeaverIcons.getImage(icon);
Rectangle imageBounds = image.getBounds();
int imageSize = imageBounds.height;
widthOccupied += imageSize;
if (event.x > tree.getClientArea().width - widthOccupied) {
return nah;
}
}
}
return null;
}
use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.
the class ImageViewCanvas method initScrollBars.
/* Initalize the scrollbar and register listeners. */
private void initScrollBars() {
ScrollBar horizontal = getHorizontalBar();
horizontal.setEnabled(false);
horizontal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
scrollHorizontally((ScrollBar) event.widget);
}
});
ScrollBar vertical = getVerticalBar();
vertical.setEnabled(false);
vertical.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
scrollVertically((ScrollBar) event.widget);
}
});
}
use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.
the class PlainTextPresentation method performHorizontalScroll.
@Override
protected void performHorizontalScroll(int scrollCount) {
ScrollBar hsb = text.getHorizontalBar();
if (hsb != null && hsb.isVisible()) {
int curPosition = text.getHorizontalPixel();
int pageIncrement = UIUtils.getFontHeight(text.getFont()) * 10;
if (scrollCount > 0) {
if (curPosition > 0) {
curPosition -= pageIncrement;
}
} else {
curPosition += pageIncrement;
}
if (curPosition < 0)
curPosition = 0;
text.setHorizontalPixel(curPosition);
// text.setHorizontalIndex();
}
}
use of org.eclipse.swt.widgets.ScrollBar in project dbeaver by dbeaver.
the class StatisticsNavigatorNodeRenderer method getTreeWidth.
// /////////////////////////////////////////////////////////////////
// Utils
private int getTreeWidth(Tree tree) {
int treeWidth;
int xShift;
ScrollBar hSB = tree.getHorizontalBar();
if (hSB == null || !hSB.isVisible()) {
treeWidth = tree.getClientArea().width;
xShift = 0;
} else {
treeWidth = hSB.getMaximum();
xShift = hSB.getSelection();
}
return treeWidth - xShift;
}
Aggregations