Search in sources :

Example 11 with FocusListener

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

the class TalendEditorComponentCreationAssist method initListeners.

private void initListeners() {
    assistText.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.stateMask == SWT.NONE) {
                if (e.keyCode == SWT.ESC) {
                    disposeAssistText();
                } else if (e.keyCode == SWT.CR) {
                    acceptProposal();
                }
            }
        }

        @Override
        public void keyPressed(KeyEvent e) {
        }
    });
    assistText.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            if (!(contentProposalAdapter.isProposalPopupOpen())) {
                disposeAssistText();
            }
        }

        @Override
        public void focusGained(FocusEvent e) {
        }
    });
    contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {

        @Override
        public void proposalPopupOpened(ContentProposalAdapter adapter) {
        }

        @Override
        public void proposalPopupClosed(ContentProposalAdapter adapter) {
            if (assistText != null && !assistText.isFocusControl()) {
                disposeAssistText();
            }
        }
    });
    contentProposalAdapter.addContentProposalListener(new IContentProposalListener() {

        @Override
        public void proposalAccepted(IContentProposal proposal) {
            acceptProposal();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) KeyListener(org.eclipse.swt.events.KeyListener) IContentProposalListener(org.eclipse.jface.fieldassist.IContentProposalListener) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) IContentProposalListener2(org.eclipse.jface.fieldassist.IContentProposalListener2) ContentProposalAdapter(org.eclipse.jface.fieldassist.ContentProposalAdapter)

Example 12 with FocusListener

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

the class DataMapTableView method createExpressionCellEditor.

protected TextCellEditor createExpressionCellEditor(final TableViewerCreator tableViewerCreator, TableViewerCreatorColumn column, final Zone[] zones, boolean isConstraintExpressionCellEditor) {
    final TextCellEditorWithProposal cellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column);
    final Text expressionTextEditor = (Text) cellEditor.getControl();
    if (isConstraintExpressionCellEditor) {
    // moved to it's caller to execute
    // constraintExpressionTextEditor = expressionTextEditor;
    } else {
        columnExpressionTextEditor = expressionTextEditor;
    }
    cellEditor.addListener(new ICellEditorListener() {

        Text text = (Text) cellEditor.getControl();

        @Override
        public void applyEditorValue() {
            ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
            mapperManager.getUiManager().parseNewExpression(text.getText(), (ITableEntry) modifiedObjectInfo.getCurrentModifiedBean(), true);
        }

        @Override
        public void cancelEditor() {
            ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
            text.setText((String) modifiedObjectInfo.getOriginalPropertyBeanValue());
            ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
            String originalExpression = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
            mapperManager.getUiManager().parseNewExpression(originalExpression, tableEntry, true);
        }

        @Override
        public void editorValueChanged(boolean oldValidState, boolean newValidState) {
            if (expressionTextEditor.isFocusControl() || lastExpressionEditorTextWhichLostFocus == expressionTextEditor) {
                ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
                ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
                mapperManager.getUiManager().parseNewExpression(text.getText(), tableEntry, false);
                resizeTextEditor(text, tableViewerCreator);
            }
        }
    });
    expressionTextEditor.addControlListener(new ControlListener() {

        ExecutionLimiter executionLimiter = null;

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            if (executionLimiter == null) {
                executionLimiter = new ExecutionLimiter(50, true) {

                    @Override
                    public void execute(boolean isFinalExecution, Object data) {
                        if (isFinalExecution && !expressionTextEditor.isDisposed()) {
                            expressionTextEditor.getDisplay().syncExec(new Runnable() {

                                @Override
                                public void run() {
                                    if (expressionTextEditor.isDisposed()) {
                                        return;
                                    }
                                    resizeTextEditor(expressionTextEditor, tableViewerCreator);
                                }
                            });
                        }
                    }
                };
            }
            executionLimiter.startIfExecutable();
        }
    });
    expressionTextEditor.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
            initExpressionProposals(cellEditor, zones, tableViewerCreator, currentModifiedEntry);
            resizeTextEditor(expressionTextEditor, tableViewerCreator);
            StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
            styledTextHandler.setCurrentEntry(currentModifiedEntry);
            //$NON-NLS-1$
            styledTextHandler.setTextWithoutNotifyListeners(currentModifiedEntry.getExpression() == null ? "" : currentModifiedEntry.getExpression());
        }

        @Override
        public void focusLost(FocusEvent e) {
            expressionEditorTextSelectionBeforeFocusLost = expressionTextEditor.getSelection();
            lastExpressionEditorTextWhichLostFocus = expressionTextEditor;
        }
    });
    column.setCellEditor(cellEditor, new CellEditorValueAdapter() {

        @Override
        public Object getCellEditorTypedValue(CellEditor cellEditor, Object originalTypedValue) {
            return super.getCellEditorTypedValue(cellEditor, originalTypedValue);
        }

        @Override
        public String getColumnText(CellEditor cellEditor, Object bean, Object cellEditorTypedValue) {
            //$NON-NLS-1$ //$NON-NLS-2$
            return super.getColumnText(cellEditor, bean, cellEditorTypedValue).replaceAll("[\r\n\t]+", " ... ");
        }

        @Override
        public Object getOriginalTypedValue(CellEditor cellEditor, Object cellEditorTypedValue) {
            return super.getOriginalTypedValue(cellEditor, cellEditorTypedValue);
        }
    });
    return cellEditor;
}
Also used : TextCellEditorWithProposal(org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) StyledTextHandler(org.talend.designer.dbmap.ui.tabs.StyledTextHandler) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) FocusEvent(org.eclipse.swt.events.FocusEvent) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) ControlListener(org.eclipse.swt.events.ControlListener) ModifiedObjectInfo(org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo) ExecutionLimiter(org.talend.commons.utils.threading.ExecutionLimiter) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener)

Example 13 with FocusListener

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

the class RowGeneratorUI method addParentListeners.

/**
     * qzhang Comment method "addParentListeners".
     * 
     * @param uiManager
     * @param uiProperties
     */
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
    rowGenUIParent.addListener(SWT.Close, new Listener() {

        @Override
        public void handleEvent(Event event) {
            if (uiManager.getRowGenResponse() == SWT.NONE) {
                uiManager.closeRowGenerator(SWT.CANCEL, false);
            }
        }
    });
    rowGenUIParent.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            updateBackground(false, true);
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });
    // store size if not maximized
    if (rowGenUIParent instanceof Shell) {
        ((Shell) rowGenUIParent).addControlListener(new ControlListener() {

            @Override
            public void controlMoved(ControlEvent e) {
            }

            @Override
            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 14 with FocusListener

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

the class VolumeSizeValidator method createVolumeGroup.

/**
	 * 
	 * Create volume group area
	 * 
	 * @param parent the parent composite
	 */
private void createVolumeGroup(Composite parent) {
    Group volumeGroup = new Group(parent, SWT.NONE);
    volumeGroup.setText(Messages.grpAddtionalVolInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    volumeGroup.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 4;
    volumeGroup.setLayout(layout);
    Label volumeNameLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumeNameLabel.setText(Messages.lblVolName);
    volumeNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeNameText = new Text(volumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeNameText.setLayoutData(gridData);
    volumeNameText.setEditable(false);
    Label volumePathLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumePathLabel.setText(Messages.lblVolPath);
    volumePathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumePathText = new Text(volumeGroup, SWT.BORDER);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    volumePathText.setLayoutData(gridData);
    Button selectDirectoryButton = new Button(volumeGroup, 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) {
                volumePathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = server.getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectDirectoryButton.setEnabled(false);
    }
    Label volumeTypeLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    volumeTypeLabel.setText(Messages.lblVolType);
    volumeTypeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeTypeCombo = new Combo(volumeGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeTypeCombo.setLayoutData(gridData);
    volumeTypeCombo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changeVolumeName();
        }
    });
    Label sizeOfPageLabel = new Label(volumeGroup, SWT.LEFT | SWT.WRAP);
    sizeOfPageLabel.setText(Messages.lblVolSize);
    sizeOfPageLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumeSizeText = new Text(volumeGroup, SWT.BORDER);
    volumeSizeText.setTextLimit(20);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    volumeSizeText.setLayoutData(gridData);
    volumeSizeText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent event) {
            volumeSizeText.addModifyListener(VolumeInfoPage.this);
        }

        public void focusLost(FocusEvent event) {
            volumeSizeText.removeModifyListener(VolumeInfoPage.this);
        }
    });
}
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) Combo(org.eclipse.swt.widgets.Combo) 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 15 with FocusListener

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

the class SetAutoAddVolumeInfoPage method createDataParaGroup.

/**
	 * Creates dataParaGroup which is the part of Dialog area
	 * 
	 * @param composite the parent composite
	 */
private void createDataParaGroup(Composite composite) {
    final Group dataParaGroup = new Group(composite, SWT.RESIZE);
    final GridData gdDataParaGroup = new GridData(SWT.FILL, SWT.CENTER, true, false);
    dataParaGroup.setLayoutData(gdDataParaGroup);
    dataParaGroup.setText(Messages.grpVolPurposeData);
    GridLayout groupLayout = new GridLayout(4, false);
    dataParaGroup.setLayout(groupLayout);
    dataUsingAutoVolButton = new Button(dataParaGroup, SWT.CHECK);
    final GridData gdUsingAutoVolButton = new GridData(SWT.LEFT, SWT.CENTER, true, false, 4, 1);
    dataUsingAutoVolButton.setLayoutData(gdUsingAutoVolButton);
    dataUsingAutoVolButton.setText(Messages.btnUsingAuto);
    final Label outOfSpaceLabel = new Label(dataParaGroup, SWT.NONE);
    outOfSpaceLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    outOfSpaceLabel.setText(Messages.lblOutOfSpaceWarning);
    dataOutRateCombo = new Combo(dataParaGroup, SWT.BORDER);
    dataOutRateCombo.setTextLimit(2);
    dataOutRateCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    final Label volumeLabel = new Label(dataParaGroup, SWT.NONE);
    volumeLabel.setText(Messages.lblVolSize);
    volumeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dataVolumeText = new Text(dataParaGroup, SWT.BORDER);
    dataVolumeText.setTextLimit(20);
    dataVolumeText.setText(GeneralInfoPage.getIntSizeString(initVolumeSize, 1));
    final GridData gdDataVolumeText = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    dataVolumeText.setLayoutData(gdDataVolumeText);
    dataVolumeText.addFocusListener(new FocusListener() {

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

        public void focusLost(FocusEvent event) {
            dataVolumeText.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)

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