this.icon = icon;
detailsShell = new Shell(display,SWT.BORDER | SWT.ON_TOP);
Utils.setShellIcon(detailsShell);
detailsShell.setLayout(new FillLayout());
StyledText textDetails = new StyledText(detailsShell, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
textDetails.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
textDetails.setWordWrap( true );
detailsShell.layout();
detailsShell.setSize(550,300);
int popupWidth = 280;
int popupHeight = 170;
shell = new Shell(display,SWT.ON_TOP);
Utils.setShellIcon(shell);
FormLayout layout = new FormLayout();
layout.marginHeight = 0; layout.marginWidth = 0;
try {
layout.spacing = 0;
} catch (NoSuchFieldError e) {
/* Ignore for Pre 3.0 SWT.. */
}
shell.setLayout(layout);
ImageLoader imageLoader = ImageLoader.getInstance();
Image popup_image = imageLoader.getImage("popup");
// this code is here to ensure that we can still show error messages even if images
// are failing to load (e.g. coz there's a ! in AZ install dir... )
GC gcImage = null;
if (ImageLoader.isRealImage(popup_image)) {
shellImg = new Image(display, popup_image, SWT.IMAGE_COPY);
popupWidth = popup_image.getBounds().width;
popupHeight = popup_image.getBounds().height;
} else {
shellImg = new Image(display,
new Rectangle(0, 0, popupWidth, popupHeight));
}
imageLoader.releaseImage("popup");
shell.setSize(popupWidth, popupHeight);
gcImage = new GC(shellImg);
Image imgIcon = imageLoader.getImage(icon);
int iconWidth = 0;
int iconHeight = 15;
if (ImageLoader.isRealImage(imgIcon)) {
gcImage.drawImage(imgIcon, 5, 5);
iconWidth = imgIcon.getBounds().width;
iconHeight = imgIcon.getBounds().height;
}
imageLoader.releaseImage(icon);
Font tempFont = shell.getFont();
FontData[] fontDataMain = tempFont.getFontData();
for (int i = 0; i < fontDataMain.length; i++) {
fontDataMain[i].setStyle(SWT.BOLD);
fontDataMain[i].setHeight((int) (fontDataMain[i].getHeight() * 1.2));
}
Font fontTitle = new Font(display, fontDataMain);
gcImage.setFont(fontTitle);
Rectangle rect = new Rectangle(iconWidth + 10, 5, popupWidth - iconWidth
- 15, iconHeight);
GCStringPrinter.printString(gcImage, title, rect);
gcImage.setFont(tempFont);
fontTitle.dispose();
rect = new Rectangle(5, iconHeight + 5, popupWidth - 10, popupHeight
- iconHeight - 60);
boolean bItFit = GCStringPrinter.printString(gcImage, errorMessage, rect);
gcImage.dispose();
if (!bItFit && details == null)
details = errorMessage;
if(details != null)
textDetails.setText(details);
final Button btnDetails = new Button(shell,SWT.TOGGLE);
Messages.setLanguageText(btnDetails,"popup.error.details");
btnDetails.setEnabled(details != null);