Lines 16-21
Link Here
|
16 |
|
16 |
|
17 |
import org.eclipse.jface.resource.JFaceColors; |
17 |
import org.eclipse.jface.resource.JFaceColors; |
18 |
import org.eclipse.jface.resource.JFaceResources; |
18 |
import org.eclipse.jface.resource.JFaceResources; |
|
|
19 |
import org.eclipse.jface.window.ToolTip; |
19 |
import org.eclipse.swt.SWT; |
20 |
import org.eclipse.swt.SWT; |
20 |
import org.eclipse.swt.events.DisposeEvent; |
21 |
import org.eclipse.swt.events.DisposeEvent; |
21 |
import org.eclipse.swt.events.DisposeListener; |
22 |
import org.eclipse.swt.events.DisposeListener; |
Lines 23-28
Link Here
|
23 |
import org.eclipse.swt.graphics.Image; |
24 |
import org.eclipse.swt.graphics.Image; |
24 |
import org.eclipse.swt.graphics.Point; |
25 |
import org.eclipse.swt.graphics.Point; |
25 |
import org.eclipse.swt.graphics.RGB; |
26 |
import org.eclipse.swt.graphics.RGB; |
|
|
27 |
import org.eclipse.swt.graphics.Rectangle; |
26 |
import org.eclipse.swt.layout.FormAttachment; |
28 |
import org.eclipse.swt.layout.FormAttachment; |
27 |
import org.eclipse.swt.layout.FormData; |
29 |
import org.eclipse.swt.layout.FormData; |
28 |
import org.eclipse.swt.layout.FormLayout; |
30 |
import org.eclipse.swt.layout.FormLayout; |
Lines 31-37
Link Here
|
31 |
import org.eclipse.swt.widgets.Composite; |
33 |
import org.eclipse.swt.widgets.Composite; |
32 |
import org.eclipse.swt.widgets.Control; |
34 |
import org.eclipse.swt.widgets.Control; |
33 |
import org.eclipse.swt.widgets.Display; |
35 |
import org.eclipse.swt.widgets.Display; |
|
|
36 |
import org.eclipse.swt.widgets.Event; |
34 |
import org.eclipse.swt.widgets.Label; |
37 |
import org.eclipse.swt.widgets.Label; |
|
|
38 |
import org.eclipse.swt.widgets.Listener; |
35 |
import org.eclipse.swt.widgets.Shell; |
39 |
import org.eclipse.swt.widgets.Shell; |
36 |
import org.eclipse.swt.widgets.Text; |
40 |
import org.eclipse.swt.widgets.Text; |
37 |
|
41 |
|
Lines 110-115
Link Here
|
110 |
|
114 |
|
111 |
private Image titleAreaImage; |
115 |
private Image titleAreaImage; |
112 |
|
116 |
|
|
|
117 |
private int xTrim; |
118 |
|
119 |
private int yTrim; |
120 |
|
113 |
/** |
121 |
/** |
114 |
* Instantiate a new title area dialog. |
122 |
* Instantiate a new title area dialog. |
115 |
* |
123 |
* |
Lines 146-151
Link Here
|
146 |
// create the dialog area and button bar |
154 |
// create the dialog area and button bar |
147 |
dialogArea = createDialogArea(workArea); |
155 |
dialogArea = createDialogArea(workArea); |
148 |
buttonBar = createButtonBar(workArea); |
156 |
buttonBar = createButtonBar(workArea); |
|
|
157 |
|
158 |
// computing trim for later |
159 |
Rectangle rect = messageLabel.computeTrim(0, 0, 100, 100); |
160 |
xTrim = rect.width - 100; |
161 |
yTrim = rect.height - 100; |
162 |
|
163 |
// need to react to new size of title area |
164 |
getShell().addListener(SWT.Resize, new Listener() { |
165 |
public void handleEvent(Event event) { |
166 |
layoutForNewMessage(true); |
167 |
} |
168 |
}); |
149 |
return contents; |
169 |
return contents; |
150 |
} |
170 |
} |
151 |
|
171 |
|
Lines 395-407
Link Here
|
395 |
setImageLabelVisible(true); |
415 |
setImageLabelVisible(true); |
396 |
} |
416 |
} |
397 |
} |
417 |
} |
398 |
layoutForNewMessage(); |
418 |
layoutForNewMessage(false); |
399 |
} |
419 |
} |
400 |
|
420 |
|
401 |
/** |
421 |
/** |
402 |
* Re-layout the labels for the new message. |
422 |
* Re-layout the labels for the new message. |
|
|
423 |
* |
424 |
* @param forceLayout |
425 |
* <code>true</code> to force a layout of the shell |
403 |
*/ |
426 |
*/ |
404 |
private void layoutForNewMessage() { |
427 |
private void layoutForNewMessage(boolean forceLayout) { |
405 |
int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); |
428 |
int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); |
406 |
int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); |
429 |
int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); |
407 |
// If there are no images then layout as normal |
430 |
// If there are no images then layout as normal |
Lines 445-454
Link Here
|
445 |
0, SWT.BOTTOM); |
468 |
0, SWT.BOTTOM); |
446 |
messageLabel.setLayoutData(messageLabelData); |
469 |
messageLabel.setLayoutData(messageLabelData); |
447 |
} |
470 |
} |
448 |
// Do not layout before the dialog area has been created |
471 |
|
449 |
// to avoid incomplete calculations. |
472 |
if (forceLayout) { |
450 |
if (dialogArea != null) |
473 |
getShell().layout(); |
451 |
workArea.getParent().layout(true); |
474 |
} else { |
|
|
475 |
// Do not layout before the dialog area has been created |
476 |
// to avoid incomplete calculations. |
477 |
if (dialogArea != null) |
478 |
workArea.getParent().layout(true); |
479 |
} |
480 |
|
481 |
int messageLabelUnclippedHeight = messageLabel.computeSize(messageLabel.getSize().x - xTrim, SWT.DEFAULT, true).y; |
482 |
boolean messageLabelClipped = messageLabelUnclippedHeight > messageLabel.getSize().y - yTrim; |
483 |
if (messageLabel.getData() instanceof ToolTip) { |
484 |
ToolTip toolTip = (ToolTip) messageLabel.getData(); |
485 |
toolTip.hide(); |
486 |
toolTip.deactivate(); |
487 |
messageLabel.setData(null); |
488 |
} |
489 |
if (messageLabelClipped) { |
490 |
ToolTip tooltip = new ToolTip(messageLabel, ToolTip.NO_RECREATE, false) { |
491 |
|
492 |
protected Composite createToolTipContentArea(Event event, Composite parent) { |
493 |
Composite result = new Composite(parent, SWT.NONE); |
494 |
result.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); |
495 |
result.setLayout(new GridLayout()); |
496 |
Text text = new Text(result, SWT.WRAP); |
497 |
text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); |
498 |
text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); |
499 |
text.setText(messageLabel.getText()); |
500 |
GridData gridData = new GridData(); |
501 |
gridData.widthHint = messageLabel.getSize().x; |
502 |
text.setLayoutData(gridData); |
503 |
Dialog.applyDialogFont(result); |
504 |
return result; |
505 |
} |
506 |
public Point getLocation(Point tipSize, Event event) { |
507 |
return messageLabel.getShell().toDisplay(messageLabel.getLocation()); |
508 |
} |
509 |
}; |
510 |
messageLabel.setData(tooltip); |
511 |
tooltip.setPopupDelay(0); |
512 |
tooltip.activate(); |
513 |
} |
452 |
} |
514 |
} |
453 |
|
515 |
|
454 |
/** |
516 |
/** |
Lines 536-542
Link Here
|
536 |
updateMessage(shownMessage); |
598 |
updateMessage(shownMessage); |
537 |
messageImageLabel.setImage(messageImage); |
599 |
messageImageLabel.setImage(messageImage); |
538 |
setImageLabelVisible(messageImage != null); |
600 |
setImageLabelVisible(messageImage != null); |
539 |
layoutForNewMessage(); |
601 |
layoutForNewMessage(false); |
540 |
} |
602 |
} |
541 |
} |
603 |
} |
542 |
|
604 |
|