Search in sources :

Example 1 with ShellEvent

use of org.eclipse.swt.events.ShellEvent 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 ShellEvent

use of org.eclipse.swt.events.ShellEvent 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 ShellEvent

use of org.eclipse.swt.events.ShellEvent 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 ShellEvent

use of org.eclipse.swt.events.ShellEvent 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 ShellEvent

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

the class MapperUI method createWindow.

/**
     * DOC amaumont Comment method "createUI".
     * 
     * @param display
     */
public Shell createWindow(final Display display, MapperModel model) {
    Shell activeShell = display.getActiveShell();
    Shell mapperShell = null;
    int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
    if (activeShell == null) {
        mapperShell = new Shell(mapperShell, style);
    } else {
        mapperShell = new Shell(activeShell, style);
    }
    this.mapperUIParent = mapperShell;
    final Shell mapperShellFinal = mapperShell;
    mapperShell.addShellListener(new ShellListener() {

        public void shellActivated(ShellEvent e) {
        }

        public void shellClosed(ShellEvent e) {
            UIManager uiManager = mapperManager.getUiManager();
            if (uiManager.getMapperResponse() == SWT.NONE) {
                for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
                    dataMapTableView.notifyFocusLost();
                }
                uiManager.setMapperResponse(SWT.CANCEL);
                uiManager.prepareClosing(uiManager.getMapperResponse());
            }
            if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
                boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
                Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
                if (!closeWindow) {
                    e.doit = false;
                } else {
                    mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
                    mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
                }
            }
        }

        public void shellDeactivated(ShellEvent e) {
        }

        public void shellDeiconified(ShellEvent e) {
        }

        public void shellIconified(ShellEvent e) {
        }
    });
    MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
    ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
    mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
    IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String productName = brandingService.getFullProductName();
    mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
    component.getUniqueName()));
    Rectangle boundsMapper = uiProperties.getBoundsMapper();
    if (uiProperties.isShellMaximized()) {
        mapperShell.setMaximized(uiProperties.isShellMaximized());
    } else {
        if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
            mapperShell.setMaximized(true);
        // boundsMapper = display.getBounds(); //no need this, will cause the full problems.
        } else {
            // // move shell at outer of display zone to avoid visual effect on loading
            // Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
            // boundsMapper.height);
            // shell.setBounds(tmpBoundsMapper);
            boundsMapper = uiProperties.getBoundsMapper();
            if (boundsMapper.x < 0) {
                boundsMapper.x = 0;
            }
            if (boundsMapper.y < 0) {
                boundsMapper.y = 0;
            }
            mapperShell.setBounds(boundsMapper);
        }
    }
    createCompositeContent(model);
    mapperShell.open();
    return mapperShell;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ExternalMapperUiProperties(org.talend.designer.mapper.external.data.ExternalMapperUiProperties) ShellListener(org.eclipse.swt.events.ShellListener) Rectangle(org.eclipse.swt.graphics.Rectangle) ShellEvent(org.eclipse.swt.events.ShellEvent) UIManager(org.talend.designer.mapper.managers.UIManager) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IBrandingService(org.talend.core.ui.branding.IBrandingService) MapperComponent(org.talend.designer.mapper.MapperComponent)

Aggregations

ShellEvent (org.eclipse.swt.events.ShellEvent)12 ShellAdapter (org.eclipse.swt.events.ShellAdapter)9 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5 Shell (org.eclipse.swt.widgets.Shell)5 ShellListener (org.eclipse.swt.events.ShellListener)3 Composite (org.eclipse.swt.widgets.Composite)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 IBrandingService (org.talend.core.ui.branding.IBrandingService)2 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)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