Search in sources :

Example 6 with SelectAllTextControlCreator

use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.

the class FileController 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) {
    this.setDragAndDropActionBool();
    this.curParameter = param;
    FormData data;
    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);
    }
    //$NON-NLS-1$
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    data = new FormData();
    data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
    data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, FILE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(dragAndDropActionBool == true || !param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);
    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);
    }
    if (canAddRepositoryDecoration(param)) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("FileController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text filePathText = (Text) dField.getControl();
    filePathText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    editionControlHelper.register(param.getName(), filePathText);
    if (!elem.isReadOnly()) {
        if (param.isRepositoryValueUsed() && dragAndDropActionBool == false) {
            addRepositoryPropertyListener(filePathText);
        }
        filePathText.setEditable(dragAndDropActionBool == true || !param.isRepositoryValueUsed() && !(elem instanceof FakeElement) || !param.isReadOnly() && elem instanceof FakeElement);
    } else {
        filePathText.setEditable(dragAndDropActionBool == true || false);
    }
    addDragAndDropTarget(filePathText);
    if (elem instanceof Node) {
        filePathText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    hashCurControls.put(param.getName(), filePathText);
    // **************************
    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.right = new FormAttachment(btnEdit, 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    if (isInWizard()) {
        labelLabel.setAlignment(SWT.RIGHT);
        if (lastControl != null) {
            data.right = new FormAttachment(lastControl, -STANDARD_BUTTON_WIDTH);
        } else {
            data.right = new FormAttachment(100, -STANDARD_BUTTON_WIDTH - ITabbedPropertyConstants.HSPACE);
        }
        data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth + ITabbedPropertyConstants.HSPACE);
        data = (FormData) labelLabel.getLayoutData();
        data.right = new FormAttachment(cLayout, 0);
        data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
        return labelLabel;
    }
    return btnEdit;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) Text(org.eclipse.swt.widgets.Text) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) FakeElement(org.talend.designer.core.model.FakeElement) Point(org.eclipse.swt.graphics.Point) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 7 with SelectAllTextControlCreator

use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.

the class EncodingTypeController method addCustomEncodingTypeText.

/**
     * DOC ftang Comment method "addCustomEncodingTypeText".
     * 
     * @param subComposite
     * @param param
     * @param lastControl
     * @param numInRow
     * @param nbInRow
     * @param top
     * @return
     */
private Control addCustomEncodingTypeText(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) {
    FormData data;
    Text labelText;
    IElementParameter encodingTypeParameter = param.getChildParameters().get(EParameterName.ENCODING_TYPE.getName());
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
    if (param.isRequired() || EmfComponent.ENCODING_TYPE_CUSTOM.equals(encodingTypeParameter.getValue())) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("TextController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    editionControlHelper.register(param.getName(), labelText);
    if (param.isRepositoryValueUsed()) {
        addRepositoryPropertyListener(labelText);
    }
    addDragAndDropTarget(labelText);
    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
    labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    data = new FormData();
    data.left = new FormAttachment(lastControl, 0);
    data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    hashCurControls.put(param.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
}
Also used : FormData(org.eclipse.swt.layout.FormData) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) IElementParameter(org.talend.core.model.process.IElementParameter) Text(org.eclipse.swt.widgets.Text) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 8 with SelectAllTextControlCreator

use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.

the class DCSchemaController method createControl.

@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 = new FormData();
    Control lastDbControl = null;
    Button openListTable = addButton(subComposite, param, top, numInRow, nbInRow);
    lastDbControl = openListTable;
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    if (openListTable != null) {
        openListTable.setLayoutData(data);
        openListTable.setData(PARAMETER_NAME, param.getName());
        openListTable.setEnabled(!param.isReadOnly());
        openListTable.addSelectionListener(schemaListener);
        //$NON-NLS-1$
        openListTable.setToolTipText("Edit Schema");
    }
    Text labelText;
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
    Control cLayout = dField.getLayoutControl();
    labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    labelText.setText(PARAMETER_NAME);
    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(!param.isReadOnly());
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(labelText);
    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);
    }
    if (openListTable != null) {
        data.right = new FormAttachment(openListTable, -5, SWT.LEFT);
    } else {
        data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
        lastDbControl = labelText;
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    hashCurControls.put(param.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return lastDbControl;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Text(org.eclipse.swt.widgets.Text) 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 9 with SelectAllTextControlCreator

use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.

the class DateController 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) {
    FormData data;
    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);
    }
    //$NON-NLS-1$
    Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    btnEdit.setData(NAME, DATE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);
    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);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("FileController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    dateText = (Text) dField.getControl();
    dateText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    dateText.setEditable(!param.isReadOnly());
    editionControlHelper.register(param.getName(), dateText);
    addDragAndDropTarget(dateText);
    if (elem instanceof Node) {
        dateText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    hashCurControls.put(param.getName(), dateText);
    // **************************
    data = new FormData();
    int currentLabelWidth = STANDARD_LABEL_WIDTH;
    GC gc = new GC(labelLabel);
    Point labelSize = gc.stringExtent(param.getDisplayName());
    gc.dispose();
    gc = new GC(dateText);
    // just an example of date //$NON-NLS-1$
    Point defaultDateDateSize = gc.stringExtent("\"2007-06-22 00:00:00\"");
    //$NON-NLS-1$
    Object paramValue = param.getValue() != null ? param.getValue() : "";
    // current value
    Point currentDateSize = gc.stringExtent((String) paramValue);
    gc.dispose();
    int currentDateWidth = defaultDateDateSize.x + ITabbedPropertyConstants.HSPACE + STANDARD_TEXT_WIDTH_ADDITION;
    if ((currentDateSize.x + ITabbedPropertyConstants.HSPACE + STANDARD_TEXT_WIDTH_ADDITION) > currentDateWidth) {
        currentDateWidth = currentDateSize.x + ITabbedPropertyConstants.HSPACE + STANDARD_TEXT_WIDTH_ADDITION;
    }
    dateText.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
    }
    data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
    data.right = new FormAttachment(labelLabel, currentDateWidth, SWT.RIGHT);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    cLayout.setLayoutData(data);
    data = new FormData();
    data.left = new FormAttachment(cLayout, 0, SWT.RIGHT);
    data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().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) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 10 with SelectAllTextControlCreator

use of org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator in project tdi-studio-se by Talend.

the class DbTableController 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) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    FormData data;
    this.paramFieldType = param.getFieldType();
    this.curParameter = param;
    Control lastDbControl = null;
    Button openListTable = null;
    if (!"DATABASE:CDC".equals(param.getFilter())) {
        //$NON-NLS-1$
        openListTable = addListTablesButton(subComposite, param, top, numInRow, nbInRow);
        lastDbControl = openListTable;
    }
    boolean isHive = false;
    //$NON-NLS-1$
    IElementParameter typePara = elem.getElementParameter("TYPE");
    if (typePara != null && "Hive".equalsIgnoreCase((String) typePara.getValue())) {
        //$NON-NLS-1$
        isHive = true;
    }
    Control openSqlBuilder = null;
    if (!isContainSqlMemo() && !"DATABASE:CDC".equals(param.getFilter()) && !isHive) {
        //$NON-NLS-1$
        openSqlBuilder = addOpenSqlBulderButton(subComposite, param, top, numInRow, nbInRow);
        FormData data1 = new FormData();
        data1.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
        data1.left = new FormAttachment(100, -(ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH));
        data1.top = new FormAttachment(0, top);
        data1.height = STANDARD_HEIGHT - 2;
        openSqlBuilder.setLayoutData(data1);
        //$NON-NLS-1$
        openSqlBuilder.setToolTipText(Messages.getString("DbTableController.openSQLBuilder"));
        lastDbControl = openSqlBuilder;
    }
    data = new FormData();
    if (openSqlBuilder != null) {
        data.right = new FormAttachment(openSqlBuilder, -5, SWT.LEFT);
        data.left = new FormAttachment(openSqlBuilder, -(15 + STANDARD_BUTTON_WIDTH), SWT.LEFT);
    } else {
        data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
        data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
    }
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    if (openListTable != null) {
        openListTable.setLayoutData(data);
        openListTable.setData(PARAMETER_NAME, param.getName());
        openListTable.setEnabled(!param.isReadOnly());
        openListTable.addSelectionListener(openTablesListener);
        //$NON-NLS-1$
        openListTable.setToolTipText(Messages.getString("DbTableController.showTableList"));
    }
    // TDI-25576 : just hide this button in Component View for Hive components , maybe later will remove this .
    if (isHive) {
        openListTable.setVisible(false);
    }
    Text labelText;
    final 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);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("TextController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    editionControlHelper.register(param.getName(), labelText);
    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(!param.isReadOnly());
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(labelText);
    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);
    }
    if (openListTable != null) {
        data.right = new FormAttachment(openListTable, -5, SWT.LEFT);
    } else {
        data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
        lastDbControl = labelText;
    }
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return lastDbControl;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Text(org.eclipse.swt.widgets.Text) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) IElementParameter(org.talend.core.model.process.IElementParameter) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)15 Point (org.eclipse.swt.graphics.Point)15 FormAttachment (org.eclipse.swt.layout.FormAttachment)15 FormData (org.eclipse.swt.layout.FormData)15 Control (org.eclipse.swt.widgets.Control)15 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)15 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)14 Node (org.talend.designer.core.ui.editor.nodes.Node)14 Text (org.eclipse.swt.widgets.Text)13 CLabel (org.eclipse.swt.custom.CLabel)12 Button (org.eclipse.swt.widgets.Button)12 GC (org.eclipse.swt.graphics.GC)11 IElementParameter (org.talend.core.model.process.IElementParameter)5 INode (org.talend.core.model.process.INode)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 FakeElement (org.talend.designer.core.model.FakeElement)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 Command (org.eclipse.gef.commands.Command)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1