Search in sources :

Example 76 with Control

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

the class CommandController method createControl.

@Override
public Control createControl(Composite subComposite, final IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    FormData data;
    // button
    final Button btnCmd = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
    btnCmd.setText(LAUNCH);
    data = new FormData();
    GC gc = new GC(btnCmd);
    Point labelSize = gc.stringExtent(LAUNCH);
    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(((numInRow * MAX_PERCENT) / nbInRow), -currentLabelWidth);
    data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT + 2;
    btnCmd.setLayoutData(data);
    btnCmd.setData(PARAMETER_NAME, param.getName());
    btnCmd.setData(NAME, COMMANDS);
    btnCmd.setData(COMMANDS, checkQuotes((String) param.getValue()));
    btnCmd.setEnabled(!param.isReadOnly());
    btnCmd.addSelectionListener(btnListenerSelection);
    // text
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    final Text commandText = (Text) dField.getControl();
    commandText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    commandText.setEditable(!param.isReadOnly());
    // init the commands from definded xml
    commandText.setText(checkQuotes((String) param.getValue()));
    commandText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            String string = checkQuotes(commandText.getText());
            param.setValue(string);
            btnCmd.setData(COMMANDS, param.getValue());
        }
    });
    editionControlHelper.register(param.getName(), commandText);
    addDragAndDropTarget(commandText);
    if (elem instanceof Node) {
        commandText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    hashCurControls.put(param.getName(), commandText);
    // label
    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();
    currentLabelWidth = STANDARD_LABEL_WIDTH;
    gc = new GC(labelLabel);
    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);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.right = new FormAttachment(btnCmd, 0);
    data.top = new FormAttachment(btnCmd, 0, SWT.CENTER);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnCmd;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) ModifyListener(org.eclipse.swt.events.ModifyListener) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 77 with Control

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

the class ComponentListController method createCommand.

private Command createCommand(SelectionEvent selectionEvent) {
    Collection<String> elementsName = hashCurControls.keySet();
    for (String name : elementsName) {
        Object o = hashCurControls.get(name);
        if (o instanceof Control) {
            Control ctrl = (Control) o;
            if (ctrl == null) {
                hashCurControls.remove(name);
                return null;
            }
            if (ctrl.equals(selectionEvent.getSource()) && ctrl instanceof CCombo) {
                boolean isDisposed = ((CCombo) ctrl).isDisposed();
                if (!isDisposed && (!elem.getPropertyValue(name).equals(((CCombo) ctrl).getText()))) {
                    //$NON-NLS-1$
                    String value = new String("");
                    List<? extends IElementParameter> elementParametersWithChildrens = elem.getElementParametersWithChildrens();
                    for (int i = 0; i < elementParametersWithChildrens.size(); i++) {
                        IElementParameter param = elementParametersWithChildrens.get(i);
                        if (getParameterName(param).equals(name)) {
                            for (int j = 0; j < param.getListItemsValue().length; j++) {
                                if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) {
                                    value = (String) param.getListItemsValue()[j];
                                }
                            }
                        }
                    }
                    return new PropertyChangeCommand(elem, name, value);
                }
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IElementParameter(org.talend.core.model.process.IElementParameter) Point(org.eclipse.swt.graphics.Point)

Example 78 with Control

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

the class ComponentListController method createControl.

@Override
public Control createControl(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    this.curParameter = param;
    boolean isJobletOk = false;
    // IJobletProviderService service = getJobletProviderService(param);
    // if (service == null) { // not joblet
    // param.setDisplayName(EParameterName.COMPONENT_LIST.getDisplayName());
    // }
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
        combo.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);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // **********************
    hashCurControls.put(getParameterName(param), combo);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) INode(org.talend.core.model.process.INode) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) 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 79 with Control

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

the class ConnectionListController method createControl.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
     */
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    if (param.getDisplayName().startsWith(Messages.KEY_NOT_FOUND_PREFIX)) {
        param.setDisplayName(EParameterName.CONNECTION_LIST.getDisplayName());
    }
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    if (param.isRequired()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    if (param.getParentParameter() != null) {
        //$NON-NLS-1$
        combo.setData(PARAMETER_NAME, param.getParentParameter().getName() + ":" + param.getName());
    } else {
        combo.setData(PARAMETER_NAME, param.getName());
    }
    combo.setEditable(false);
    cLayout.setBackground(subComposite.getBackground());
    combo.setEnabled(!param.isReadOnly());
    combo.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
        combo.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);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // **********************
    hashCurControls.put(param.getName(), combo);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    updateConnectionList(elem, param);
    combo.setItems(param.getListItemsDisplayName());
    if (param.getValue() != null) {
        combo.setText((String) param.getValue());
    }
    return cLayout;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) 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 80 with Control

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

the class ColorController method createCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
     */
private Command createCommand(SelectionEvent event) {
    Control ctrl = (Control) event.getSource();
    if (ctrl instanceof Button) {
        String paramName = (String) ctrl.getData(PARAMETER_NAME);
        if (paramName != null) {
            ColorDialog colorDialog = new ColorDialog(ctrl.getShell());
            colorDialog.setRGB(ColorUtils.parseStringToRGB((String) elem.getPropertyValue(paramName)));
            RGB rgb = colorDialog.open();
            if (rgb != null) {
                setButtonColor((Button) ctrl, rgb);
                Command cmd;
                cmd = new PropertyChangeCommand(elem, paramName, ColorUtils.getRGBValue(rgb));
                return cmd;
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) ColorDialog(org.eclipse.swt.widgets.ColorDialog) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Button(org.eclipse.swt.widgets.Button) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

Control (org.eclipse.swt.widgets.Control)475 Point (org.eclipse.swt.graphics.Point)149 Composite (org.eclipse.swt.widgets.Composite)141 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)93 Label (org.eclipse.swt.widgets.Label)73 GridLayout (org.eclipse.swt.layout.GridLayout)71 Text (org.eclipse.swt.widgets.Text)70 FormData (org.eclipse.swt.layout.FormData)62 FormAttachment (org.eclipse.swt.layout.FormAttachment)61 Node (org.talend.designer.core.ui.editor.nodes.Node)46 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)45 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 StyledText (org.eclipse.swt.custom.StyledText)42 GC (org.eclipse.swt.graphics.GC)41 CLabel (org.eclipse.swt.custom.CLabel)38 ArrayList (java.util.ArrayList)36 Shell (org.eclipse.swt.widgets.Shell)35 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 CCombo (org.eclipse.swt.custom.CCombo)32