Search in sources :

Example 41 with DisposeEvent

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

the class WindowsStartup method hookWindow.

private void hookWindow(IWorkbenchWindow window) {
    Shell shell = window.getShell();
    if (shell != null && !shell.isDisposed()) {
        Number hWnd = getShellWindowHandle(shell);
        logPrimaryWindow(hWnd);
        shell.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent e) {
                WindowState.get(WindowState.WINDOW).delete();
                e.display.asyncExec(new Runnable() {

                    public void run() {
                        checkRemainingWindow();
                    }
                });
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 42 with DisposeEvent

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

the class FloatingPalette method createShell.

private void createShell() {
    fShell = new Shell(fParentShell, SWT.TOOL | SWT.RESIZE | SWT.CLOSE);
    if (fPaletteState.isTranslucent) {
        fShell.setAlpha(210);
    }
    checkSafeBounds(fParentShell);
    fShell.setBounds(fPaletteState.bounds);
    fShell.setImage(IArchiImages.ImageFactory.getImage(IArchiImages.ICON_APP));
    fShell.setText(Messages.FloatingPalette_0);
    // Disposed by system
    fShell.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            if (fClient != null) {
                fClient.dispose();
            }
            if (fPalettePage != null) {
                fPalettePage.dispose();
            }
            fShell = null;
        }
    });
    // Closed by user
    fShell.addListener(SWT.Close, new Listener() {

        @Override
        public void handleEvent(Event event) {
            fPaletteState.isOpen = false;
            // Don't call this in DisposeListener as on Linux getBounds() returns bogus info
            saveState(fShell);
        }
    });
    fShell.setLayout(new FillLayout());
    fClient = new Composite(fShell, SWT.NONE);
    fClient.setLayout(new FillLayout());
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    fClient.setLayoutData(gd);
    fPalettePage = fEditor.getAdapter(PalettePage.class);
    fPalettePage.createControl(fClient);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) PalettePage(org.eclipse.gef.ui.views.palette.PalettePage) Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) FillLayout(org.eclipse.swt.layout.FillLayout) DisposeEvent(org.eclipse.swt.events.DisposeEvent)

Example 43 with DisposeEvent

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

the class CheckBoxGroupFieldEditor method getCheckBoxControl.

private Control getCheckBoxControl(Composite parent) {
    if (checkBoxBox == null) {
        Font font = parent.getFont();
        if (useGroup) {
            Group group = new Group(parent, SWT.NONE);
            group.setFont(font);
            String text = getLabelText();
            if (text != null) {
                group.setText(text);
            }
            checkBoxBox = group;
            GridLayout layout = new GridLayout();
            layout.horizontalSpacing = HORIZONTAL_GAP;
            layout.numColumns = numColumns;
            checkBoxBox.setLayout(layout);
        } else {
            checkBoxBox = new Composite(parent, SWT.NONE);
            GridLayout layout = new GridLayout();
            layout.marginWidth = 0;
            layout.marginHeight = 0;
            layout.horizontalSpacing = HORIZONTAL_GAP;
            layout.numColumns = numColumns;
            checkBoxBox.setLayout(layout);
            checkBoxBox.setFont(font);
        }
        checkBoxButtons = new Button[labelsAndValues.length];
        for (int i = 0; i < labelsAndValues.length; i++) {
            Button checkBox = new Button(checkBoxBox, SWT.CHECK | SWT.LEFT);
            checkBoxButtons[i] = checkBox;
            String[] labelAndValue = labelsAndValues[i];
            checkBox.setText(labelAndValue[0]);
            checkBox.setData(labelAndValue[1]);
            checkBox.setFont(font);
            checkBox.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    setPresentsDefaultValue(false);
                    String oldResult = result;
                    result = gatherSettings();
                    fireValueChanged(VALUE, oldResult, result);
                }
            });
        }
        checkBoxBox.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent event) {
                checkBoxBox = null;
                checkBoxButtons = null;
            }
        });
    } else {
        checkParent(checkBoxBox, parent);
    }
    return checkBoxBox;
}
Also used : Group(org.eclipse.swt.widgets.Group) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 44 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 45 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)

Aggregations

DisposeEvent (org.eclipse.swt.events.DisposeEvent)365 DisposeListener (org.eclipse.swt.events.DisposeListener)362 GridData (org.eclipse.swt.layout.GridData)103 Composite (org.eclipse.swt.widgets.Composite)91 SelectionEvent (org.eclipse.swt.events.SelectionEvent)88 GridLayout (org.eclipse.swt.layout.GridLayout)76 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)71 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 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)37 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 Control (org.eclipse.swt.widgets.Control)36 Color (org.eclipse.swt.graphics.Color)35 FillLayout (org.eclipse.swt.layout.FillLayout)35 Event (org.eclipse.swt.widgets.Event)35 MouseEvent (org.eclipse.swt.events.MouseEvent)32 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)31