Search in sources :

Example 11 with KeyListener

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

the class CubridNavigatorView method addListener.

/**
	 *
	 * Add listener
	 *
	 */
protected void addListener() {
    tv.getTree().addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
        }

        public void mouseUp(MouseEvent event) {
            if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
                ISelection selection = tv.getSelection();
                if (selection == null || selection.isEmpty()) {
                    return;
                }
                Object obj = ((IStructuredSelection) selection).getFirstElement();
                if (!(obj instanceof ICubridNode)) {
                    return;
                }
                ICubridNode cubridNode = (ICubridNode) obj;
                LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
            }
        }
    });
    tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {

        public void mouseHover(MouseEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            int x = event.x;
            int y = event.y;
            TreeItem item = tv.getTree().getItem(new Point(x, y));
            if (item == null) {
                return;
            }
            showToolTip(item);
        }
    });
    tv.getTree().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent event) {
            widgetSelected(event);
        }

        public void widgetSelected(SelectionEvent event) {
            if (toolTip.isVisible()) {
                toolTip.setVisible(false);
            }
            TreeItem[] items = tv.getTree().getSelection();
            if (items == null || items.length == 0) {
                return;
            }
            showToolTip(items[0]);
            if (items.length == 1) {
                showSchemaInfo(items[0]);
            } else {
                showSchemaInfo(null);
            }
        }
    });
    addDragDropSupport(tv.getTree());
    tv.getTree().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            // prevent to make events by key press for a long time
            if (e.character == ' ') {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                if (items.length == 1) {
                    showSchemaInfo(items[0]);
                } else {
                    showSchemaInfo(null);
                }
            }
            lastKeyInputTimestamp = System.currentTimeMillis();
            // by showing object information tab on the query editor.
            if (e.keyCode == SWT.F2) {
                TreeItem[] items = tv.getTree().getSelection();
                if (items == null || items.length == 0) {
                    return;
                }
                for (TreeItem item : items) {
                    Object obj = item.getData();
                    if (obj instanceof ICubridNode) {
                        ICubridNode node = (ICubridNode) obj;
                        if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
                            DefaultSchemaNode table = (DefaultSchemaNode) obj;
                            OpenTargetAction action = new OpenTargetAction();
                            action.showObjectInfo(table);
                        } else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
                            CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
                            if (view == null) {
                                view = CubridNavigatorView.getNavigatorView(ID_CM);
                            }
                            if (view == null) {
                                return;
                            }
                            TreeViewer treeViewer = view.getViewer();
                            //if not expand ,expand the node and wait until all children be added
                            if (!treeViewer.getExpandedState(node)) {
                                treeViewer.expandToLevel(node, 1);
                                while (node.getChildren().size() == 0) {
                                    try {
                                        Thread.sleep(500);
                                    } catch (Exception ignored) {
                                    }
                                }
                            }
                            CubridDatabase database = (CubridDatabase) node.getParent();
                            OpenTargetAction action = new OpenTargetAction();
                            action.showTableDashboard(database);
                        }
                    }
                }
            }
        }
    });
}
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) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.swt.graphics.Point) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) OpenTargetAction(com.cubrid.common.ui.common.action.OpenTargetAction) KeyEvent(org.eclipse.swt.events.KeyEvent) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 12 with KeyListener

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

the class QueryExecuter method bindEvents.

private void bindEvents() {
    selectableSupport.getTableCursor().addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent e) {
            performEdit();
        }
    });
    selectableSupport.getTableCursor().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.CR) {
                performEdit();
            }
        }
    });
    selectableSupport.getTableCursor().addKeyListener(new org.eclipse.swt.events.KeyAdapter() {

        public void keyReleased(KeyEvent event) {
            if (isEditMode() && event.keyCode == SWT.DEL) {
                deleteRecord(tblResult, null);
            } else if (((event.stateMask & SWT.CTRL) != 0 || (event.stateMask & SWT.COMMAND) != 0) && (event.keyCode == 'c' || event.character == '')) {
                // key press 'ctrl + c' is intercept by editor text so add
                // here
                copySelectedItems();
            } else if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'a') {
                selectableSupport.selectAll();
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Example 13 with KeyListener

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

the class QuickBuilderDialog method createContents.

protected void createContents() {
    sqlComp = CommonUITool.getActiveSQLEditorComposite();
    if (sqlComp == null) {
        closeThisDialog();
        return;
    }
    CubridDatabase cubridDatabase = sqlComp.getQueryEditorPart().getSelectedDatabase();
    if (CubridDatabase.hasValidDatabaseInfo(cubridDatabase)) {
        databaseInfo = cubridDatabase.getDatabaseInfo();
    }
    boolean loadedProposal = true;
    proposal = ColumnProposalAdvisor.getInstance().findProposal(databaseInfo);
    if (proposal == null) {
        proposal = new ColumnProposal();
        if (databaseInfo != null) {
            startTimerForUpdateProposal();
        }
        loadedProposal = false;
    }
    isSupportLimit = CompatibleUtil.isSupportLimit(cubridDatabase.getDatabaseInfo());
    shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 1;
        shell.setLayout(gl);
    }
    shell.setSize(450, 300);
    shell.setText(Messages.quickQueryBuilderTitle);
    final Composite composite = new Composite(shell, SWT.NONE);
    {
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        composite.setLayoutData(gd);
        GridLayout gl = new GridLayout();
        composite.setLayout(gl);
    }
    final Label findWhatLabel = new Label(composite, SWT.NONE);
    findWhatLabel.setText(Messages.quickQueryBuilderLabel);
    inputText = new Text(composite, SWT.BORDER);
    {
        GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false);
        inputText.setLayoutData(gd);
    }
    inputText.setEditable(true);
    inputText.addKeyListener(inputTextKeyListener);
    searchView = new TableViewer(composite, SWT.BORDER);
    {
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
        searchView.getTable().setLayoutData(gd);
    }
    searchView.setContentProvider(searchViewContentProvider);
    searchView.setLabelProvider(searchViewLabelProvider);
    searchView.setInput(proposal);
    searchView.getTable().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {
        }

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                makeQueryAndClose(0);
            }
        }
    });
    TableColumn col1 = new TableColumn(searchView.getTable(), SWT.NONE);
    col1.setWidth(200);
    TableColumn col2 = new TableColumn(searchView.getTable(), SWT.NONE);
    col2.setWidth(200);
    if (!loadedProposal) {
        updateNoticeBanner = new Label(composite, SWT.BORDER);
        {
            GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
            updateNoticeBanner.setLayoutData(gd);
        }
        updateNoticeBanner.setText(Messages.quickQueryBuilderLoading);
        updateNoticeBanner.setBackground(ResourceManager.getColor(255, 255, 255));
    }
    Composite bottomPanel = new Composite(composite, SWT.NONE);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 4;
        bottomPanel.setLayout(gl);
        GridData gd = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
        bottomPanel.setLayoutData(gd);
    }
    createButtons(bottomPanel);
}
Also used : ColumnProposal(com.cubrid.common.ui.query.editor.ColumnProposal) SQLEditorComposite(com.cubrid.common.ui.query.control.SQLEditorComposite) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) KeyListener(org.eclipse.swt.events.KeyListener) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 14 with KeyListener

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

use of org.eclipse.swt.events.KeyListener in project sling by apache.

the class SetupServerWizardPage method createControl.

public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.numColumns = 3;
    layout.verticalSpacing = 9;
    layout.marginBottom = 10;
    GridDataFactory singleRowGridDataFactory = GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).span(layout.numColumns, 1);
    useExistingServer = new Button(container, SWT.RADIO);
    useExistingServer.setText("Add to existing server");
    singleRowGridDataFactory.applyTo(useExistingServer);
    Label existingServerLabel = new Label(container, SWT.NONE);
    GridData locationLabelData = new GridData();
    locationLabelData.horizontalIndent = HORIZONTAL_INDENT;
    existingServerLabel.setLayoutData(locationLabelData);
    existingServerLabel.setText("Location:");
    existingServerLabel.setEnabled(true);
    existingServerCombo = new SlingLaunchpadCombo(container, null);
    existingServerCombo.getWidget().addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    });
    existingServerCombo.refreshRepositoryList(new NullProgressMonitor());
    existingServerCombo.getWidget().setEnabled(true);
    {
        startExistingServerButton = new Button(container, SWT.CHECK);
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
        gd.horizontalIndent = HORIZONTAL_INDENT;
        startExistingServerButton.setLayoutData(gd);
        startExistingServerButton.setText("Start server after project creation (if server not yet started).");
        startExistingServerButton.setSelection(true);
    }
    skipServerConfiguration = new Button(container, SWT.RADIO);
    skipServerConfiguration.setText("Don't deploy on a server");
    singleRowGridDataFactory.applyTo(skipServerConfiguration);
    setupNewServer = new Button(container, SWT.RADIO);
    setupNewServer.setText("Setup new server");
    singleRowGridDataFactory.applyTo(setupNewServer);
    newLabel(container, "Server name:");
    newServerName = newText(container);
    newLabel(container, "Host name:");
    newServerHostnameName = newText(container);
    newServerHostnameName.setText("localhost");
    newLabel(container, "Port:");
    newServerPort = newText(container);
    newServerPort.setText(Integer.toString(config.getPort()));
    newLabel(container, "Username:");
    newServerUsername = newText(container);
    newServerUsername.setText(config.getUsername());
    newLabel(container, "Password:");
    newServerPassword = newText(container);
    newServerPassword.setText(config.getPassword());
    newLabel(container, "Debug Port:");
    newServerDebugPort = newText(container);
    newServerDebugPort.setText(Integer.toString(config.getDebugPort()));
    SelectionAdapter radioListener = new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            updateEnablements();
            dialogChanged();
        }
    };
    useExistingServer.addSelectionListener(radioListener);
    setupNewServer.addSelectionListener(radioListener);
    ModifyListener ml = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            dialogChanged();
        }
    };
    KeyListener kl = new KeyListener() {

        @Override
        public void keyReleased(KeyEvent e) {
            dialogChanged();
        }

        @Override
        public void keyPressed(KeyEvent e) {
            dialogChanged();
        }
    };
    newServerName.addModifyListener(ml);
    newServerName.addKeyListener(kl);
    newServerHostnameName.addModifyListener(ml);
    newServerHostnameName.addKeyListener(kl);
    newServerPort.addModifyListener(ml);
    newServerPort.addKeyListener(kl);
    newServerDebugPort.addModifyListener(ml);
    newServerDebugPort.addKeyListener(kl);
    useExistingServer.setSelection(existingServerCombo.hasServers());
    existingServerCombo.getWidget().setEnabled(existingServerCombo.hasServers());
    startExistingServerButton.setEnabled(existingServerCombo.hasServers());
    setupNewServer.setSelection(!existingServerCombo.hasServers());
    updateEnablements();
    setPageComplete(false);
    setControl(container);
    // allow the selection to proceed in case we have a preselected server
    if (useExistingServer.getSelection()) {
        if (existingServerCombo.getErrorMessage(SKIP_SERVER_STARTED) == null) {
            updateStatus(null);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SlingLaunchpadCombo(org.apache.sling.ide.eclipse.ui.internal.SlingLaunchpadCombo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyListener(org.eclipse.swt.events.KeyListener)

Aggregations

KeyListener (org.eclipse.swt.events.KeyListener)34 KeyEvent (org.eclipse.swt.events.KeyEvent)32 Point (org.eclipse.swt.graphics.Point)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 MouseEvent (org.eclipse.swt.events.MouseEvent)10 GridData (org.eclipse.swt.layout.GridData)10 Text (org.eclipse.swt.widgets.Text)9 MouseListener (org.eclipse.swt.events.MouseListener)8 Button (org.eclipse.swt.widgets.Button)8 ModifyEvent (org.eclipse.swt.events.ModifyEvent)7 ModifyListener (org.eclipse.swt.events.ModifyListener)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 Composite (org.eclipse.swt.widgets.Composite)7 FocusEvent (org.eclipse.swt.events.FocusEvent)6 Label (org.eclipse.swt.widgets.Label)6 StyledText (org.eclipse.swt.custom.StyledText)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionListener (org.eclipse.swt.events.SelectionListener)5 FocusListener (org.eclipse.swt.events.FocusListener)4 Event (org.eclipse.swt.widgets.Event)4