Search in sources :

Example 41 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project tdi-studio-se by Talend.

the class ConfigureConnParamDialog method createFileComponent.

/**
     * qiang.zhang Comment method "createFileComponent".
     * 
     * @param key
     * @param defaultContext
     */
private void createFileComponent(final EConnectionParameterName key, IContext defaultContext) {
    GridLayout gridLayout;
    GridData gridData;
    Composite hostComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 2;
    gridLayout.marginTop = 5;
    gridLayout.marginBottom = 2;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostComposite.setLayout(gridLayout);
    hostComposite.setLayoutData(gridData);
    Label hostLabel = new Label(hostComposite, SWT.NONE);
    //$NON-NLS-1$
    hostLabel.setText(key.getDisplayName() + ":");
    // GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(hostLabel);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    hostLabel.setLayoutData(data);
    Composite fileComposite = new Composite(hostComposite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    fileComposite.setLayout(gridLayout);
    fileComposite.setLayoutData(gridData);
    final Text host = new Text(fileComposite, SWT.BORDER);
    host.setText(pvValues.get(key));
    if (host.getText().trim().length() == 0) {
        host.setBackground(ColorConstants.red);
        host.redraw();
    }
    // GridDataFactory.swtDefaults().hint(TEXT_DEFAULT_X, DEFAULT_HEIGHT).applyTo(host);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    host.setLayoutData(gridData);
    Button button = new Button(fileComposite, SWT.PUSH);
    //$NON-NLS-1$
    button.setText("...");
    button.addSelectionListener(new SelectionListener() {

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(mainComposite.getShell(), SWT.NONE);
            String path = PathExtractor.extractPath(host.getText());
            dialog.setFileName(PathUtils.getOSPath(path));
            String file = dialog.open();
            if (file != null) {
                if (!file.equals("")) {
                    //$NON-NLS-1$
                    host.setText(PathUtils.getPortablePath(file));
                }
            }
        }
    });
    final Text hostText = new Text(hostComposite, SWT.NONE);
    hostText.setEditable(false);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostText.setLayoutData(gridData);
    hostText.setText(CONTEXT_WITH + ContextParameterUtils.parseScriptContextCode(host.getText(), defaultContext));
    host.setData(TEXT_CONTROL, hostText);
    host.setData(key);
    allParamText.add(host);
    host.addModifyListener(new ModifyListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
        @Override
        public void modifyText(ModifyEvent e) {
            if (isRequriedValue(key.getName())) {
                if (host.getText().trim().length() == 0) {
                    host.setBackground(ColorConstants.red);
                    host.redraw();
                } else {
                    host.setBackground(ColorConstants.white);
                    host.redraw();
                }
                resetValues(host, hostText);
            }
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 42 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project tdi-studio-se by Talend.

the class ConfigureConnParamDialog method createDirectoryComponent.

/**
     * qiang.zhang Comment method "createDirectoryComponent".
     * 
     * @param key
     * @param defaultContext
     */
private void createDirectoryComponent(final EConnectionParameterName key, IContext defaultContext) {
    GridLayout gridLayout;
    GridData gridData;
    Composite hostComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 2;
    gridLayout.marginTop = 5;
    gridLayout.marginBottom = 2;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostComposite.setLayout(gridLayout);
    hostComposite.setLayoutData(gridData);
    Label hostLabel = new Label(hostComposite, SWT.NONE);
    //$NON-NLS-1$
    hostLabel.setText(key.getDisplayName() + ":");
    // GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(hostLabel);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    hostLabel.setLayoutData(data);
    Composite fileComposite = new Composite(hostComposite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.verticalSpacing = 0;
    gridLayout.marginTop = 0;
    gridLayout.marginBottom = 0;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    fileComposite.setLayout(gridLayout);
    fileComposite.setLayoutData(gridData);
    final Text host = new Text(fileComposite, SWT.BORDER);
    host.setText(pvValues.get(key));
    if (host.getText().trim().length() == 0) {
        host.setBackground(ColorConstants.red);
        host.redraw();
    }
    // GridDataFactory.swtDefaults().hint(TEXT_DEFAULT_X, DEFAULT_HEIGHT).applyTo(host);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    host.setLayoutData(gridData);
    Button button = new Button(fileComposite, SWT.PUSH);
    //$NON-NLS-1$
    button.setText("...");
    button.addSelectionListener(new SelectionListener() {

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dialog = new DirectoryDialog(mainComposite.getShell(), SWT.NONE);
            String path = PathExtractor.extractPath(host.getText());
            dialog.setFilterPath(PathUtils.getOSPath(path));
            String file = dialog.open();
            if (file != null) {
                if (!file.equals("")) {
                    //$NON-NLS-1$
                    host.setText(PathUtils.getPortablePath(file));
                }
            }
        }
    });
    final Text hostText = new Text(hostComposite, SWT.NONE);
    hostText.setEditable(false);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostText.setLayoutData(gridData);
    hostText.setText(CONTEXT_WITH + ContextParameterUtils.parseScriptContextCode(host.getText(), defaultContext));
    host.setData(TEXT_CONTROL, hostText);
    host.setData(key);
    allParamText.add(host);
    host.addModifyListener(new ModifyListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
        @Override
        public void modifyText(ModifyEvent e) {
            if (isRequriedValue(key.getName())) {
                if (host.getText().trim().length() == 0) {
                    host.setBackground(ColorConstants.red);
                    host.redraw();
                } else {
                    host.setBackground(ColorConstants.white);
                    host.redraw();
                }
                resetValues(host, hostText);
            }
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 43 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project tdi-studio-se by Talend.

the class MapperUI method configureZoneScrollBars.

private void configureZoneScrollBars(final Display display) {
    vBar1 = sc1.getVerticalBar();
    vBar2 = sc2.getVerticalBar();
    vBar3 = sc3.getVerticalBar();
    vBar1.setIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    vBar2.setIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    vBar3.setIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    vBar1.setPageIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    vBar2.setPageIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    vBar3.setPageIncrement(INCREMENT_VERTICAL_SCROLLBAR_ZONE);
    SelectionListener scrollListener = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (event.detail == SWT.NONE) {
                mouseMoveScrollZoneHelper.mouseDownOnScroll = false;
                mouseMoveScrollZoneHelper.scrolling = false;
                updateBackground(false, true);
            } else {
                mouseMoveScrollZoneHelper.mouseDownOnScroll = true;
                mouseMoveScrollZoneHelper.scrolling = true;
                backgroundRefreshLimiter.setTimeBeforeNewExecution(backgroundRefreshTimeForScrolling);
                display.asyncExec(new Runnable() {

                    public void run() {
                        backgroundRefreshLimiter.startIfExecutable();
                    }
                });
            }
        }
    };
    vBar1.addSelectionListener(scrollListener);
    vBar2.addSelectionListener(scrollListener);
    vBar3.addSelectionListener(scrollListener);
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 44 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project tdi-studio-se by Talend.

the class FooterComposite method createComponents.

/**
     * DOC amaumont Comment method "createComponents".
     */
private void createComponents() {
    FormLayout formLayout = new FormLayout();
    formLayout.spacing = 15;
    this.setLayout(formLayout);
    Button applyButton = new Button(this, SWT.NONE);
    applyButton.setEnabled(!mapperUi.getMapperComponent().isReadOnly());
    //$NON-NLS-1$
    applyButton.setText("Apply");
    FormData applyFormData = new FormData();
    applyFormData.width = 100;
    applyButton.setLayoutData(applyFormData);
    applyButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            mapperUi.closeMapperDialog(SWT.APPLICATION_MODAL);
        }
    });
    statusBar = new StatusBar(this, SWT.NONE);
    final ProblemsAnalyser problemsAnalyser = mapperUi.getMapperManager().getProblemsAnalyser();
    if (!problemsAnalyser.getProblems().isEmpty()) {
        statusBar.setValues(STATUS.ERROR, problemsAnalyser.getErrorMessage());
    }
    Button okButton = new Button(this, SWT.NONE);
    okButton.setEnabled(!mapperUi.getMapperComponent().isReadOnly());
    //$NON-NLS-1$
    okButton.setText("OK");
    FormData okFormData = new FormData();
    okFormData.width = 100;
    okButton.setLayoutData(okFormData);
    okButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            mapperUi.closeMapperDialog(SWT.OK);
        }
    });
    Button cancelButton = new Button(this, SWT.NONE);
    //$NON-NLS-1$
    cancelButton.setText("Cancel");
    cancelButton.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            mapperUi.closeMapperDialog(SWT.CANCEL);
        }
    });
    FormData cancelFormData = new FormData();
    cancelFormData.width = 100;
    cancelButton.setLayoutData(cancelFormData);
    cancelFormData.right = new FormAttachment(100, -5);
    okFormData.right = new FormAttachment(cancelButton, -5);
    applyFormData.right = new FormAttachment(okButton, -5);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ProblemsAnalyser(org.talend.designer.xmlmap.util.problem.ProblemsAnalyser) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 45 with SelectionListener

use of org.eclipse.swt.events.SelectionListener in project tdi-studio-se by Talend.

the class PatternPropertyCellEditor method createControl.

@Override
protected Control createControl(Composite parent) {
    combo = new CCombo(parent, SWT.BORDER);
    stringToDisplay = new ArrayList<String>();
    stringToDisplay.add(EmfComponent.BUILTIN);
    stringToDisplay.add(EmfComponent.REPOSITORY);
    combo.setItems(stringToDisplay.toArray(new String[0]));
    combo.setEditable(false);
    combo.setEnabled(true);
    combo.select(0);
    combo.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // do nothing.
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            int selectionIndex = combo.getSelectionIndex();
            if (selectionIndex == 0) {
                //clear the pattern id/name of the same row
                clearPatterInfoOnRow();
                if (allBuiltin()) {
                    // if all changed to BUILTIN, change the property type of the node to BUILTIN
                    IElementParameter property = node.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
                    if (property != null) {
                        IElementParameter repositoryParam = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                        property.setValue(EmfComponent.BUILTIN);
                        if (repositoryParam != null) {
                            repositoryParam.setValue(StringUtils.EMPTY);
                        }
                    }
                }
            }
        }
    });
    return combo;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IElementParameter(org.talend.core.model.process.IElementParameter) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

SelectionListener (org.eclipse.swt.events.SelectionListener)302 SelectionEvent (org.eclipse.swt.events.SelectionEvent)268 GridData (org.eclipse.swt.layout.GridData)149 Button (org.eclipse.swt.widgets.Button)143 GridLayout (org.eclipse.swt.layout.GridLayout)142 Composite (org.eclipse.swt.widgets.Composite)134 Label (org.eclipse.swt.widgets.Label)102 Group (org.eclipse.swt.widgets.Group)69 Text (org.eclipse.swt.widgets.Text)67 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)61 Combo (org.eclipse.swt.widgets.Combo)50 ModifyListener (org.eclipse.swt.events.ModifyListener)44 ModifyEvent (org.eclipse.swt.events.ModifyEvent)43 FormAttachment (org.eclipse.swt.layout.FormAttachment)36 FormData (org.eclipse.swt.layout.FormData)36 Point (org.eclipse.swt.graphics.Point)35 Event (org.eclipse.swt.widgets.Event)33 ArrayList (java.util.ArrayList)30 FillLayout (org.eclipse.swt.layout.FillLayout)26 FormLayout (org.eclipse.swt.layout.FormLayout)26