Вы можете создать класс, полученный из MessageDialog
и переопределить метод createMessageArea
с чем-то вроде:
public class MessageDialogWithCopy extends MessageDialog
{
public MessageDialogWithCopy(Shell parentShell, String dialogTitle, Image dialogTitleImage,
String dialogMessage, int dialogImageType, String [] dialogButtonLabels, int defaultIndex)
{
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType,
dialogButtonLabels, defaultIndex);
}
@Override
protected Control createMessageArea(final Composite composite)
{
Image image = getImage();
if (image != null)
{
imageLabel = new Label(composite, SWT.NULL);
image.setBackground(imageLabel.getBackground());
imageLabel.setImage(image);
imageLabel.setLayoutData(new GridData(SWT.CENTER, SWT.BEGINNING, false, false));
}
// Use Text control for message to allow copy
if (message != null)
{
Text msg = new Text(composite, SWT.READ_ONLY | SWT.MULTI);
msg.setText(message);
GridData data = new GridData(SWT.FILL, SWT.TOP, true, false);
data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
msg.setLayoutData(data);
}
return composite;
}
public static void openInformation(Shell parent, String title, String message)
{
MessageDialogWithCopy dialog
= new MessageDialogWithCopy(parent, title, null, message, INFORMATION,
new String[] {IDialogConstants.OK_LABEL}, 0);
dialog.open();
}
}
Bummer. Я рассмотрю это. Благодаря! –