Search in sources :

Example 96 with GC

use of org.eclipse.swt.graphics.GC in project tdi-studio-se by Talend.

the class InsertionIndicator method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
private void addListeners() {
    Listener paintListener = new Listener() {

        public void handleEvent(Event event) {
            Composite composite = (Composite) event.widget;
            Rectangle bounds = composite.getBounds();
            // //////////////////////////////////////////////////////////
            // draw image filled with transparent pixels
            RGB transparentColor = new RGB(0, 255, 0);
            PaletteData paletteData = new PaletteData(new RGB[] { transparentColor });
            ImageData imageData = new ImageData(bounds.width, bounds.height, 1, paletteData);
            int transparentPixelValue = imageData.palette.getPixel(transparentColor);
            imageData.transparentPixel = transparentPixelValue;
            GC gc = event.gc;
            final Image image = new Image(gc.getDevice(), imageData);
            gc.drawImage(image, 0, 0);
            image.dispose();
            // ////////////////////////////////////////////////////////////////////////////
            // //////////////////////////////////////////////////////////
            // draw left arrow
            int yCenter = bounds.height / 2;
            int widthExternalArrow = 10;
            gc.setBackground(colorIndicator);
            gc.setForeground(colorIndicator);
            if (composite == leftArrowDraggingIndicator) {
                // external left arrow
                Point leftCrossPoint = new Point(widthExternalArrow, yCenter);
                gc.fillPolygon(new int[] { 0, 0, leftCrossPoint.x, leftCrossPoint.y, 0, bounds.height });
                gc.drawLine(leftCrossPoint.x, leftCrossPoint.y, bounds.width, leftCrossPoint.y);
            } else {
                // external right arrow
                Point rightCrossPoint = new Point(bounds.width - widthExternalArrow, yCenter);
                gc.fillPolygon(new int[] { bounds.width, 0, rightCrossPoint.x, rightCrossPoint.y, bounds.width, bounds.height });
                gc.drawLine(rightCrossPoint.x, rightCrossPoint.y, -bounds.width, rightCrossPoint.y);
            }
        }
    };
    leftArrowDraggingIndicator.addListener(SWT.Paint, paintListener);
    rightArrowDraggingIndicator.addListener(SWT.Paint, paintListener);
}
Also used : PaletteData(org.eclipse.swt.graphics.PaletteData) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ImageData(org.eclipse.swt.graphics.ImageData) Rectangle(org.eclipse.swt.graphics.Rectangle) Event(org.eclipse.swt.widgets.Event) Point(org.eclipse.swt.graphics.Point) RGB(org.eclipse.swt.graphics.RGB) GC(org.eclipse.swt.graphics.GC) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point)

Example 97 with GC

use of org.eclipse.swt.graphics.GC in project tdi-studio-se by Talend.

the class InsertionIndicator method drawIndicatorLineInTable.

private void drawIndicatorLineInTable(Event event) {
    if (visible) {
        GC gc = event.gc;
        Rectangle area = draggableTable.getClientArea();
        int y = 0;
        if (WindowSystem.isGTK()) {
            y = indicYPositionRefTable;
        } else {
            y = draggableTable.getHeaderHeight() + indicYPositionRefTable;
        }
        gc.setForeground(colorIndicator);
        gc.drawLine(0, y, area.width, y);
    }
}
Also used : Rectangle(org.eclipse.swt.graphics.Rectangle) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point)

Example 98 with GC

use of org.eclipse.swt.graphics.GC in project tdi-studio-se by Talend.

the class GenerateGrammarController method createControl.

/**
     * create a button and a listener
     */
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    Button btnEdit;
    //$NON-NLS-1$
    btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnEdit.setImage(ImageProvider.getImage(DesignerPlugin.getImageDescriptor("icons/routine_generate.gif")));
    FormData data;
    btnEdit.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
        btnEdit.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    // **************************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }
    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
            data.right = new FormAttachment(lastControl, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
            data.right = new FormAttachment(0, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
        data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH + 8, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    btnEdit.setLayoutData(data);
    // **************************
    hashCurControls.put(param.getName(), btnEdit);
    Point initialSize = btnEdit.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return addButton(subComposite, param, btnEdit, numInRow, top);
// return btnEdit;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment) Point(org.eclipse.swt.graphics.Point)

Example 99 with GC

use of org.eclipse.swt.graphics.GC in project tdi-studio-se by Talend.

the class GenerateSurvivorshipRulesController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    Button btnEdit;
    //$NON-NLS-1$
    btnEdit = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
    //$NON-NLS-1$
    btnEdit.setImage(ImageProvider.getImage(DesignerPlugin.getImageDescriptor("icons/survivorship_generate.gif")));
    FormData data;
    btnEdit.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
        btnEdit.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
    data = new FormData();
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    data.top = new FormAttachment(0, top);
    labelLabel.setLayoutData(data);
    if (numInRow != 1) {
        labelLabel.setAlignment(SWT.RIGHT);
    }
    // **************************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }
    if (numInRow == 1) {
        if (lastControl != null) {
            data.left = new FormAttachment(lastControl, currentLabelWidth);
            data.right = new FormAttachment(lastControl, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
            data.right = new FormAttachment(0, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
        data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH + 8, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    btnEdit.setLayoutData(data);
    // **************************
    hashCurControls.put(param.getName(), btnEdit);
    Point initialSize = btnEdit.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment) Point(org.eclipse.swt.graphics.Point)

Example 100 with GC

use of org.eclipse.swt.graphics.GC in project tdi-studio-se by Talend.

the class GuessSchemaController method createControl.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#createControl
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
     * org.eclipse.swt.widgets.Control)
     */
@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    FormData data;
    final Button btnCmd = new Button(subComposite, SWT.NONE);
    btnCmd.setText(GUESS_SCHEMA_NAME);
    data = new FormData();
    GC gc = new GC(btnCmd);
    Point labelSize = gc.stringExtent(GUESS_SCHEMA_NAME);
    gc.dispose();
    int currentLabelWidth = STANDARD_BUTTON_WIDTH;
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE * 2) > STANDARD_BUTTON_WIDTH) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE * 2;
    }
    data.left = new FormAttachment(lastControl, 0);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT + 2;
    btnCmd.setLayoutData(data);
    btnCmd.setData(PARAMETER_NAME, param.getName());
    btnCmd.setData(NAME, SCHEMA);
    btnCmd.setData(SCHEMA, checkQuotes((String) param.getValue()));
    btnCmd.setEnabled(!param.isReadOnly());
    btnCmd.addSelectionListener(listenerSelection);
    return btnCmd;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Button(org.eclipse.swt.widgets.Button) ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

GC (org.eclipse.swt.graphics.GC)122 Point (org.eclipse.swt.graphics.Point)90 FormAttachment (org.eclipse.swt.layout.FormAttachment)46 FormData (org.eclipse.swt.layout.FormData)46 CLabel (org.eclipse.swt.custom.CLabel)42 Node (org.talend.designer.core.ui.editor.nodes.Node)39 Control (org.eclipse.swt.widgets.Control)31 Rectangle (org.eclipse.swt.graphics.Rectangle)29 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)28 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)27 Image (org.eclipse.swt.graphics.Image)27 Button (org.eclipse.swt.widgets.Button)24 Composite (org.eclipse.swt.widgets.Composite)18 CCombo (org.eclipse.swt.custom.CCombo)16 Text (org.eclipse.swt.widgets.Text)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 GridData (org.eclipse.swt.layout.GridData)11 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)11 INode (org.talend.core.model.process.INode)10 Label (org.eclipse.swt.widgets.Label)9