Search in sources :

Example 16 with FocusListener

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

the class SetAutoAddVolumeInfoPage method createIndexParaGroup.

/**
	 * Creates indexParaGroup which is the part of Dialog area
	 * 
	 * @param composite the parent composite
	 */
private void createIndexParaGroup(Composite composite) {
    final Group indexParaGroup = new Group(composite, SWT.RESIZE);
    final GridData gdIndexParaGroup = new GridData(SWT.FILL, SWT.CENTER, true, false);
    final GridLayout gridLayout = new GridLayout(4, false);
    indexParaGroup.setLayout(gridLayout);
    indexParaGroup.setLayoutData(gdIndexParaGroup);
    indexParaGroup.setText(Messages.grpVolPurposeIndex);
    indexUsingAutoVolButton = new Button(indexParaGroup, SWT.CHECK);
    indexUsingAutoVolButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 4, 1));
    indexUsingAutoVolButton.setText(Messages.btnUsingAuto);
    final Label outOfSpaceLabel = new Label(indexParaGroup, SWT.NONE);
    outOfSpaceLabel.setText(Messages.lblOutOfSpaceWarning);
    outOfSpaceLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    indexOutRateCombo = new Combo(indexParaGroup, SWT.BORDER);
    indexOutRateCombo.setTextLimit(2);
    indexOutRateCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    final Label volumeLabel = new Label(indexParaGroup, SWT.NONE);
    volumeLabel.setText(Messages.lblVolSize);
    volumeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    indexVolumeText = new Text(indexParaGroup, SWT.BORDER);
    indexVolumeText.setTextLimit(20);
    indexVolumeText.setText(GeneralInfoPage.getIntSizeString(initVolumeSize, 1));
    final GridData gdDataVolumeText = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    indexVolumeText.setLayoutData(gdDataVolumeText);
    indexVolumeText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            indexVolumeText.addModifyListener(SetAutoAddVolumeInfoPage.this);
        }

        public void focusLost(FocusEvent event) {
            indexVolumeText.removeModifyListener(SetAutoAddVolumeInfoPage.this);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 17 with FocusListener

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

the class RecentlyUsedSQLComposite method initialize.

/**
	 * Create the SQL history composite
	 */
public void initialize() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.numColumns = 2;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
    delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
    delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
    delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
    delHistory.setText(Messages.btn_qedit_sql_history_delete);
    delHistory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
                return;
            }
            MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
            messageBox.setMessage(Messages.sql_history_delete_message);
            // remove data ,both view and model
            int buttonID = messageBox.open();
            if (buttonID == SWT.YES) {
                deleteHistory();
            }
        }
    });
    // help messages
    Label helpMsg = new Label(toolBarComposite, SWT.None);
    helpMsg.setText(Messages.recentlyUsedSQLHelp);
    helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
    // create the query result tab folder
    recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
    recentlyUsedSQLTabFolder.setSimple(false);
    recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
    recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
    recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
    recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    //TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
    //tabContextMenuManager.createContextMenu();
    recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
    recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
    recentlyUsedSQLTabItem.setControl(this);
    recentlyUsedSQLTabItem.setShowClose(false);
    final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    createHistoryTable(bottomSash);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
    bottomSash.setWeights(new int[] { 80, 20 });
    logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
    logMessageArea.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            bottomSash.setWeights(new int[] { 80, 20 });
        }

        public void focusGained(FocusEvent e) {
            bottomSash.setWeights(new int[] { 20, 80 });
        }
    });
    CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_sql_history);
    tabItem.setControl(bottomSash);
    tabItem.setShowClose(false);
    recentlyUsedSQLTabFolder.setSelection(tabItem);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FocusEvent(org.eclipse.swt.events.FocusEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 18 with FocusListener

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

the class GeneralInfoPage method createGenericVolumeGroup.

/**
	 * Create generic volume information group
	 *
	 * @param parent the parent composite
	 */
private void createGenericVolumeGroup(Composite parent) {
    Group genericVolumeGroup = new Group(parent, SWT.NONE);
    genericVolumeGroup.setText(Messages.grpGenericVolInfo);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    genericVolumeGroup.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    genericVolumeGroup.setLayoutData(gridData);
    Label genericSizeLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
    genericSizeLabel.setText(Messages.lblVolSize);
    gridData = new GridData();
    gridData.widthHint = 150;
    genericSizeLabel.setLayoutData(gridData);
    genericVolumeSizeText = new Text(genericVolumeGroup, SWT.BORDER);
    genericVolumeSizeText.setTextLimit(20);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    genericVolumeSizeText.setLayoutData(gridData);
    genericVolumeSizeText.addFocusListener(new FocusListener() {

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

        public void focusLost(FocusEvent event) {
            genericVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
        }
    });
    Label genericVolumePathLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
    genericVolumePathLabel.setText(Messages.lblGenericVolPath);
    gridData = new GridData();
    gridData.widthHint = 150;
    genericVolumePathLabel.setLayoutData(gridData);
    genericVolumePathText = new Text(genericVolumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    genericVolumePathText.setLayoutData(gridData);
    Button selectDirectoryButton = new Button(genericVolumeGroup, 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) {
                genericVolumePathText.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) 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 19 with FocusListener

use of org.eclipse.swt.events.FocusListener 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 20 with FocusListener

use of org.eclipse.swt.events.FocusListener 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)

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