Search in sources :

Example 36 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class VersionAuthorSection method createControls.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls(org.eclipse.swt.widgets.Composite,
     * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
     */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    authorText = getWidgetFactory().createText(composite, "");
    authorText.setEnabled(false);
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(35, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    authorText.setLayoutData(data);
    //$NON-NLS-1$
    CLabel authorLabel = getWidgetFactory().createCLabel(composite, Messages.getString("VersionAuthorSection.authorLabel"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(authorText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(authorText, 0, SWT.CENTER);
    authorLabel.setLayoutData(data);
    //$NON-NLS-1$
    lockerText = getWidgetFactory().createText(composite, "");
    lockerText.setEnabled(false);
    data = new FormData();
    data.left = new FormAttachment(37, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(70, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    lockerText.setLayoutData(data);
    //$NON-NLS-1$
    CLabel lockerLabel = getWidgetFactory().createCLabel(composite, Messages.getString("VersionAuthorSection.lockerLabel"));
    data = new FormData();
    data.left = new FormAttachment(37, 0);
    data.right = new FormAttachment(lockerText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(lockerText, 0, SWT.CENTER);
    lockerLabel.setLayoutData(data);
    //$NON-NLS-1$
    btnDown = getWidgetFactory().createButton(composite, "m", SWT.PUSH);
    data = new FormData();
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    btnDown.setLayoutData(data);
    btnDown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            versionMinorUp();
        }
    });
    //$NON-NLS-1$
    btnUp = getWidgetFactory().createButton(composite, "M", SWT.PUSH);
    data = new FormData();
    data.right = new FormAttachment(btnDown, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    btnUp.setLayoutData(data);
    btnUp.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            versionMajorUp();
        }
    });
    //$NON-NLS-1$
    versionText = getWidgetFactory().createText(composite, "");
    versionText.setEnabled(false);
    data = new FormData();
    data.left = new FormAttachment(lockerText, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(btnUp, -2);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    versionText.setLayoutData(data);
    //$NON-NLS-1$
    CLabel versionLabel = getWidgetFactory().createCLabel(composite, Messages.getString("VersionAuthorSection.versionLabel"));
    data = new FormData();
    data.left = new FormAttachment(lockerText, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(versionText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(versionText, 0, SWT.CENTER);
    versionLabel.setLayoutData(data);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 37 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class SQLPatternComposite method createCodeControl.

/**
     * DOC bqian Comment method "createCodeControl".
     * 
     * @param panel
     * @param
     */
private void createCodeControl(Composite panel, Control reference) {
    codeText = new Text(panel, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    codeText.setEditable(false);
    FormData fd = new FormData();
    fd.left = new FormAttachment(10, 0);
    fd.right = new FormAttachment(90, 0);
    fd.top = new FormAttachment(reference, 2);
    fd.bottom = new FormAttachment(95, 0);
    codeText.setLayoutData(fd);
    codeText.addMouseListener(new MouseListener() {

        @Override
        public void mouseUp(MouseEvent e) {
            if (tableViewer.getTable().getSelection().length == 0) {
                return;
            }
            TableItem item = tableViewer.getTable().getSelection()[0];
            if (item == null || item.getText() == null) {
                return;
            }
            String sqlpatternName = item.getText();
            SQLPatternItem patternItem = SQLPatternUtils.getSQLPatternItem(SQLPatternComposite.this.element, sqlpatternName);
            if (patternItem.isSystem()) {
                boolean answer = //$NON-NLS-1$
                MessageDialog.openQuestion(//$NON-NLS-1$
                getShell(), //$NON-NLS-1$
                Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
                Messages.getString("SQLPatternComposite.forbidModification"));
                if (!answer) {
                    return;
                }
                IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
                IElementParameter parameter = element.getElementParameter(EParameterName.SQLPATTERN_DB_NAME.getName());
                String dbName = (String) parameter.getValue();
                //$NON-NLS-1$
                String path = dbName + "/" + RepositoryConstants.USER_DEFINED;
                repositoryService.createSqlpattern(path, true);
            } else if (sqlPatternAndProject.get(patternItem) != null) {
                MessageDialog.openInformation(getShell(), "Information", "Forbid modification on sql template from reference project");
            } else {
                boolean answer = //$NON-NLS-1$
                MessageDialog.openQuestion(//$NON-NLS-1$
                getShell(), //$NON-NLS-1$
                Messages.getString("SQLPatternComposite.TOS"), //$NON-NLS-1$
                Messages.getString("SQLPatternComposite.modifySQLPattern"));
                if (!answer) {
                    return;
                }
                IRepositoryService repositoryService = (IRepositoryService) GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
                repositoryService.openSQLPatternEditor(patternItem, false);
            }
        }

        @Override
        public void mouseDown(MouseEvent e) {
        // do nothing
        }

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            mouseUp(e);
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) TableItem(org.eclipse.swt.widgets.TableItem) IElementParameter(org.talend.core.model.process.IElementParameter) Text(org.eclipse.swt.widgets.Text) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 38 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class HeaderComposite method createComponents.

private void createComponents() {
    GridData headerCompositeGridData = new GridData(GridData.FILL_HORIZONTAL);
    this.setLayoutData(headerCompositeGridData);
    FormLayout formLayout = new FormLayout();
    this.setLayout(formLayout);
    this.statusLabel = new Label(this, SWT.NONE);
    this.iconLabel = new Label(this, SWT.NONE);
    FormData iconFormData = new FormData();
    Point minSize = statusLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    iconFormData.width = Math.max(15, minSize.x);
    iconFormData.left = new FormAttachment(0, 5);
    iconLabel.setLayoutData(iconFormData);
    iconLabel.setImage(null);
    FormData labelFormData = new FormData();
    Point iconminSize = statusLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    labelFormData.width = Math.max(1000, iconminSize.x);
    labelFormData.left = new FormAttachment(iconLabel, 5);
    statusLabel.setLayoutData(labelFormData);
    //$NON-NLS-1$
    statusLabel.setText("");
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 39 with FormData

use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.

the class InsertionIndicator method createComponents.

/**
     * DOC amaumont Comment method "createComponents".
     */
private void createComponents() {
    leftArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
    leftArrowDraggingIndicator.setVisible(false);
    leftArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
    FormData formDataLeftArrow = new FormData();
    formDataLeftArrow.width = 12;
    formDataLeftArrow.height = HEIGHT_INDICATOR;
    formDataLeftArrow.left = new FormAttachment(0, 0);
    formDataLeftArrow.left = new FormAttachment(0, -formDataLeftArrow.width + 2);
    formDataLeftArrow.top = new FormAttachment(0, 0);
    leftArrowDraggingIndicator.setLayoutData(formDataLeftArrow);
    rightArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
    rightArrowDraggingIndicator.setVisible(false);
    rightArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
    FormData formDataRightArrow = new FormData();
    formDataRightArrow.width = 13;
    formDataRightArrow.height = HEIGHT_INDICATOR;
    // this property is recalculated at each top changement
    formDataRightArrow.left = new FormAttachment(0, 0);
    formDataRightArrow.top = new FormAttachment(0, 0);
    rightArrowDraggingIndicator.setLayoutData(formDataRightArrow);
    addListeners();
}
Also used : FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 40 with FormData

use of org.eclipse.swt.layout.FormData 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)

Aggregations

FormData (org.eclipse.swt.layout.FormData)1050 FormAttachment (org.eclipse.swt.layout.FormAttachment)999 FormLayout (org.eclipse.swt.layout.FormLayout)667 Label (org.eclipse.swt.widgets.Label)554 Button (org.eclipse.swt.widgets.Button)550 SelectionEvent (org.eclipse.swt.events.SelectionEvent)477 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)433 Composite (org.eclipse.swt.widgets.Composite)423 Text (org.eclipse.swt.widgets.Text)420 ModifyListener (org.eclipse.swt.events.ModifyListener)360 Shell (org.eclipse.swt.widgets.Shell)358 ModifyEvent (org.eclipse.swt.events.ModifyEvent)356 Listener (org.eclipse.swt.widgets.Listener)356 Event (org.eclipse.swt.widgets.Event)355 Display (org.eclipse.swt.widgets.Display)342 ShellEvent (org.eclipse.swt.events.ShellEvent)331 ShellAdapter (org.eclipse.swt.events.ShellAdapter)324 TextVar (org.pentaho.di.ui.core.widget.TextVar)234 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)224 TableView (org.pentaho.di.ui.core.widget.TableView)219