Search in sources :

Example 1 with ShellAdapter

use of org.eclipse.swt.events.ShellAdapter in project cogtool by cogtool.

the class FrameEditorUI method addEventListeners.

/**
     * Add the important event listeners to the contents.
     *
     * Includes both the Mouse & Mouse Motion listeners as well as the Keyboard
     *
     */
protected void addEventListeners() {
    // Add them to the contents.
    InteractionFigure interactionLayer = view.getEditor().getInteractionFigure();
    // let mouseState handle delete key events
    interactionLayer.addKeyListener(mouseState);
    getShell().addShellListener(new ShellAdapter() {

        @Override
        public void shellDeactivated(ShellEvent e) {
            mouseState.cancelDynamicOperation();
        }
    });
}
Also used : ShellAdapter(org.eclipse.swt.events.ShellAdapter) ShellEvent(org.eclipse.swt.events.ShellEvent) InteractionFigure(edu.cmu.cs.hcii.cogtool.view.InteractionFigure)

Example 2 with ShellAdapter

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

the class ColumnRenameDialog method initComponents.

@Override
protected void initComponents(final Shell shell) {
    GridLayout shellLayout = new GridLayout();
    shell.setLayout(shellLayout);
    shell.setText("Rename column");
    // Closing the window is the same as canceling the form
    shell.addShellListener(new ShellAdapter() {

        @Override
        public void shellClosed(ShellEvent e) {
            doFormCancel(shell);
        }
    });
    // Tabs panel
    Composite panel = new Composite(shell, SWT.NONE);
    panel.setLayout(new GridLayout());
    GridData fillGridData = new GridData();
    fillGridData.grabExcessHorizontalSpace = true;
    fillGridData.horizontalAlignment = GridData.FILL;
    panel.setLayoutData(fillGridData);
    columnLabelPanel = new ColumnLabelPanel(panel, columnLabel, renamedColumnLabel);
    try {
        columnLabelPanel.edit(renamedColumnLabel);
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) ShellEvent(org.eclipse.swt.events.ShellEvent)

Example 3 with ShellAdapter

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

the class TmDbManagerDialog method configureShell.

@Override
protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    newShell.setText(Messages.getString("dialog.TmDbManagerDialog.title"));
    newShell.addShellListener(new ShellAdapter() {

        public void shellActivated(ShellEvent e) {
            if (lastShellSize == null) {
                lastShellSize = getShell().getSize();
            }
        }
    });
}
Also used : ShellAdapter(org.eclipse.swt.events.ShellAdapter) ShellEvent(org.eclipse.swt.events.ShellEvent)

Example 4 with ShellAdapter

use of org.eclipse.swt.events.ShellAdapter in project tdi-studio-se by Talend.

the class TalendEditPartTipHelper method hookShellListeners.

@Override
protected void hookShellListeners() {
    /*
         * If the cursor leaves the tip window, hide the tooltip and dispose of its shell
         */
    getShell().addMouseTrackListener(new MouseTrackAdapter() {

        @Override
        public void mouseExit(MouseEvent e) {
            getShell().setCapture(false);
            dispose();
        }
    });
    /*
         * If the mouseExit listener does not get called, dispose of the shell if the cursor is no longer in the
         * tooltip. This occurs in the rare case that a mouseEnter is not received on the tooltip when it appears.
         */
    getShell().addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent e) {
            Point eventPoint = getShell().toDisplay(new Point(e.x, e.y));
            if (!getShell().getBounds().contains(eventPoint)) {
                if (isShowing()) {
                    getShell().setCapture(false);
                }
                dispose();
            }
        }
    });
    // window.
    if (shellListener == null) {
        shellListener = new ShellAdapter() {

            @Override
            public void shellDeactivated(ShellEvent event) {
                Display.getCurrent().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        Shell active = Display.getCurrent().getActiveShell();
                        if (getShell() == active || control.getShell() == active || getShell().isDisposed()) {
                            return;
                        }
                        if (isShowing()) {
                            getShell().setCapture(false);
                        }
                        dispose();
                    }
                });
            }
        };
        control.getShell().addShellListener(shellListener);
        getShell().addShellListener(shellListener);
    }
    /*
         * Workaround for GTK Bug - Control.setCapture(boolean) not implemented: If the cursor is not over the shell
         * when it is first painted, hide the tooltip and dispose of the shell.
         */
    if (SWT.getPlatform().equals("gtk")) {
        //$NON-NLS-1$
        getShell().addPaintListener(new PaintListener() {

            @Override
            public void paintControl(PaintEvent event) {
                Point cursorLoc = Display.getCurrent().getCursorLocation();
                if (!getShell().getBounds().contains(cursorLoc)) {
                    // This must be run asynchronously. If not, other paint
                    // listeners may attempt to paint on a disposed control.
                    Display.getCurrent().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            if (isShowing()) {
                                getShell().setCapture(false);
                            }
                            dispose();
                        }
                    });
                }
            }
        });
    }
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) ShellAdapter(org.eclipse.swt.events.ShellAdapter) Shell(org.eclipse.swt.widgets.Shell) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) ShellEvent(org.eclipse.swt.events.ShellEvent) Point(org.eclipse.swt.graphics.Point)

Example 5 with ShellAdapter

use of org.eclipse.swt.events.ShellAdapter in project bndtools by bndtools.

the class JpmDependencyWizardPage method createControl.

@Override
@SuppressWarnings("unused")
public void createControl(Composite parent) {
    // CREATE CONTROLS
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    Label lblDirect = new Label(container, SWT.NONE);
    lblDirect.setFont(JFaceResources.getBannerFont());
    lblDirect.setText("Direct Dependencies:");
    Table tblDirect = new Table(container, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    viewerDirect = new TableViewer(tblDirect);
    viewerDirect.setContentProvider(ArrayContentProvider.getInstance());
    viewerDirect.setLabelProvider(new ResourceDescriptorLabelProvider());
    createHelpLabel(container, "The above dependencies will be added to the project and, if necessary, to the JPM4J local index.");
    Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
    Label lblIndirect = new Label(container, SWT.NONE);
    lblIndirect.setFont(JFaceResources.getBannerFont());
    lblIndirect.setText("Transitive Dependencies:");
    Composite cmpIndirect = new Composite(container, SWT.NONE);
    Table tblIndirect = new Table(cmpIndirect, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    viewerIndirect = new CheckboxTableViewer(tblIndirect);
    viewerIndirect.setContentProvider(ArrayContentProvider.getInstance());
    viewerIndirect.setLabelProvider(new ResourceDescriptorLabelProvider());
    Button btnSelectAll = new Button(cmpIndirect, SWT.PUSH);
    btnSelectAll.setText("All");
    Button btnSelectNone = new Button(cmpIndirect, SWT.PUSH);
    btnSelectNone.setText("None");
    new Label(cmpIndirect, SWT.NONE);
    createHelpLabel(container, "The above dependencies will be added to the JPM4J local index. Checked dependencies will also be added directly to the project.");
    // LISTENERS
    // Query JPM and show results *after* dialog is shown. This ensures progress is visible in the dialog's
    // progress bar
    getContainer().getShell().addShellListener(new ShellAdapter() {

        @Override
        public void shellActivated(ShellEvent e) {
            runQuery();
        }
    });
    viewerIndirect.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent ev) {
            if (selectedIndirectResources == null)
                selectedIndirectResources = new HashSet<ResourceDescriptor>();
            ResourceDescriptor resource = (ResourceDescriptor) ev.getElement();
            if (ev.getChecked())
                selectedIndirectResources.add(resource);
            else
                selectedIndirectResources.remove(resource);
        }
    });
    btnSelectAll.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedIndirectResources.addAll(indirectResources);
            updateSelectedCheckboxes();
        }
    });
    btnSelectNone.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            selectedIndirectResources.clear();
            updateSelectedCheckboxes();
        }
    });
    viewerDirect.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = event.getSelection();
            if (sel.isEmpty())
                selection = (ResourceDescriptor) ((IStructuredSelection) viewerIndirect.getSelection()).getFirstElement();
            else
                selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
            getContainer().updateMessage();
        }
    });
    viewerIndirect.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = event.getSelection();
            if (sel.isEmpty())
                selection = (ResourceDescriptor) ((IStructuredSelection) viewerDirect.getSelection()).getFirstElement();
            else
                selection = (ResourceDescriptor) ((IStructuredSelection) sel).getFirstElement();
            getContainer().updateMessage();
        }
    });
    // LAYOUT
    GridLayout layout;
    GridData gd;
    layout = new GridLayout(1, true);
    container.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.heightHint = 30;
    tblDirect.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    separator.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    cmpIndirect.setLayoutData(gd);
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = 2;
    layout.verticalSpacing = 2;
    cmpIndirect.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3);
    gd.heightHint = 100;
    tblIndirect.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    btnSelectAll.setLayoutData(gd);
    gd = new GridData(SWT.FILL, SWT.FILL, false, false);
    btnSelectNone.setLayoutData(gd);
}
Also used : ShellAdapter(org.eclipse.swt.events.ShellAdapter) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ResourceDescriptor(aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)

Aggregations

ShellAdapter (org.eclipse.swt.events.ShellAdapter)9 ShellEvent (org.eclipse.swt.events.ShellEvent)9 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Shell (org.eclipse.swt.widgets.Shell)2 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)1 InteractionFigure (edu.cmu.cs.hcii.cogtool.view.InteractionFigure)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)1 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 CTabItem (org.eclipse.swt.custom.CTabItem)1