Search in sources :

Example 46 with DecoratedField

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

the class AS400CheckController 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(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
    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);
        }
    });
    if (param.isRepositoryValueUsed()) {
        FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
        //$NON-NLS-1$
        decoration.setDescription(Messages.getString("CheckController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    cLayout.setBackground(subComposite.getBackground());
    Button checkBtn = (Button) dField.getControl();
    FormData data = new FormData();
    data.top = new FormAttachment(0, top);
    if (lastControl != null) {
        data.left = new FormAttachment(lastControl, 0);
    } else {
        data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    cLayout.setLayoutData(data);
    hashCurControls.put(param.getName(), checkBtn);
    checkBtn.setEnabled(!param.isReadOnly());
    String propertyType = (String) elem.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
    if (propertyType.equals(EmfComponent.REPOSITORY)) {
        IProxyRepositoryFactory factory = DesignerPlugin.getDefault().getProxyRepositoryFactory();
        List<ConnectionItem> metadataConnectionsItem = null;
        try {
            metadataConnectionsItem = factory.getMetadataConnectionsItem();
        } catch (PersistenceException e) {
            throw new RuntimeException(e);
        }
        if (metadataConnectionsItem != null) {
            for (ConnectionItem connectionItem : metadataConnectionsItem) {
                //$NON-NLS-1$
                String value = connectionItem.getProperty().getId() + "";
                if (value.equals(elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()))) {
                    boolean b = getConnection(connectionItem).isStandardSQL();
                    checkBtn.setSelection(b);
                }
            }
        }
    } else {
        boolean b = CoreUIPlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.AS400_SQL_SEG);
        checkBtn.setSelection(b);
    }
    if (elem instanceof Node) {
        checkBtn.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    Point initialSize = checkBtn.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}
Also used : FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) ConnectionItem(org.talend.core.model.properties.ConnectionItem) 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) IControlCreator(org.eclipse.jface.fieldassist.IControlCreator) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) PersistenceException(org.talend.commons.exception.PersistenceException) FormAttachment(org.eclipse.swt.layout.FormAttachment) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 47 with DecoratedField

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

the class RadioController 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) {
    final DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new IControlCreator() {

        public Control createControl(Composite parent, int style) {
            return getWidgetFactory().createButton(parent, param.getDisplayName(), SWT.RADIO);
        }
    });
    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)

Example 48 with DecoratedField

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

the class ModuleListController 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("!!")) {
        //$NON-NLS-1$
        if (param.getFieldType() == EParameterFieldType.MODULE_LIST) {
            param.setDisplayName(EParameterName.MODULE_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();
    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());
    FormData 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);
    //$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(cLayout, 0, SWT.RIGHT);
    data.right = new FormAttachment(cLayout, ITabbedPropertyConstants.HSPACE + STANDARD_BUTTON_WIDTH, SWT.RIGHT);
    data.top = new FormAttachment(0, top);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, MODULE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(!param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);
    // **********************
    hashCurControls.put(param.getName(), combo);
    hashCurControls.put(param.getName() + BUTTON_EDIT, btnEdit);
    updateData();
    // this.dynamicTabbedPropertySection.updateColumnList(null);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return cLayout;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) FormData(org.eclipse.swt.layout.FormData) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) FieldDecoration(org.eclipse.jface.fieldassist.FieldDecoration) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) 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 49 with DecoratedField

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

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

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