Search in sources :

Example 21 with FieldDecoration

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

the class OpenedListController 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) {
    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);
    }
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("ComboController.valueFromRepository"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    CCombo combo = (CCombo) dField.getControl();
    FormData data;
    combo.setItems(getListToDisplay(param));
    combo.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
    combo.setEnabled(!param.isReadOnly() && !param.isRepositoryValueUsed());
    cLayout.setBackground(subComposite.getBackground());
    combo.addSelectionListener(listenerSelection);
    combo.addModifyListener(modifySelection);
    combo.setData(PARAMETER_NAME, param.getName());
    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);
    // **********************
    hashCurControls.put(param.getName(), combo);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    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) 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 22 with FieldDecoration

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

the class MemoController 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();
    int nbLines = param.getNbLines();
    DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, 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();
    Text text = (Text) dField.getControl();
    editionControlHelper.register(param.getName(), text);
    FormData d = (FormData) text.getLayoutData();
    if (getAdditionalHeightSize() != 0) {
        nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    d.height = text.getLineHeight() * nbLines;
    FormData data;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof Text)) {
        text.setEnabled(!param.isReadOnly());
    } else {
        text.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
    }
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    String fontType = preferenceStore.getString(TalendDesignerPrefConstants.MEMO_TEXT_FONT);
    FontData fontData = new FontData(fontType);
    Font font = new Font(null, fontData);
    addResourceDisposeListener(text, font);
    text.setFont(font);
    if (elem instanceof Node) {
        text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);
    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.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);
    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) CLabel(org.eclipse.swt.custom.CLabel) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) FontData(org.eclipse.swt.graphics.FontData) 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) Point(org.eclipse.swt.graphics.Point) Font(org.eclipse.swt.graphics.Font) SelectAllTextControlCreator(org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator) Control(org.eclipse.swt.widgets.Control) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 23 with FieldDecoration

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

the class ProcessController method 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;
    IElementParameter processTypeParameter = param.getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
    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);
    }
    Control cLayout = dField.getLayoutControl();
    labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(false);
    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 + 1)), 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.right = new FormAttachment((numInRow * MAX_PERCENT) / (nbInRow + 1), 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Button btn;
    Point btnSize;
    //$NON-NLS-1$
    btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    btn.addSelectionListener(listenerSelection);
    //$NON-NLS-1$
    btn.setData(PARAMETER_NAME, param.getName() + ":" + processTypeParameter.getName());
    btn.setEnabled(!param.isReadOnly());
    data = new FormData();
    data.left = new FormAttachment(cLayout, 0);
    data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btn.setLayoutData(data);
    // **********************
    //$NON-NLS-1$
    hashCurControls.put(param.getName() + ":" + processTypeParameter.getName(), labelText);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    // feature 19312
    IElementParameter useDynamicJobParameter = param.getElement().getElementParameter(EParameterName.USE_DYNAMIC_JOB.getName());
    if (useDynamicJobParameter != null && useDynamicJobParameter instanceof IElementParameter) {
        Object useDynamicJobValue = useDynamicJobParameter.getValue();
        if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
            isSelectUseDynamic = (Boolean) useDynamicJobValue;
        }
    }
    Control lastControlUsed = btn;
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean allowVerchange = brandingService.getBrandingConfiguration().isAllowChengeVersion();
    if (allowVerchange) {
        lastControlUsed = addJobVersionCombo(subComposite, param.getChildParameters().get(EParameterName.PROCESS_TYPE_VERSION.getName()), lastControlUsed, numInRow + 1, nbInRow, top);
    }
    if (!isSelectUseDynamic) {
        addContextCombo(subComposite, param.getChildParameters().get(EParameterName.PROCESS_TYPE_CONTEXT.getName()), lastControlUsed, numInRow + 1, nbInRow, top);
    }
    dynamicProperty.setCurRowSize(Math.max(initialSize.y, btnSize.y) + ITabbedPropertyConstants.VSPACE);
    return btn;
}
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) RepositoryNode(org.talend.repository.model.RepositoryNode) Text(org.eclipse.swt.widgets.Text) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Point(org.eclipse.swt.graphics.Point) IBrandingService(org.talend.core.ui.branding.IBrandingService) 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) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 24 with FieldDecoration

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

the class AbstractSchemaController method addRepositoryChoice.

public Control addRepositoryChoice(Composite subComposite, Control lastControl, int numInRow, int nbInRow, int top, IElementParameter param) {
    FormData data;
    IElementParameter repositoryParameter = param.getChildParameters().get(getRepositoryChoiceParamName());
    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);
    }
    Control cLayout = dField.getLayoutControl();
    labelText = (Text) dField.getControl();
    labelText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    labelText.setEditable(false);
    if (elem instanceof Node) {
        labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    // *********************
    data = new FormData();
    data.left = new FormAttachment(lastControl, 0);
    data.right = new FormAttachment(lastControl, STANDARD_REPOSITORY_WIDTH, SWT.RIGHT);
    // data.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    Button btn;
    Point btnSize;
    //$NON-NLS-1$
    btn = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
    btnSize = btn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    btn.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
    btn.addSelectionListener(listenerSelection);
    btn.setData(NAME, REPOSITORY_CHOICE);
    btn.setData(PARAMETER_NAME, param.getName());
    btn.setEnabled(!param.isReadOnly());
    data = new FormData();
    data.left = new FormAttachment(cLayout, 0);
    data.right = new FormAttachment(cLayout, STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btn.setLayoutData(data);
    // **********************
    //$NON-NLS-1$
    hashCurControls.put(param.getName() + ":" + repositoryParameter.getName(), labelText);
    return btn;
}
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) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) 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 25 with FieldDecoration

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

the class AbstractLanguageMemoController 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();
    int nbLines = param.getNbLines();
    final String paramName = param.getName();
    Control cLayout;
    StyledText text;
    FormData data;
    viewer = null;
    if (param.getNbLines() != 1) {
        if (language.equals("java")) {
            //$NON-NLS-1$
            String context = param.getContext();
            if (!param.isNoCheck() && context != null && (context.equals("begin") || context.equals("main") || context.equals("end"))) {
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                Composite a = new Composite(subComposite, SWT.NO_FOCUS);
                a.setLayout(new FormLayout());
                Composite b = new Composite(a, SWT.NO_FOCUS);
                b.setLayout(new GridLayout());
                data = new FormData();
                data.left = new FormAttachment(0, 0);
                data.top = new FormAttachment(0, 0);
                data.right = new FormAttachment(100, 0);
                data.bottom = new FormAttachment(100, 0);
                b.setLayoutData(data);
                Process process = null;
                if (elem instanceof Node) {
                    process = (Process) ((Node) elem).getProcess();
                } else if (elem instanceof Connection) {
                    process = (Process) ((Connection) elem).getSource().getProcess();
                }
                TalendJavaEditor javaEditor = ((AbstractMultiPageTalendEditor) process.getEditor()).getCodeEditor();
                viewer = TalendJavaSourceViewer.createViewerForComponent(b, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, javaEditor, null, elem.getElementName(), context);
                text = viewer.getTextWidget();
                IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                Font font = new Font(text.getDisplay(), fontData);
                addResourceDisposeListener(text, font);
                text.setFont(font);
                text.setData(PARAMETER_NAME, param.getName());
                editionControlHelper.register(param.getName(), text);
                cLayout = a;
            } else {
                Composite a = new Composite(subComposite, SWT.NO_FOCUS);
                a.setLayout(new FormLayout());
                Composite b = new Composite(a, SWT.NO_FOCUS);
                b.setLayout(new GridLayout());
                data = new FormData();
                data.left = new FormAttachment(0, 0);
                data.top = new FormAttachment(0, 0);
                data.right = new FormAttachment(100, 0);
                data.bottom = new FormAttachment(100, 0);
                b.setLayoutData(data);
                if (isNeedToAddCodeGenerateButton()) {
                    addCodeGenerateButton(b);
                }
                Process process = null;
                if (elem instanceof Node) {
                    process = (Process) ((Node) elem).getProcess();
                } else if (elem instanceof Connection) {
                    Connection connection = (Connection) elem;
                    process = (Process) connection.getSource().getProcess();
                    // see bug 0001645
                    if (connection.getLineStyle().equals(EConnectionType.RUN_IF) || connection.getLineStyle().equals(EConnectionType.ROUTE_WHEN) || connection.getLineStyle().equals(EConnectionType.ROUTE_CATCH)) {
                        viewer = TalendJavaSourceViewer.createViewerForIfConnection(b);
                    }
                }
                if (viewer == null) {
                    viewer = TalendJavaSourceViewer.createViewer(b, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP, false);
                }
                text = viewer.getTextWidget();
                IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                Font font = new Font(text.getDisplay(), fontData);
                addResourceDisposeListener(text, font);
                text.setFont(font);
                text.setData(PARAMETER_NAME, param.getName());
                editionControlHelper.register(param.getName(), text);
                cLayout = a;
            }
        } else {
            Composite a = new Composite(subComposite, SWT.NO_FOCUS);
            a.setLayout(new FormLayout());
            Composite b = new Composite(a, SWT.NO_FOCUS);
            b.setLayout(new GridLayout());
            data = new FormData();
            data.left = new FormAttachment(0, 0);
            data.top = new FormAttachment(0, 0);
            data.right = new FormAttachment(100, 0);
            data.bottom = new FormAttachment(100, 0);
            b.setLayoutData(data);
            if (isNeedToAddCodeGenerateButton()) {
                addCodeGenerateButton(b);
            }
            text = viewer.getTextWidget();
            IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
            FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.MEMO_TEXT_FONT);
            Font font = new Font(text.getDisplay(), fontData);
            addResourceDisposeListener(text, font);
            text.setFont(font);
            Process process = null;
            if (elem instanceof Node) {
                process = (Process) ((Node) elem).getProcess();
            } else if (elem instanceof Connection) {
                process = (Process) ((Connection) elem).getSource().getProcess();
            }
            text.setData(PARAMETER_NAME, param.getName());
            editionControlHelper.register(param.getName(), text);
            cLayout = a;
        }
    } else {
        IControlCreator txtCtrl = new IControlCreator() {

            @Override
            public Control createControl(final Composite parent, final int style) {
                final StyledText control = new ColorStyledText(parent, style, CorePlugin.getDefault().getPreferenceStore(), language);
                Display display = Display.getCurrent();
                if (display == null) {
                    display = Display.getDefault();
                }
                if (display != null) {
                    display.syncExec(new Runnable() {

                        @Override
                        public void run() {
                            IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
                            FontData fontData = PreferenceConverter.getFontData(preferenceStore, TalendDesignerPrefConstants.MEMO_TEXT_FONT);
                            Font font = new Font(parent.getDisplay(), fontData);
                            addResourceDisposeListener(control, font);
                            control.setFont(font);
                        }
                    });
                }
                return control;
            }
        };
        DecoratedField dField = null;
        dField = new DecoratedField(subComposite, SWT.BORDER | SWT.WRAP, txtCtrl);
        cLayout = dField.getLayoutControl();
        text = (StyledText) dField.getControl();
        data = (FormData) text.getLayoutData();
        editionControlHelper.register(param.getName(), text);
        if (param.isRequired()) {
            FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
            dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
        }
    }
    if (getAdditionalHeightSize() != 0) {
        nbLines += this.getAdditionalHeightSize() / text.getLineHeight();
    }
    data.height = text.getLineHeight() * nbLines;
    text.getParent().setSize(subComposite.getSize().x, text.getLineHeight() * nbLines);
    cLayout.setBackground(subComposite.getBackground());
    // for bug 7580
    if (!(text instanceof ReconcilerStyledText)) {
        text.setEnabled(!param.isReadOnly());
    } else {
        text.setEditable(!param.isReadOnly());
    }
    if (elem instanceof Node) {
        text.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    addDragAndDropTarget(text);
    // IDocument document = viewer.getDocument();
    // if (document != null) {
    // Process pro = null;
    // if (elem instanceof Node) {
    // pro = (Process) ((Node) elem).getProcess();
    // } else if (elem instanceof Connection) {
    // pro = (Process) ((Connection) elem).getSource().getProcess();
    // }
    // final Process process = pro;
    // document.addDocumentListener(new IDocumentListener() {
    //
    // public void documentChanged(DocumentEvent event) {
    // if (!process.isReadOnly())
    // ContextParameterExtractor.saveContext(paramName, elem, viewer.getTextWidget().getText(), process);
    // }
    //
    // public void documentAboutToBeChanged(DocumentEvent event) {
    // // nothing to do
    // }
    // });
    //
    // }
    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.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    data.top = new FormAttachment(0, top);
    cLayout.setLayoutData(data);
    // **********************
    hashCurControls.put(param.getName(), text);
    Point initialSize = cLayout.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return null;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) TalendJavaEditor(org.talend.designer.core.ui.editor.TalendJavaEditor) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Node(org.talend.designer.core.ui.editor.nodes.Node) Process(org.talend.designer.core.ui.editor.process.Process) DecoratedField(org.eclipse.jface.fieldassist.DecoratedField) Font(org.eclipse.swt.graphics.Font) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) FormLayout(org.eclipse.swt.layout.FormLayout) StyledText(org.eclipse.swt.custom.StyledText) ColorStyledText(org.talend.commons.ui.swt.colorstyledtext.ColorStyledText) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) Composite(org.eclipse.swt.widgets.Composite) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) FontData(org.eclipse.swt.graphics.FontData) Connection(org.talend.designer.core.ui.editor.connections.Connection) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ReconcilerStyledText(org.talend.designer.core.ui.viewer.ReconcilerStyledText) Display(org.eclipse.swt.widgets.Display)

Aggregations

FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)37 FormAttachment (org.eclipse.swt.layout.FormAttachment)34 FormData (org.eclipse.swt.layout.FormData)34 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)33 Point (org.eclipse.swt.graphics.Point)33 Control (org.eclipse.swt.widgets.Control)33 Node (org.talend.designer.core.ui.editor.nodes.Node)31 CLabel (org.eclipse.swt.custom.CLabel)28 GC (org.eclipse.swt.graphics.GC)27 Button (org.eclipse.swt.widgets.Button)20 Text (org.eclipse.swt.widgets.Text)14 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)14 CCombo (org.eclipse.swt.custom.CCombo)12 Composite (org.eclipse.swt.widgets.Composite)10 INode (org.talend.core.model.process.INode)9 IControlCreator (org.eclipse.jface.fieldassist.IControlCreator)7 ModifyEvent (org.eclipse.swt.events.ModifyEvent)5 ModifyListener (org.eclipse.swt.events.ModifyListener)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5