Search in sources :

Example 16 with MouseEvent

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

the class ImportComponentDialog method createDialogArea.

/*
     * (non-Javadoc) Method declared on Dialog.
     */
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout gl = new GridLayout(5, true);
    composite.setLayout(gl);
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL);
        data.horizontalSpan = 5;
        label.setLayoutData(data);
        label.setFont(parent.getFont());
    }
    Label label1 = new Label(composite, SWT.NONE);
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    gd.horizontalSpan = 2;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
    text = new Text(composite, SWT.BORDER);
    text.setEditable(false);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    text.setLayoutData(gd);
    if (paletteComponentsPath == null) {
        //$NON-NLS-1$
        paletteComponentsPath = "";
    }
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput(true);
        }
    });
    Button button = new Button(composite, SWT.NONE);
    //$NON-NLS-1$
    button.setText(Messages.getString("ImportComponentDialog.Browser"));
    gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 1;
    button.setLayoutData(gd);
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
            String path = dd.open();
            if (path != null) {
                text.setText(path);
            }
        }
    });
    Button showPaletteComponents = new Button(composite, SWT.NONE);
    gd = new GridData();
    gd.horizontalSpan = 2;
    showPaletteComponents.setLayoutData(gd);
    //$NON-NLS-1$
    showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
    showPaletteComponents.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            text.setText(paletteComponentsPath);
        }
    });
    label1 = new Label(composite, SWT.LEFT);
    gd = new GridData();
    gd.horizontalSpan = 1;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.Filter"));
    filterText = new Text(composite, SWT.BORDER);
    filterText.setEditable(true);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 2;
    filterText.setLayoutData(gd);
    filterText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            validateInput(false);
        }
    });
    label1 = new Label(composite, SWT.LEFT);
    gd = new GridData();
    gd.horizontalSpan = 5;
    label1.setLayoutData(gd);
    //$NON-NLS-1$
    label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
    componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 5;
    componentList.setLayoutData(gd);
    componentList.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
            validateSelected();
        }

        public void mouseUp(MouseEvent e) {
            validateSelected();
        }
    });
    errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = 5;
    label1.setLayoutData(gd);
    errorMessageText.setLayoutData(gd);
    errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    applyDialogFont(composite);
    //$NON-NLS-1$
    text.setText("");
    return composite;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(org.eclipse.swt.widgets.List) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 17 with MouseEvent

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

the class AbstractTalendEditor method initializeGraphicalViewer.

// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    // this uses the PartFactory set in configureGraphicalViewer
    // to create an EditPart for the diagram and sets it as the
    // content for the viewer
    IProcess2 process = getProcess();
    getGraphicalViewer().setContents(process);
    // containers are not correctly updated by default, so update them after all nodes have been added
    if (process != null) {
        for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
            subjobContainer.updateSubjobContainer();
        }
    }
    getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            updateActions(getSelectionActions());
        }
    });
    talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
    getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendEditorDropTargetListener(org.talend.designer.core.ui.editor.process.TalendEditorDropTargetListener) IProcess2(org.talend.core.model.process.IProcess2) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 18 with MouseEvent

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

the class DataMapTableView method addListeners.

/**
     * DOC amaumont Comment method "addListeners".
     */
protected void addListeners() {
    final UIManager uiManager = mapperManager.getUiManager();
    MouseTrackListener mouseTracker = new MouseTrackListener() {

        @Override
        public void mouseEnter(MouseEvent e) {
        }

        @Override
        public void mouseExit(MouseEvent e) {
            setDefaultCursor();
            resizeHelper.stopDrag();
        }

        @Override
        public void mouseHover(MouseEvent e) {
        }
    };
    this.addMouseTrackListener(mouseTracker);
    SelectionListener scrollListener = new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            uiManager.refreshBackground(true, false);
        }
    };
    tableForEntries.getVerticalBar().addSelectionListener(scrollListener);
    // /////////////////////////////////////////////////////////////////
    addManualTableResizeListeners(uiManager);
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    Listener onSelectDataMapTableViewListener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.MouseDown:
                    onSelectDataMapTableView();
                    break;
                default:
            }
        }
    };
    this.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    headerComposite.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    nameLabel.addListener(SWT.MouseDown, onSelectDataMapTableViewListener);
    // /////////////////////////////////////////////////////////////////
    // /////////////////////////////////////////////////////////////////
    minimizeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // TODO Auto-generated method stub
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            minimizeTable(!abstractDataMapTable.isMinimized());
        }
    });
    // /////////////////////////////////////////////////////////////////
    initShowMessageErrorListener(tableForEntries);
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) IModifiedBeanListener(org.talend.commons.ui.swt.tableviewer.IModifiedBeanListener) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IListenableListListener(org.talend.commons.utils.data.list.IListenableListListener) FocusListener(org.eclipse.swt.events.FocusListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener) KeyListener(org.eclipse.swt.events.KeyListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) UIManager(org.talend.designer.dbmap.managers.UIManager) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) ModifiedBeanEvent(org.talend.commons.ui.swt.tableviewer.ModifiedBeanEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ListenableListEvent(org.talend.commons.utils.data.list.ListenableListEvent) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LineSelectionEvent(org.talend.commons.ui.runtime.swt.tableviewer.selection.LineSelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener) ILineSelectionListener(org.talend.commons.ui.runtime.swt.tableviewer.selection.ILineSelectionListener)

Example 19 with MouseEvent

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

the class DataMapTableView method attachCellExpressionToStyledTextEditor.

/**
     * DOC amaumont Comment method "attachCellExpressionToStyledTextEditor".
     * 
     * @param tableViewerCreator TODO
     * @param styledTextHandler
     * @param expressionEditorText2
     */
protected void attachCellExpressionToStyledTextEditor(final TableViewerCreator tableViewerCreator, final Text expressionTextEditor, final StyledTextHandler styledTextHandler) {
    expressionTextEditor.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
            styledTextHandler.setCurrentEntry(currentModifiedEntry);
            Text text = (Text) e.widget;
            if (Math.abs(text.getText().length() - styledTextHandler.getStyledText().getText().length()) > 1) {
                styledTextHandler.setTextWithoutNotifyListeners(text.getText());
            // highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
            }
        }
    });
    expressionTextEditor.addKeyListener(new KeyListener() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
             */
        @Override
        public void keyPressed(KeyEvent e) {
            // System.out.println("e.character=" + e.character);
            // System.out.println("keyCode=" + e.keyCode);
            boolean ctrl = (e.stateMask & SWT.CTRL) != 0;
            boolean altgr = (e.stateMask & SWT.ALT) != 0;
            if (e.character == '\0' || ctrl && !altgr) {
                highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
            } else {
                UnnotifiableColorStyledText mapperColorStyledText = (UnnotifiableColorStyledText) styledTextHandler.getStyledText();
                Point selection = expressionTextEditor.getSelection();
                if (e.character == '\r' || e.character == '') {
                    e.doit = false;
                    styledTextHandler.setTextWithoutNotifyListeners(expressionTextEditor.getText());
                    highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
                } else {
                    if (e.character == SWT.BS || e.character == SWT.DEL) {
                        if (selection.x == selection.y) {
                            if (e.character == SWT.BS) {
                                if (selection.x - 1 > 0 && mapperColorStyledText.getText().length() > selection.x - 1) {
                                    char previousChar = mapperColorStyledText.getText().charAt(selection.x - 1);
                                    if (previousChar == '\n') {
                                        //$NON-NLS-1$
                                        mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 2, 2, "");
                                    } else {
                                        //$NON-NLS-1$
                                        mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x - 1, 1, "");
                                    }
                                }
                            } else {
                                if (selection.x < mapperColorStyledText.getText().length()) {
                                    char nextChar = mapperColorStyledText.getText().charAt(selection.x);
                                    if (nextChar == '\r') {
                                        //$NON-NLS-1$
                                        mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 2, "");
                                    } else {
                                        //$NON-NLS-1$
                                        mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, 1, "");
                                    }
                                }
                            }
                        } else {
                            if (selection.y <= mapperColorStyledText.getCharCount()) {
                                mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, //$NON-NLS-1$
                                "");
                            }
                            highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
                        }
                    } else {
                        // System.out.println("mapperColorStyledText.getText()="+mapperColorStyledText.getText().length());
                        if (selection.y <= mapperColorStyledText.getCharCount()) {
                            mapperColorStyledText.replaceTextRangeWithoutNotifyListeners(selection.x, selection.y - selection.x, String.valueOf(e.character));
                        }
                        highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
                    }
                }
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
        // highlightLineOfCursorPosition();
        }
    });
    expressionTextEditor.addMouseListener(new MouseListener() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
        }

        @Override
        public void mouseDown(MouseEvent e) {
            highlightLineAndSetSelectionOfStyledText(expressionTextEditor);
        }

        @Override
        public void mouseUp(MouseEvent e) {
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) KeyListener(org.eclipse.swt.events.KeyListener) UnnotifiableColorStyledText(org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText) Point(org.eclipse.swt.graphics.Point)

Example 20 with MouseEvent

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

the class Marker method createLineHover.

private void createLineHover(Integer invertedSeriesIndex) {
    if (lineHover == null || lineHover.isDisposed() || !lineHover.isVisible()) {
        lineHover = new Shell(chart.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL | SWT.NO_BACKGROUND);
        lineHover.addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                e.gc.setLineStyle(SWT.LINE_DOT);
                e.gc.setAntialias(SWT.ON);
                e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
                //        			e.gc.fillOval(2-1,150-1, 3, 3);
                e.gc.drawLine(2, 0, 2, chart.getPlotArea().getSize().y);
            }
        });
        lineHover.addMouseTrackListener(new MouseTrackAdapter() {

            @Override
            public void mouseEnter(MouseEvent e) {
                if (!isDisposed()) {
                    setPosition(mouseXPosition);
                }
            }
        });
    }
    lineHover.setSize(4, chart.getPlotArea().getSize().y);
    ISeries largestSeries = getLargestSeries();
    Date[] dates = largestSeries.getXDateSeries();
    long time = dates[dates.length - invertedSeriesIndex].getTime();
    int timeInPixel = chart.getAxisSet().getXAxes()[0].getPixelCoordinate(time);
    lineHover.setLocation(chart.getPlotArea().toDisplay(timeInPixel - 3, 0));
    lineHover.redraw();
    lineHover.setVisible(true);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) PaintEvent(org.eclipse.swt.events.PaintEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintListener(org.eclipse.swt.events.PaintListener) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) ISeries(org.swtchart.ISeries) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point)

Aggregations

MouseEvent (org.eclipse.swt.events.MouseEvent)75 MouseAdapter (org.eclipse.swt.events.MouseAdapter)39 GridData (org.eclipse.swt.layout.GridData)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 MouseListener (org.eclipse.swt.events.MouseListener)25 Point (org.eclipse.swt.graphics.Point)25 KeyEvent (org.eclipse.swt.events.KeyEvent)22 Composite (org.eclipse.swt.widgets.Composite)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)18 Button (org.eclipse.swt.widgets.Button)15 FocusEvent (org.eclipse.swt.events.FocusEvent)14 PaintEvent (org.eclipse.swt.events.PaintEvent)12 Text (org.eclipse.swt.widgets.Text)12 KeyListener (org.eclipse.swt.events.KeyListener)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)11 ModifyListener (org.eclipse.swt.events.ModifyListener)11 TraverseEvent (org.eclipse.swt.events.TraverseEvent)11 Event (org.eclipse.swt.widgets.Event)11 Label (org.eclipse.swt.widgets.Label)11