Search in sources :

Example 31 with FocusListener

use of org.eclipse.swt.events.FocusListener in project OpenGrok by OpenGrok.

the class ResultsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    parent.setLayout(new GridLayout(1, true));
    filter = new Text(parent, SWT.FILL);
    filter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    TextUtils.setToDefault(filter, FILTER_DEFAULT);
    filter.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if ("".equals(filter.getText())) {
                TextUtils.setToDefault(filter, FILTER_DEFAULT);
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
            TextUtils.makeEditable(filter);
        }
    });
    filter.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            viewer.refresh();
        }
    });
    return parent;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 32 with FocusListener

use of org.eclipse.swt.events.FocusListener in project OpenGrok by OpenGrok.

the class ToolBarControl method createControl.

@Override
protected Control createControl(Composite parent) {
    final Text searchBox = new Text(parent, SWT.FILL | SWT.BORDER);
    TextUtils.setToDefault(searchBox, "{OpenGrok");
    searchBox.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!disableFocusLostEvent) {
                TextUtils.setToDefault(searchBox, "{OpenGrok");
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
            TextUtils.makeEditable(searchBox);
        }
    });
    searchBox.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                doSearch();
            } else if (e.keyCode == SWT.ARROW_UP) {
                historyIndex++;
                if (historyIndex > history.size()) {
                    historyIndex = history.size();
                }
                if (historyIndex >= 0 && history.size() >= historyIndex) {
                    searchBox.setText(history.get(historyIndex - 1));
                }
            } else if (e.keyCode == SWT.ARROW_DOWN) {
                historyIndex--;
                if (historyIndex < 0) {
                    historyIndex = 0;
                } else if (history.size() > historyIndex) {
                    searchBox.setText(history.get(historyIndex));
                }
            } else if ((e.stateMask & SWT.CTRL) == SWT.CTRL && e.keyCode == 'v') {
                searchBox.setText("");
                searchBox.paste();
                if ((e.stateMask & SWT.SHIFT) == SWT.SHIFT) {
                    doSearch();
                }
            } else if (e.stateMask == SWT.CTRL && e.keyCode == 'c') {
                searchBox.copy();
            }
        }

        private void doSearch() {
            String text = searchBox.getText();
            if (text != null && !"".equals(text)) {
                history.add(0, text);
                historyIndex = 0;
                Rectangle bounds = searchBox.getBounds();
                Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
                topLeft = searchBox.getShell().toDisplay(topLeft);
                final ResultsDialog dialog = new ResultsDialog(Display.getCurrent().getActiveShell(), text, topLeft);
                Query query = new Query(text);
                disableFocusLostEvent = true;
                query.run(dialog);
                disableFocusLostEvent = false;
            }
        }
    });
    return parent;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Query(org.opensolaris.opengrok.egrok.query.Query) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 33 with FocusListener

use of org.eclipse.swt.events.FocusListener in project dbeaver by serge-rider.

the class TabbedFolderPageEditor method createControl.

@Override
public void createControl(Composite parent) {
    editor = editorDescriptor.createEditor();
    final IWorkbenchPartSite ownerSite = this.mainEditor.getSite();
    if (ownerSite instanceof MultiPageEditorSite) {
        final MultiPageEditorPart ownerMultiPageEditor = ((MultiPageEditorSite) ownerSite).getMultiPageEditor();
        nestedEditorSite = new TabbedFolderPageEditorSite(ownerMultiPageEditor, editor);
        // We need it to tell owner editor about dirty state change
        if (ownerMultiPageEditor instanceof IPropertyChangeReflector) {
            editor.addPropertyListener(new IPropertyListener() {

                @Override
                public void propertyChanged(Object source, int propId) {
                    ((IPropertyChangeReflector) ownerMultiPageEditor).handlePropertyChange(propId);
                }
            });
        }
    } else {
        nestedEditorSite = new SubEditorSite(mainEditor.getEditorSite());
    }
    try {
        editor.init(nestedEditorSite, editorDescriptor.getNestedEditorInput(mainEditor.getEditorInput()));
    } catch (PartInitException e) {
        UIUtils.showErrorDialog(parent.getShell(), "Create SQL viewer", null, e);
    }
    editor.createPartControl(parent);
    if (editor instanceof ISingleControlEditor) {
        // Use focus to active selection provider and contributed actions
        Control editorControl = ((ISingleControlEditor) editor).getEditorControl();
        assert editorControl != null;
        editorControl.addFocusListener(new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {
                ISelectionProvider selectionProvider = editor.getSite().getSelectionProvider();
                mainEditor.getSite().setSelectionProvider(selectionProvider);
                if (actionContributor != null) {
                    actionContributor.setActiveEditor(editor);
                }
                activateNestedSite(true);
            }

            @Override
            public void focusLost(FocusEvent e) {
                activateNestedSite(false);
                if (actionContributor != null) {
                    actionContributor.setActiveEditor(null);
                }
            }
        });
    }
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (editor != null) {
                editor.dispose();
                editor = null;
            }
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) FocusListener(org.eclipse.swt.events.FocusListener)

Example 34 with FocusListener

use of org.eclipse.swt.events.FocusListener in project cubrid-manager by CUBRID.

the class GeneralInfoPage method createLogVolumeGroup.

/**
	 * Create log volume information group
	 *
	 * @param parent the parent composite
	 */
private void createLogVolumeGroup(Composite parent) {
    Group logVolumeGroup = new Group(parent, SWT.NONE);
    logVolumeGroup.setText(Messages.grpLogVolInfo);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    logVolumeGroup.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    logVolumeGroup.setLayoutData(gridData);
    if (CompatibleUtil.isSupportLogPageSize(server.getServerInfo())) {
        Label logPageSizeLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
        logPageSizeLabel.setText(Messages.lblLogPageSize);
        gridData = new GridData();
        gridData.widthHint = 150;
        logPageSizeLabel.setLayoutData(gridData);
        logPageSizeCombo = new Combo(logVolumeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 3;
        logPageSizeCombo.setLayoutData(gridData);
        logPageSizeCombo.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                valid();
            }
        });
    }
    Label logSizeLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
    logSizeLabel.setText(Messages.lblVolSize);
    gridData = new GridData();
    gridData.widthHint = 150;
    logSizeLabel.setLayoutData(gridData);
    logVolumeSizeText = new Text(logVolumeGroup, SWT.BORDER);
    logVolumeSizeText.setTextLimit(20);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    logVolumeSizeText.setLayoutData(gridData);
    logVolumeSizeText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            logVolumeSizeText.addModifyListener(GeneralInfoPage.this);
        }

        public void focusLost(FocusEvent event) {
            logVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
        }
    });
    Label logVolumePathLabel = new Label(logVolumeGroup, SWT.LEFT | SWT.WRAP);
    logVolumePathLabel.setText(Messages.lblLogVolPath);
    gridData = new GridData();
    gridData.widthHint = 150;
    logVolumePathLabel.setLayoutData(gridData);
    logVolumePathText = new Text(logVolumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    logVolumePathText.setLayoutData(gridData);
    Button selectDirectoryButton = new Button(logVolumeGroup, SWT.NONE);
    selectDirectoryButton.setText(Messages.btnBrowse);
    selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    selectDirectoryButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            if (databasePath != null && databasePath.trim().length() > 0) {
                dlg.setFilterPath(databasePath);
            }
            dlg.setText(Messages.msgSelectDir);
            dlg.setMessage(Messages.msgSelectDir);
            String dir = dlg.open();
            if (dir != null) {
                logVolumePathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = server.getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectDirectoryButton.setEnabled(false);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 35 with FocusListener

use of org.eclipse.swt.events.FocusListener in project mechanoid by robotoworks.

the class NewMechanoidNetServiceClientPage method onAfterAddNameField.

@Override
protected void onAfterAddNameField(Composite parent, Font font) {
    mBaseUrlField = new TextField(parent, Messages.NewMechanoidNetServiceClientPage_Widget_Label_Url);
    mBaseUrlField.getTextField().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
        }

        @Override
        public void focusGained(FocusEvent e) {
            getFieldInfoLabel().setText(Messages.NewMechanoidNetServiceClientPage_Widget_Label_Message_Url);
        }
    });
}
Also used : TextField(com.robotoworks.mechanoid.ui.wizard.fields.TextField) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

FocusListener (org.eclipse.swt.events.FocusListener)50 FocusEvent (org.eclipse.swt.events.FocusEvent)49 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 GridData (org.eclipse.swt.layout.GridData)15 KeyEvent (org.eclipse.swt.events.KeyEvent)11 GridLayout (org.eclipse.swt.layout.GridLayout)11 ControlEvent (org.eclipse.swt.events.ControlEvent)10 MouseEvent (org.eclipse.swt.events.MouseEvent)10 Text (org.eclipse.swt.widgets.Text)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 Event (org.eclipse.swt.widgets.Event)9 SelectionListener (org.eclipse.swt.events.SelectionListener)8 Button (org.eclipse.swt.widgets.Button)8 Composite (org.eclipse.swt.widgets.Composite)8 Label (org.eclipse.swt.widgets.Label)8 ControlListener (org.eclipse.swt.events.ControlListener)7 SashForm (org.eclipse.swt.custom.SashForm)6 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 Listener (org.eclipse.swt.widgets.Listener)6