Search in sources :

Example 1 with CLabel

use of org.eclipse.swt.custom.CLabel 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 CLabel

use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.

the class TreeTableController 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 parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControlPrm) {
    this.curParameter = param;
    this.paramFieldType = param.getFieldType();
    final Composite container = parentComposite;
    final TreeViewer viewer = new TreeViewer(container, SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setHeaderVisible(true);
    // key column
    TreeColumn column = new TreeColumn(viewer.getTree(), SWT.LEFT);
    column.setText("Key");
    column.setWidth(150);
    // columns for values
    if (param.getValue() != null) {
        List<Map<String, Object>> values = (List<Map<String, Object>>) param.getValue();
        for (int i = 0; i < values.size(); i++) {
            column = new TreeColumn(viewer.getTree(), SWT.LEFT);
            column.setText("Value" + i);
            column.setWidth(100);
        }
    }
    viewer.setContentProvider(new MyTreeContentProvider(param));
    viewer.setLabelProvider(new MyTableLableProvider(param));
    viewer.setInput(param);
    CLabel labelLabel2 = getWidgetFactory().createCLabel(container, param.getDisplayName());
    FormData formData = new FormData();
    if (lastControlPrm != null) {
        formData.left = new FormAttachment(lastControlPrm, 0);
    } else {
        formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
    }
    formData.top = new FormAttachment(0, top);
    labelLabel2.setLayoutData(formData);
    if (numInRow != 1) {
        labelLabel2.setAlignment(SWT.RIGHT);
    }
    // *********************
    formData = new FormData();
    int currentLabelWidth2 = STANDARD_LABEL_WIDTH;
    GC gc2 = new GC(labelLabel2);
    Point labelSize2 = gc2.stringExtent(param.getDisplayName());
    gc2.dispose();
    boolean needOffset = true;
    if ((labelSize2.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth2) {
        currentLabelWidth2 = labelSize2.x + ITabbedPropertyConstants.HSPACE;
        needOffset = false;
    }
    int tableHorizontalOffset = -5;
    if (numInRow == 1) {
        if (lastControlPrm != null) {
            if (needOffset) {
                formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2 + tableHorizontalOffset);
            } else {
                formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2);
            }
        } else {
            if (needOffset) {
                formData.left = new FormAttachment(0, currentLabelWidth2 + tableHorizontalOffset);
            } else {
                formData.left = new FormAttachment(0, currentLabelWidth2);
            }
        }
    } else {
        formData.left = new FormAttachment(labelLabel2, 0 + tableHorizontalOffset, SWT.RIGHT);
    }
    formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
    formData.top = new FormAttachment(0, top);
    int toolbarSize = 0;
    if (!param.isBasedOnSchema()) {
        Point size = viewer.getTree().computeSize(SWT.DEFAULT, SWT.DEFAULT);
        toolbarSize = size.y - 95;
    }
    int currentHeightEditor = viewer.getTree().getHeaderHeight() + param.getListItemsValue().length * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
    int minHeightEditor = viewer.getTree().getHeaderHeight() + getNumberLines(param) * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
    int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
    formData.bottom = new FormAttachment(0, top + ySize2);
    viewer.getTree().setLayoutData(formData);
    this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
    top += this.dynamicProperty.getCurRowSize();
    return null;
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) TreeColumn(org.eclipse.swt.widgets.TreeColumn) List(java.util.List) GC(org.eclipse.swt.graphics.GC) Map(java.util.Map) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with CLabel

use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.

the class DateSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    creationDate = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(33, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    creationDate.setLayoutData(data);
    creationDate.setEnabled(false);
    //$NON-NLS-1$
    CLabel creationLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DateSection.creationLabel"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(creationDate, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(creationDate, 0, SWT.CENTER);
    creationLabel.setLayoutData(data);
    //$NON-NLS-1$
    modificationDate = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(creationDate, STANDARD_LABEL_WIDTH + 15);
    data.right = new FormAttachment(66, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    modificationDate.setLayoutData(data);
    modificationDate.setEnabled(false);
    CLabel modificationLabel = getWidgetFactory().createCLabel(composite, //$NON-NLS-1$
    Messages.getString("DateSection.ModificationLabel"));
    data = new FormData();
    data.left = new FormAttachment(creationDate, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(modificationDate, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(modificationDate, 0, SWT.CENTER);
    modificationLabel.setLayoutData(data);
    //$NON-NLS-1$
    commitDate = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(modificationDate, STANDARD_LABEL_WIDTH + 15);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    commitDate.setLayoutData(data);
    commitDate.setEnabled(false);
    //$NON-NLS-1$
    commitLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DateSection.commitLabel"));
    data = new FormData();
    data.left = new FormAttachment(modificationDate, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(commitDate, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(commitDate, 0, SWT.CENTER);
    commitLabel.setLayoutData(data);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with CLabel

use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.

the class DescriptionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    descriptionText = getWidgetFactory().createText(composite, "", SWT.MULTI);
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    data.height = NB_LINES * descriptionText.getLineHeight();
    descriptionText.setLayoutData(data);
    addFocusListener(descriptionText);
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("DescriptionSection.Label"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(descriptionText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(descriptionText, 0, SWT.TOP);
    labelLabel.setLayoutData(data);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Composite(org.eclipse.swt.widgets.Composite) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 5 with CLabel

use of org.eclipse.swt.custom.CLabel in project tdi-studio-se by Talend.

the class NameSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    nameText = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(50, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    nameText.setLayoutData(data);
    addFocusListener(nameText);
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            IStatus status = evaluateTextField();
            if (status.getSeverity() == IStatus.ERROR) {
                errorLabel.setText(status.getMessage());
                errorLabel.setVisible(true);
            } else {
                errorLabel.setVisible(false);
            }
        }
    });
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("NameSection.Name"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(nameText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(nameText, 0, SWT.CENTER);
    labelLabel.setLayoutData(data);
    //$NON-NLS-1$
    errorLabel = getWidgetFactory().createCLabel(composite, "");
    data = new FormData();
    data.left = new FormAttachment(nameText, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(nameText, 0, SWT.CENTER);
    errorLabel.setLayoutData(data);
    errorLabel.setImage(ImageProvider.getImage(EImage.ERROR_ICON));
    errorLabel.setVisible(false);
    addFocusListenerToChildren(composite);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IStatus(org.eclipse.core.runtime.IStatus) ModifyListener(org.eclipse.swt.events.ModifyListener) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

CLabel (org.eclipse.swt.custom.CLabel)200 Composite (org.eclipse.swt.widgets.Composite)89 FormAttachment (org.eclipse.swt.layout.FormAttachment)84 FormData (org.eclipse.swt.layout.FormData)84 GridData (org.eclipse.swt.layout.GridData)84 Point (org.eclipse.swt.graphics.Point)77 GridLayout (org.eclipse.swt.layout.GridLayout)71 GC (org.eclipse.swt.graphics.GC)49 Node (org.talend.designer.core.ui.editor.nodes.Node)43 Button (org.eclipse.swt.widgets.Button)41 Control (org.eclipse.swt.widgets.Control)39 Label (org.eclipse.swt.widgets.Label)35 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)30 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)29 SelectionEvent (org.eclipse.swt.events.SelectionEvent)28 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)26 Text (org.eclipse.swt.widgets.Text)24 CCombo (org.eclipse.swt.custom.CCombo)18 INode (org.talend.core.model.process.INode)14 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)13