Search in sources :

Example 31 with KeyEvent

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

the class TableDashboardComposite method createColumnsTable.

/**
	 * Create the column information table
	 *
	 */
private void createColumnsTable(Composite topComposite) {
    columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    Table columnsTable = columnTableView.getTable();
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.heightHint = 189;
    columnsTable.setLayoutData(gdColumnsTable);
    // 0 PK
    TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(WIDTH_PKCOLUMN);
    tblCol.setText(Messages.tblColumnPK);
    // 1 NAME
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnName);
    // 2 MEMO
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnMemo);
    // 3 DATATYPE
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_DATATYPECOLUMN);
    tblCol.setText(Messages.tblColumnDataType);
    // 4 DEFAULT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(98);
    tblCol.setText(Messages.tblColumnDefault);
    // 5 AUTO INCREMENT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnAutoIncr);
    // 6 NOT NULL
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
    tblCol.setText(Messages.tblColumnNotNull);
    tblCol.setAlignment(SWT.CENTER);
    // 7 UK
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_UNIQUECOLUMN);
    tblCol.setText(Messages.tblColumnUnique);
    tblCol.setAlignment(SWT.CENTER);
    // 8 SHARED
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_SHAREDCOLUMN);
    tblCol.setResizable(true);
    tblCol.setText(Messages.tblColumnShared);
    tblCol.setAlignment(SWT.CENTER);
    labelProvider = new TableDashboardDetailLabelProvider(null, null);
    columnTableView.setContentProvider(new TableDashboardDetailContentProvider());
    columnTableView.setLabelProvider(labelProvider);
    columnTableView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
                copyTablesDetailToClipboard();
            } else if (event.keyCode == SWT.CR) {
                showEditDialog(columnTableView.getTable(), columnTableView.getTable().getSelectionIndex());
            }
        }
    });
    registerContextMenu();
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 32 with KeyEvent

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

the class ImportResultDialog method createDialogArea.

/**
	 * Create the dialog area
	 *
	 * @param parent Composite
	 * @return 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 = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
    }
    TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table = tableViewer.getTable();
    {
        GridData gdData = new GridData(GridData.FILL_BOTH);
        gdData.heightHint = 400;
        gdData.widthHint = 500;
        table.setLayoutData(gdData);
    }
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnNO);
    tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnMessage);
    tableViewer.setLabelProvider(new TableLabelProvider(tableViewer, null));
    tableViewer.setContentProvider(new TableContentProvider());
    tableViewer.setInput(errorList);
    //Create the context menu
    MenuManager contextMenuManager = new MenuManager();
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            //copy action
            Action copyAction = new Action(Messages.bind(Messages.contextCopy, "Ctrl+C")) {

                public void run() {
                    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

                        public void run() {
                            copyDataToClipboard();
                        }
                    });
                }
            };
            manager.add(copyAction);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    //Add listener
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                copyDataToClipboard();
            }
        }
    });
    for (int i = 0; i < table.getColumnCount(); i++) {
        TableColumn tblColumn = table.getColumn(i);
        tblColumn.pack();
        if (tblColumn.getWidth() > 400) {
            tblColumn.setWidth(400);
        }
    }
    Label label = new Label(composite, SWT.LEFT);
    label.setForeground(ResourceManager.getColor(255, 0, 0));
    label.setText(message);
    return composite;
}
Also used : Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 33 with KeyEvent

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

the class ERSchemaToolBar method createSearchComp.

/**
	 * create searching table text composite
	 *
	 * @return comp composite
	 */
private Composite createSearchComp() {
    Composite comp = new Composite(this, SWT.NONE);
    final GridLayout gdLayout = new GridLayout(1, true);
    gdLayout.marginHeight = 1;
    gdLayout.marginWidth = 1;
    gdLayout.horizontalSpacing = 1;
    gdLayout.verticalSpacing = 1;
    comp.setLayout(gdLayout);
    // comp.setLayoutData(new GridData(GridData.RIGHT, SWT.CENTER, false,
    // false));
    comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END, GridData.VERTICAL_ALIGN_CENTER, false, false));
    final Text text = new Text(comp, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    text.setToolTipText(Messages.tipSearchTableName);
    text.setLayoutData(CommonUITool.createGridData(1, 1, 140, 14));
    text.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            String keyWord = text.getText().trim();
            erSchemaEditor.doSearchTables(keyWord);
        }
    });
    return comp;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text)

Example 34 with KeyEvent

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

the class GotoLineDialog 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.gotoLineTitle);
    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);
        int lineCount = sqlComp.getText().getContent().getLineCount();
        String msg = Messages.bind(Messages.gotoLineMessage, "1", lineCount);
        findWhatLabel.setText(msg);
        findText = new Text(group, SWT.BORDER);
        final GridData gdFind = new GridData(SWT.FILL, SWT.CENTER, true, false);
        findText.setLayoutData(gdFind);
        findText.addKeyListener(new KeyListener() {

            public void keyReleased(KeyEvent e) {
            }

            public void keyPressed(KeyEvent e) {
                if (e.keyCode == SWT.CR) {
                    gotoLine();
                }
            }
        });
    }
    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.gotoLineBtn);
    findBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            gotoLine();
        }
    });
    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.gotoLineCancelBtn);
    closeBtn.addSelectionListener(new SelectionAdapter() {

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

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

        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 35 with KeyEvent

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

the class QueryRecordListComparator method addTextViewerListener.

/**
	 * Add SQL viewer listener
	 *
	 * @param text
	 */
private void addTextViewerListener(final StyledText text) {
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            ServerInfo serverInfo = getServerInfo();
            boolean isLowerCase = QueryOptions.getKeywordLowercase(serverInfo);
            boolean isNoAutoUpperCase = QueryOptions.getNoAutoUppercaseKeyword(serverInfo);
            if (!isLowerCase && !isNoAutoUpperCase) {
                autoReplaceKeyword();
            }
        }

        // replace keyword to upper case automatically
        public void autoReplaceKeyword() {
            // FIXME extract tokenize code to utility
            if (pendingCompletionsListener) {
                return;
            }
            int pos = text.getCaretOffset() - 1;
            if (pos <= 0) {
                return;
            }
            String currentKey = text.getText(pos, pos);
            if (currentKey == null || currentKey.length() <= 0) {
                return;
            }
            char cur = currentKey.charAt(0);
            if (cur != ' ' && cur != '(' && cur != '\t' && cur != '\n' && cur != '\r' && cur != ',') {
                return;
            }
            pos--;
            if (pos < 0) {
                return;
            }
            int spos = pos - 20;
            if (spos < 0) {
                spos = 0;
            }
            String txt = text.getText(spos, pos);
            spos = pos + 1;
            for (int i = txt.length() - 1; i >= 0; i--) {
                char c = txt.charAt(i);
                if (c == ' ' || c == '\t' || c == '\n' || c == '(') {
                    break;
                }
                spos--;
            }
            int epos = pos;
            if (spos < 0 || epos < 0 || spos > epos) {
                return;
            }
            String currentKeyword = text.getText(spos, epos);
            if (currentKeyword == null) {
                return;
            }
            int len = currentKeyword.length();
            for (int i = 0; i < QuerySyntax.KEYWORDS_AUTO_UPPER.length; i++) {
                String keyword = QuerySyntax.KEYWORDS_AUTO_UPPER[i];
                if (keyword.equalsIgnoreCase(currentKeyword)) {
                    pendingCompletionsListener = true;
                    text.replaceTextRange(spos, len, keyword.toUpperCase());
                    pendingCompletionsListener = false;
                    break;
                }
            }
        }
    });
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.COMMAND) != 0) {
                //for Mac
                if ((event.stateMask & SWT.SHIFT) != 0) {
                    if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                        runQuery();
                        return;
                    }
                }
            }
            if (event.keyCode == SWT.F5 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'e') {
                runQuery();
            } else if (event.keyCode == SWT.F6 || (event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'l') {
                runQueryPlan();
            } else if (event.keyCode == SWT.F3) {
                if ((event.stateMask & SWT.SHIFT) == 0) {
                    TextEditorFindReplaceMediator.findNext();
                } else {
                    TextEditorFindReplaceMediator.findPrevious();
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == ' ') {
                contentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'r') {
                recentlyUsedSQLcontentAssistant.showPossibleCompletions();
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0) {
                if (event.keyCode == 'z' || event.keyCode == 'Z') {
                    undoManager.undo();
                } else if (event.keyCode == 'y' || event.keyCode == 'Y') {
                    undoManager.redo();
                }
            } else if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) != 0) {
                if (event.keyCode == 'f' || event.keyCode == 'F') {
                    try {
                        formatHandler.execute(null);
                    } catch (Exception ex) {
                        CommonUITool.openErrorBox(ex.getMessage());
                    }
                }
            } else if ((event.stateMask & SWT.ALT) != 0 && event.keyCode == '/') {
                try {
                    contentAssistHandler.execute(null);
                } catch (Exception ex) {
                    CommonUITool.openErrorBox(ex.getMessage());
                }
            }
            if (SQLContentAssistProcessor.isShowProposal(event.character)) {
                contentAssistant.showPossibleCompletions();
                useCompletions = true;
            } else if ((event.character >= 'A' && event.character <= 'Z') || (event.character >= 'a' && event.character <= 'z')) {
                if (useCompletions) {
                    contentAssistant.showPossibleCompletions();
                }
                useCompletions = false;
            } else if (event.character == ' ' || event.character == '\t' || event.keyCode == SWT.KEYPAD_CR || event.keyCode == SWT.CR || event.keyCode == SWT.BS || (text.getText().trim().length() < 1)) {
                useCompletions = true;
            }
        }
    });
    TextEditorFindReplaceMediator editorDialogMediator = new TextEditorFindReplaceMediator();
    text.addFocusListener(editorDialogMediator);
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TextEditorFindReplaceMediator(com.cubrid.tool.editor.TextEditorFindReplaceMediator) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter)

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