Search in sources :

Example 26 with MouseAdapter

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

the class ColumnCategoriesDialog method addListenersToListViewer.

private void addListenersToListViewer() {
    listViewer.getControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            removeSelected();
        }
    });
    listViewer.getControl().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
            if (controlMask && e.keyCode == SWT.ARROW_UP) {
                moveSelectedUp();
                e.doit = false;
            } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
                moveSelectedDown();
                e.doit = false;
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                removeSelected();
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 27 with MouseAdapter

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

the class ColumnChooserDialog method populateDialogArea.

@Override
public void populateDialogArea(Composite parent) {
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    parent.setLayout(new GridLayout(4, false));
    createLabels(parent, availableLabel, selectedLabel);
    availableTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    GridData gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    availableTree.setLayoutData(gridData);
    availableTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            addSelected();
        }
    });
    availableTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                addSelected();
        }
    });
    Composite buttonComposite = new Composite(parent, SWT.NONE);
    buttonComposite.setLayout(new GridLayout(1, true));
    Button addButton = new Button(buttonComposite, SWT.PUSH);
    addButton.setImage(GUIHelper.getImage("arrow_right"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            addSelected();
        }
    });
    Button removeButton = new Button(buttonComposite, SWT.PUSH);
    removeButton.setImage(GUIHelper.getImage("arrow_left"));
    gridData = GridDataFactory.copyData(gridData);
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            removeSelected();
        }
    });
    selectedTree = new Tree(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.Expand);
    gridData = GridDataFactory.fillDefaults().grab(true, true).create();
    selectedTree.setLayoutData(gridData);
    selectedTree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            removeSelected();
        }
    });
    selectedTree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean controlMask = (e.stateMask & SWT.CONTROL) == SWT.CONTROL;
            if (controlMask && e.keyCode == SWT.ARROW_UP) {
                moveSelectedUp();
                e.doit = false;
            } else if (controlMask && e.keyCode == SWT.ARROW_DOWN) {
                moveSelectedDown();
                e.doit = false;
            }
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.character == ' ')
                removeSelected();
        }
    });
    selectedTree.addTreeListener(new TreeListener() {

        public void treeCollapsed(TreeEvent event) {
            selectedTreeCollapsed(event);
        }

        public void treeExpanded(TreeEvent event) {
            selectedTreeExpanded(event);
        }
    });
    selectedTree.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent event) {
            toggleColumnGroupSelection((TreeItem) event.item);
        }
    });
    Composite upDownbuttonComposite = new Composite(parent, SWT.NONE);
    upDownbuttonComposite.setLayout(new GridLayout(1, true));
    Button upButton = new Button(upDownbuttonComposite, SWT.PUSH);
    upButton.setImage(GUIHelper.getImage("arrow_up"));
    gridData = GridDataFactory.fillDefaults().grab(false, true).align(SWT.CENTER, SWT.CENTER).create();
    upButton.setLayoutData(gridData);
    upButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            moveSelectedUp();
        }
    });
    Button downButton = new Button(upDownbuttonComposite, SWT.PUSH);
    downButton.setImage(GUIHelper.getImage("arrow_down"));
    gridData = GridDataFactory.copyData(gridData);
    downButton.setLayoutData(gridData);
    downButton.addSelectionListener(new SelectionListener() {

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

        public void widgetSelected(SelectionEvent e) {
            moveSelectedDown();
        }
    });
}
Also used : ISelectionTreeListener(net.sourceforge.nattable.columnChooser.ISelectionTreeListener) TreeListener(org.eclipse.swt.events.TreeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) TreeEvent(org.eclipse.swt.events.TreeEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 28 with MouseAdapter

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

the class HtmlBrowserEditor method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));
    cmp = new Composite(parent, SWT.BORDER);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(cmp);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(cmp);
    browser = new Browser(cmp, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_BOTH));
    browser.setUrl(htmlUrl);
    browser.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent e) {
            getSite().getPart().setFocus();
            super.mouseDown(e);
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Browser(org.eclipse.swt.browser.Browser)

Example 29 with MouseAdapter

use of org.eclipse.swt.events.MouseAdapter in project dbeaver by serge-rider.

the class PostgreScriptExecuteWizardPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    Composite composite = UIUtils.createPlaceholder(parent, 1);
    Group inputGroup = UIUtils.createControlGroup(composite, "Input", 3, GridData.FILL_HORIZONTAL, 0);
    inputFileText = UIUtils.createLabelText(inputGroup, "Input file", "", //$NON-NLS-2$
    SWT.BORDER | SWT.READ_ONLY);
    inputFileText.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            chooseInputFile();
        }
    });
    Button browseButton = new Button(inputGroup, SWT.PUSH);
    browseButton.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            chooseInputFile();
        }
    });
    if (wizard.getInputFile() != null) {
        inputFileText.setText(wizard.getInputFile().getName());
    }
    /*
        Group settingsGroup = UIUtils.createControlGroup(
                composite, PostgreMessages.tools_script_execute_wizard_page_settings_group_settings, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
        logLevelCombo = UIUtils.createLabelCombo(
                settingsGroup, PostgreMessages.tools_script_execute_wizard_page_settings_label_log_level, SWT.DROP_DOWN | SWT.READ_ONLY);
        for (PostgreScriptExecuteWizard.LogLevel logLevel : PostgreScriptExecuteWizard.LogLevel.values()) {
            logLevelCombo.add(logLevel.name());
        }
        logLevelCombo.select(wizard.getLogLevel().ordinal());
        logLevelCombo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e)
            {
                wizard.setLogLevel(PostgreScriptExecuteWizard.LogLevel.valueOf(logLevelCombo.getText()));
            }
        });
*/
    createSecurityGroup(composite);
    setControl(composite);
//updateState();
}
Also used : Group(org.eclipse.swt.widgets.Group) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 30 with MouseAdapter

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

the class ProductInfoDialog method addListeners.

/**
	 * Adds listeners to the given styled text
	 * 
	 * @param styledText the StyledText object
	 */
protected void addListeners(StyledText styledText) {
    styledText.addMouseListener(new MouseAdapter() {

        public void mouseDown(MouseEvent event) {
            if (event.button != 1) {
                return;
            }
            mouseDown = true;
        }

        public void mouseUp(MouseEvent event) {
            mouseDown = false;
            StyledText text = (StyledText) event.widget;
            int offset = text.getCaretOffset();
            if (dragEvent) {
                // don't activate a link during a drag/mouse up operation
                dragEvent = false;
                if (item != null && item.isLinkAt(offset)) {
                    text.setCursor(handCursor);
                }
            } else if (item != null && item.isLinkAt(offset)) {
                text.setCursor(busyCursor);
                String url = item.getLinkAt(offset);
                if (StringUtil.isEmpty(url)) {
                    LOGGER.warn("The url is a null or empty string : {}.", url);
                } else {
                    openLink(url);
                }
                StyleRange selectionRange = getCurrentRange(text);
                if (selectionRange == null) {
                    LOGGER.warn("The selectionRange is a null.");
                } else {
                    text.setSelectionRange(selectionRange.start, selectionRange.length);
                    text.setCursor(null);
                }
            }
        }
    });
    styledText.addMouseMoveListener(new MouseMoveListener() {

        public void mouseMove(MouseEvent event) {
            if (mouseDown) {
                if (!dragEvent) {
                    StyledText text = (StyledText) event.widget;
                    text.setCursor(null);
                }
                dragEvent = true;
                return;
            }
            StyledText text = (StyledText) event.widget;
            int offset = -1;
            try {
                offset = text.getOffsetAtLocation(new Point(event.x, event.y));
            } catch (IllegalArgumentException ex) {
                offset = -1;
            }
            if (offset == -1) {
                text.setCursor(null);
            } else if (item != null && item.isLinkAt(offset)) {
                text.setCursor(handCursor);
            } else {
                text.setCursor(null);
            }
        }
    });
    styledText.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            StyledText text = (StyledText) event.widget;
            switch(event.detail) {
                case SWT.TRAVERSE_ESCAPE:
                    event.doit = true;
                    break;
                case SWT.TRAVERSE_TAB_NEXT:
                    // Previously traverse out in the backward direction?
                    Point nextSelection = text.getSelection();
                    int charCount = text.getCharCount();
                    if ((nextSelection.x == charCount) && (nextSelection.y == charCount)) {
                        text.setSelection(0);
                    }
                    StyleRange nextRange = findNextRange(text);
                    if (nextRange == null) {
                        // Next time in start at beginning, also used by
                        // TRAVERSE_TAB_PREVIOUS to indicate we traversed out
                        // in the forward direction
                        text.setSelection(0);
                        event.doit = true;
                    } else {
                        text.setSelectionRange(nextRange.start, nextRange.length);
                        event.doit = true;
                        event.detail = SWT.TRAVERSE_NONE;
                    }
                    break;
                case SWT.TRAVERSE_TAB_PREVIOUS:
                    // Previously traverse out in the forward direction?
                    Point previousSelection = text.getSelection();
                    if ((previousSelection.x == 0) && (previousSelection.y == 0)) {
                        text.setSelection(text.getCharCount());
                    }
                    StyleRange previousRange = findPreviousRange(text);
                    if (previousRange == null) {
                        // Next time in start at the end, also used by
                        // TRAVERSE_TAB_NEXT to indicate we traversed out
                        // in the backward direction
                        text.setSelection(text.getCharCount());
                        event.doit = true;
                    } else {
                        text.setSelectionRange(previousRange.start, previousRange.length);
                        event.doit = true;
                        event.detail = SWT.TRAVERSE_NONE;
                    }
                    break;
                default:
                    break;
            }
        }
    });
    // Listen for Tab and Space to allow keyboard navigation
    styledText.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            StyledText text = (StyledText) event.widget;
            if (event.character == ' ' || event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
                if (item == null) {
                    LOGGER.warn("AboutItem is a null.");
                    return;
                }
                // Be sure we are in the selection
                int offset = text.getSelection().x + 1;
                if (item.isLinkAt(offset)) {
                    text.setCursor(busyCursor);
                    String url = item.getLinkAt(offset);
                    if (StringUtil.isEmpty(url)) {
                        LOGGER.warn("The url is a null or empty string : {}.", url);
                    } else {
                        openLink(url);
                    }
                    StyleRange selectionRange = getCurrentRange(text);
                    if (selectionRange == null) {
                        LOGGER.warn("The selectionRange is a null.");
                    } else {
                        text.setSelectionRange(selectionRange.start, selectionRange.length);
                        text.setCursor(null);
                    }
                }
            }
        }
    });
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseEvent(org.eclipse.swt.events.MouseEvent) StyledText(org.eclipse.swt.custom.StyledText) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) StyleRange(org.eclipse.swt.custom.StyleRange) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point)

Aggregations

MouseAdapter (org.eclipse.swt.events.MouseAdapter)39 MouseEvent (org.eclipse.swt.events.MouseEvent)39 GridData (org.eclipse.swt.layout.GridData)20 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 Composite (org.eclipse.swt.widgets.Composite)15 GridLayout (org.eclipse.swt.layout.GridLayout)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 KeyEvent (org.eclipse.swt.events.KeyEvent)11 Button (org.eclipse.swt.widgets.Button)11 Point (org.eclipse.swt.graphics.Point)10 Text (org.eclipse.swt.widgets.Text)9 KeyAdapter (org.eclipse.swt.events.KeyAdapter)8 StyledText (org.eclipse.swt.custom.StyledText)6 SelectionListener (org.eclipse.swt.events.SelectionListener)6 Label (org.eclipse.swt.widgets.Label)6 TraverseEvent (org.eclipse.swt.events.TraverseEvent)5 TraverseListener (org.eclipse.swt.events.TraverseListener)5 ArrayList (java.util.ArrayList)4 Table (org.eclipse.swt.widgets.Table)4 Tree (org.eclipse.swt.widgets.Tree)4