Search in sources :

Example 46 with FocusEvent

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

the class CustomCheckboxCellEditor method createControl.

@Override
protected Control createControl(Composite parent) {
    checkBox = new Button(parent, SWT.CHECK);
    checkBox.setFont(parent.getFont());
    checkBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            applyEditorValue();
            // This is needed for MacOS
            fireApplyEditorValue();
        }
    });
    checkBox.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            CustomCheckboxCellEditor.this.focusLost();
        }
    });
    return checkBox;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 47 with FocusEvent

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

the class BaseValueEditor method initInlineControl.

protected void initInlineControl(final Control inlineControl) {
    boolean isInline = (valueController.getEditType() == IValueController.EditType.INLINE);
    if (isInline && UIUtils.isInDialog(inlineControl)) {
    //isInline = false;
    }
    UIUtils.enableHostEditorKeyBindingsSupport(valueController.getValueSite(), inlineControl);
    //            if (!isInline) {
    //                inlineControl.setBackground(valueController.getEditPlaceholder().getBackground());
    //            }
    final IContextService contextService = valueController.getValueSite().getService(IContextService.class);
    inlineControl.addFocusListener(new FocusListener() {

        private IContextActivation activationEditor;

        @Override
        public void focusGained(FocusEvent e) {
            if (contextService != null) {
                activationEditor = contextService.activateContext(RESULTS_EDIT_CONTEXT_ID);
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            contextService.deactivateContext(activationEditor);
            activationEditor = null;
        }
    });
    if (isInline) {
        inlineControl.setFont(valueController.getEditPlaceholder().getFont());
        inlineControl.setFocus();
        if (valueController instanceof IMultiController) {
            // In dialog it also should handle all standard stuff because we have params dialog
            inlineControl.addTraverseListener(new TraverseListener() {

                @Override
                public void keyTraversed(TraverseEvent e) {
                    if (e.detail == SWT.TRAVERSE_RETURN) {
                        saveValue();
                        ((IMultiController) valueController).closeInlineEditor();
                        e.doit = false;
                        e.detail = SWT.TRAVERSE_NONE;
                    } else if (e.detail == SWT.TRAVERSE_ESCAPE) {
                        ((IMultiController) valueController).closeInlineEditor();
                        e.doit = false;
                        e.detail = SWT.TRAVERSE_NONE;
                    } else if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                        saveValue();
                        ((IMultiController) valueController).nextInlineEditor(e.detail == SWT.TRAVERSE_TAB_NEXT);
                        e.doit = false;
                        e.detail = SWT.TRAVERSE_NONE;
                    }
                }
            });
            if (!UIUtils.isInDialog(inlineControl)) {
                addAutoSaveSupport(inlineControl);
            }
        }
    }
    final ControlModifyListener modifyListener = new ControlModifyListener();
    control.addListener(SWT.Modify, modifyListener);
    control.addListener(SWT.Selection, modifyListener);
}
Also used : TraverseEvent(org.eclipse.swt.events.TraverseEvent) IContextActivation(org.eclipse.ui.contexts.IContextActivation) TraverseListener(org.eclipse.swt.events.TraverseListener) IContextService(org.eclipse.ui.contexts.IContextService) IMultiController(org.jkiss.dbeaver.ui.data.IMultiController) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 48 with FocusEvent

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

the class EditMultiHostStatisticItemDialog method createDialogArea.

/**
	 * Creates and returns the contents of the upper part of this dialog (above
	 * the button bar).
	 * 
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    final Composite parentComp = (Composite) super.createDialogArea(parent);
    final int DEFAULT_WIDTH = 80;
    Composite compHost = new Composite(parentComp, SWT.RESIZE);
    compHost.setLayout(new FillLayout());
    compHost.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    hostTableViewer = new TableViewer(compHost, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    hostTableViewer.getTable().setHeaderVisible(true);
    hostTableViewer.getTable().setLinesVisible(true);
    hostTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            TableItem[] tableItems = hostTableViewer.getTable().getSelection();
            StatisticChartHost hostItem = (StatisticChartHost) tableItems[0].getData();
            openAddStatisticHostDialog(hostItem, hostList.size() == 1, false);
        }
    });
    //Host Name
    final TableViewerColumn nameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    nameColumn.getColumn().setWidth(DEFAULT_WIDTH);
    nameColumn.getColumn().setText(Messages.lblHostName);
    //IP
    final TableViewerColumn ipColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    ipColumn.getColumn().setWidth(DEFAULT_WIDTH);
    ipColumn.getColumn().setText(Messages.lblIp);
    //Port
    final TableViewerColumn portColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    portColumn.getColumn().setWidth(50);
    portColumn.getColumn().setText(Messages.lblPort);
    //Data Type
    final TableViewerColumn dataTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    dataTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
    dataTypeColumn.getColumn().setText(Messages.lblDataType);
    //Time Type
    final TableViewerColumn timeTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    timeTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
    timeTypeColumn.getColumn().setText(Messages.lblTimeType);
    //Database Name
    final TableViewerColumn dbNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    dbNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
    dbNameColumn.getColumn().setText(Messages.lblDbName);
    //Database Volume Name
    final TableViewerColumn volNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    volNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
    volNameColumn.getColumn().setText(Messages.lblVolName);
    //Broker Name
    final TableViewerColumn brokerColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    brokerColumn.getColumn().setWidth(DEFAULT_WIDTH);
    brokerColumn.getColumn().setText(Messages.lblBrokerName);
    //Metric
    final TableViewerColumn metricColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
    metricColumn.getColumn().setWidth(DEFAULT_WIDTH);
    metricColumn.getColumn().setText(Messages.lblMetric);
    hostTableViewer.setContentProvider(new HostTableViewerContentProvider());
    hostTableViewer.setLabelProvider(new HostTableViewerLabelProvider());
    hostTableViewer.getTable().addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(hostTableViewer.getTable());
        }
    });
    hostTableViewer.getTable().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            TableItem[] items = hostTableViewer.getTable().getSelection();
            btnEditHost.setEnabled(items.length > 0);
            btnDeleteHost.setEnabled(items.length > 0);
        }
    });
    Composite compBtn = new Composite(parentComp, SWT.RESIZE);
    GridLayout layoutCompBtn = new GridLayout(6, false);
    layoutCompBtn.marginRight = 0;
    //		layoutCompBtn.numColumns = 6;
    layoutCompBtn.marginWidth = 0;
    compBtn.setLayout(layoutCompBtn);
    compBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    btnAddHost = new Button(compBtn, SWT.NONE);
    btnAddHost.setText(Messages.btnAddHost);
    btnAddHost.addSelectionListener(new ButtonAddHostAdapter());
    btnEditHost = new Button(compBtn, SWT.NONE);
    btnEditHost.setText(Messages.btnEditHost);
    btnEditHost.addSelectionListener(new ButtonEditHostAdapter());
    btnEditHost.setEnabled(false);
    btnDeleteHost = new Button(compBtn, SWT.NONE);
    btnDeleteHost.setText(Messages.btnDelHost);
    btnDeleteHost.addSelectionListener(new ButtonDeleteHostAdapter());
    btnDeleteHost.setEnabled(false);
    if (!isNew && statisticChartItem != null) {
        MultiHostChartItem multiHostChartItem = (MultiHostChartItem) statisticChartItem;
        type = multiHostChartItem.getType();
        timeType = TimeType.getEnumByType(multiHostChartItem.getDType());
        hostList = multiHostChartItem.getHostList();
        hostTableViewer.setInput(hostList);
    } else {
        hostList = new ArrayList<StatisticChartHost>();
    }
    return parentComp;
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) MultiHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) StatisticChartHost(com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)

Example 49 with FocusEvent

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

the class CUBRIDTextEditor method createPartControl.

/**
	 * Create Part Controls.
	 *
	 * @param parent composite.
	 */
public void createPartControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    initTextViewer(composite);
    undoManager.connect(textViewer);
    createActions();
    updateActions();
    //create context menu
    MenuManager contextMenuManager = new MenuManager("#PopupMenu", "CUBRIDTExtEditorContextMenu");
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            createContextMenu(manager);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(textViewer.getTextWidget());
    textViewer.getTextWidget().setMenu(contextMenu);
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(contextMenuManager, textViewer);
    site.setSelectionProvider(textViewer);
    textViewer.getTextWidget().addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            hookRetargetActions();
        }

        public void focusLost(FocusEvent event) {
            unHookRetargetActions();
        }
    });
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) FillLayout(org.eclipse.swt.layout.FillLayout) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) IMenuListener(org.eclipse.jface.action.IMenuListener)

Example 50 with FocusEvent

use of org.eclipse.swt.events.FocusEvent in project eclipse.platform.text by eclipse.

the class CompletionProposalPopup method addCommandSupport.

/**
 * Adds command support to the given control.
 *
 * @param control the control to watch for focus
 * @since 3.2
 */
private void addCommandSupport(final Control control) {
    final KeySequence commandSequence = fContentAssistant.getRepeatedInvocationKeySequence();
    if (commandSequence != null && !commandSequence.isEmpty() && fContentAssistant.isRepeatedInvocationMode()) {
        control.addFocusListener(new FocusListener() {

            private CommandKeyListener fCommandKeyListener;

            @Override
            public void focusGained(FocusEvent e) {
                if (Helper.okToUse(control)) {
                    if (fCommandKeyListener == null) {
                        fCommandKeyListener = new CommandKeyListener(commandSequence);
                        fProposalTable.addKeyListener(fCommandKeyListener);
                    }
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                if (fCommandKeyListener != null) {
                    control.removeKeyListener(fCommandKeyListener);
                    fCommandKeyListener = null;
                }
            }
        });
    }
    if (fAdditionalInfoController != null) {
        control.addFocusListener(new FocusListener() {

            private TraverseListener fTraverseListener;

            @Override
            public void focusGained(FocusEvent e) {
                if (Helper.okToUse(control)) {
                    if (fTraverseListener == null) {
                        fTraverseListener = new TraverseListener() {

                            @Override
                            public void keyTraversed(TraverseEvent event) {
                                if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
                                    IInformationControl iControl = fAdditionalInfoController.getCurrentInformationControl2();
                                    if (fAdditionalInfoController.getInternalAccessor().canReplace(iControl)) {
                                        fAdditionalInfoController.getInternalAccessor().replaceInformationControl(true);
                                        event.doit = false;
                                    }
                                }
                            }
                        };
                        fProposalTable.addTraverseListener(fTraverseListener);
                    }
                }
            }

            @Override
            public void focusLost(FocusEvent e) {
                if (fTraverseListener != null) {
                    control.removeTraverseListener(fTraverseListener);
                    fTraverseListener = null;
                }
            }
        });
    }
}
Also used : TraverseEvent(org.eclipse.swt.events.TraverseEvent) IInformationControl(org.eclipse.jface.text.IInformationControl) TraverseListener(org.eclipse.swt.events.TraverseListener) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

FocusEvent (org.eclipse.swt.events.FocusEvent)115 FocusAdapter (org.eclipse.swt.events.FocusAdapter)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)54 FocusListener (org.eclipse.swt.events.FocusListener)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)42 GridData (org.eclipse.swt.layout.GridData)38 Composite (org.eclipse.swt.widgets.Composite)34 Text (org.eclipse.swt.widgets.Text)33 GridLayout (org.eclipse.swt.layout.GridLayout)32 Label (org.eclipse.swt.widgets.Label)26 Menu (org.eclipse.swt.widgets.Menu)22 KeyEvent (org.eclipse.swt.events.KeyEvent)21 Button (org.eclipse.swt.widgets.Button)21 Point (org.eclipse.swt.graphics.Point)20 ModifyEvent (org.eclipse.swt.events.ModifyEvent)19 MenuManager (org.eclipse.jface.action.MenuManager)18 ModifyListener (org.eclipse.swt.events.ModifyListener)18 Combo (org.eclipse.swt.widgets.Combo)17 Group (org.eclipse.swt.widgets.Group)17 SelectionListener (org.eclipse.swt.events.SelectionListener)15