Search in sources :

Example 6 with ScrollBar

use of org.eclipse.swt.widgets.ScrollBar in project cogtool by cogtool.

the class StandardDrawingEditor method setScrollIncrements.

protected void setScrollIncrements() {
    // Update the scroll bar when the internal content size changes.
    org.eclipse.swt.graphics.Point scrollSize = scrollComposite.getSize();
    org.eclipse.swt.graphics.Point editorSize = editorComposite.getSize();
    if ((scrollSize.x != 0) && (scrollSize.y != 0)) {
        ScrollBar horizontal = scrollComposite.getHorizontalBar();
        ScrollBar vertical = scrollComposite.getVerticalBar();
        // Update the scroll Step after the size info has been set
        horizontal.setIncrement((editorSize.x * 10) / scrollSize.x);
        vertical.setIncrement((editorSize.y * 10) / scrollSize.y);
        horizontal.setPageIncrement(PrecisionUtilities.ceiling(scrollSize.x * 0.75));
        vertical.setPageIncrement(PrecisionUtilities.ceiling(scrollSize.y * 0.75));
    }
}
Also used : Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 7 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)

Example 8 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();
    // System.out.println("verticalBar.getSelection()="+verticalBar.getSelection() + "
    // currentTable.getItemHeight()="+currentTable.getItemHeight());
    DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentTable);
    int indicYPositionRefZone = 0;
    if (WindowSystem.isGTK()) {
        int offsetVerticalBar = -verticalBar.getSelection();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * (currentTable.getItemHeight() + 2) + offsetVerticalBar;
        }
        // System.out.println("indicYPositionRefTable="+indicYPositionRefTable);
        indicYPositionRefZone = indicYPositionRefTable + tablePositionRefZone.y + formLayout.marginTop - HEIGHT_INDICATOR / 2;
        indicYPositionRefZone -= currentTable.getItemHeight() + 1;
    // System.out.println("indicYPositionRefZone="+indicYPositionRefZone);
    } else {
        int offsetVerticalBar = -verticalBar.getSelection() * currentTable.getItemHeight();
        if (itemIndexTarget == 0) {
            indicYPositionRefTable = 0 + offsetVerticalBar;
        } else {
            indicYPositionRefTable = itemIndexTarget * currentTable.getItemHeight() - 1 + offsetVerticalBar;
        }
        Point point = currentTable.getDisplay().map(currentTable, tablesZoneViewParent, new Point(0, indicYPositionRefTable));
        indicYPositionRefZone = point.y + 5;
    }
    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.mapper.managers.UIManager) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) Point(org.eclipse.swt.graphics.Point) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) ScrollBar(org.eclipse.swt.widgets.ScrollBar) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 9 with ScrollBar

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

the class UIManager method convertPointToReferenceOrigin.

public Point convertPointToReferenceOrigin(final Composite referenceComposite, Point point, Composite child) {
    Point returnedPoint = new Point(point.x, point.y);
    while (child != referenceComposite) {
        Rectangle bounds = child.getBounds();
        child = child.getParent();
        ScrollBar vScrollBar = child.getVerticalBar();
        if (vScrollBar != null) {
            returnedPoint.y += vScrollBar.getSelection();
        }
        returnedPoint.x += bounds.x;
        returnedPoint.y += bounds.y;
    }
    return returnedPoint;
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Example 10 with ScrollBar

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

the class JSONFileStep2Form method setVisible.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.widgets.Control#setVisible(boolean)
     */
@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (super.isVisible()) {
        if (this.linker != null) {
            this.linker.removeAllLinks();
        }
        String pathStr = getConnection().getJSONFilePath();
        boolean isContextMode = isContextMode();
        if (isContextMode) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(), connectionItem.getConnection().getContextName());
            pathStr = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, pathStr));
        }
        exportContextBtn.setEnabled(!isContextMode);
        revertContextBtn.setEnabled(isContextMode);
        // diffrent from xml , we do not save the content in item , find it in wizard temp
        if (EJsonReadbyMode.XPATH.getValue().equals(this.wizard.getReadbyMode()) && (pathStr == null || !new File(pathStr).exists())) {
            // initFileContent();
            tempJSONXsdPath = JSONUtil.tempJSONXsdPath;
            pathStr = tempJSONXsdPath;
        }
        // fix bug: when the JSON file is changed, the linker doesn't work.
        resetStatusIfNecessary();
        String tempJson = this.wizard.getTempJsonPath();
        this.treePopulator.populateTree(tempJson, treeNode);
        ScrollBar verticalBar = availableJSONTree.getVerticalBar();
        if (verticalBar != null) {
            verticalBar.setSelection(0);
        }
        if (this.linker == null) {
            this.linker = prepareJsonLinker();
        } else {
            this.linker.init(treePopulator);
            this.linker.createLinks();
        }
        checkFilePathAndManageIt();
        if (isContextMode()) {
            adaptFormToEditable();
        }
    }
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) File(java.io.File) 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