Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 116197
Collapse All | Expand All

(-)src/org/eclipse/help/ui/internal/ContextHelpDialog.java (-2 / +2 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.help.*;
14
import org.eclipse.help.*;
15
import org.eclipse.help.internal.base.BaseHelpSystem;
15
import org.eclipse.help.internal.base.BaseHelpSystem;
16
import org.eclipse.help.ui.internal.views.HelpTray;
16
import org.eclipse.jface.dialogs.TrayDialog;
17
import org.eclipse.jface.dialogs.TrayDialog;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.accessibility.*;
19
import org.eclipse.swt.accessibility.*;
Lines 309-317 Link Here
309
		}
310
		}
310
311
311
		// create dynamic help link if current context allows dynamic help
312
		// create dynamic help link if current context allows dynamic help
312
		Object shellData = parentShell.getData();
313
		IWorkbenchWindow wbWindow = HelpUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
313
		IWorkbenchWindow wbWindow = HelpUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
314
		if (DefaultHelpUI.isActiveShell(parentShell, wbWindow) || shellData instanceof TrayDialog) {
314
		if (DefaultHelpUI.isActiveShell(parentShell, wbWindow) || HelpTray.isAppropriateFor(parentShell)) {
315
			// Create separator.
315
			// Create separator.
316
			label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
316
			label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
317
			label.setBackground(backgroundColour);
317
			label.setBackground(backgroundColour);
(-)src/org/eclipse/help/ui/internal/DefaultHelpUI.java (-6 / +3 lines)
Lines 276-287 Link Here
276
			}
276
			}
277
		}
277
		}
278
		// check the dialog
278
		// check the dialog
279
		if (activeShell != null) {
279
		if (HelpTray.isAppropriateFor(activeShell) && (!dinfopop || noInfopop)) {
280
			Object data = activeShell.getData();
280
			displayContextAsHelpTray(activeShell, context);
281
			if (data instanceof TrayDialog && (!dinfopop || noInfopop)) {
281
			return;
282
				displayContextAsHelpTray(activeShell, context);
283
				return;
284
			}
285
		}
282
		}
286
		// we are here either as a fallback or because of the user preferences
283
		// we are here either as a fallback or because of the user preferences
287
		displayContextAsInfopop(context, x, y);
284
		displayContextAsInfopop(context, x, y);
(-)src/org/eclipse/help/ui/internal/views/HelpTray.java (+60 lines)
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
	 * 

Return to bug 116197