Search in sources :

Example 16 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class MapperUI method addParentListeners.

private void addParentListeners(final UIManager uiManager, final ExternalDbMapUiProperties 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) 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) 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)

Example 17 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class MapperUI method addKeyListener.

private void addKeyListener(final UIManager uiManager, final Display display) {
    Listener listener = new Listener() {

        public void handleEvent(Event event) {
            if (event.type == SWT.KeyUp || event.type == SWT.KeyDown) {
                boolean isPressed = event.type == SWT.KeyDown ? true : false;
                if (event.keyCode == SWT.CTRL) {
                    uiManager.setCtrlPressed(isPressed);
                // System.out.println("+++++ Ctrl : " + isPressed);
                }
                if (event.keyCode == SWT.SHIFT) {
                    uiManager.setShiftPressed(isPressed);
                // System.out.println("+++++ Shift : "+ isPressed);
                }
            }
        // System.out.println(event.stateMask);
        }
    };
    display.addFilter(SWT.KeyUp, listener);
    display.addFilter(SWT.KeyDown, listener);
// display.addFilter(SWT.Move, listener);
// display.addFilter(SWT.MouseMove, listener);
// display.addFilter(SWT.HardKeyDown, listener);
// display.addFilter(SWT.HardKeyUp, listener);
// display.addFilter(SWT.None, listener);
// display.addFilter(SWT.DragDetect, listener);
// display.addFilter(SWT.Paint, listener);
// display.addListener(SWT.KeyUp, listener);
// display.addListener(SWT.KeyDown, listener);
// display.addListener(SWT.Move, listener);
// display.addListener(SWT.MouseMove, listener);
// display.addListener(SWT.HardKeyDown, listener);
// display.addListener(SWT.HardKeyUp, listener);
// display.addListener(SWT.None, listener);
// display.addListener(SWT.DragDetect, listener);
// display.addListener(SWT.Paint, listener);
}
Also used : 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) 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) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 18 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class JSONFileStep2Form method addGroupSchemaTarget.

private void addGroupSchemaTarget(final Composite mainComposite, final int width, final int height) {
    // Group Schema Viewer
    schemaTargetGroup = Form.createGroup(mainComposite, 1, "Target Schema", height);
    // to correct graphic bug under Linux-GTK when the wizard is opened the first time
    if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
        schemaTargetGroup.addListener(SWT.Paint, new Listener() {

            @Override
            public void handleEvent(Event event) {
                Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), schemaTargetGroup, new Point(0, 0));
                linker.setOffset(offsetPoint);
                linker.drawBackground(event.gc);
            }
        });
    }
    // ///////////////////////////////////////////
    schemaTargetGroup.setBackgroundMode(SWT.INHERIT_FORCE);
    CommandStackForComposite commandStack = new CommandStackForComposite(schemaTargetGroup);
    loopModel = new JSONExtractorLoopModel("Path loop expression");
    loopTableEditorView = new ExtractionLoopWithJSONXPathEditorView(loopModel, schemaTargetGroup);
    loopTableEditorView.getExtendedTableViewer().setCommandStack(commandStack);
    GridData data2 = new GridData(GridData.FILL_HORIZONTAL);
    data2.heightHint = 90;
    final Composite loopTableEditorComposite = loopTableEditorView.getMainComposite();
    loopTableEditorComposite.setLayoutData(data2);
    loopTableEditorComposite.setBackground(null);
    // to correct graphic bug under Linux-GTK when the wizard is opened the first time
    if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
        loopTableEditorComposite.addListener(SWT.Paint, new Listener() {

            @Override
            public void handleEvent(Event event) {
                Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), loopTableEditorComposite, new Point(0, 0));
                linker.setOffset(offsetPoint);
                linker.drawBackground(event.gc);
            }
        });
    }
    // ///////////////////////////////////////////
    // Messages.getString("FileStep3.metadataDescription")
    fieldsModel = new JSONExtractorFieldModel("Fields to extract");
    fieldsTableEditorView = new ExtractionFieldsWithJSONXPathEditorView(fieldsModel, schemaTargetGroup);
    fieldsTableEditorView.getExtendedTableViewer().setCommandStack(commandStack);
    final Composite fieldTableEditorComposite = fieldsTableEditorView.getMainComposite();
    data2 = new GridData(GridData.FILL_BOTH);
    data2.heightHint = 180;
    fieldTableEditorComposite.setLayoutData(data2);
    fieldTableEditorComposite.setBackground(null);
    // to correct graphic bug under Linux-GTK when the wizard is opened the first time
    if (WindowSystem.isGTK() && firstTimeWizardOpened.equals(Boolean.TRUE)) {
        fieldTableEditorComposite.addListener(SWT.Paint, new Listener() {

            @Override
            public void handleEvent(Event event) {
                Point offsetPoint = event.display.map(linker.getBgDrawableComposite(), fieldTableEditorComposite, new Point(0, 0));
                linker.setOffset(offsetPoint);
                linker.drawBackground(event.gc);
            }
        });
    }
// ///////////////////////////////////////////
}
Also used : CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) JSONExtractorFieldModel(org.talend.repository.json.ui.wizards.extraction.JSONExtractorFieldModel) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) IPreviewHandlerListener(org.talend.metadata.managment.ui.preview.IPreviewHandlerListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) ExtractionLoopWithJSONXPathEditorView(org.talend.repository.json.ui.wizards.extraction.ExtractionLoopWithJSONXPathEditorView) GridData(org.eclipse.swt.layout.GridData) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) Event(org.eclipse.swt.widgets.Event) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExtractionFieldsWithJSONXPathEditorView(org.talend.repository.json.ui.wizards.extraction.ExtractionFieldsWithJSONXPathEditorView) Point(org.eclipse.swt.graphics.Point) JSONExtractorLoopModel(org.talend.repository.json.ui.wizards.extraction.JSONExtractorLoopModel)

Example 19 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class AbstractTreeNodeButton method init.

private void init(Composite parent, String tooltip, Image image) {
    button = new Button(parent, SWT.PUSH);
    button.setToolTipText(tooltip);
    button.setImage(image);
    button.setEnabled(false);
    button.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (treeViewer != null && !treeViewer.getTree().isDisposed() && treeViewer.getSelection() instanceof ITreeSelection) {
                handleSelectionEvent((TreeSelection) treeViewer.getSelection());
            }
        }
    });
    treeViewer = form.getTreeViewer();
    addTreeListeners();
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) Button(org.eclipse.swt.widgets.Button) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event)

Example 20 with Listener

use of org.eclipse.swt.widgets.Listener in project tdi-studio-se by Talend.

the class MergeOrderDialog method createDialogArea.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
     */
@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite tableComposite = new Composite(composite, SWT.None);
    tableComposite.setLayout(new GridLayout());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.widthHint = WIDTH;
    gridData.minimumWidth = WIDTH;
    gridData.heightHint = HEIGHT;
    gridData.minimumHeight = HEIGHT;
    tableComposite.setLayoutData(gridData);
    final TableViewerCreator tableViewerCreator = new TableViewerCreator(tableComposite);
    tableViewerCreator.setBorderVisible(true);
    tableViewerCreator.setCheckboxInFirstColumn(false);
    tableViewerCreator.setColumnsResizableByDefault(true);
    tableViewerCreator.setColumnsSortableByDefault(true);
    tableViewerCreator.setLayoutMode(LAYOUT_MODE.FILL_HORIZONTAL);
    Table table = tableViewerCreator.createTable();
    table.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MergeOrderDialog.Order"));
    column.setModifiable(true);
    column.setWidth(50);
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MergeOrderDialog.CurrentOrderConnection"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {

        public String get(Connection bean) {
            return String.valueOf(connectionList.indexOf(bean) + 1);
        }

        public void set(Connection bean, String value) {
        // bean.setName(value);
        }
    });
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MergeOrderDialog.ConnectionName"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Connection, String>() {

        public String get(Connection bean) {
            return getDisplayStr(bean);
        }

        public void set(Connection bean, String value) {
        // bean.setName(value);
        }
    });
    column.setModifiable(false);
    column.setWidth(200);
    tableViewerCreator.init(connectionList);
    Composite buttonComposite = new Composite(composite, SWT.None);
    buttonComposite.setLayout(new RowLayout(SWT.HORIZONTAL));
    Button moveUp = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveUp.setToolTipText(Messages.getString("MergeOrderDialog.MoveUp"));
    moveUp.setImage(ImageProvider.getImage(EImage.UP_ICON));
    moveUp.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
            Connection connection = (Connection) selection.getFirstElement();
            int connId = connectionList.indexOf(connection);
            if (connId > 0) {
                Collections.swap(connectionList, connId - 1, connId);
                tableViewerCreator.getTableViewer().refresh();
            }
        }
    });
    Button moveDown = new Button(buttonComposite, SWT.PUSH);
    //$NON-NLS-1$
    moveDown.setToolTipText(Messages.getString("MergeOrderDialog.MoveDown"));
    moveDown.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
    if (getMergeNode() != null && getMergeNode().isReadOnly()) {
        moveUp.setEnabled(false);
        moveDown.setEnabled(false);
    }
    final int nbConn = getConnectionQty();
    moveDown.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            IStructuredSelection selection = (IStructuredSelection) tableViewerCreator.getTableViewer().getSelection();
            if (selection.size() > 0) {
                Connection connection = (Connection) selection.getFirstElement();
                int connId = connectionList.indexOf(connection);
                if (connId < (nbConn - 1)) {
                    Collections.swap(connectionList, connId + 1, connId);
                    tableViewerCreator.getTableViewer().refresh();
                }
            }
        }
    });
    return composite;
}
Also used : TableViewerCreator(org.talend.commons.ui.swt.tableviewer.TableViewerCreator) Table(org.eclipse.swt.widgets.Table) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Aggregations

Listener (org.eclipse.swt.widgets.Listener)876 Event (org.eclipse.swt.widgets.Event)841 SelectionEvent (org.eclipse.swt.events.SelectionEvent)538 Button (org.eclipse.swt.widgets.Button)480 Label (org.eclipse.swt.widgets.Label)452 Text (org.eclipse.swt.widgets.Text)392 ModifyListener (org.eclipse.swt.events.ModifyListener)385 Shell (org.eclipse.swt.widgets.Shell)385 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)382 ModifyEvent (org.eclipse.swt.events.ModifyEvent)376 FormData (org.eclipse.swt.layout.FormData)356 ShellEvent (org.eclipse.swt.events.ShellEvent)354 FormAttachment (org.eclipse.swt.layout.FormAttachment)353 FormLayout (org.eclipse.swt.layout.FormLayout)353 Display (org.eclipse.swt.widgets.Display)342 ShellAdapter (org.eclipse.swt.events.ShellAdapter)325 Composite (org.eclipse.swt.widgets.Composite)295 GridData (org.eclipse.swt.layout.GridData)229 GridLayout (org.eclipse.swt.layout.GridLayout)195 TextVar (org.pentaho.di.ui.core.widget.TextVar)184