Search in sources :

Example 51 with ControlListener

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

the class MapperUI method addParentListeners.

private void addParentListeners(final UIManager uiManager, final ExternalMapperUiProperties uiProperties) {
    mapperUIParent.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            release();
        }
    });
    mapperUIParent.addListener(SWT.Close, new Listener() {

        public void handleEvent(Event event) {
            if (uiManager.getMapperResponse() == SWT.NONE) {
                uiManager.setMapperResponse(SWT.CANCEL);
            }
        }
    });
    mapperUIParent.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            updateBackground(false, true);
        }

        public void focusLost(FocusEvent e) {
        }
    });
    // store size if not maximized
    if (mapperUIParent instanceof Shell) {
        ((Shell) mapperUIParent).addControlListener(new ControlListener() {

            public void controlMoved(ControlEvent e) {
            }

            public void controlResized(ControlEvent e) {
                if (!((Shell) e.getSource()).getMaximized()) {
                    uiProperties.setBoundsMapper(((Shell) e.getSource()).getBounds());
                }
            }
        });
    }
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) DisposeListener(org.eclipse.swt.events.DisposeListener) DropTargetOperationListener(org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) Listener(org.eclipse.swt.widgets.Listener) ShellListener(org.eclipse.swt.events.ShellListener) MouseScrolledListener(org.talend.designer.abstractmap.ui.listener.MouseScrolledListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 52 with ControlListener

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

the class AbstractTemplatesPage method createPatternForm.

/**
 * Setup the pattern viewer.
 *
 * @param parent the parent composite
 */
private void createPatternForm(Composite parent) {
    ViewForm viewForm = new ViewForm(parent, SWT.NONE);
    viewForm.setBorderVisible(false);
    CLabel previewLabel = new CLabel(viewForm, SWT.NONE);
    previewLabel.setText(TemplatesMessages.TemplatesPage_preview);
    previewLabel.setImage(TemplatesPageImages.get(TemplatesPageImages.IMG_OBJ_PREVIEW));
    viewForm.setTopLeft(previewLabel);
    fPatternViewer = createPatternViewer(viewForm);
    viewForm.setContent(fPatternViewer.getControl());
    viewForm.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            int[] weights = fControl.getWeights();
            int sashSize = (int) (weights[0] * 100.0 / (weights[0] + weights[1]));
            fPreferenceStore.setValue(SASH_SIZE_PREF_ID, sashSize);
        }
    });
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) ViewForm(org.eclipse.swt.custom.ViewForm) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 53 with ControlListener

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

the class CompletionProposalPopup2 method createProposalSelector.

/**
 * Creates the proposal selector.
 */
private void createProposalSelector() {
    if (Helper2.okToUse(fProposalShell))
        return;
    Control control = fViewer.getTextWidget();
    fProposalShell = new Shell(control.getShell(), SWT.ON_TOP);
    // fProposalShell= new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE );
    fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
    // fProposalTable= new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL);
    fIsColoredLabelsSupportEnabled = fContentAssistant.isColoredLabelsSupportEnabled();
    if (fIsColoredLabelsSupportEnabled)
        TableOwnerDrawSupport.install(fProposalTable);
    fProposalTable.setLocation(0, 0);
    if (fAdditionalInfoController != null)
        fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    fProposalShell.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    fProposalTable.setLayoutData(data);
    fProposalShell.pack();
    // set location
    Point currentLocation = fProposalShell.getLocation();
    Point newLocation = getLocation();
    if ((newLocation.x < currentLocation.x && newLocation.y == currentLocation.y) || newLocation.y < currentLocation.y)
        fProposalShell.setLocation(newLocation);
    if (fAdditionalInfoController != null) {
        fProposalShell.addControlListener(new ControlListener() {

            @Override
            public void controlMoved(ControlEvent e) {
            }

            @Override
            public void controlResized(ControlEvent e) {
                // resets the cached resize constraints
                fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
            }
        });
    }
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    Color background = colorRegistry.get(JFacePreferences.CONTENT_ASSIST_BACKGROUND_COLOR);
    if (background == null) {
        background = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
    }
    Color foreground = colorRegistry.get(JFacePreferences.CONTENT_ASSIST_FOREGROUND_COLOR);
    if (foreground == null) {
        foreground = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
    }
    fProposalShell.setBackground(background);
    fProposalTable.setBackground(background);
    fProposalTable.setForeground(foreground);
    fProposalTable.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            selectProposalWithMask(e.stateMask);
        }
    });
    fPopupCloser.install(fContentAssistant, fProposalTable);
    fProposalShell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // but don't dispose the shell, since we're being called from its disposal event!
            unregister();
        }
    });
    fProposalTable.setHeaderVisible(false);
    fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant2.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Table(org.eclipse.swt.widgets.Table) Color(org.eclipse.swt.graphics.Color) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ColorRegistry(org.eclipse.jface.resource.ColorRegistry) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 54 with ControlListener

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

the class CompletionProposalPopup method createProposalSelector.

/**
 * Creates the proposal selector.
 */
void createProposalSelector() {
    if (Helper.okToUse(fProposalShell))
        return;
    Control control = fContentAssistSubjectControlAdapter.getControl();
    fProposalShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
    fProposalShell.setFont(JFaceResources.getDefaultFont());
    fProposalTable = new Table(fProposalShell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.VIRTUAL);
    Listener listener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            handleSetData(event);
        }
    };
    fProposalTable.addListener(SWT.SetData, listener);
    fIsColoredLabelsSupportEnabled = fContentAssistant.isColoredLabelsSupportEnabled();
    if (fIsColoredLabelsSupportEnabled)
        TableOwnerDrawSupport.install(fProposalTable);
    fProposalTable.setLocation(0, 0);
    if (fAdditionalInfoController != null)
        fAdditionalInfoController.setSizeConstraints(50, 10, true, true);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 1;
    fProposalShell.setLayout(layout);
    if (fContentAssistant.isStatusLineVisible()) {
        createMessageText();
    }
    GridData data = new GridData(GridData.FILL_BOTH);
    Point size = fContentAssistant.restoreCompletionProposalPopupSize();
    if (size != null) {
        fProposalTable.setLayoutData(data);
        fProposalShell.setSize(size);
    } else {
        int height = fProposalTable.getItemHeight() * 10;
        // use golden ratio as default aspect ratio
        final double aspectRatio = (1 + Math.sqrt(5)) / 2;
        int width = (int) (height * aspectRatio);
        Rectangle trim = fProposalTable.computeTrim(0, 0, width, height);
        data.heightHint = trim.height;
        data.widthHint = trim.width;
        fProposalTable.setLayoutData(data);
        fProposalShell.pack();
    }
    fContentAssistant.addToLayout(this, fProposalShell, ContentAssistant.LayoutManager.LAYOUT_PROPOSAL_SELECTOR, fContentAssistant.getSelectionOffset());
    fProposalShell.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            if (fAdditionalInfoController != null) {
                // reset the cached resize constraints
                fAdditionalInfoController.setSizeConstraints(50, 10, true, false);
                fAdditionalInfoController.hideInformationControl();
                fAdditionalInfoController.handleTableSelectionChanged();
            }
            fSize = fProposalShell.getSize();
        }
    });
    Color background = getBackgroundColor(control);
    if (background == null) {
        background = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
    }
    Color foreground = getForegroundColor(control);
    if (foreground == null) {
        foreground = JFaceColors.getInformationViewerBackgroundColor(Display.getDefault());
    }
    fProposalShell.setBackground(background);
    fProposalTable.setBackground(background);
    fProposalTable.setForeground(foreground);
    fProposalTable.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            insertSelectedProposalWithMask(e.stateMask);
        }
    });
    fPopupCloser.install(fContentAssistant, fProposalTable, fAdditionalInfoController);
    fProposalShell.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            // but don't dispose the shell, since we're being called from its disposal event!
            unregister();
        }
    });
    fProposalTable.setHeaderVisible(false);
    addCommandSupport(fProposalTable);
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Table(org.eclipse.swt.widgets.Table) DisposeListener(org.eclipse.swt.events.DisposeListener) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionListener(org.eclipse.swt.events.SelectionListener) ControlListener(org.eclipse.swt.events.ControlListener) FocusListener(org.eclipse.swt.events.FocusListener) IDocumentListener(org.eclipse.jface.text.IDocumentListener) Listener(org.eclipse.swt.widgets.Listener) KeyListener(org.eclipse.swt.events.KeyListener) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point) IContentAssistSubjectControl(org.eclipse.jface.contentassist.IContentAssistSubjectControl) IInformationControl(org.eclipse.jface.text.IInformationControl) Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) DocumentEvent(org.eclipse.jface.text.DocumentEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) VerifyEvent(org.eclipse.swt.events.VerifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 55 with ControlListener

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

the class ContextInformationPopup method createContextSelector.

/**
 * Creates the context selector in case the user has the choice between multiple valid contexts
 * at a given offset.
 */
private void createContextSelector() {
    if (Helper.okToUse(fContextSelectorShell))
        return;
    Control control = fContentAssistSubjectControlAdapter.getControl();
    fContextSelectorShell = new Shell(control.getShell(), SWT.ON_TOP | SWT.RESIZE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    fContextSelectorShell.setLayout(layout);
    fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    fContextSelectorShell.addControlListener(new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
        }

        @Override
        public void controlResized(ControlEvent e) {
            fContextSelectorPopupSize = fContextSelectorShell.getSize();
        }
    });
    if (fViewer instanceof ITextViewerExtension) {
        final ITextViewerExtension textViewerExtension = (ITextViewerExtension) fViewer;
        final StyledText textWidget = fViewer.getTextWidget();
        final VerifyKeyListener verifyListener = new VerifyKeyListener() {

            @Override
            public void verifyKey(VerifyEvent event) {
                if (isActive() && event.keyCode == 13 && event.character == '\r' && event.widget == textWidget) {
                    event.doit = false;
                    insertSelectedContext();
                    hideContextSelector();
                }
            }
        };
        textViewerExtension.prependVerifyKeyListener(verifyListener);
        fContextSelectorShell.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                textViewerExtension.removeVerifyKeyListener(verifyListener);
            }
        });
    }
    fContextSelectorTable = new Table(fContextSelectorShell, SWT.H_SCROLL | SWT.V_SCROLL);
    fContextSelectorTable.setLocation(1, 1);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = fContextSelectorTable.getItemHeight() * 10;
    gd.widthHint = 300;
    fContextSelectorTable.setLayoutData(gd);
    Point size = fContentAssistant.restoreContextSelectorPopupSize();
    if (size != null)
        fContextSelectorShell.setSize(size);
    else
        fContextSelectorShell.pack(true);
    Color c = fContentAssistant.getContextSelectorBackground();
    if (c == null)
        c = control.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
    fContextSelectorTable.setBackground(c);
    c = fContentAssistant.getContextSelectorForeground();
    if (c == null)
        c = control.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
    fContextSelectorTable.setForeground(c);
    fContextSelectorTable.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            insertSelectedContext();
            hideContextSelector();
        }
    });
    fPopupCloser.install(fContentAssistant, fContextSelectorTable);
    fContextSelectorTable.setHeaderVisible(false);
    fContentAssistant.addToLayout(this, fContextSelectorShell, ContentAssistant.LayoutManager.LAYOUT_CONTEXT_SELECTOR, fContentAssistant.getSelectionOffset());
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) StyledText(org.eclipse.swt.custom.StyledText) Table(org.eclipse.swt.widgets.Table) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) Color(org.eclipse.swt.graphics.Color) Point(org.eclipse.swt.graphics.Point) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IContentAssistSubjectControl(org.eclipse.jface.contentassist.IContentAssistSubjectControl) Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) VerifyEvent(org.eclipse.swt.events.VerifyEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ControlListener (org.eclipse.swt.events.ControlListener)87 ControlEvent (org.eclipse.swt.events.ControlEvent)82 GridData (org.eclipse.swt.layout.GridData)31 FocusEvent (org.eclipse.swt.events.FocusEvent)19 Composite (org.eclipse.swt.widgets.Composite)19 Test (org.junit.Test)19 MouseEvent (org.eclipse.swt.events.MouseEvent)18 Point (org.eclipse.swt.graphics.Point)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 KeyEvent (org.eclipse.swt.events.KeyEvent)16 ArrayList (java.util.ArrayList)14 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 DisposeEvent (org.eclipse.swt.events.DisposeEvent)13 Control (org.eclipse.swt.widgets.Control)13 Event (org.eclipse.swt.widgets.Event)13 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)11 DisposeListener (org.eclipse.swt.events.DisposeListener)11 FocusListener (org.eclipse.swt.events.FocusListener)11 Listener (org.eclipse.swt.widgets.Listener)10 ModifyEvent (org.eclipse.swt.events.ModifyEvent)9