Search in sources :

Example 41 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class XmlComboCellEditor method createControl.

@Override
protected Control createControl(Composite parent) {
    Control control = super.createControl(parent);
    CCombo combo = (CCombo) control;
    combo.addSelectionListener(new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent event) {
        // applyEditorValueAndDeactivate();
        }

        public void widgetSelected(SelectionEvent event) {
            valueChanged(true, true);
        }
    });
    return control;
}
Also used : Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 42 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class StatusDialog method setErrorMessage.

public void setErrorMessage(String errorMessage) {
    if (errorMessageText != null && !errorMessageText.isDisposed()) {
        //$NON-NLS-1$
        errorMessageText.setText(errorMessage == null ? "" : errorMessage);
        errorMessageText.getParent().update();
        // Access the ok button by id, in case clients have overridden button creation.
        // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
            button.setEnabled(errorMessage == null);
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control)

Example 43 with Control

use of org.eclipse.swt.widgets.Control 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 44 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class JobSettingsView method cleanDisplay.

@Override
public void cleanDisplay() {
    setPartName(null);
    tabFactory.setInput(null);
    tabFactory.setTitle(null, null);
    if (tabFactory.getTabComposite() != null) {
        for (Control curControl : tabFactory.getTabComposite().getChildren()) {
            curControl.setVisible(false);
            curControl.dispose();
        }
    }
    this.currentSelectedTab = null;
    this.element = null;
    this.cleaned = true;
    this.selectedPrimary = true;
    process = null;
}
Also used : Control(org.eclipse.swt.widgets.Control)

Example 45 with Control

use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.

the class JobSettingsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // tabFactory = new HorizontalTabFactory();
    this.parent = parent;
    tabFactory.initComposite(parent, false);
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null) {
                if ((!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getData() != descriptor.getData() || currentSelectedTab.getCategory() != descriptor.getCategory())) {
                    for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                        curControl.dispose();
                    }
                }
            }
            if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                Object data = descriptor.getData();
                if (data instanceof Element) {
                    element = (Element) data;
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), element, descriptor.getCategory());
                } else if (data instanceof IRepositoryViewObject) {
                    IRepositoryViewObject viewObject = (IRepositoryViewObject) data;
                    IProcess process = getProcess(viewObject);
                    if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
                        data = process;
                    }
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), data, descriptor.getCategory());
                } else if (data instanceof IEditorPart) {
                    currentSelectedTab = descriptor;
                    IRepositoryViewObject repObj = retrieveBusiness((IEditorPart) data);
                    if (repObj != null) {
                        IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), repObj, descriptor.getCategory());
                    }
                } else {
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), null, descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Aggregations

Control (org.eclipse.swt.widgets.Control)475 Point (org.eclipse.swt.graphics.Point)149 Composite (org.eclipse.swt.widgets.Composite)141 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)93 Label (org.eclipse.swt.widgets.Label)73 GridLayout (org.eclipse.swt.layout.GridLayout)71 Text (org.eclipse.swt.widgets.Text)70 FormData (org.eclipse.swt.layout.FormData)62 FormAttachment (org.eclipse.swt.layout.FormAttachment)61 Node (org.talend.designer.core.ui.editor.nodes.Node)46 DecoratedField (org.eclipse.jface.fieldassist.DecoratedField)45 SelectionEvent (org.eclipse.swt.events.SelectionEvent)44 StyledText (org.eclipse.swt.custom.StyledText)42 GC (org.eclipse.swt.graphics.GC)41 CLabel (org.eclipse.swt.custom.CLabel)38 ArrayList (java.util.ArrayList)36 Shell (org.eclipse.swt.widgets.Shell)35 FieldDecoration (org.eclipse.jface.fieldassist.FieldDecoration)33 CCombo (org.eclipse.swt.custom.CCombo)32