Search in sources :

Example 56 with KeyListener

use of org.eclipse.swt.events.KeyListener in project translationstudio8 by heartsome.

the class TermBaseSearchDialog method initListener.

/**
	 * 初始化各控件的监听 ;
	 */
private void initListener() {
    // 当点击添加/删除语言按钮时,菜单要显示在按钮下方
    btnSelectLang.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            Rectangle rect = btnSelectLang.getBounds();
            // Point pt = selLangBar.toDisplay(new Point(event.x + rect.width, event.y + rect.height));
            // menu.setOrientation(SWT.RIGHT_TO_LEFT);
            Point pt = btnSelectLang.toDisplay(new Point(event.x, event.y + rect.height));
            menu.setLocation(pt.x, pt.y);
            menu.setVisible(true);
        }
    });
    btnApplyRegularExpression.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            setEnabled();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnSearch.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            search();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    cmbSearch.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
                search();
            }
        }

        public void keyReleased(KeyEvent e) {
        }
    });
    /**
		 * 添加双击插入术语到编辑区
		 */
    grid.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            // TODO Auto-generated method stub
            InsertGridTgtToEditor();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) DisposeListener(org.eclipse.swt.events.DisposeListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) Rectangle(org.eclipse.swt.graphics.Rectangle) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener) Point(org.eclipse.swt.graphics.Point) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 57 with KeyListener

use of org.eclipse.swt.events.KeyListener in project cubrid-manager by CUBRID.

the class ReformatColumnsAliasDialog method createContents.

protected void createContents() {
    shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    shell.setLayout(gridLayout);
    shell.setSize(450, 100);
    shell.setText(Messages.reformatTableAliasTitle);
    final Composite composite = new Composite(shell, SWT.NONE);
    final GridData gdComposite = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdComposite.heightHint = 0;
    gdComposite.widthHint = 296;
    composite.setLayoutData(gdComposite);
    composite.setLayout(new GridLayout());
    sqlComp = getActiveSQLEditorComposite();
    if (sqlComp == null) {
        close();
        return;
    }
    final Composite group = new Composite(composite, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    final GridLayout gridLayoutGroup = new GridLayout();
    gridLayoutGroup.marginHeight = 0;
    gridLayoutGroup.numColumns = 1;
    group.setLayout(gridLayoutGroup);
    {
        final Label findWhatLabel = new Label(group, SWT.NONE);
        String msg = Messages.reformatTableAliasMessage;
        findWhatLabel.setText(msg);
        aliasText = new Text(group, SWT.BORDER);
        final GridData gdFind = new GridData(SWT.FILL, SWT.CENTER, true, false);
        aliasText.setLayoutData(gdFind);
        aliasText.addKeyListener(new KeyListener() {

            public void keyReleased(KeyEvent e) {
            }

            public void keyPressed(KeyEvent e) {
                if (e.keyCode == SWT.CR) {
                    submit();
                }
            }
        });
    }
    final Composite composite1 = new Composite(shell, SWT.NONE);
    final GridData gdComposite1 = new GridData(SWT.RIGHT, SWT.FILL, false, false);
    composite1.setLayoutData(gdComposite1);
    final GridLayout gridLayoutGroup2 = new GridLayout();
    gridLayoutGroup2.marginHeight = 0;
    gridLayoutGroup2.numColumns = 2;
    composite1.setLayout(gridLayoutGroup2);
    new Label(composite1, SWT.NONE);
    new Label(composite1, SWT.NONE);
    final Button findBtn = new Button(composite1, SWT.NONE);
    final GridData gdFindBtn = new GridData(SWT.FILL, SWT.CENTER, false, false);
    findBtn.setLayoutData(gdFindBtn);
    findBtn.setText(Messages.reformatTableAliasBtn);
    findBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            submit();
        }
    });
    final Button closeBtn = new Button(composite1, SWT.NONE);
    final GridData gdCloseBtn = new GridData(SWT.FILL, SWT.CENTER, false, false);
    closeBtn.setLayoutData(gdCloseBtn);
    closeBtn.setText(Messages.reformatTableAliasCancelBtn);
    closeBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            close();
        }
    });
    aliasText.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                submit();
            }
        }

        public void keyPressed(KeyEvent e) {
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener)

Example 58 with KeyListener

use of org.eclipse.swt.events.KeyListener in project cubrid-manager by CUBRID.

the class ShardIdSelectionDialog method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 5;
        layout.marginWidth = 5;
        layout.verticalSpacing = 5;
        layout.horizontalSpacing = 5;
        composite.setLayout(layout);
    }
    setTitle(Messages.titleChooseShardIdDialog);
    setMessage(Messages.msgChooseShardIdDialog);
    Composite inputComposite = new Composite(composite, SWT.NONE);
    inputComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 3;
        layout.marginHeight = 10;
        layout.marginWidth = 5;
        layout.verticalSpacing = 10;
        layout.horizontalSpacing = 5;
        inputComposite.setLayout(layout);
    }
    // SHARD ID
    btnUseShardId = new Button(inputComposite, SWT.RADIO);
    btnUseShardId.setText(Messages.btnUseShardIdHint);
    txtShardId = new Text(inputComposite, SWT.BORDER);
    txtShardId.setText(String.valueOf(shardId));
    txtShardId.setLayoutData(CommonUITool.createGridData(GridData.BEGINNING, 1, 1, 100, -1));
    if (shardQueryType == DatabaseInfo.SHARD_QUERY_TYPE_ID) {
        //txtShardVal.setEnabled(false);
        //txtShardId.setEnabled(true);
        txtShardId.selectAll();
    }
    final Label lblHintId = new Label(inputComposite, SWT.NONE);
    lblHintId.setText("/*+shard_id(" + shardId + ")*/");
    lblHintId.setLayoutData(CommonUITool.createGridData(GridData.BEGINNING, 1, 1, 200, -1));
    txtShardId.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            lblHintId.setText("/*+shard_id(" + txtShardId.getText() + ")*/");
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    // SHARD VAL
    btnUseShardVal = new Button(inputComposite, SWT.RADIO);
    btnUseShardVal.setText(Messages.btnUseShardValHint);
    txtShardVal = new Text(inputComposite, SWT.BORDER);
    txtShardVal.setText(String.valueOf(shardVal));
    txtShardVal.setLayoutData(CommonUITool.createGridData(GridData.BEGINNING, 1, 1, 100, -1));
    if (shardQueryType == DatabaseInfo.SHARD_QUERY_TYPE_VAL) {
        txtShardVal.selectAll();
    }
    final Label lblHintVal = new Label(inputComposite, SWT.NONE);
    lblHintVal.setText("/*+shard_val(" + shardVal + ")*/");
    lblHintVal.setLayoutData(CommonUITool.createGridData(GridData.BEGINNING, 1, 1, 200, -1));
    txtShardVal.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
            lblHintVal.setText("/*+shard_val(" + txtShardVal.getText() + ")*/");
        }

        public void keyPressed(KeyEvent e) {
        }
    });
    btnUseShardId.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            shardQueryType = DatabaseInfo.SHARD_QUERY_TYPE_ID;
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    btnUseShardVal.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            shardQueryType = DatabaseInfo.SHARD_QUERY_TYPE_VAL;
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    if (shardQueryType == DatabaseInfo.SHARD_QUERY_TYPE_VAL) {
        btnUseShardId.setSelection(false);
        btnUseShardVal.setSelection(true);
    } else {
        btnUseShardId.setSelection(true);
        btnUseShardVal.setSelection(false);
    }
    return parentComp;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) KeyListener(org.eclipse.swt.events.KeyListener) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 59 with KeyListener

use of org.eclipse.swt.events.KeyListener in project cubrid-manager by CUBRID.

the class SelectedLoactionComparator method bindListener.

/**
	 * 
	 * Bind the linsteners
	 */
private void bindListener() {
    tableCursor.addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent event) {
            handleMouseUp(event);
        }

        public void mouseDown(MouseEvent event) {
            handleMouseDown(event);
        }

        public void mouseDoubleClick(MouseEvent event) {
            handleMouseDoubleClick(event);
        }
    });
    tableCursor.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent event) {
            handleMouseMove(event);
        }
    });
    table.addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent event) {
            handleMouseUp(event);
        }

        public void mouseDown(MouseEvent event) {
            handleMouseDown(event);
        }

        public void mouseDoubleClick(MouseEvent event) {
            handleMouseDoubleClick(event);
        }
    });
    table.addMouseTrackListener(new MouseTrackAdapter() {

        public void mouseExit(MouseEvent e) {
            Rectangle bound = table.getClientArea();
            if (!bound.contains(e.x, e.y)) {
                handleMouseExit(e);
            }
        }
    });
    table.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent event) {
            handleMouseMove(event);
        }
    });
    table.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent event) {
            handleKeyReleased(event);
        }

        public void keyPressed(KeyEvent event) {
            handleKeyPressed(event);
        }
    });
    tableCursor.addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent event) {
            handleKeyReleased(event);
        }

        public void keyPressed(KeyEvent event) {
            handleKeyPressed(event);
            if (ctrlPressed) {
                if (event.keyCode == SWT.ARROW_DOWN) {
                    int maxY = getMaxY();
                    int minX = getMinX();
                    int maxX = getMaxX();
                    int y = maxY + 1;
                    if (maxY > -1 && minX > -1 && maxX > -1 && y < table.getItemCount()) {
                        tableCursor.setSelection(y, maxX);
                        for (int x = minX; x <= maxX; x++) {
                            Point p = new Point(x, y);
                            addSelectPoint(p, true);
                            drawSelectedItem(p, true);
                        }
                    }
                } else if (event.keyCode == SWT.ARROW_UP) {
                    int maxY = getMaxY();
                    int minX = getMinX();
                    int maxX = getMaxX();
                    int y = maxY;
                    if (maxY > -1 && minX > -1 && maxX > -1 && y > 0) {
                        tableCursor.setSelection(y - 1, maxX);
                        for (int x = minX; x <= maxX; x++) {
                            Point p = new Point(x, y);
                            removeSelectPoint(p, true);
                            drawUnselectedItem(p, true);
                        }
                    }
                } else if (event.keyCode == SWT.ARROW_LEFT) {
                    int maxY = getMaxY();
                    int minY = getMinY();
                    int maxX = getMaxX();
                    if (maxY > -1 && minY > -1 && maxX > 0) {
                        tableCursor.setSelection(maxY, maxX - 1);
                        for (int y = minY; y <= maxY; y++) {
                            Point p = new Point(maxX, y);
                            removeSelectPoint(p, true);
                            drawUnselectedItem(p, true);
                        }
                    }
                } else if (event.keyCode == SWT.ARROW_RIGHT) {
                    int maxY = getMaxY();
                    int minY = getMinY();
                    int maxX = getMaxX();
                    int columnCount = table.getColumnCount();
                    if (maxY > -1 && minY > -1 && maxX + 1 < columnCount) {
                        int x = maxX + 1;
                        tableCursor.setSelection(maxY, x);
                        for (int y = minY; y <= maxY; y++) {
                            Point p = new Point(x, y);
                            addSelectPoint(p, true);
                            drawSelectedItem(p, true);
                        }
                    }
                }
            } else if (!ctrlPressed && !shiftPressed) {
                if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT) {
                    selectedList.clear();
                    int y = table.indexOf(tableCursor.getRow());
                    int x = tableCursor.getColumn();
                    Point p = new Point(x, y);
                    addSelectPoint(p, true);
                    drawSelectedItems(true);
                }
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) KeyListener(org.eclipse.swt.events.KeyListener) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 60 with KeyListener

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

Aggregations

KeyListener (org.eclipse.swt.events.KeyListener)99 KeyEvent (org.eclipse.swt.events.KeyEvent)91 GridData (org.eclipse.swt.layout.GridData)39 Composite (org.eclipse.swt.widgets.Composite)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)33 Text (org.eclipse.swt.widgets.Text)32 Button (org.eclipse.swt.widgets.Button)29 Label (org.eclipse.swt.widgets.Label)29 MouseEvent (org.eclipse.swt.events.MouseEvent)24 Point (org.eclipse.swt.graphics.Point)23 SelectionListener (org.eclipse.swt.events.SelectionListener)22 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)19 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14 MouseListener (org.eclipse.swt.events.MouseListener)14 Combo (org.eclipse.swt.widgets.Combo)14 Event (org.eclipse.swt.widgets.Event)13 ArrayList (java.util.ArrayList)12 StyledText (org.eclipse.swt.custom.StyledText)9