Search in sources :

Example 1 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 2 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 3 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 4 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 5 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)84 Point (org.eclipse.swt.graphics.Point)39 Rectangle (org.eclipse.swt.graphics.Rectangle)25 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 GC (org.eclipse.swt.graphics.GC)14 GridData (org.eclipse.swt.layout.GridData)12 Event (org.eclipse.swt.widgets.Event)12 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)11 Composite (org.eclipse.swt.widgets.Composite)8 GridLayout (org.eclipse.swt.layout.GridLayout)7 Listener (org.eclipse.swt.widgets.Listener)7 StyledText (org.eclipse.swt.custom.StyledText)6 Button (org.eclipse.swt.widgets.Button)6 Label (org.eclipse.swt.widgets.Label)6 SWT (org.eclipse.swt.SWT)5 ControlListener (org.eclipse.swt.events.ControlListener)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 Font (org.eclipse.swt.graphics.Font)5 Text (org.eclipse.swt.widgets.Text)5 AffineTransform (java.awt.geom.AffineTransform)4