Search in sources :

Example 1 with CompositeValidator

use of org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator in project eclipse-integration-commons by spring-projects.

the class PreferencePageWithSections method createContents.

@Override
protected Control createContents(Composite parent) {
    final Composite page = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 1;
    layout.marginWidth = 1;
    page.setLayout(layout);
    CompositeValidator validator = new CompositeValidator();
    for (PrefsPageSection section : getSections()) {
        section.createContents(page);
        validator.addChild(section.getValidator());
    }
    validator.addListener(this);
    // Listener below is workaround for a layout glitch. Seems
    // we occasionally need to trigger an additional 'layout'
    // the first time the page is drawn. Otherwise widgets
    // aren't properly layed out until the page is
    // being resized.
    Listener listener = new Listener() {

        @Override
        public void handleEvent(Event event) {
            page.getShell().layout(true, true);
            page.getShell().redraw();
            page.removeListener(event.type, this);
        }
    };
    page.addListener(SWT.Paint, listener);
    return page;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CompositeValidator(org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator) Listener(org.eclipse.swt.widgets.Listener) ValueListener(org.springsource.ide.eclipse.commons.livexp.core.ValueListener) Composite(org.eclipse.swt.widgets.Composite) Event(org.eclipse.swt.widgets.Event)

Example 2 with CompositeValidator

use of org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator in project eclipse-integration-commons by spring-projects.

the class DialogWithSections method createDialogArea.

protected Control createDialogArea(Composite parent) {
    // readSettings();
    scroller = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {
    };
    scroller.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // GridDataFactory.fillDefaults()/*.grab(true, true)*/.applyTo(scroller);
    // scroller.setWidthHint(500); // Avoid excessively wide dialogs
    // Display display = Display.getCurrent();
    // Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    // scroller.setBackground(blue);
    scroller.setExpandHorizontal(true);
    scroller.setExpandVertical(true);
    Composite page = new Composite(scroller, SWT.NONE);
    applyDialogFont(page);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 12;
    layout.marginWidth = 12;
    page.setLayout(layout);
    validator = new CompositeValidator();
    for (PageSection section : getSections()) {
        section.createContents(page);
        validator.addChild(section.getValidator());
    }
    validator.addListener(this);
    page.pack(true);
    scroller.setContent(page);
    return parent;
}
Also used : SharedScrolledComposite(org.eclipse.ui.forms.widgets.SharedScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) CompositeValidator(org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator) Composite(org.eclipse.swt.widgets.Composite) SharedScrolledComposite(org.eclipse.ui.forms.widgets.SharedScrolledComposite) GridData(org.eclipse.swt.layout.GridData)

Example 3 with CompositeValidator

use of org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator in project eclipse-integration-commons by spring-projects.

the class WizardPageWithSections method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
public void createControl(Composite parent) {
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
    scroller = new SharedScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL) {
    };
    // scroller.setWidthHint(500); // Avoid excessively wide dialogs
    // Display display = Display.getCurrent();
    // Color blue = display.getSystemColor(SWT.COLOR_BLUE);
    // scroller.setBackground(blue);
    scroller.setExpandHorizontal(true);
    scroller.setExpandVertical(true);
    page = new Composite(scroller, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 12;
    layout.marginWidth = 12;
    page.setLayout(layout);
    validator = new CompositeValidator();
    for (PageSection section : getSections()) {
        section.createContents(page);
        validator.addChild(section.getValidator());
    }
    validator.addListener(this);
    Dialog.applyDialogFont(page);
    page.pack(true);
    // scroller.setMinSize(page.getSize());
    // scroller.setSize(page.getSize());
    scroller.setContent(page);
    setControl(scroller);
    page.addPaintListener(new PaintListener() {

        // This is a bit yuck. But don't know a better way to 'reflow' the page the first time
        // it gets shown. And if we don't do that, then there are often layout issues.
        // See for example: https://www.pivotaltracker.com/story/show/130209913
        @Override
        public void paintControl(PaintEvent e) {
            page.removePaintListener(this);
            reflow();
        }
    });
    if (getContainer().getCurrentPage() != null) {
        // Otherwise an NPE will ensue when updating buttons. Buttons depend on current page so that is logical.
        getContainer().updateButtons();
        getContainer().updateMessage();
    }
}
Also used : SharedScrolledComposite(org.eclipse.ui.forms.widgets.SharedScrolledComposite) GridLayout(org.eclipse.swt.layout.GridLayout) CompositeValidator(org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator) PaintEvent(org.eclipse.swt.events.PaintEvent) Composite(org.eclipse.swt.widgets.Composite) SharedScrolledComposite(org.eclipse.ui.forms.widgets.SharedScrolledComposite) PaintListener(org.eclipse.swt.events.PaintListener)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 CompositeValidator (org.springsource.ide.eclipse.commons.livexp.core.CompositeValidator)3 SharedScrolledComposite (org.eclipse.ui.forms.widgets.SharedScrolledComposite)2 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1 GridData (org.eclipse.swt.layout.GridData)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 ValueListener (org.springsource.ide.eclipse.commons.livexp.core.ValueListener)1