Search in sources :

Example 26 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project otertool by wuntee.

the class CTabItemWithHexViewer method addListeners.

private void addListeners(final StyledText txt) {
    txt.addMouseWheelListener(new MouseWheelListener() {

        public void mouseScrolled(MouseEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    txt.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }

        public void widgetSelected(SelectionEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    txt.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    txt.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    txt.addCaretListener(new CaretListener() {

        public void caretMoved(CaretEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    txt.addDragDetectListener(new DragDetectListener() {

        public void dragDetected(DragDetectEvent arg0) {
            binContent.setTopIndex(txt.getTopIndex());
            hexContent.setTopIndex(txt.getTopIndex());
            counter.setTopIndex(txt.getTopIndex());
        }
    });
    ScrollBar vbar = txt.getVerticalBar();
    if (vbar != null) {
        vbar.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event arg0) {
                binContent.setTopIndex(txt.getTopIndex());
                hexContent.setTopIndex(txt.getTopIndex());
                counter.setTopIndex(txt.getTopIndex());
            }
        });
    }
}
Also used : CaretEvent(org.eclipse.swt.custom.CaretEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) DragDetectListener(org.eclipse.swt.events.DragDetectListener) Listener(org.eclipse.swt.widgets.Listener) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) CaretListener(org.eclipse.swt.custom.CaretListener) SelectionListener(org.eclipse.swt.events.SelectionListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) DragDetectListener(org.eclipse.swt.events.DragDetectListener) KeyEvent(org.eclipse.swt.events.KeyEvent) CaretListener(org.eclipse.swt.custom.CaretListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DragDetectEvent(org.eclipse.swt.events.DragDetectEvent) DragDetectEvent(org.eclipse.swt.events.DragDetectEvent) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) CaretEvent(org.eclipse.swt.custom.CaretEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrollBar(org.eclipse.swt.widgets.ScrollBar) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 27 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project tdi-studio-se by Talend.

the class MouseScrolledListener method mouseScrolled.

public void mouseScrolled(MouseEvent e) {
    if (scrolledComposite != null && !scrolledComposite.isDisposed()) {
        Control content = scrolledComposite.getContent();
        if (content != null) {
            Point location = content.getLocation();
            ScrollBar vBar = scrolledComposite.getVerticalBar();
            if (e.count > 0) {
                vBar.setSelection(vBar.getSelection() - INCREMENT);
            } else {
                vBar.setSelection(vBar.getSelection() + INCREMENT);
            }
            int vSelection = vBar.getSelection();
            content.setLocation(location.x, -vSelection);
            uiManager.refreshBackground(true, false);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Point(org.eclipse.swt.graphics.Point)

Example 28 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project tdi-studio-se by Talend.

the class InsertionIndicator method updatePosition.

/**
     * Update position of the indicator at top of <code>itemIndexTarget</code> position of the
     * <code>draggableTable</code>.
     * 
     * @param currentTable
     * @param itemIndexTarget
     */
public void updatePosition(Table currentTable, int itemIndexTarget) {
    // System.out.println(itemIndexTarget);
    this.draggableTable = currentTable;
    removeTablePaintListener();
    if (tablePaintListener == null) {
        tablePaintListener = new Listener() {

            public void handleEvent(Event event) {
                drawIndicatorLineInTable(event);
            }
        };
    }
    FormLayout formLayout = tablesZoneViewParent.getLayout();
    UIManager uiManager = mapperManager.getUiManager();
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    Display display = tablesZoneViewOutputs.getDisplay();
    Point tablePositionRefZone = display.map(currentTable, tablesZoneViewParent, new Point(0, 0));
    FormData formDataLeftArrow = (FormData) leftArrowDraggingIndicator.getLayoutData();
    FormData formDataRightArrow = (FormData) rightArrowDraggingIndicator.getLayoutData();
    ScrollBar verticalBar = currentTable.getVerticalBar();
    int offsetVerticalBar = -verticalBar.getSelection() * currentTable.getItemHeight();
    int indicYPositionRefZone = 0;
    if (WindowSystem.isGTK()) {
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * (currentTable.getItemHeight() + 2) + offsetVerticalBar;
        }
        indicYPositionRefZone = indicYPositionRefTable + tablePositionRefZone.y + formLayout.marginTop - HEIGHT_INDICATOR / 2;
        indicYPositionRefZone -= currentTable.getItemHeight() + 1;
    } else {
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * currentTable.getItemHeight() - 1 + offsetVerticalBar;
        }
        indicYPositionRefZone = indicYPositionRefTable + tablePositionRefZone.y + formLayout.marginTop - HEIGHT_INDICATOR / 2 + 4;
    }
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTable);
    Rectangle boundsTableView = dataMapTableView.getBounds();
    int testValue = boundsTableView.y + boundsTableView.height - formLayout.marginTop - HEIGHT_INDICATOR / 2 - 5;
    if (indicYPositionRefZone > testValue) {
        indicYPositionRefZone = testValue;
    }
    currentTable.addListener(SWT.Paint, tablePaintListener);
    if (lastIndicYPositionRefZone != indicYPositionRefZone) {
        formDataLeftArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.top.offset = indicYPositionRefZone;
        formDataRightArrow.left.offset = currentTable.getSize().x + 2;
        currentTable.redraw();
        tablesZoneViewParent.layout();
    }
    lastIndicYPositionRefZone = indicYPositionRefZone;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Listener(org.eclipse.swt.widgets.Listener) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) UIManager(org.talend.designer.dbmap.managers.UIManager) DataMapTableView(org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView) Point(org.eclipse.swt.graphics.Point) TablesZoneView(org.talend.designer.dbmap.ui.visualmap.zone.scrollable.TablesZoneView) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 29 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project tdi-studio-se by Talend.

the class UIManager method setPositionOfVerticalScrollBarZone.

private void setPositionOfVerticalScrollBarZone(ScrolledComposite scrollComposite, int scrollBarSelection) {
    ScrollBar verticalBar = scrollComposite.getVerticalBar();
    verticalBar.setSelection(scrollBarSelection);
    scrollComposite.setOrigin(0, scrollBarSelection);
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 30 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project tdi-studio-se by Talend.

the class SearchZoneMapper method setPositionOfVerticalScrollBarZone.

private void setPositionOfVerticalScrollBarZone(ScrolledComposite scrollComposite, int scrollBarSelection) {
    ScrollBar verticalBar = scrollComposite.getVerticalBar();
    verticalBar.setSelection(scrollBarSelection);
    scrollComposite.setOrigin(0, scrollBarSelection);
}
Also used : ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

ScrollBar (org.eclipse.swt.widgets.ScrollBar)50 Point (org.eclipse.swt.graphics.Point)32 Rectangle (org.eclipse.swt.graphics.Rectangle)20 GC (org.eclipse.swt.graphics.GC)14 Event (org.eclipse.swt.widgets.Event)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridData (org.eclipse.swt.layout.GridData)7 Listener (org.eclipse.swt.widgets.Listener)7 Composite (org.eclipse.swt.widgets.Composite)6 SWT (org.eclipse.swt.SWT)5 Font (org.eclipse.swt.graphics.Font)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Button (org.eclipse.swt.widgets.Button)5 AccessibleControlEvent (org.eclipse.swt.accessibility.AccessibleControlEvent)4 AccessibleEvent (org.eclipse.swt.accessibility.AccessibleEvent)4 AccessibleTableEvent (org.eclipse.swt.accessibility.AccessibleTableEvent)4 ControlListener (org.eclipse.swt.events.ControlListener)4 Color (org.eclipse.swt.graphics.Color)4 ClientAreaResizeCommand (net.sourceforge.nattable.grid.command.ClientAreaResizeCommand)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3