Search in sources :

Example 41 with FocusListener

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

Example 42 with FocusListener

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

the class RowGeneratorUI method init.

/**
     * yzhang Comment method "init".
     * 
     * @param fromDialog
     */
public void init(boolean fromDialog) {
    uiManager = generatorManager.getUiManager();
    final ExternalRowGeneratorUiProperties uiProperties = uiManager.getUiProperties();
    addParentListeners(uiManager, uiProperties);
    final Display display = rowGenUIParent.getDisplay();
    GridLayout parentLayout = new GridLayout(1, true);
    rowGenUIParent.setLayout(parentLayout);
    addKeyListener(uiManager, display);
    mainSashForm = new SashForm(rowGenUIParent, SWT.SMOOTH | SWT.VERTICAL);
    GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
    mainSashForm.setLayoutData(mainSashFormGridData);
    datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
    datasFlowViewSashForm.setLayoutData(mainSashFormGridData);
    datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
    initBackgroundComponents();
    // if (WindowSystem.isGTK()) {
    // datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
    // }
    /* Create Schema Table Editor */
    createSchemaComposite();
    /* Create the tabs */
    tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, externalNode, dataTableView);
    tabFolderEditors.setRowGeneratorUI(this);
    tabFolderEditors.getProcessPreview().refreshTablePreview(outputMetaTable.getListColumns(), null, true);
    if (!fromDialog) {
        new FooterComposite(this.rowGenUIParent, SWT.NONE, generatorManager);
    }
    dataTableView.getTable().addSelectionListener(new SelectionAdapter() {

        /*
             * (non-Java)
             * 
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateFunParameter((Table) e.getSource());
        }
    });
    dataTableView.getTable().addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            dataTableView.getTableViewerCreator().refresh();
        }

        @Override
        public void focusLost(FocusEvent e) {
        // TODO Auto-generated method stub
        }
    });
}
Also used : TabFolderEditors(org.talend.designer.rowgenerator.ui.tabs.TabFolderEditors) Table(org.eclipse.swt.widgets.Table) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FooterComposite(org.talend.designer.rowgenerator.ui.footer.FooterComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FocusEvent(org.eclipse.swt.events.FocusEvent) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ExternalRowGeneratorUiProperties(org.talend.designer.rowgenerator.external.data.ExternalRowGeneratorUiProperties) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) Display(org.eclipse.swt.widgets.Display)

Example 43 with FocusListener

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

the class FunParaTableView2 method updateData.

private void updateData(List<Parameter> params) {
    final Table table = this.getTable();
    final TableViewer viewer = this.getTableViewerCreator().getTableViewer();
    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // editing the Third column
    final int eDITABLECOLUMN = 2;
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // Clean up any previous editor control
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) {
                oldEditor.dispose();
            }
            // Identify the selected row
            TableItem item = (TableItem) e.item;
            if (item == null) {
                return;
            }
            Parameter param = (Parameter) item.getData();
            if (param instanceof ListParameter) {
                createCombo((ListParameter) param, item);
            }
        }

        private void createCombo(final ListParameter list, TableItem item) {
            final CCombo combo = new CCombo(table, SWT.NONE);
            combo.setItems(list.getValues());
            combo.setFocus();
            editor.setEditor(combo, item, eDITABLECOLUMN);
            combo.setText(list.getValue());
            Point size = combo.computeSize(SWT.DEFAULT, table.getItemHeight());
            // Set attributes of the editor
            editor.horizontalAlignment = SWT.LEFT;
            editor.minimumHeight = size.y;
            editor.minimumWidth = size.x;
            combo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    list.setValue(combo.getText());
                    viewer.refresh(list);
                    ext.setChanged(true);
                    rowGenTableEditor2.getTableViewerCreator().getTableViewer().refresh();
                }
            });
            combo.addFocusListener(new FocusListener() {

                public void focusGained(FocusEvent e) {
                }

                /**
                     * Sent when a control loses focus.
                     * 
                     * @param e an event containing information about the focus change
                     */
                public void focusLost(FocusEvent e) {
                    combo.dispose();
                }
            });
        }
    });
    getTableViewerCreator().setInputList(params);
}
Also used : Table(org.eclipse.swt.widgets.Table) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) TableEditor(org.eclipse.swt.custom.TableEditor) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) Control(org.eclipse.swt.widgets.Control) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Parameter(org.talend.designer.rowgenerator.data.Parameter) ListParameter(org.talend.designer.rowgenerator.data.ListParameter) ListParameter(org.talend.designer.rowgenerator.data.ListParameter) TableViewer(org.eclipse.jface.viewers.TableViewer) FocusListener(org.eclipse.swt.events.FocusListener)

Example 44 with FocusListener

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

the class HeapHistogramPage method createContextMenu.

/**
     * Creates the context menu.
     * 
     * @param actionBars The action bars
     */
private void createContextMenu(IActionBars actionBars) {
    final OpenDeclarationAction openAction = OpenDeclarationAction.createOpenDeclarationAction(actionBars);
    final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
    configureColumnsAction = new ConfigureColumnsAction(this);
    heapViewer.addSelectionChangedListener(openAction);
    heapViewer.getControl().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            heapViewer.removeSelectionChangedListener(copyAction);
        }

        @Override
        public void focusGained(FocusEvent e) {
            heapViewer.addSelectionChangedListener(copyAction);
        }
    });
    heapViewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            openAction.run();
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            manager.add(openAction);
            manager.add(copyAction);
            manager.add(new Separator());
            manager.add(configureColumnsAction);
        }
    });
    Menu menu = menuMgr.createContextMenu(heapViewer.getControl());
    heapViewer.getControl().setMenu(menu);
}
Also used : OpenDeclarationAction(org.talend.designer.runtime.visualization.internal.actions.OpenDeclarationAction) CopyAction(org.talend.designer.runtime.visualization.internal.actions.CopyAction) FocusEvent(org.eclipse.swt.events.FocusEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) IOpenListener(org.eclipse.jface.viewers.IOpenListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) ConfigureColumnsAction(org.talend.designer.runtime.visualization.internal.actions.ConfigureColumnsAction) FocusListener(org.eclipse.swt.events.FocusListener) Separator(org.eclipse.jface.action.Separator) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 45 with FocusListener

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

the class MapperUI method addParentListeners.

private void addParentListeners(final UIManager uiManager, final ExternalMapperUiProperties uiProperties) {
    mapperUIParent.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            release();
        }
    });
    mapperUIParent.addListener(SWT.Close, new Listener() {

        public void handleEvent(Event event) {
            if (uiManager.getMapperResponse() == SWT.NONE) {
                uiManager.setMapperResponse(SWT.CANCEL);
            }
        }
    });
    mapperUIParent.addFocusListener(new FocusListener() {

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

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

            public void controlMoved(ControlEvent e) {
            }

            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ShellListener(org.eclipse.swt.events.ShellListener) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) 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