Search in sources :

Example 76 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project MonjaDB by Kanatoko.

the class MDocumentList method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    table = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            onMouseDown(e);
        }
    });
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    FormData d1 = new FormData();
    d1.top = new FormAttachment(0, 32);
    d1.left = new FormAttachment(0, 1);
    d1.right = new FormAttachment(100, -1);
    d1.bottom = new FormAttachment(100, -1);
    table.setLayoutData(d1);
    menuManager = new MenuManager();
    Menu contextMenu = menuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    historyCombo = new Combo(parent, SWT.NONE);
    historyCombo.setToolTipText("Find Query. Hit Enter to apply.");
    historyCombo.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            //debug( e );
            if (e.keyCode == 13) {
                String text = historyCombo.getText();
                if (text != null && text.length() > 0) {
                    executeAction(text);
                }
            }
        }
    });
    FormData fd_combo = new FormData();
    fd_combo.bottom = new FormAttachment(table, -3);
    fd_combo.left = new FormAttachment(0, 4);
    fd_combo.right = new FormAttachment(30, 0);
    historyCombo.setLayoutData(fd_combo);
    //listeners
    table.addListener(SWT.MouseDoubleClick, this);
    table.addListener(SWT.Selection, this);
    table.addListener(SWT.KeyDown, this);
    image = MUtil.getImage(parent.getShell().getDisplay(), "table.png");
    final MDocumentList documentList = this;
    {
        //editDocumentAction
        editDocumentAction = new Action() {

            public void run() {
                //--------
                editDocument();
            }
        };
        //-----
        editDocumentAction.setText("Edit Document");
        setActionImage(editDocumentAction, "table_edit.png");
        menuManager.add(editDocumentAction);
    }
    {
        //editFieldAction
        editFieldAction = new Action() {

            public void run() {
                //--------
                editField();
            }
        };
        //-----
        editFieldAction.setText("Edit Field");
        setActionImage(editFieldAction, "page_edit.png");
        menuManager.add(editFieldAction);
    }
    menuManager.add(new Separator());
    {
        //copyAction
        copyAction = new Action() {

            public void run() {
                //--------
                copy();
            }
        };
        //-----
        copyAction.setText("Copy\tCtrl+C");
        setActionImage(copyAction, "page_copy.png");
        menuManager.add(copyAction);
    }
    {
        //pasteAction
        pasteAction = new Action() {

            public void run() {
                //--------
                paste();
            }
        };
        //-----
        pasteAction.setText("Paste\tCtrl+V");
        setActionImage(pasteAction, "page_white_paste_table.png");
        menuManager.add(pasteAction);
    }
    {
        //insertBlankAction
        insertBlankAction = new Action() {

            public void run() {
                //--------
                insertBlankDocument();
            }
        };
        //-----
        insertBlankAction.setText("Insert Blank Document");
        setActionImage(insertBlankAction, "table_add.png");
        menuManager.add(insertBlankAction);
    }
    {
        //insertJsonAction
        insertJsonAction = new Action() {

            public void run() {
                //--------
                insertJsonDocument();
            }
        };
        //-----
        insertJsonAction.setText("Insert JSON");
        setActionImage(insertJsonAction, "table_add.png");
        menuManager.add(insertJsonAction);
    }
    menuManager.add(new Separator());
    {
        copyFieldAction = new Action() {

            public void run() {
                //--------
                copyField();
            }
        };
        //-----
        copyFieldAction.setText("Copy Field(s)");
        menuManager.add(copyFieldAction);
    }
    {
        copyAsJsonAction = new Action() {

            public void run() {
                //--------
                copyAsJson();
            }
        };
        //-----
        copyAsJsonAction.setText("Copy Documents As JSON");
        menuManager.add(copyAsJsonAction);
    }
    {
        copyAsStringAction = new Action() {

            public void run() {
                //--------
                copyAsString();
            }
        };
        //-----
        copyAsStringAction.setText("Copy Documents As String");
        menuManager.add(copyAsStringAction);
    }
    menuManager.add(new Separator());
    {
        //removeAction
        removeAction = new Action() {

            public void run() {
                //--------
                remove();
            }
        };
        //-----
        removeAction.setText("Remove\tDEL");
        setActionImage(removeAction, "table_delete.png");
        menuManager.add(removeAction);
    }
    menuManager.add(new Separator());
    {
        //reloadAction
        reloadAction = new Action() {

            public void run() {
                //--------
                reload();
            }
        };
        //-----
        reloadAction.setText("Reload\tF5/Ctrl+R");
        reloadAction.setToolTipText("Reload Documents");
        initAction(reloadAction, "table_refresh.png", menuManager);
    }
    menuManager.add(new Separator());
    {
        //backAction
        backAction = new Action() {

            public void run() {
                //--------
                MHistory findHistory = dataManager.getFindHistory();
                if (!findHistory.atBegin()) {
                    findHistory.back();
                    documentList.executeAction(findHistory.current() + "");
                }
            }
        };
        //-----
        backAction.setText("Back");
        backAction.setToolTipText("Previous Find Query");
        initAction(backAction, "bullet_left.png", menuManager);
    }
    {
        //forwardAction
        forwardAction = new Action() {

            public void run() {
                //--------
                MHistory findHistory = dataManager.getFindHistory();
                if (!findHistory.atEnd()) {
                    findHistory.forward();
                    documentList.executeAction(findHistory.current() + "");
                }
            }
        };
        //-----
        forwardAction.setText("Forward");
        forwardAction.setToolTipText("Next Find Query");
        initAction(forwardAction, "bullet_right.png", menuManager);
    }
    menuManager.add(new Separator());
    {
        //prevItemsAction
        prevItemsAction = new Action() {

            public void run() {
                //--------
                showPrevItems();
            }
        };
        //-----
        prevItemsAction.setText("Previous Items");
        prevItemsAction.setToolTipText("Show Previous Results");
        setActionImage(prevItemsAction, "page_back.png");
        addActionToDropDownMenu(prevItemsAction);
        menuManager.add(prevItemsAction);
    }
    {
        //prevItemsButton
        prevItemsButton = new Button(parent, SWT.FLAT);
        prevItemsButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                showPrevItems();
            }
        });
        FormData fd_btnNewButton = new FormData();
        fd_btnNewButton.right = new FormAttachment(table, -40, SWT.RIGHT);
        prevItemsButton.setLayoutData(fd_btnNewButton);
        Image image = MUtil.getImage(parent.getShell().getDisplay(), "page_back.png");
        prevItemsButton.setImage(image);
    }
    {
        //nextItemsAction
        nextItemsAction = new Action() {

            public void run() {
                //--------
                showNextItems();
            }
        };
        //-----
        nextItemsAction.setText("Next Items");
        nextItemsAction.setToolTipText("Show Next Results");
        setActionImage(nextItemsAction, "page_forward.png");
        addActionToDropDownMenu(nextItemsAction);
        menuManager.add(nextItemsAction);
    }
    {
        //nextItemsButton
        nextItemsButton = new Button(parent, SWT.FLAT);
        nextItemsButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                showNextItems();
            }
        });
        FormData fd_btnNewButton = new FormData();
        fd_btnNewButton.right = new FormAttachment(table, -10, SWT.RIGHT);
        nextItemsButton.setLayoutData(fd_btnNewButton);
        Image image = MUtil.getImage(parent.getShell().getDisplay(), "page_forward.png");
        nextItemsButton.setImage(image);
    }
    naviLabel = new Label(parent, SWT.NONE);
    FormData fd_naviLabel = new FormData();
    fd_naviLabel.top = new FormAttachment(historyCombo, 6, SWT.TOP);
    //fd_naviLabel.left = new FormAttachment(prevItemsButton, -66, SWT.LEFT);
    fd_naviLabel.right = new FormAttachment(prevItemsButton, -6, SWT.LEFT);
    naviLabel.setLayoutData(fd_naviLabel);
    naviLabel.setText("");
    grepCombo = new Combo(parent, SWT.NONE);
    grepCombo.setToolTipText("Grep(RegEx). Hit Enter to apply");
    FormData fd_grepCombo = new FormData();
    fd_grepCombo.right = new FormAttachment(50);
    fd_grepCombo.bottom = new FormAttachment(table, -3);
    fd_grepCombo.left = new FormAttachment(30, 6);
    grepCombo.setLayoutData(fd_grepCombo);
    grepCombo.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
                grep();
            }
        }
    });
    initActionsAndButtons();
}
Also used : MEditAction(net.jumperz.app.MMonjaDBCore.action.mj.MEditAction) MShowAllDbStatsAction(net.jumperz.app.MMonjaDBCore.action.mj.MShowAllDbStatsAction) MouseEvent(org.eclipse.swt.events.MouseEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 77 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project AutoRefactor by JnRouvignac.

the class ChooseRefactoringWizardPage method createFilterText.

private void createFilterText(Composite parent) {
    filterText = new Text(parent, SWT.BORDER | SWT.SINGLE);
    filterText.setMessage("Type in to filter refactorings");
    filterText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    filterText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent event) {
            // trigger a call to StyledCellLabelProvider.update()
            tableViewer.refresh(true);
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text)

Example 78 with KeyEvent

use of org.eclipse.swt.events.KeyEvent in project KaiZen-OpenAPI-Editor by RepreZen.

the class QuickOutline method createTreeViewer.

protected TreeViewer createTreeViewer(Composite parent) {
    final Tree tree = new Tree(parent, SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = tree.getItemHeight();
    tree.setLayoutData(gd);
    final TreeViewer treeViewer = new TreeViewer(tree);
    treeViewer.setContentProvider(new OutlineContentProvider());
    treeViewer.setLabelProvider(new OutlineStyledLabelProvider());
    treeViewer.addFilter(new NamePatternFilter());
    // Using ALL_LEVELS will cause editor to hang on large specs
    treeViewer.setAutoExpandLevel(2);
    treeViewer.setUseHashlookup(true);
    tree.addKeyListener(new KeyListener() {

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

        @Override
        public void keyPressed(KeyEvent e) {
            if (isInvocationEvent(e)) {
                e.doit = false;
                handleMultiView();
            } else if (e.keyCode == SWT.CR) {
                handleSelection();
                QuickOutline.this.close();
            }
        }
    });
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            super.mouseDown(e);
        }

        public void mouseUp(MouseEvent e) {
            if (tree.getSelectionCount() < 1) {
                return;
            }
            if (e.button != 1) {
                return;
            }
            if (tree.equals(e.getSource())) {
                Object o = tree.getItem(new Point(e.x, e.y));
                TreeItem selection = tree.getSelection()[0];
                if (selection.equals(o)) {
                    handleSelection();
                }
            }
        }
    });
    tree.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
        // do nothing
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            handleSelection();
        }
    });
    return treeViewer;
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) KeyListener(org.eclipse.swt.events.KeyListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 79 with KeyEvent

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

the class MultiSchemasUI method addFieldsListenersGroupFileSettings.

private void addFieldsListenersGroupFileSettings() {
    // Event encodingCombo
    encodingCombo.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            getConnection().setEncoding(encodingCombo.getText());
            checkFieldsValue();
        }
    });
    // Separator Combo (field and row)
    fieldSeparatorCombo.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            // Label Custom of fieldSeparatorText
            fieldSeparatorManager();
        }
    });
    rowSeparatorCombo.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            // Label Custom of rowSeparatorText
            rowSeparatorManager();
        }
    });
    // Separator Text (field and row)
    fieldSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            getConnection().setFieldSeparatorValue(fieldSeparatorText.getText());
            checkFieldsValue();
        }
    });
    multiSeparatorsText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            getConnection().setFieldSeparatorValue(multiSeparatorsText.getText());
            previewBtn.setEnabled(checkFieldsValue());
        }
    });
    keyIndexText.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.character > '9' || e.character < '0') {
                if (e.character != '\b' || e.keyCode == '') {
                    e.doit = false;
                }
            }
        }
    });
    keyIndexText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            boolean modify = false;
            if (keyIndexText.getText() == null || "".equals(keyIndexText.getText())) {
                multiSchemaManager.setSelectedColumnIndex(0);
                modify = true;
            } else {
                int index = 0;
                try {
                    index = Integer.parseInt(keyIndexText.getText());
                } catch (Exception ex) {
                    index = 0;
                    keyIndexText.setText(String.valueOf(index));
                }
                multiSchemaManager.setSelectedColumnIndex(index);
                modify = true;
            }
            if (modify) {
            // refreshPreview();
            }
            previewBtn.setEnabled(checkFieldsValue());
            if (previewBtn.isEnabled()) {
                refreshPreview();
            }
        }
    });
    keyValuesText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            previewBtn.setEnabled(checkFieldsValue());
        }
    });
    rowSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(final ModifyEvent e) {
            getConnection().setRowSeparatorValue(rowSeparatorText.getText());
            checkFieldsValue();
        }
    });
    cardText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            IStructuredSelection selection = (IStructuredSelection) schemaTreeViewer.getSelection();
            Object element = selection.getFirstElement();
            if (element != null && (element instanceof SchemasKeyData)) {
                ((SchemasKeyData) element).setCard(cardText.getText());
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 80 with KeyEvent

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

the class MultiSchemasUI method addFieldListeners.

private void addFieldListeners() {
    fileField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setFilePath(fileField.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
            refreshPreview();
        }
    });
    rowSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setRowSeparatorValue(rowSeparatorText.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
        }
    });
    fieldSeparatorText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getConnection().setFieldSeparatorValue(fieldSeparatorText.getText());
            previewBtn.setEnabled(checkFieldsValue());
            clearPreview();
        }
    });
    useMultiSaparators.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean selected = useMultiSaparators.getSelection();
            fieldSeparatorCombo.setEnabled(!selected);
            fieldSeparatorText.setEditable(!selected);
            multiSeparatorsText.setEditable(selected);
            keyValuesText.setEditable(selected);
            keyIndexText.setEditable(selected);
            escapeCharCombo.setEnabled(selected);
            textEnclosureCombo.setEnabled(selected);
            csvRadio.setSelection(selected);
            delimitedRadio.setSelection(!selected);
            delimitedRadio.setEnabled(!selected);
            if (selected) {
                getConnection().setFieldSeparatorValue(multiSeparatorsText.getText());
                multiSchemaManager.setSelectedColumnIndex(Integer.parseInt(keyIndexText.getText()));
            } else {
                getConnection().setFieldSeparatorValue(fieldSeparatorText.getText());
            }
            clearPreview();
            previewBtn.setEnabled(checkFieldsValue());
            if (previewBtn.isEnabled()) {
                refreshPreview();
            }
        }
    });
    schemaTreeViewer.getTree().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            getUIManager().refreshSchemasDetailView(schemaTreeViewer, schemaDetailsViewer, getSchemaDetailModel());
        }
    });
    schemaTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            removeRow.setEnabled(true);
            editSchema.setEnabled(true);
            if (isReadOnly()) {
                leftBtn.setEnabled(false);
                rightBtn.setEnabled(false);
            } else {
                leftBtn.setEnabled(getUIManager().enableMovedRecord(schemaTreeViewer, true));
                rightBtn.setEnabled(getUIManager().enableMovedRecord(schemaTreeViewer, false));
            }
            IStructuredSelection selection = (IStructuredSelection) schemaTreeViewer.getSelection();
            Object element = selection.getFirstElement();
            if (element != null && (element instanceof SchemasKeyData) && ((SchemasKeyData) element).getTagLevel() > 0) {
                cardText.setText(((SchemasKeyData) element).getCard());
                cardText.setEnabled(true);
            } else {
                //$NON-NLS-1$
                cardText.setText("");
                cardText.setEnabled(false);
            }
        }
    });
    schemaTreeViewer.getTree().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
        //
        }

        @Override
        public void keyReleased(KeyEvent e) {
        //
        }
    });
    schemaTreeViewer.addTreeListener(new ITreeViewerListener() {

        public void treeCollapsed(TreeExpansionEvent event) {
        // getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
        }

        public void treeExpanded(TreeExpansionEvent event) {
        // getUIManager().packSchemaTreeFirstColumn(schemaTreeViewer);
        }
    });
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

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