Search in sources :

Example 1 with RadioButtonsGroup

use of org.eclipse.sapphire.ui.forms.swt.RadioButtonsGroup in project liferay-ide by liferay.

the class PossibleValuesRadioPropertyEditorPresentation method createContents.

@Override
protected void createContents(final Composite parent) {
    final PropertyEditorPart part = part();
    final boolean showLabel = part.label() != null;
    final int leftMargin = part.getMarginLeft();
    PropertyEditorAssistDecorator decorator = null;
    final Composite composite = createMainComposite(parent, new CreateMainCompositeDelegate(part) {

        @Override
        public boolean getShowLabel() {
            return false;
        }

        @Override
        public boolean getSpanBothColumns() {
            return true;
        }
    });
    composite.setLayout(glspacing(glayout(2, 0, 0), 2, 5));
    decorator = createDecorator(composite);
    decorator.addEditorControl(composite);
    if (showLabel) {
        decorator.control().setLayoutData(gdvalign(gd(), SWT.CENTER));
        final Label label = new Label(composite, SWT.WRAP);
        label.setLayoutData(gd());
        final Runnable updateLabelOp = new Runnable() {

            public void run() {
                label.setText(part.label(CapitalizationType.FIRST_WORD_ONLY, true));
            }
        };
        final org.eclipse.sapphire.Listener listener = new org.eclipse.sapphire.Listener() {

            @Override
            public void handle(final org.eclipse.sapphire.Event event) {
                if (event instanceof LabelChangedEvent) {
                    updateLabelOp.run();
                    PossibleValuesRadioPropertyEditorPresentation.this.layout();
                }
            }
        };
        part.attach(listener);
        updateLabelOp.run();
        label.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(final DisposeEvent event) {
                part.detach(listener);
            }
        });
        decorator.addEditorControl(label);
    } else {
        decorator.control().setLayoutData(gdvindent(gdvalign(gd(), SWT.TOP), 4));
    }
    _control = new RadioButtonsGroup(composite, true);
    if (showLabel) {
        _control.setLayoutData(gdhindent(gdhspan(gdhfill(), 2), leftMargin + 20));
    } else {
        _control.setLayoutData(gdhfill());
    }
    binding = new PossibleValuesRadioButtonsGroupBinding<>(this, (RadioButtonsGroup) _control);
    _control.setData(DATA_BINDING, binding);
    decorator.addEditorControl(_control, true);
    addControl(_control);
}
Also used : PropertyEditorPart(org.eclipse.sapphire.ui.forms.PropertyEditorPart) DisposeListener(org.eclipse.swt.events.DisposeListener) DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) LabelChangedEvent(org.eclipse.sapphire.ui.SapphirePart.LabelChangedEvent) RadioButtonsGroup(org.eclipse.sapphire.ui.forms.swt.RadioButtonsGroup) DisposeEvent(org.eclipse.swt.events.DisposeEvent) PropertyEditorAssistDecorator(org.eclipse.sapphire.ui.assist.internal.PropertyEditorAssistDecorator) DisposeEvent(org.eclipse.swt.events.DisposeEvent) LabelChangedEvent(org.eclipse.sapphire.ui.SapphirePart.LabelChangedEvent)

Aggregations

LabelChangedEvent (org.eclipse.sapphire.ui.SapphirePart.LabelChangedEvent)1 PropertyEditorAssistDecorator (org.eclipse.sapphire.ui.assist.internal.PropertyEditorAssistDecorator)1 PropertyEditorPart (org.eclipse.sapphire.ui.forms.PropertyEditorPart)1 RadioButtonsGroup (org.eclipse.sapphire.ui.forms.swt.RadioButtonsGroup)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1