Search in sources :

Example 1 with DecoratedField

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

the class TextController 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;
    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 (canAddRepositoryDecoration(param)) {
        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();
    Text labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    editionControlHelper.register(param.getName(), labelText);
    cLayout.setBackground(subComposite.getBackground());
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    if (!isReadOnly()) {
        if (param.isRepositoryValueUsed() && !(elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement)) {
            addRepositoryPropertyListener(labelText);
        }
        if (param.isRequired()) {
            labelText.addModifyListener(new ModifyListener() {

                @Override
                public void modifyText(ModifyEvent e) {
                    checkTextError(param, labelText, labelText.getText());
                }
            });
        }
        boolean editable = !param.isReadOnly() && (elem instanceof FakeElement || !param.isRepositoryValueUsed());
        labelText.setEditable(editable);
    } else {
        labelText.setEditable(false);
    }
    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);
    // *********************
    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 * 2)) > currentLabelWidth) {
        currentLabelWidth = labelSize.x + (ITabbedPropertyConstants.HSPACE * 2);
    }
    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((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), labelText);
    Point initialSize = cLayout.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    if (isInWizard()) {
        labelLabel.setAlignment(SWT.RIGHT);
        if (lastControl != null) {
            data.right = new FormAttachment(lastControl, 0);
        } else {
            data.right = new FormAttachment(100, -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 cLayout;
}
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) 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) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ImplicitContextLoadElement(org.talend.designer.core.ui.projectsetting.ImplicitContextLoadElement) GC(org.eclipse.swt.graphics.GC) StatsAndLogsElement(org.talend.designer.core.ui.projectsetting.StatsAndLogsElement) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 2 with DecoratedField

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

the class TextController 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) {
    if (!estimateInitialized) {
        final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new TextControlCreator());
        Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
        dField.getLayoutControl().dispose();
        rowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
        estimateInitialized = true;
    }
    return rowSize;
}
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 3 with DecoratedField

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

the class VersionController 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();
    Button btnUp, btnDown;
    //$NON-NLS-1$
    btnUp = getWidgetFactory().createButton(subComposite, "M", SWT.PUSH);
    Point btnUpSize = btnUp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    btnUp.dispose();
    //$NON-NLS-1$
    btnDown = getWidgetFactory().createButton(subComposite, "m", SWT.PUSH);
    Point btnDownSize = btnDown.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    btnDown.dispose();
    Point btnSize = new Point(Math.max(btnUpSize.x, btnDownSize.x), Math.max(btnUpSize.y, btnDownSize.y));
    return Math.max(btnSize.y, initialSize.y) + ITabbedPropertyConstants.VSPACE;
}
Also used : Button(org.eclipse.swt.widgets.Button) 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 4 with DecoratedField

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

the class SqlMemoController 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) {
    IControlCreator txtCtrl = new IControlCreator() {

        @Override
        public Control createControl(final Composite parent, final int style) {
            return createColorStyledText(parent, style);
        }
    };
    DecoratedField dField = null;
    if (param.getNbLines() != 1) {
        dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, txtCtrl);
    } else {
        dField = new DecoratedField(subComposite, SWT.BORDER, txtCtrl);
    }
    ColorStyledText text = (ColorStyledText) dField.getControl();
    FormData d = (FormData) text.getLayoutData();
    d.height = text.getLineHeight() * param.getNbLines();
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * param.getNbLines());
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : FormData(org.eclipse.swt.layout.FormData) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)

Example 5 with DecoratedField

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

the class AS400CheckController 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, final IElementParameter param) {
    // TODO Auto-generated method stub
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        @Override
        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, param.getDisplayName(), SWT.CHECK);
        }
    });
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dField.getLayoutControl().dispose();
    return initialSize.y + ITabbedPropertyConstants.VSPACE;
}
Also used : IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)69 Point (org.eclipse.swt.graphics.Point)68 Control (org.eclipse.swt.widgets.Control)46 FormData (org.eclipse.swt.layout.FormData)41 FormAttachment (org.eclipse.swt.layout.FormAttachment)37 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)34 Node (org.talend.designer.core.ui.editor.nodes.Node)33 CLabel (org.eclipse.swt.custom.CLabel)31 GC (org.eclipse.swt.graphics.GC)29 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)26 Button (org.eclipse.swt.widgets.Button)25 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)21 Composite (org.eclipse.swt.widgets.Composite)21 Text (org.eclipse.swt.widgets.Text)15 CCombo (org.eclipse.swt.custom.CCombo)12 TextControlCreator (org.eclipse.jface.fieldassist.TextControlCreator)11 INode (org.talend.core.model.process.INode)11 IElementParameter (org.talend.core.model.process.IElementParameter)6 ColorStyledText (org.talend.commons.ui.swt.colorstyledtext.ColorStyledText)5 RepositoryNode (org.talend.repository.model.RepositoryNode)4