Search in sources :

Example 76 with ModifyListener

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

the class DatabaseTypeFilter method createFilterField.

/**
     * DOC bqian Comment method "createFilterField".
     * 
     * @param container
     */
private void createFilterField(Composite container) {
    if (type != ERepositoryObjectType.PROCESS && !showFilterText) {
        return;
    }
    // create text filter
    Label label = new Label(container, SWT.NONE);
    //$NON-NLS-1$
    label.setText(Messages.getString("RepositoryReviewDialog.jobNameFormat"));
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    final Text text = new Text(container, SWT.BORDER);
    text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    text.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            String pattern = text.getText();
            //$NON-NLS-1$ //$NON-NLS-2$
            pattern = pattern.replace("*", ".*");
            //$NON-NLS-1$ //$NON-NLS-2$
            pattern = pattern.replace("?", ".");
            //$NON-NLS-1$ //$NON-NLS-2$
            pattern = "(?i)" + pattern + ".*";
            textFilter.setText(pattern);
            getRepositoryTreeViewer().refresh();
            getRepositoryTreeViewer().expandAll();
        // repositoryView.selectFirstOne();
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text)

Example 77 with ModifyListener

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

the class ReviewComponentDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(composite, SWT.NONE);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.marginBottom = 15;
    gridLayout.marginLeft = 15;
    gridLayout.marginRight = 15;
    gridLayout.marginTop = 15;
    container.setLayout(gridLayout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Label titleLabel = new Label(container, SWT.NONE);
    titleLabel.setText("Title:*");
    titleText = new Text(container, SWT.BORDER);
    titleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    titleText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            checkInput();
        }
    });
    createRatingComp(container);
    final Label reviewLabel = new Label(container, SWT.NONE);
    reviewLabel.setText("Review:*");
    reviewText = new Text(container, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
    reviewText.setLayoutData(new GridData(GridData.FILL_BOTH));
    reviewText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            checkInput();
        }
    });
    checkInput();
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 78 with ModifyListener

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

the class ComponentsPreferencePage method createFieldEditors.

@Override
public void createFieldEditors() {
    final Composite parent = getFieldEditorParent();
    filePathTemp = new DirectoryFieldEditor(IComponentPreferenceConstant.USER_COMPONENTS_FOLDER, //$NON-NLS-1$
    Messages.getString("ComponentsPreferencePage.directoryFieldLabel"), parent);
    addField(filePathTemp);
    filePathTemp.getTextControl(parent).addModifyListener(new ModifyListener() {

        String oldPath = getPreferenceStore().getString(IComponentPreferenceConstant.USER_COMPONENTS_FOLDER);

        @Override
        public void modifyText(ModifyEvent e) {
            String newPath = filePathTemp.getTextControl(parent).getText();
            File file = new File(newPath);
            if (!file.exists() && !"".equals(newPath)) {
                //$NON-NLS-1$
                // getPreferenceStore().setValue(IComponentPreferenceConstant.USER_COMPONENTS_FOLDER, "");
                filePathTemp.showErrorMessage();
                setValid(false);
            } else {
                if (oldPath.equals(newPath)) {
                    setValid(true);
                    return;
                }
                if (!StringUtils.isEmpty(newPath)) {
                    if (!checkUserComponentsFolder(file)) {
                        filePathTemp.getTextControl(parent).setText(oldPath);
                    }
                }
                setValid(true);
            }
        }
    });
    if (PluginChecker.isPreviewPluginLoaded()) {
        createForDataViewer(parent);
    }
    createForMapper(parent);
    createFortRunJob(parent);
    if (PluginChecker.isJobLetPluginLoaded()) {
        createForJoblet(parent);
    }
    createForComponentAssist(parent);
    parent.pack();
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) DirectoryFieldEditor(org.eclipse.jface.preference.DirectoryFieldEditor) File(java.io.File)

Example 79 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project KaiZen-OpenAPI-Editor by RepreZen.

the class QuickOutline method createTitleControl.

@Override
protected Control createTitleControl(Composite parent) {
    filterText = new Text(parent, SWT.NONE);
    Dialog.applyDialogFont(filterText);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.CENTER;
    filterText.setLayoutData(data);
    filterText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (isInvocationEvent(e)) {
                e.doit = false;
                handleMultiView();
            } else if (e.keyCode == SWT.CR) {
                handleSelection();
                QuickOutline.this.close();
            } else if (e.keyCode == SWT.ARROW_DOWN) {
                treeViewer.getTree().setFocus();
            } else if (e.keyCode == SWT.ARROW_UP) {
                treeViewer.getTree().setFocus();
            } else if (e.character == SWT.ESC) {
                QuickOutline.this.close();
            }
        }

        public void keyReleased(KeyEvent e) {
        // do nothing
        }
    });
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            if (filterTimer != null) {
                filterTimer.cancel();
            }
            // reset the timer each time there is a
            // text modification, so that only the last
            // one will be executed.
            filterTimer = new Timer();
            filterTimer.schedule(new TimerTask() {

                @Override
                public void run() {
                    if (filterText.isDisposed()) {
                        return;
                    }
                    // Make sure we access the text in the correct thread.
                    filterText.getDisplay().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            // refreshing the tree will execute the filter.
                            if (Strings.emptyToNull(filterText.getText()) == null) {
                                treeViewer.refresh();
                                treeViewer.collapseAll();
                            } else {
                                treeViewer.refresh();
                                TreeItem[] items = treeViewer.getTree().getItems();
                                if (items != null && items.length > 0) {
                                    treeViewer.getTree().setSelection(items[0]);
                                    treeViewer.getTree().showItem(items[0]);
                                } else {
                                    treeViewer.setSelection(StructuredSelection.EMPTY);
                                }
                                treeViewer.expandAll();
                            }
                        }
                    });
                }
            }, 500);
        }
    });
    return filterText;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) Timer(java.util.Timer) TimerTask(java.util.TimerTask) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener)

Example 80 with ModifyListener

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

the class ImportComponentDialog method createDialogArea.

/*
     * (non-Javadoc) Method declared on Dialog.
     */
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout gl = new GridLayout(5, true);
    composite.setLayout(gl);
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL);
        data.horizontalSpan = 5;
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    Label label1 = new Label(composite, SWT.NONE);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.horizontalSpan = 2;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
    text = new Text(composite, SWT.BORDER);
    text.setEditable(false);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    text.setLayoutData(gd);
    if (paletteComponentsPath == null) {
        //$NON-NLS-1$
        paletteComponentsPath = "";
    }
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput(true);
        }
    });
    Button button = new Button(composite, SWT.NONE);
    //$NON-NLS-1$
    button.setText(Messages.getString("ImportComponentDialog.Browser"));
    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 1;
    button.setLayoutData(gd);
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
            String path = dd.open();
            if (path != null) {
                text.setText(path);
            }
        }
    });
    Button showPaletteComponents = new Button(composite, SWT.NONE);
    gd = new GridData();
    gd.horizontalSpan = 2;
    showPaletteComponents.setLayoutData(gd);
    //$NON-NLS-1$
    showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
    showPaletteComponents.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            text.setText(paletteComponentsPath);
        }
    });
    label1 = new Label(composite, SWT.LEFT);
    gd = new GridData();
    gd.horizontalSpan = 1;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.Filter"));
    filterText = new Text(composite, SWT.BORDER);
    filterText.setEditable(true);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    filterText.setLayoutData(gd);
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput(false);
        }
    });
    label1 = new Label(composite, SWT.LEFT);
    gd = new GridData();
    gd.horizontalSpan = 5;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
    componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 5;
    componentList.setLayoutData(gd);
    componentList.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
            validateSelected();
        }

        public void mouseUp(MouseEvent e) {
            validateSelected();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 5;
    label1.setLayoutData(gd);
    errorMessageText.setLayoutData(gd);
    errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    applyDialogFont(composite);
    //$NON-NLS-1$
    text.setText("");
    return composite;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(org.eclipse.swt.widgets.List) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

ModifyListener (org.eclipse.swt.events.ModifyListener)308 ModifyEvent (org.eclipse.swt.events.ModifyEvent)296 GridData (org.eclipse.swt.layout.GridData)209 GridLayout (org.eclipse.swt.layout.GridLayout)185 Text (org.eclipse.swt.widgets.Text)185 Composite (org.eclipse.swt.widgets.Composite)171 Label (org.eclipse.swt.widgets.Label)165 SelectionEvent (org.eclipse.swt.events.SelectionEvent)158 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)127 Button (org.eclipse.swt.widgets.Button)101 Combo (org.eclipse.swt.widgets.Combo)65 Group (org.eclipse.swt.widgets.Group)50 SelectionListener (org.eclipse.swt.events.SelectionListener)48 File (java.io.File)30 KeyEvent (org.eclipse.swt.events.KeyEvent)26 StyledText (org.eclipse.swt.custom.StyledText)24 FileDialog (org.eclipse.swt.widgets.FileDialog)23 Point (org.eclipse.swt.graphics.Point)22 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)21 ArrayList (java.util.ArrayList)18