Search in sources :

Example 31 with ControlListener

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

the class MetadataTableEditorViewExt method addTableColumnsListener.

private void addTableColumnsListener() {
    ControlListener controlListener = new ControlListener() {

        @Override
        public void controlMoved(ControlEvent e) {
            MetadataTableEditorViewExt.this.attachLabelPosition(getTable().getHorizontalBar().getSelection());
        }

        @Override
        public void controlResized(ControlEvent e) {
            MetadataTableEditorViewExt.this.attachLabelPosition(getTable().getHorizontalBar().getSelection());
        }
    };
    for (Object element2 : getTableViewerCreator().getColumns()) {
        TableViewerCreatorColumnNotModifiable element = (TableViewerCreatorColumnNotModifiable) element2;
        element.getTableColumn().addControlListener(controlListener);
    }
}
Also used : TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 32 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 33 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 34 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 35 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)

Aggregations

ControlEvent (org.eclipse.swt.events.ControlEvent)54 ControlListener (org.eclipse.swt.events.ControlListener)54 GridData (org.eclipse.swt.layout.GridData)21 FocusEvent (org.eclipse.swt.events.FocusEvent)14 Control (org.eclipse.swt.widgets.Control)12 FocusListener (org.eclipse.swt.events.FocusListener)11 MouseEvent (org.eclipse.swt.events.MouseEvent)11 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 ArrayList (java.util.ArrayList)9 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)9 DisposeEvent (org.eclipse.swt.events.DisposeEvent)9 DisposeListener (org.eclipse.swt.events.DisposeListener)9 KeyEvent (org.eclipse.swt.events.KeyEvent)9 Point (org.eclipse.swt.graphics.Point)9 Event (org.eclipse.swt.widgets.Event)8 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)6 Listener (org.eclipse.swt.widgets.Listener)6 Table (org.eclipse.swt.widgets.Table)6