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);
}
Aggregations