Composite top = new Composite(parent, SWT.NONE);
top.setLayoutData(new GridData());
top.setLayout(new GridLayout(1, false));
new Label(top, SWT.NONE).setText(
String.format("Configuration for the alternate version of %1$s", mFileName));
mSelector = new ConfigurationSelector(top);
mSelector.setConfiguration(mConfig);
// parent's layout is a GridLayout as specified in the javadoc.
GridData gd = new GridData();
gd.widthHint = ConfigurationSelector.WIDTH_HINT;
gd.heightHint = ConfigurationSelector.HEIGHT_HINT;
mSelector.setLayoutData(gd);
// add a listener to check on the validity of the FolderConfiguration as
// they are built.
mSelector.setOnChangeListener(new Runnable() {
public void run() {
ConfigurationState state = mSelector.getState();
switch (state) {
case OK:
mSelector.getConfiguration(mConfig);
resetStatus();
mStatusImage.setImage(null);
getButton(IDialogConstants.OK_ID).setEnabled(true);
break;
case INVALID_CONFIG:
ResourceQualifier invalidQualifier = mSelector.getInvalidQualifier();
mStatusLabel.setText(String.format(
"Invalid Configuration: %1$s has no filter set.",
invalidQualifier.getName()));
mStatusImage.setImage(IconFactory.getInstance().getIcon("warning")); //$NON-NLS-1$
getButton(IDialogConstants.OK_ID).setEnabled(false);
break;
case REGION_WITHOUT_LANGUAGE:
mStatusLabel.setText(
"The Region qualifier requires the Language qualifier.");
mStatusImage.setImage(IconFactory.getInstance().getIcon("warning")); //$NON-NLS-1$
getButton(IDialogConstants.OK_ID).setEnabled(false);
break;
}
// need to relayout, because of the change in size in mErrorImage.
mStatusComposite.layout();
}
});
mStatusComposite = new Composite(top, SWT.NONE);
mStatusComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout gl = new GridLayout(2, false);
mStatusComposite.setLayout(gl);
gl.marginHeight = gl.marginWidth = 0;
mStatusImage = new Label(mStatusComposite, SWT.NONE);
mStatusLabel = new Label(mStatusComposite, SWT.NONE);
mStatusLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
resetStatus();
return top;