Search in sources :

Example 66 with KeyEvent

use of org.eclipse.swt.events.KeyEvent 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 67 with KeyEvent

use of org.eclipse.swt.events.KeyEvent 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 68 with KeyEvent

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

the class EditUserDialog method createUserPwdGroup.

/**
	 * Create the user password group
	 * 
	 * @param composite the parent composite
	 */
private void createUserPwdGroup(Composite composite) {
    final Group userNameGroup = new Group(composite, SWT.NONE);
    final GridData gdUserPasswordGroup = new GridData(SWT.FILL, SWT.FILL, true, false);
    userNameGroup.setLayoutData(gdUserPasswordGroup);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    userNameGroup.setLayout(layout);
    final Label userNameLabel = new Label(userNameGroup, SWT.NONE);
    final GridData gdUserNameLabel = new GridData(SWT.FILL, SWT.FILL, false, false);
    userNameLabel.setLayoutData(gdUserNameLabel);
    userNameLabel.setText(Messages.lblUserName);
    userNameText = new Text(userNameGroup, SWT.BORDER);
    userNameText.setEnabled(false);
    final GridData gdUserNameText = new GridData(SWT.FILL, SWT.FILL, true, false);
    userNameText.setLayoutData(gdUserNameText);
    userNameText.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
        }

        public void keyReleased(KeyEvent event) {
            String userName = userNameText.getText();
            if (null == userName || "".equals(userName) || userName.length() <= 0) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
                return;
            }
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
    final Group userPasswordGroup = new Group(userNameGroup, SWT.NONE);
    final GridData gdPasswordGroup = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdPasswordGroup.horizontalSpan = 2;
    userPasswordGroup.setLayoutData(gdPasswordGroup);
    layout = new GridLayout();
    layout.numColumns = 2;
    userPasswordGroup.setLayout(layout);
    userPasswordGroup.setText(Messages.grpPasswordSetting);
    if (newFlag) {
        final Label passwordLabel = new Label(userPasswordGroup, SWT.NONE);
        passwordLabel.setText(Messages.lblPassword);
        pwdText = new Text(userPasswordGroup, SWT.BORDER | SWT.PASSWORD);
        final GridData gdPwdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
        pwdText.setLayoutData(gdPwdText);
        final Label newPasswordConfirmLabel = new Label(userPasswordGroup, SWT.NONE);
        newPasswordConfirmLabel.setText(Messages.lblPasswordConf);
        pwdCfmText = new Text(userPasswordGroup, SWT.BORDER | SWT.PASSWORD);
        final GridData gdPwdCfmText = new GridData(SWT.FILL, SWT.CENTER, true, false);
        pwdCfmText.setLayoutData(gdPwdCfmText);
    } else {
        changePwdBtn = new Button(userPasswordGroup, SWT.CHECK);
        changePwdBtn.setText(Messages.btnPasswordChange);
        changePwdBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        changePwdBtn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(final SelectionEvent event) {
                if (changePwdBtn.getSelection()) {
                    if (!database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(DB_DBA_USERNAME) || (database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(DB_DBA_USERNAME) && DB_DBA_USERNAME.equalsIgnoreCase(userName))) {
                        oldPwdText.setEnabled(true);
                    }
                    pwdText.setEnabled(true);
                    pwdCfmText.setEnabled(true);
                } else {
                    oldPwdText.setEnabled(false);
                    pwdText.setEnabled(false);
                    pwdCfmText.setEnabled(false);
                }
            }
        });
        final Label oldPasswordLabel = new Label(userPasswordGroup, SWT.NONE);
        oldPasswordLabel.setText(Messages.lblOldPassword);
        oldPwdText = new Text(userPasswordGroup, SWT.BORDER | SWT.PASSWORD);
        final GridData gdOldPwdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
        oldPwdText.setLayoutData(gdOldPwdText);
        oldPwdText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
        final Label passwordLabel = new Label(userPasswordGroup, SWT.NONE);
        passwordLabel.setText(Messages.lblNewPassword);
        pwdText = new Text(userPasswordGroup, SWT.BORDER | SWT.PASSWORD);
        pwdText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
        final GridData gdPwdText = new GridData(SWT.FILL, SWT.CENTER, true, false);
        pwdText.setLayoutData(gdPwdText);
        final Label newPasswordConfirmLabel = new Label(userPasswordGroup, SWT.NONE);
        newPasswordConfirmLabel.setText(Messages.lblNewPasswordConf);
        pwdCfmText = new Text(userPasswordGroup, SWT.BORDER | SWT.PASSWORD);
        final GridData gdPwdCfmText = new GridData(SWT.FILL, SWT.CENTER, true, false);
        pwdCfmText.setLayoutData(gdPwdCfmText);
        pwdCfmText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
        oldPwdText.setEnabled(false);
        pwdText.setEnabled(false);
        pwdCfmText.setEnabled(false);
    }
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) KeyAdapter(org.eclipse.swt.events.KeyAdapter) 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)

Example 69 with KeyEvent

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

the class ViewDashboardEditorPart method createViewsDetailInfoTable.

public void createViewsDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    {
        tableComposite.setLayout(new FillLayout());
        tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }
    viewsDetailInfoTable = new TableViewer(tableComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    viewsDetailInfoTable.getTable().setHeaderVisible(true);
    viewsDetailInfoTable.getTable().setLinesVisible(true);
    final TableViewerColumn columnViewName = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    columnViewName.getColumn().setWidth(150);
    columnViewName.getColumn().setText(Messages.viewDetailInfoPartColViewName);
    final TableViewerColumn scriptDescColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    scriptDescColumn.getColumn().setWidth(200);
    scriptDescColumn.getColumn().setText(Messages.viewDetailInfoPartTableDefColumn);
    final TableViewerColumn ownerColumn = new TableViewerColumn(viewsDetailInfoTable, SWT.LEFT);
    ownerColumn.getColumn().setWidth(80);
    ownerColumn.getColumn().setText(Messages.viewDetailInfoPartTableOwnerColumn);
    viewsDetailInfoTable.setContentProvider(new ViewsDetailTableViewerContentProvider());
    viewsDetailInfoTable.setLabelProvider(new ViewsDetailTableViewerLabelProvider());
    viewsDetailInfoTable.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            ViewDetailInfo oneViewDetail = (ViewDetailInfo) selection.getFirstElement();
            //if had opend,set it selection
            for (CTabItem tabItem : tabFolder.getItems()) {
                if (tabItem.getText().equals(oneViewDetail.getViewName())) {
                    tabFolder.setSelection(tabItem);
                    return;
                }
            }
            //if a new view info,create a new tab
            ViewDashboardComposite viewComp = new ViewDashboardComposite(tabFolder, SWT.NONE);
            viewComp.initialize();
            SchemaInfo schemaInfo = database.getDatabaseInfo().getSchemaInfo(oneViewDetail.getViewName());
            viewComp.setInput(schemaInfo);
        }
    });
    viewsDetailInfoTable.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
            }
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ViewDetailInfo(com.cubrid.common.core.common.model.ViewDetailInfo) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ViewsDetailInfoCTabItem(com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 70 with KeyEvent

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

the class BrowserEditorPart method initUrlBar.

private void initUrlBar(Composite parent) {
    Label urlLabel = new Label(parent, SWT.None);
    urlLabel.setLayoutData(createGridData(1, 1, -1, -1));
    urlLabel.setText(Messages.lblLocation);
    location = new Text(parent, SWT.BORDER);
    location.setLayoutData(createGridData(FILL_HORIZONTAL, 1, 1, -1, -1));
    location.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.LF || e.character == SWT.CR) {
                e.doit = false;
                go(location.getText());
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text)

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