Search in sources :

Example 86 with KeyEvent

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

the class ConfigureConnParamDialog method createTextComponent.

private void createTextComponent(final EConnectionParameterName key, IContext defaultContext) {
    GridLayout gridLayout;
    GridData gridData;
    Composite hostComposite = new Composite(mainComposite, SWT.NONE);
    gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 2;
    gridLayout.marginTop = 5;
    gridLayout.marginBottom = 2;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 0;
    gridLayout.marginRight = 0;
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostComposite.setLayout(gridLayout);
    hostComposite.setLayoutData(gridData);
    Label hostLabel = new Label(hostComposite, SWT.NONE);
    //$NON-NLS-1$
    hostLabel.setText(key.getDisplayName() + ":");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    // GridDataFactory.swtDefaults().hint(LABEL_DEFAULT_X, DEFAULT_HEIGHT).applyTo(hostLabel);
    hostLabel.setLayoutData(data);
    boolean isContext = ContextParameterUtils.isContainContextParam(pvValues.get(key));
    int passStyle = SWT.BORDER;
    if ((key == EConnectionParameterName.PASSWORD) && !isContext) {
        passStyle = SWT.PASSWORD;
    }
    final Text host = new Text(hostComposite, passStyle);
    host.setText(pvValues.get(key));
    if (host.getText().trim().length() == 0) {
        host.setBackground(ColorConstants.red);
        host.redraw();
    }
    // GridDataFactory.swtDefaults().hint(TEXT_DEFAULT_X, DEFAULT_HEIGHT).applyTo(host);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    host.setLayoutData(gridData);
    Composite contextComposite = new Composite(hostComposite, SWT.NULL);
    GridLayout naviCommonCompLayout = new GridLayout(2, false);
    naviCommonCompLayout.marginWidth = 0;
    naviCommonCompLayout.marginHeight = 0;
    contextComposite.setLayout(naviCommonCompLayout);
    contextComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    contextComposite.setVisible(isContext);
    final Text hostText = new Text(contextComposite, SWT.NONE);
    hostText.setEditable(false);
    gridData = new GridData();
    hostText.setLayoutData(gridData);
    hostText.setText(CONTEXT_WITH);
    passStyle = SWT.NONE;
    if (key == EConnectionParameterName.PASSWORD) {
        passStyle = SWT.PASSWORD;
    }
    final Text hostValue = new Text(contextComposite, passStyle);
    hostValue.setEditable(false);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    hostValue.setLayoutData(gridData);
    hostValue.setText(ContextParameterUtils.parseScriptContextCode(host.getText(), defaultContext));
    host.setData(TEXT_CONTROL, hostValue);
    host.setData(key);
    allParamText.add(host);
    host.addKeyListener(new KeyAdapter() {

        /*
             * c (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.KeyAdapter#keyReleased(org.eclipse.swt.events.KeyEvent)
             */
        @Override
        public void keyReleased(KeyEvent e) {
            if (isRequriedValue(key.getName())) {
                if (host.getText().trim().length() == 0) {
                    host.setBackground(ColorConstants.red);
                    host.redraw();
                } else {
                    host.setBackground(ColorConstants.white);
                    host.redraw();
                }
                resetValues(host, hostValue);
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

Example 87 with KeyEvent

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

the class ToolbarSearchZone method addCommonsComponentListeners.

private void addCommonsComponentListeners() {
    final SearchZoneMapper searchZoneMapper = new SearchZoneMapper(mapperManager);
    searchText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            // if change the search text ,need clear the data .
            hightLightAllButton.setSelection(false);
            searchZoneMapper.setHightlightAll(hightLightAllButton.getSelection());
            if (searchMaps.size() > 0) {
                searchZoneMapper.hightlightAll(searchMaps, false);
                searchMaps.clear();
            }
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                e.doit = false;
                searchZoneMapper.search(searchMaps, searchText.getText());
                selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
            }
        }

        public void keyReleased(KeyEvent e) {
        }
    });
    downTableButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (searchMaps.isEmpty()) {
                searchZoneMapper.search(searchMaps, searchText.getText());
            }
            if (selectKey + 1 < searchMaps.size()) {
                if (!searchZoneMapper.isHightlightAll()) {
                    searchZoneMapper.hightlightAll(searchMaps, false);
                } else {
                    searchZoneMapper.hightlightAll(searchMaps, true);
                }
            }
            Integer selectKeyAtTableItem = searchZoneMapper.getSelectedKeyAtSelectedTableItem(searchMaps);
            if (selectKeyAtTableItem > 0) {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKeyAtTableItem, "next");
            } else if (selectKeyAtTableItem == 0 && selectKey == -1) {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
            } else {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKey, "next");
            }
        }
    });
    upTableButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (searchMaps.isEmpty()) {
                searchZoneMapper.search(searchMaps, searchText.getText());
            }
            if (selectKey > 0) {
                if (!searchZoneMapper.isHightlightAll()) {
                    searchZoneMapper.hightlightAll(searchMaps, false);
                } else {
                    searchZoneMapper.hightlightAll(searchMaps, true);
                }
            }
            Integer selectKeyAtTableItem = searchZoneMapper.getSelectedKeyAtSelectedTableItem(searchMaps);
            if (selectKeyAtTableItem > 0) {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKeyAtTableItem, "previous");
            } else if (selectKeyAtTableItem == 0 && selectKey == -1) {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, 0, "first");
            } else {
                selectKey = searchZoneMapper.selectHightlight(searchMaps, selectKey, "previous");
            }
        }
    });
    hightLightAllButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (hightLightAllButton.getSelection()) {
                searchMaps.clear();
                searchZoneMapper.search(searchMaps, searchText.getText());
            }
            searchZoneMapper.setHightlightAll(hightLightAllButton.getSelection());
            searchZoneMapper.hightlightAll(searchMaps, hightLightAllButton.getSelection());
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 88 with KeyEvent

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

the class GenericSchemaForm method addFieldsListeners.

@Override
protected void addFieldsListeners() {
    metadataNameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            MetadataToolHelper.validateSchema(metadataNameText.getText());
            metadataTable.setLabel(metadataNameText.getText());
            checkFieldsValue();
        }
    });
    metadataNameText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            MetadataToolHelper.checkSchema(getShell(), e);
        }
    });
    metadataCommentText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            metadataTable.setComment(metadataCommentText.getText());
        }
    });
    tableEditorView.getMetadataEditor().addAfterOperationListListener(new IListenableListListener() {

        @Override
        public void handleEvent(ListenableListEvent event) {
            checkFieldsValue();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener)

Example 89 with KeyEvent

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

the class DataSetTableKeyListener method createPopup.

/**
     * Display column finder popup.
     */
private void createPopup() {
    plastNameSearched = null;
    // recycle old popup
    if (ppopup != null && !ppopup.isDisposed()) {
        if (!ppopup.isVisible()) {
            ppopup.open();
        }
        return;
    }
    // find out where to put the popup on screen
    Point popupLocation = ptable.toDisplay(10, 40);
    // create new shell
    ppopup = new Shell(pparent.getShell(), SWT.BORDER | SWT.ON_TOP);
    ppopup.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    ppopup.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
    ppopup.setSize(250, 50);
    ppopup.setLocation(popupLocation);
    ppopup.setLayout(new GridLayout());
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    // add 'find:' label
    Label label = new Label(ppopup, SWT.NULL);
    //$NON-NLS-1$
    label.setText(Messages.getString("DataSetTable.PopUp.Find"));
    label.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    // add input field for search text
    final Text input = new Text(ppopup, SWT.SINGLE | SWT.FILL);
    input.setLayoutData(gridData);
    input.setBackground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    // scroll columns whenever something is typed in input field.
    input.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            Text t = (Text) e.widget;
            String text = t.getText();
            // locate column and show if found
            if (jumpToColumn(text)) {
                input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
            } else {
                // give some subtle feedback to user that column doesn't exist..
                input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
            }
        }
    });
    // add listener so that we can jump to next column match when
    // user hits enter..
    input.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == ENTER) {
                // scroll to next match
                if (jumpToColumn(null)) {
                    input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
                } else {
                    // give some subtle feedback to user that column doesn't exist..
                    input.setForeground(pparent.getDisplay().getSystemColor(SWT.COLOR_RED));
                }
            }
        }
    });
    // close popup when user is no longer in inputfield
    input.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent e) {
            disposePopup();
        }
    });
    // activate popup
    ppopup.open();
    ppopup.forceActive();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData)

Example 90 with KeyEvent

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

the class StyledTextHandler method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
private void addListeners() {
    styledText.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            refreshProposalSize();
        }

        public void focusLost(FocusEvent e) {
        }
    });
    styledText.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            refreshProposalSize();
        }
    });
    styledText.addExtendedModifyListener(new ExtendedModifyListener() {

        public void modifyText(ExtendedModifyEvent event) {
            // System.out.println("ExtendedModifyListener modify text");
            updateCellExpression();
        }
    });
    styledText.getContent().addTextChangeListener(new TextChangeListener() {

        public void textChanged(TextChangedEvent event) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void textChanging(TextChangingEvent event) {
        // System.out.println("textChanging");
        }

        public void textSet(TextChangedEvent event) {
        // System.out.println("textSet");
        }
    });
    styledText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }
    });
    styledText.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void keyReleased(KeyEvent e) {
        // TODO Auto-generated method stub
        }
    });
    styledText.addVerifyKeyListener(new VerifyKeyListener() {

        public void verifyKey(VerifyEvent verifyEvent) {
            if (verifyEvent.character == '\r' && contentProposalAdapter != null && contentProposalAdapter.isProposalOpened()) {
                verifyEvent.doit = false;
            } else {
                verifyEvent.doit = true;
            }
        }
    });
    styledText.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseDown(MouseEvent e) {
            mapperManager.fireCurrentDirectEditApply();
            highlightLineOfCursorPosition(styledText.getSelection());
        }

        public void mouseUp(MouseEvent e) {
        }
    });
}
Also used : ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) ExtendedModifyListener(org.eclipse.swt.custom.ExtendedModifyListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) TextChangingEvent(org.eclipse.swt.custom.TextChangingEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) TextChangedEvent(org.eclipse.swt.custom.TextChangedEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ExtendedModifyEvent(org.eclipse.swt.custom.ExtendedModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) ControlListener(org.eclipse.swt.events.ControlListener) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) KeyListener(org.eclipse.swt.events.KeyListener) ControlEvent(org.eclipse.swt.events.ControlEvent) TextChangeListener(org.eclipse.swt.custom.TextChangeListener) FocusListener(org.eclipse.swt.events.FocusListener) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Aggregations

KeyEvent (org.eclipse.swt.events.KeyEvent)98 KeyAdapter (org.eclipse.swt.events.KeyAdapter)63 GridData (org.eclipse.swt.layout.GridData)54 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 Text (org.eclipse.swt.widgets.Text)34 KeyListener (org.eclipse.swt.events.KeyListener)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 Label (org.eclipse.swt.widgets.Label)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)22 ModifyListener (org.eclipse.swt.events.ModifyListener)22 Point (org.eclipse.swt.graphics.Point)21 Button (org.eclipse.swt.widgets.Button)21 MouseEvent (org.eclipse.swt.events.MouseEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)19 StyledText (org.eclipse.swt.custom.StyledText)13 FocusEvent (org.eclipse.swt.events.FocusEvent)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12