Search in sources :

Example 36 with DecoratedField

use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.

the class DirectoryController method estimateRowSize.

/*
     * (non-Javadoc)
     *
     * @see org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#
     * estimateRowSize (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new TextControlCreator());
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) TextControlCreator(org.eclipse.jface.fieldassist.TextControlCreator) Point(org.eclipse.swt.graphics.Point)

Example 37 with DecoratedField

use of org.eclipse.jface.fieldassist.DecoratedField 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 38 with DecoratedField

use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.

the class DbTableController method addOpenSqlBulderButton.

/**
     * qzhang Comment method "addOpenSqlBulderButton".
     * 
     * @param subComposite
     * @param param
     * @param top
     * @param numInRow
     * @param nbInRow
     * @return
     */
private Control addOpenSqlBulderButton(Composite subComposite, IElementParameter param, int top, int numInRow, int nbInRow) {
    final DecoratedField dField1 = new DecoratedField(subComposite, SWT.PUSH, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new Button(parent, style);
        }
    });
    Control buttonControl = dField1.getLayoutControl();
    Button openSQLEditorButton = (Button) dField1.getControl();
    openSQLEditorButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    openSQLEditorButton.setImage(ImageProvider.getImage(ImageProvider.getImageDesc(EImage.READ_ICON)));
    buttonControl.setBackground(subComposite.getBackground());
    openSQLEditorButton.setEnabled(!param.isReadOnly());
    openSQLEditorButton.setData(NAME, SQLEDITOR);
    openSQLEditorButton.setData(PARAMETER_NAME, param.getName());
    if (param.getFieldType() == EParameterFieldType.DBTABLE) {
        openSQLEditorButton.setEnabled(ExtractMetaDataUtils.getInstance().haveLoadMetadataNode());
    }
    openSQLEditorButton.addSelectionListener(openSQLListener);
    return buttonControl;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) ErrorDialogWithDetailAreaAndContinueButton(org.talend.commons.ui.swt.dialogs.ErrorDialogWithDetailAreaAndContinueButton) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point)

Example 39 with DecoratedField

use of org.eclipse.jface.fieldassist.DecoratedField in project tdi-studio-se by Talend.

the class DbTypeListController method estimateRowSize.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractElementPropertySectionController#estimateRowSize
     * (org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter)
     */
@Override
public int estimateRowSize(Composite subComposite, IElementParameter param) {
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point)

Example 40 with DecoratedField

use of org.eclipse.jface.fieldassist.DecoratedField 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)

Aggregations

DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)67 Point (org.eclipse.swt.graphics.Point)66 Control (org.eclipse.swt.widgets.Control)45 FormData (org.eclipse.swt.layout.FormData)40 FormAttachment (org.eclipse.swt.layout.FormAttachment)36 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 Node (org.talend.designer.core.ui.editor.nodes.Node)32 CLabel (org.eclipse.swt.custom.CLabel)30 GC (org.eclipse.swt.graphics.GC)28 Button (org.eclipse.swt.widgets.Button)24 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)24 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)21 Composite (org.eclipse.swt.widgets.Composite)21 Text (org.eclipse.swt.widgets.Text)14 CCombo (org.eclipse.swt.custom.CCombo)12 TextControlCreator (org.eclipse.jface.fieldassist.TextControlCreator)10 INode (org.talend.core.model.process.INode)10 IElementParameter (org.talend.core.model.process.IElementParameter)6 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 RepositoryNode (org.talend.repository.model.RepositoryNode)4