Search in sources :

Example 51 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project archi by archimatetool.

the class FindReplaceDialog method configureShell.

@Override
protected void configureShell(Shell newShell) {
    super.configureShell(newShell);
    newShell.setText(Messages.FindReplaceDialog_1);
    loadParameter();
    startListeningToPartChanges();
    newShell.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            saveParameter();
            stopListeningToPartChanges();
        }
    });
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 52 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project xtext-eclipse by eclipse.

the class EmbeddedEditorActions method initialize.

protected void initialize() {
    final List<IHandlerActivation> handlerActivations = Lists.newArrayListWithExpectedSize(3);
    final IHandlerService handlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class);
    final IContextService contextService = (IContextService) workbench.getAdapter(IContextService.class);
    Shell shell = viewer.getTextWidget().getShell();
    final ActiveShellExpression expression = new ActiveShellExpression(shell);
    final IContextActivation contextActivation = contextService.activateContext(EMBEDDED_TEXT_EDITOR_SCOPE, expression);
    shell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            handlerService.deactivateHandlers(handlerActivations);
            contextService.deactivateContext(contextActivation);
        }
    });
    viewer.getTextWidget().addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            handlerService.deactivateHandlers(handlerActivations);
            handlerActivations.clear();
        }

        @Override
        public void focusGained(FocusEvent e) {
            for (final IAction action : allActions.values()) {
                handlerActivations.add(handlerService.activateHandler(action.getActionDefinitionId(), new ActionHandler(action), expression, true));
            }
        }
    });
    createActions();
    // create context menu
    MenuManager manager = new MenuManager(null, null);
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager mgr) {
            fillContextMenu(mgr);
        }
    });
    StyledText text = viewer.getTextWidget();
    Menu menu = manager.createContextMenu(text);
    text.setMenu(menu);
    List<ActionActivationCode> activationCodes = Lists.newArrayList();
    setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_RIGHT_TAB, '\t', -1, SWT.NONE);
    setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
    viewer.getTextWidget().addVerifyKeyListener(new ActivationCodeTrigger(allActions, activationCodes));
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) StyledText(org.eclipse.swt.custom.StyledText) IAction(org.eclipse.jface.action.IAction) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) Shell(org.eclipse.swt.widgets.Shell) IHandlerService(org.eclipse.ui.handlers.IHandlerService) IContextActivation(org.eclipse.ui.contexts.IContextActivation) IHandlerActivation(org.eclipse.ui.handlers.IHandlerActivation) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IContextService(org.eclipse.ui.contexts.IContextService) ActiveShellExpression(org.eclipse.ui.ActiveShellExpression) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) FocusListener(org.eclipse.swt.events.FocusListener) ActionHandler(org.eclipse.jface.commands.ActionHandler)

Example 53 with DisposeEvent

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

the class FontGroup method createChangeControl.

/**
	 * create change color button
	 * 
	 * @param parent the parent container
	 * @return button the instance of Button
	 */
private Button createChangeControl(Composite parent) {
    if (changeFontButton == null) {
        changeFontButton = new Button(parent, SWT.PUSH);
    }
    if (changeButtonText != null) {
        changeFontButton.setText(changeButtonText);
    }
    changeFontButton.addSelectionListener(new ChangeSelectListen());
    changeFontButton.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent event) {
            changeFontButton = null;
        }
    });
    changeFontButton.setFont(parent.getFont());
    return changeFontButton;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Button(org.eclipse.swt.widgets.Button) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 54 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project eclipse.platform.text by eclipse.

the class OverviewRuler method createControl.

@Override
public Control createControl(Composite parent, ITextViewer textViewer) {
    fTextViewer = textViewer;
    fHitDetectionCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
    fHeader = new Canvas(parent, SWT.NONE);
    if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
        fHeader.addMouseTrackListener(new MouseTrackAdapter() {

            /*
				 * @see org.eclipse.swt.events.MouseTrackAdapter#mouseHover(org.eclipse.swt.events.MouseEvent)
				 * @since 3.3
				 */
            @Override
            public void mouseEnter(MouseEvent e) {
                updateHeaderToolTipText();
            }
        });
    }
    fCanvas = new Canvas(parent, SWT.NO_BACKGROUND);
    fCanvas.addPaintListener(new PaintListener() {

        @Override
        public void paintControl(PaintEvent event) {
            if (fTextViewer != null)
                doubleBufferPaint(event.gc);
        }
    });
    fCanvas.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent event) {
            handleDispose();
            fTextViewer = null;
        }
    });
    fCanvas.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDown(MouseEvent event) {
            handleMouseDown(event);
        }
    });
    fCanvas.addMouseMoveListener(new MouseMoveListener() {

        @Override
        public void mouseMove(MouseEvent event) {
            handleMouseMove(event);
        }
    });
    fCanvas.addMouseWheelListener(new MouseWheelListener() {

        @Override
        public void mouseScrolled(MouseEvent e) {
            handleMouseScrolled(e);
        }
    });
    if (fTextViewer != null) {
        fTextViewer.addTextListener(fInternalListener);
        // on word wrap toggle a "resized" ControlEvent is fired: suggest a redraw of the ruler
        fTextViewer.getTextWidget().addControlListener(new ControlAdapter() {

            @Override
            public void controlResized(ControlEvent e) {
                if (fTextViewer == null) {
                    return;
                }
                StyledText textWidget = fTextViewer.getTextWidget();
                if (textWidget != null && textWidget.getWordWrap()) {
                    redraw();
                }
            }
        });
    }
    return fCanvas;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) MouseEvent(org.eclipse.swt.events.MouseEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) StyledText(org.eclipse.swt.custom.StyledText) ControlAdapter(org.eclipse.swt.events.ControlAdapter) PaintListener(org.eclipse.swt.events.PaintListener) Canvas(org.eclipse.swt.widgets.Canvas) MouseTrackAdapter(org.eclipse.swt.events.MouseTrackAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 55 with DisposeEvent

use of org.eclipse.swt.events.DisposeEvent in project eclipse.platform.text by eclipse.

the class DefaultRangeIndicator method getImage.

/**
 * Returns the image of this range indicator.
 *
 * @param control the control
 * @param rangeIndicatorColor the color to be used to paint the range indicator
 * @return an image
 */
private Image getImage(Control control, Color rangeIndicatorColor) {
    if (fImage == null) {
        fImage = createImage(control.getDisplay(), control.getSize(), rangeIndicatorColor);
        control.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                if (fImage != null && !fImage.isDisposed()) {
                    fImage.dispose();
                    fImage = null;
                }
            }
        });
    } else {
        Rectangle imageRectangle = fImage.getBounds();
        Point controlSize = control.getSize();
        if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y || !rangeIndicatorColor.equals(fLastRangeIndicatorColor)) {
            fImage.dispose();
            fImage = createImage(control.getDisplay(), controlSize, rangeIndicatorColor);
        }
    }
    return fImage;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)366 DisposeListener (org.eclipse.swt.events.DisposeListener)363 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)75 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)70 Image (org.eclipse.swt.graphics.Image)53 Cursor (org.eclipse.swt.graphics.Cursor)49 Label (org.eclipse.swt.widgets.Label)42 ToolBar (org.eclipse.swt.widgets.ToolBar)42 Point (org.eclipse.swt.graphics.Point)38 Control (org.eclipse.swt.widgets.Control)38 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 Color (org.eclipse.swt.graphics.Color)34 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31