Search in sources :

Example 46 with CLabel

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

the class TextNotePropertySection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    text = getWidgetFactory().createText(composite, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    // 5 lines
    data.height = 5 * text.getLineHeight();
    text.setLayoutData(data);
    //$NON-NLS-1$
    CLabel labelLabel = getWidgetFactory().createCLabel(composite, Messages.getString("TextNoteSection.Label"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(text, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(text, 0, SWT.TOP);
    labelLabel.setLayoutData(data);
    text.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!text.getText().equals(note.getText())) {
                ChangeNoteTextCommand command = new ChangeNoteTextCommand(note, text.getText());
                getCommandStack().execute(command);
            }
        }
    });
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) FocusEvent(org.eclipse.swt.events.FocusEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) ChangeNoteTextCommand(org.talend.designer.core.ui.editor.cmd.ChangeNoteTextCommand)

Example 47 with CLabel

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

the class PurposeStatusSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    Composite composite = getWidgetFactory().createFlatFormComposite(parent);
    FormData data;
    //$NON-NLS-1$
    purposeText = getWidgetFactory().createText(composite, "");
    data = new FormData();
    data.left = new FormAttachment(0, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(70, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    purposeText.setLayoutData(data);
    addFocusListener(purposeText);
    //$NON-NLS-1$
    CLabel purposeLabel = getWidgetFactory().createCLabel(composite, Messages.getString("PurposeStatusSection.purposeLabel"));
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(purposeText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(purposeText, 0, SWT.CENTER);
    purposeLabel.setLayoutData(data);
    //$NON-NLS-1$
    statusText = getWidgetFactory().createCCombo(composite, SWT.READ_ONLY | SWT.BORDER);
    data = new FormData();
    data.left = new FormAttachment(purposeText, STANDARD_LABEL_WIDTH);
    data.right = new FormAttachment(100, 0);
    data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
    statusText.setLayoutData(data);
    addFocusListener(statusText);
    // addComboFieldListeners(statusText, new ModifyListener() {
    // public void modifyText(ModifyEvent e) {
    // if (enableListener)
    // needSave = true;
    // }}, true);
    //$NON-NLS-1$
    CLabel statusLabel = getWidgetFactory().createCLabel(composite, Messages.getString("PurposeStatusSection.statusLabel"));
    data = new FormData();
    data.left = new FormAttachment(purposeText, ITabbedPropertyConstants.HSPACE * 3);
    data.right = new FormAttachment(statusText, -ITabbedPropertyConstants.HSPACE);
    data.top = new FormAttachment(statusText, 0, SWT.CENTER);
    statusLabel.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 48 with CLabel

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

the class GenerateSurvivorshipRulesController 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(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    Button btnEdit;
    //$NON-NLS-1$
    btnEdit = getWidgetFactory().createButton(subComposite, null, SWT.PUSH);
    //$NON-NLS-1$
    btnEdit.setImage(ImageProvider.getImage(DesignerPlugin.getImageDescriptor("icons/survivorship_generate.gif")));
    FormData data;
    btnEdit.addSelectionListener(listenerSelection);
    if (elem instanceof Node) {
        btnEdit.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    //$NON-NLS-1$
    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);
            data.right = new FormAttachment(lastControl, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        } else {
            data.left = new FormAttachment(0, currentLabelWidth);
            data.right = new FormAttachment(0, currentLabelWidth + STANDARD_BUTTON_WIDTH + 8);
        }
    } else {
        data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
        data.right = new FormAttachment(labelLabel, STANDARD_BUTTON_WIDTH + 8, SWT.RIGHT);
    }
    data.top = new FormAttachment(0, top);
    btnEdit.setLayoutData(data);
    // **************************
    hashCurControls.put(param.getName(), btnEdit);
    Point initialSize = btnEdit.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return btnEdit;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Button(org.eclipse.swt.widgets.Button) Node(org.talend.designer.core.ui.editor.nodes.Node) 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 CLabel

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

the class FileController 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.setDragAndDropActionBool();
    this.curParameter = param;
    FormData data;
    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);
    }
    //$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(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
    data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    data.height = STANDARD_HEIGHT - 2;
    btnEdit.setLayoutData(data);
    btnEdit.setData(NAME, FILE);
    btnEdit.setData(PARAMETER_NAME, param.getName());
    btnEdit.setEnabled(dragAndDropActionBool == true || !param.isReadOnly());
    btnEdit.addSelectionListener(listenerSelection);
    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("FileController.decoration.description"));
        dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
    }
    Control cLayout = dField.getLayoutControl();
    Text filePathText = (Text) dField.getControl();
    filePathText.setData(PARAMETER_NAME, param.getName());
    cLayout.setBackground(subComposite.getBackground());
    editionControlHelper.register(param.getName(), filePathText);
    if (!elem.isReadOnly()) {
        if (param.isRepositoryValueUsed() && dragAndDropActionBool == false) {
            addRepositoryPropertyListener(filePathText);
        }
        filePathText.setEditable(dragAndDropActionBool == true || !param.isRepositoryValueUsed() && !(elem instanceof FakeElement) || !param.isReadOnly() && elem instanceof FakeElement);
    } else {
        filePathText.setEditable(dragAndDropActionBool == true || false);
    }
    addDragAndDropTarget(filePathText);
    if (elem instanceof Node) {
        filePathText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
    }
    hashCurControls.put(param.getName(), filePathText);
    // **************************
    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(btnEdit, 0);
    data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
    cLayout.setLayoutData(data);
    Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    if (isInWizard()) {
        labelLabel.setAlignment(SWT.RIGHT);
        if (lastControl != null) {
            data.right = new FormAttachment(lastControl, -STANDARD_BUTTON_WIDTH);
        } else {
            data.right = new FormAttachment(100, -STANDARD_BUTTON_WIDTH - 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 btnEdit;
}
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) 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) Button(org.eclipse.swt.widgets.Button) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 50 with CLabel

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

the class EncodingTypeController 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(Composite subComposite, IElementParameter param, int numInRow, int nbInRow, int top, Control lastControl) {
    CCombo combo;
    Control lastControlUsed = lastControl;
    combo = new CCombo(subComposite, SWT.BORDER);
    IElementParameter encodingTypeParameter = param.getChildParameters().get(EParameterName.ENCODING_TYPE.getName());
    // see 10693 ,only for component tChangeFileEncoding
    if ("INENCODING".equals(param.getName())) {
        addEncodingType(encodingTypeParameter);
    }
    FormData data;
    String[] originalList = encodingTypeParameter.getListItemsDisplayName();
    List<String> stringToDisplay = new ArrayList<String>();
    String[] itemsShowIf = encodingTypeParameter.getListItemsShowIf();
    if (itemsShowIf != null) {
        String[] itemsNotShowIf = encodingTypeParameter.getListItemsNotShowIf();
        for (int i = 0; i < originalList.length; i++) {
            if (encodingTypeParameter.isShow(itemsShowIf[i], itemsNotShowIf[i], elem.getElementParameters())) {
                stringToDisplay.add(originalList[i]);
            }
        }
    } else {
        for (int i = 0; i < originalList.length; i++) {
            stringToDisplay.add(originalList[i]);
        }
    }
    combo.setItems(stringToDisplay.toArray(new String[0]));
    combo.setEditable(false);
    combo.setEnabled(!encodingTypeParameter.isReadOnly() && !encodingTypeParameter.isRepositoryValueUsed());
    combo.setData(PARAMETER_NAME, param.getName());
    if (elem instanceof Node) {
        combo.setToolTipText(VARIABLE_TOOLTIP + encodingTypeParameter.getVariableName());
    }
    CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, encodingTypeParameter.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(encodingTypeParameter.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);
    combo.setLayoutData(data);
    combo.addSelectionListener(selectionChangeListener);
    lastControlUsed = combo;
    String tempValue = (String) param.getValue();
    //$NON-NLS-1$ //$NON-NLS-2$
    tempValue = tempValue.replaceAll("'", "");
    //$NON-NLS-1$ //$NON-NLS-2$
    tempValue = tempValue.replaceAll("\"", "");
    if (!ArrayUtils.contains(encodingTypeParameter.getListItemsValue(), tempValue)) {
        encodingTypeParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
    }
    String encodingType = (String) encodingTypeParameter.getValue();
    if (encodingType != null && encodingType.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) {
        lastControlUsed = addCustomEncodingTypeText(subComposite, param, lastControlUsed, numInRow, nbInRow, top);
    }
    // **********************
    hashCurControls.put(param.getName() + NAME_SEPARATOR + encodingTypeParameter.getName(), combo);
    Point initialSize = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
    return lastControlUsed;
}
Also used : FormData(org.eclipse.swt.layout.FormData) CLabel(org.eclipse.swt.custom.CLabel) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) IElementParameter(org.talend.core.model.process.IElementParameter) GC(org.eclipse.swt.graphics.GC) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

CLabel (org.eclipse.swt.custom.CLabel)82 Point (org.eclipse.swt.graphics.Point)56 FormAttachment (org.eclipse.swt.layout.FormAttachment)56 FormData (org.eclipse.swt.layout.FormData)56 GC (org.eclipse.swt.graphics.GC)43 Node (org.talend.designer.core.ui.editor.nodes.Node)42 Control (org.eclipse.swt.widgets.Control)37 Button (org.eclipse.swt.widgets.Button)31 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)29 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)28 Composite (org.eclipse.swt.widgets.Composite)27 CCombo (org.eclipse.swt.custom.CCombo)17 GridData (org.eclipse.swt.layout.GridData)14 INode (org.talend.core.model.process.INode)13 GridLayout (org.eclipse.swt.layout.GridLayout)12 Text (org.eclipse.swt.widgets.Text)12 SelectAllTextControlCreator (org.talend.designer.core.ui.editor.properties.controllers.creator.SelectAllTextControlCreator)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Label (org.eclipse.swt.widgets.Label)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9