Package org.eclipse.swt.custom

Examples of org.eclipse.swt.custom.ControlEditor


            item.setText(1, "");
        }

        final TableCursor cursor = new TableCursor(table, SWT.NONE);

        final ControlEditor editor = new ControlEditor(cursor);
        editor.grabHorizontal = true;
        editor.grabVertical = true;

        cursor.addMouseListener(new MouseAdapter() {
            public void mouseDoubleClick(MouseEvent arg0) {
                if (cursor.getColumn() == 1) {
                    final Text text = new Text(cursor, SWT.NONE);
                    text.setFocus();

                    text.setText(cursor.getRow().getText(cursor.getColumn()));
                    text.setFocus();

                    text.addFocusListener(new FocusListener() {
                        public void focusLost(FocusEvent event) {
                            cursor.getRow().setText(cursor.getColumn(), text.getText());
                            text.dispose();
                        }

                        public void focusGained(FocusEvent arg0) {
                        }
                    });

                    text.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent event) {
                            switch (event.keyCode) {
                                case SWT.CR:
                                    cursor.getRow().setText(cursor.getColumn(), text.getText());
                                case SWT.ESC:
                                    text.dispose();
                                    break;
                            }
                        }
                    });

                    editor.setEditor(text);
                }
            }
        });

        cursor.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent event) {
                table.setSelection(new TableItem[] { cursor.getRow() });
            }

            public void widgetDefaultSelected(SelectionEvent event) {
                if (cursor.getColumn() == 1) {
                    final Text text = new Text(cursor, SWT.NONE);
                    text.setFocus();

                    text.setText(cursor.getRow().getText(cursor.getColumn()));
                    text.setFocus();

                    text.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent event) {
                            switch (event.keyCode) {
                                case SWT.CR:
                                    cursor.getRow().setText(cursor.getColumn(), text.getText());
                                case SWT.ESC:
                                    text.dispose();
                                    break;
                            }
                        }
                    });

                    text.addFocusListener(new FocusListener() {
                        public void focusLost(FocusEvent event) {
                            cursor.getRow().setText(cursor.getColumn(), text.getText());
                            text.dispose();
                        }

                        public void focusGained(FocusEvent arg0) {
                        }
                    });

                    editor.setEditor(text);
                }
            }
        });
       
        FormData data = new FormData();
View Full Code Here


    paymentTable.setLinesVisible(true);
    paymentTable.setHeaderVisible(true);

    final TableCursor cursor = new TableCursor(paymentTable, SWT.NONE);

    final ControlEditor editor = new ControlEditor(cursor);
    editor.grabHorizontal = true;
    editor.grabVertical = true;

    GridData dataTable = new GridData(GridData.FILL_BOTH);
    dataTable.heightHint = 150;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.custom.ControlEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.