final Button btnText = toolkit.createButton(encodingPanel, "Text", SWT.RADIO);
btnText.setSelection(showAsText);
Button btnBinary = toolkit.createButton(encodingPanel, "Binary (hex)", SWT.RADIO);
btnBinary.setSelection(!showAsText);
toolkit.createLabel(encodingPanel, "Text Encoding:");
final Combo encodingCombo = new Combo(encodingPanel, SWT.READ_ONLY);
encodingCombo.setEnabled(showAsText);
// INITIALISE
encodingCombo.setItems(charsets);
encodingCombo.select(selectedCharset);
// LISTENERS
encodingSection.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
getManagedForm().reflow(true);
}
});
SelectionListener radioListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showAsText = btnText.getSelection();
encodingCombo.setEnabled(showAsText);
loadContent();
}
};
btnText.addSelectionListener(radioListener);
btnBinary.addSelectionListener(radioListener);
encodingCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedCharset = encodingCombo.getSelectionIndex();
loadContent();
}
});
// LAYOUT
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
parent.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
textSection.setLayoutData(gd);
layout = new GridLayout(1, false);
textComposite.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
encodingSection.setLayoutData(gd);
encodingSection.setLayout(new FillLayout());
encodingPanel.setLayout(new GridLayout(3, false));
encodingCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
}