|
Lines 26-31
Link Here
|
| 26 |
import org.eclipse.swt.graphics.Image; |
26 |
import org.eclipse.swt.graphics.Image; |
| 27 |
import org.eclipse.swt.graphics.ImageData; |
27 |
import org.eclipse.swt.graphics.ImageData; |
| 28 |
import org.eclipse.swt.graphics.PaletteData; |
28 |
import org.eclipse.swt.graphics.PaletteData; |
|
|
29 |
import org.eclipse.swt.graphics.Point; |
| 29 |
import org.eclipse.swt.graphics.RGB; |
30 |
import org.eclipse.swt.graphics.RGB; |
| 30 |
import org.eclipse.swt.layout.GridData; |
31 |
import org.eclipse.swt.layout.GridData; |
| 31 |
import org.eclipse.swt.layout.GridLayout; |
32 |
import org.eclipse.swt.layout.GridLayout; |
|
Lines 50-56
Link Here
|
| 50 |
*/ |
51 |
*/ |
| 51 |
public class HelpTray extends DialogTray implements IPageChangedListener { |
52 |
public class HelpTray extends DialogTray implements IPageChangedListener { |
| 52 |
|
53 |
|
|
|
54 |
public static final int MINIMUM_HEIGHT = 450; |
| 53 |
private static final int DEFAULT_WIDTH = 210; |
55 |
private static final int DEFAULT_WIDTH = 210; |
|
|
56 |
|
| 57 |
private int originalHeight; |
| 58 |
private int heightAdded; |
| 59 |
|
| 54 |
private FormToolkit toolkit; |
60 |
private FormToolkit toolkit; |
| 55 |
private ReusableHelpPart helpPart; |
61 |
private ReusableHelpPart helpPart; |
| 56 |
private Shell shell; |
62 |
private Shell shell; |
|
Lines 89-94
Link Here
|
| 89 |
* @param parent the parent composite that will contain the tray |
95 |
* @param parent the parent composite that will contain the tray |
| 90 |
*/ |
96 |
*/ |
| 91 |
protected Control createContents(Composite parent) { |
97 |
protected Control createContents(Composite parent) { |
|
|
98 |
// if the dialog is too short, make it taller |
| 99 |
ensureMinimumHeight(parent.getShell()); |
| 100 |
|
| 92 |
toolkit = new FormToolkit(parent.getDisplay()); |
101 |
toolkit = new FormToolkit(parent.getDisplay()); |
| 93 |
toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkGroup.UNDERLINE_HOVER); |
102 |
toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkGroup.UNDERLINE_HOVER); |
| 94 |
toolkit.getColors().initializeSectionToolBarColors(); |
103 |
toolkit.getColors().initializeSectionToolBarColors(); |
|
Lines 187-195
Link Here
|
| 187 |
hover.dispose(); |
196 |
hover.dispose(); |
| 188 |
toolkit.dispose(); |
197 |
toolkit.dispose(); |
| 189 |
helpPart.dispose(); |
198 |
helpPart.dispose(); |
|
|
199 |
|
| 200 |
/* |
| 201 |
* Shell is about to be closed. Add a one-time-only listener |
| 202 |
* that will return the dialog height back to original. |
| 203 |
*/ |
| 204 |
shell.addListener(SWT.Resize, new Listener() { |
| 205 |
public void handleEvent(Event event) { |
| 206 |
shell.removeListener(SWT.Resize, this); |
| 207 |
Point p = shell.getSize(); |
| 208 |
if (heightAdded > 0 && p.y > originalHeight) { |
| 209 |
p.y = Math.max(p.y - heightAdded, originalHeight); |
| 210 |
shell.setSize(p); |
| 211 |
} |
| 212 |
} |
| 213 |
}); |
| 190 |
} |
214 |
} |
| 191 |
|
215 |
|
| 192 |
/** |
216 |
/** |
|
|
217 |
* Ensures that the dialog's height is sufficient to contain the help tray. |
| 218 |
* If the dialog is too short, its height is increased. When closing the tray, |
| 219 |
* the height is returned to original (see dispose()). |
| 220 |
* |
| 221 |
* @param shell the dialog's shell |
| 222 |
*/ |
| 223 |
private void ensureMinimumHeight(Shell shell) { |
| 224 |
Point p = shell.getSize(); |
| 225 |
originalHeight = p.y; |
| 226 |
if (p.y < MINIMUM_HEIGHT) { |
| 227 |
heightAdded = MINIMUM_HEIGHT - p.y; |
| 228 |
p.y = MINIMUM_HEIGHT; |
| 229 |
shell.setSize(p); |
| 230 |
} |
| 231 |
else { |
| 232 |
heightAdded = 0; |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
/** |
| 193 |
* Returns the ReusableHelpPart contained in the tray. |
237 |
* Returns the ReusableHelpPart contained in the tray. |
| 194 |
* |
238 |
* |
| 195 |
* @return the tray's ReusableHelpPart |
239 |
* @return the tray's ReusableHelpPart |
|
Lines 212-217
Link Here
|
| 212 |
} |
256 |
} |
| 213 |
|
257 |
|
| 214 |
/** |
258 |
/** |
|
|
259 |
* Returns whether or not the help tray can handle the given shell. In some |
| 260 |
* cases the help tray is not appropriate for shells that are too short and |
| 261 |
* not resizable. In these cases infopops are used. |
| 262 |
* |
| 263 |
* @param shell the shell to check |
| 264 |
* @return whether or not the help tray is appropriate for the hsell |
| 265 |
*/ |
| 266 |
public static boolean isAppropriateFor(Shell shell) { |
| 267 |
if (shell != null && !shell.isDisposed() && shell.isVisible()) { |
| 268 |
Object data = shell.getData(); |
| 269 |
return (data instanceof TrayDialog && (shell.getSize().y >= MINIMUM_HEIGHT || (shell.getStyle() & SWT.RESIZE) != 0)); |
| 270 |
} |
| 271 |
return false; |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 215 |
* Called whenever the dialog we're inside has changed pages. This updates |
275 |
* Called whenever the dialog we're inside has changed pages. This updates |
| 216 |
* the context help page if it is visible. |
276 |
* the context help page if it is visible. |
| 217 |
* |
277 |
* |