View | Details | Raw Unified | Return to bug 69732 | Differences between
and this patch

Collapse All | Expand All

(-)cheatsheets/CVS_1.xml (-4 / +2 lines)
Lines 18-25 Link Here
18
18
19
	<item
19
	<item
20
		href="/org.eclipse.platform.doc.user/tasks/tasks-100b.htm"
20
		href="/org.eclipse.platform.doc.user/tasks/tasks-100b.htm"
21
		title="Load the Destination into your Workspace"
21
		title="Load the Destination into your Workspace">
22
		dialog="true">
23
		<description>
22
		<description>
24
Select the project and choose Replace With &gt; Another Branch or Version from the context menu. Then select the branch to replace with. In this step you must ensure that the destination is loaded into your workspace. This is a manual task, you will need to perform the work and click the "Click to complete" button to move to the next step.
23
Select the project and choose Replace With &gt; Another Branch or Version from the context menu. Then select the branch to replace with. In this step you must ensure that the destination is loaded into your workspace. This is a manual task, you will need to perform the work and click the "Click to complete" button to move to the next step.
25
		</description>
24
		</description>
Lines 27-34 Link Here
27
26
28
	<item
27
	<item
29
		href="/org.eclipse.platform.doc.user/tasks/tasks-100b.htm" 
28
		href="/org.eclipse.platform.doc.user/tasks/tasks-100b.htm" 
30
		title="Merge Details"
29
		title="Merge Details">
31
		dialog="true">
32
		<description>
30
		<description>
33
Select the project, choose Team &gt; Merge and complete the wizard as required. This step specifies the details of the merge.  This is a manual task, you will need to perform the work and click the "Click to complete" button to move to the next step.
31
Select the project, choose Team &gt; Merge and complete the wizard as required. This step specifies the details of the merge.  This is a manual task, you will need to perform the work and click the "Click to complete" button to move to the next step.
34
		</description>
32
		</description>
(-)cheatsheets/HelloWorldSWT.xml (-4 lines)
Lines 33-39 Link Here
33
	<item
33
	<item
34
		href="/org.eclipse.platform.doc.isv/samples/org.eclipse.swt.examples/doc-html/swt_manual_setup.html"
34
		href="/org.eclipse.platform.doc.isv/samples/org.eclipse.swt.examples/doc-html/swt_manual_setup.html"
35
		title="Add SWT projects to your workspace"
35
		title="Add SWT projects to your workspace"
36
		dialog="true"
37
		skip="true">
36
		skip="true">
38
		<description>
37
		<description>
39
		Since you are creating a standalone SWT application, you need to download 
38
		Since you are creating a standalone SWT application, you need to download 
Lines 59-65 Link Here
59
	<item
58
	<item
60
		href="/org.eclipse.jdt.doc.user/tasks/tasks-12.htm"
59
		href="/org.eclipse.jdt.doc.user/tasks/tasks-12.htm"
61
		title="Create a Java project"
60
		title="Create a Java project"
62
		dialog="true"
63
		skip="true">
61
		skip="true">
64
		<action
62
		<action
65
			pluginId="org.eclipse.jdt.ui"
63
			pluginId="org.eclipse.jdt.ui"
Lines 78-84 Link Here
78
	<item
76
	<item
79
		href="/org.eclipse.jdt.doc.user/tasks/tasks-110.htm"
77
		href="/org.eclipse.jdt.doc.user/tasks/tasks-110.htm"
80
		title="Configure the Java project"
78
		title="Configure the Java project"
81
		dialog="true"
82
		skip="true">
79
		skip="true">
83
		<description>
80
		<description>
84
			1. Select your Java project and from the context menu select Properties. 
81
			1. Select your Java project and from the context menu select Properties. 
Lines 95-101 Link Here
95
	<item
92
	<item
96
		href="/org.eclipse.jdt.doc.user/gettingStarted/qs-9.htm" 
93
		href="/org.eclipse.jdt.doc.user/gettingStarted/qs-9.htm" 
97
		title="Create the HelloWorld class"
94
		title="Create the HelloWorld class"
98
		dialog="true"
99
		skip="true">
95
		skip="true">
100
		<action
96
		<action
101
			pluginId="org.eclipse.jdt.ui"
97
			pluginId="org.eclipse.jdt.ui"
(-)cheatsheets/HelloWorld.xml (-2 lines)
Lines 31-37 Link Here
31
	<item
31
	<item
32
		href="/org.eclipse.jdt.doc.user/tasks/tasks-12.htm"
32
		href="/org.eclipse.jdt.doc.user/tasks/tasks-12.htm"
33
		title="Create a Java project"
33
		title="Create a Java project"
34
		dialog="true"
35
		skip="true">
34
		skip="true">
36
		<action
35
		<action
37
			pluginId="org.eclipse.jdt.ui"
36
			pluginId="org.eclipse.jdt.ui"
Lines 50-56 Link Here
50
	<item
49
	<item
51
		href="/org.eclipse.jdt.doc.user/gettingStarted/qs-9.htm" 
50
		href="/org.eclipse.jdt.doc.user/gettingStarted/qs-9.htm" 
52
		title="Create your HelloWorld class"
51
		title="Create your HelloWorld class"
53
		dialog="true"
54
		skip="true">
52
		skip="true">
55
		<action
53
		<action
56
			pluginId="org.eclipse.jdt.ui"
54
			pluginId="org.eclipse.jdt.ui"
(-)src/org/eclipse/help/ui/internal/ContextHelpDialog.java (-19 / +10 lines)
Lines 13-19 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.jface.dialogs.TrayDialog;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.accessibility.*;
17
import org.eclipse.swt.accessibility.*;
19
import org.eclipse.swt.custom.BusyIndicator;
18
import org.eclipse.swt.custom.BusyIndicator;
Lines 22-28 Link Here
22
import org.eclipse.swt.graphics.*;
21
import org.eclipse.swt.graphics.*;
23
import org.eclipse.swt.layout.*;
22
import org.eclipse.swt.layout.*;
24
import org.eclipse.swt.widgets.*;
23
import org.eclipse.swt.widgets.*;
25
import org.eclipse.ui.IWorkbenchWindow;
26
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.PlatformUI;
27
25
28
/**
26
/**
Lines 305-327 Link Here
305
		for (int i = 0; i < relatedTopics.length; i++) {
303
		for (int i = 0; i < relatedTopics.length; i++) {
306
			createLink(composite, relatedTopics[i]);
304
			createLink(composite, relatedTopics[i]);
307
		}
305
		}
308
306
		// Create separator.
309
		// create dynamic help link if current context allows dynamic help
307
		label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
310
		Object shellData = parentShell.getData();
308
		label.setBackground(backgroundColour);
311
		IWorkbenchWindow wbWindow = HelpUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
309
		label.setForeground(foregroundColour);
312
		if (DefaultHelpUI.isActiveShell(parentShell, wbWindow) || shellData instanceof TrayDialog) {
310
		data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
313
			// Create separator.
311
				| GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
314
			label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
312
		data.horizontalSpan = 2;
315
			label.setBackground(backgroundColour);
313
		label.setLayoutData(data);
316
			label.setForeground(foregroundColour);
314
		// create link to the dynamic help
317
			data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
315
		createDynamicHelpLink(composite);
318
					| GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
319
			data.horizontalSpan = 2;
320
			label.setLayoutData(data);
321
322
			// create link to the dynamic help
323
			createDynamicHelpLink(composite);
324
		}
325
		
316
		
326
		return composite;
317
		return composite;
327
	}
318
	}
(-)src/org/eclipse/help/ui/internal/Messages.properties (-2 / +1 lines)
Lines 71-77 Link Here
71
ReusableHelpPart_internalWebBrowserError=Error while opening internal web browser
71
ReusableHelpPart_internalWebBrowserError=Error while opening internal web browser
72
ReusableHelpPart_openInHelpContentsAction_label=Open in Help &Contents
72
ReusableHelpPart_openInHelpContentsAction_label=Open in Help &Contents
73
ReusableHelpPart_copyAction_label=&Copy
73
ReusableHelpPart_copyAction_label=&Copy
74
ReusableHelpPart_closeAction_tooltip=Close
75
ReusableHelpPart_bookmarkAction_label=&Add Bookmark
74
ReusableHelpPart_bookmarkAction_label=&Add Bookmark
76
ReusableHelpPart_internalBrowserTitle=Help
75
ReusableHelpPart_internalBrowserTitle=Help
77
ReusableHelpPart_status = {0} - {1}
76
ReusableHelpPart_status = {0} - {1}
Lines 175-181 Link Here
175
BrowsersPreferencePage_wgroup=Open window context help
174
BrowsersPreferencePage_wgroup=Open window context help
176
BrowsersPreferencePage_view=in a dynamic help &view
175
BrowsersPreferencePage_view=in a dynamic help &view
177
BrowsersPreferencePage_dgroup=Open dialog context help
176
BrowsersPreferencePage_dgroup=Open dialog context help
178
BrowsersPreferencePage_tray=in dialog &tray
177
BrowsersPreferencePage_window=in a dynamic help &window
179
InfoCenterPage_url = &URL:
178
InfoCenterPage_url = &URL:
180
InfoCenterPage_invalidURL=Invalid URL
179
InfoCenterPage_invalidURL=Invalid URL
181
InfoCenterPage_tocError=Error while loading table of contents
180
InfoCenterPage_tocError=Error while loading table of contents
(-)src/org/eclipse/help/ui/internal/DefaultHelpUI.java (-36 / +42 lines)
Lines 11-16 Link Here
11
11
12
import java.net.URL;
12
import java.net.URL;
13
13
14
import org.eclipse.core.runtime.Platform;
14
import org.eclipse.core.runtime.Preferences;
15
import org.eclipse.core.runtime.Preferences;
15
import org.eclipse.help.IContext;
16
import org.eclipse.help.IContext;
16
import org.eclipse.help.browser.IBrowser;
17
import org.eclipse.help.browser.IBrowser;
Lines 19-31 Link Here
19
import org.eclipse.help.internal.base.IHelpBaseConstants;
20
import org.eclipse.help.internal.base.IHelpBaseConstants;
20
import org.eclipse.help.ui.internal.util.ErrorUtil;
21
import org.eclipse.help.ui.internal.util.ErrorUtil;
21
import org.eclipse.help.ui.internal.views.ContextHelpPart;
22
import org.eclipse.help.ui.internal.views.ContextHelpPart;
22
import org.eclipse.help.ui.internal.views.HelpTray;
23
import org.eclipse.help.ui.internal.views.ContextHelpWindow;
23
import org.eclipse.help.ui.internal.views.HelpView;
24
import org.eclipse.help.ui.internal.views.HelpView;
24
import org.eclipse.help.ui.internal.views.ReusableHelpPart;
25
import org.eclipse.jface.dialogs.DialogTray;
26
import org.eclipse.jface.dialogs.MessageDialog;
25
import org.eclipse.jface.dialogs.MessageDialog;
27
import org.eclipse.jface.dialogs.TrayDialog;
26
import org.eclipse.jface.window.Window;
28
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.DisposeEvent;
29
import org.eclipse.swt.events.DisposeListener;
30
import org.eclipse.swt.graphics.Rectangle;
29
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Display;
32
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Shell;
33
import org.eclipse.swt.widgets.Shell;
Lines 53-58 Link Here
53
public class DefaultHelpUI extends AbstractHelpUI {
55
public class DefaultHelpUI extends AbstractHelpUI {
54
56
55
	private ContextHelpDialog f1Dialog = null;
57
	private ContextHelpDialog f1Dialog = null;
58
	private ContextHelpWindow f1Window = null;
56
	private static DefaultHelpUI instance;
59
	private static DefaultHelpUI instance;
57
60
58
	private static final String HELP_VIEW_ID = "org.eclipse.help.ui.HelpView"; //$NON-NLS-1$
61
	private static final String HELP_VIEW_ID = "org.eclipse.help.ui.HelpView"; //$NON-NLS-1$
Lines 157-165 Link Here
157
				// check the dialog
160
				// check the dialog
158
				if (activeShell != null) {
161
				if (activeShell != null) {
159
					Object data = activeShell.getData();
162
					Object data = activeShell.getData();
160
					if (data instanceof TrayDialog) {
163
					if (data instanceof Window) {
161
						IContext context = ContextHelpPart.findHelpContext(c);
164
						IContext context = ContextHelpPart.findHelpContext(c);
162
						displayContextAsHelpTray(activeShell, context);
165
						displayContextAsHelpPane(activeShell, context);
163
						return;
166
						return;
164
					}
167
					}
165
				}
168
				}
Lines 195-207 Link Here
195
				// check the dialog
198
				// check the dialog
196
				if (activeShell != null) {
199
				if (activeShell != null) {
197
					Object data = activeShell.getData();
200
					Object data = activeShell.getData();
198
					if (data instanceof TrayDialog) {
201
					if (data instanceof Window) {
199
						displayContextAsHelpTray(activeShell, null);
202
						displayContextAsHelpPane(activeShell, null);
200
						return;
201
					}
202
					else {
203
						// tried to summon help from a non-tray dialog
204
						// not supported
205
						return;
203
						return;
206
					}
204
					}
207
				}
205
				}
Lines 278-285 Link Here
278
		// check the dialog
276
		// check the dialog
279
		if (activeShell != null) {
277
		if (activeShell != null) {
280
			Object data = activeShell.getData();
278
			Object data = activeShell.getData();
281
			if (data instanceof TrayDialog && (!dinfopop || noInfopop)) {
279
			if (data instanceof Window && (!dinfopop || noInfopop)) {
282
				displayContextAsHelpTray(activeShell, context);
280
				displayContextAsHelpPane(activeShell, context);
283
				return;
281
				return;
284
			}
282
			}
285
		}
283
		}
Lines 310-316 Link Here
310
		return display.getActiveShell();
308
		return display.getActiveShell();
311
	}
309
	}
312
310
313
	static boolean isActiveShell(Shell activeShell, IWorkbenchWindow window) {
311
	private static boolean isActiveShell(Shell activeShell, IWorkbenchWindow window) {
314
		// Test if the active shell belongs to this window
312
		// Test if the active shell belongs to this window
315
		return activeShell != null && activeShell.equals(window.getShell());
313
		return activeShell != null && activeShell.equals(window.getShell());
316
	}
314
	}
Lines 324-351 Link Here
324
		f1Dialog.open();
322
		f1Dialog.open();
325
	}
323
	}
326
324
327
	private void displayContextAsHelpTray(Shell activeShell, IContext context) {
325
	private void displayContextAsHelpPane(Shell activeShell, IContext context) {
328
		Control controlInFocus = activeShell.getDisplay().getFocusControl();
326
		Control c = activeShell.getDisplay().getFocusControl();
329
		TrayDialog dialog = (TrayDialog)activeShell.getData();
327
		if (f1Window != null) {
330
		
328
			Shell parentShell = activeShell;
331
		DialogTray tray = dialog.getTray();
329
			if (activeShell.getData() instanceof ContextHelpWindow)
332
		if (tray == null) {
330
				parentShell = (Shell) activeShell.getParent();
333
			tray = new HelpTray();
331
			if (f1Window.getShell().getParent().equals(parentShell)) {
334
			dialog.openTray(tray);
332
				f1Window.update(context, c);
335
		}
333
				return;
336
		if (tray instanceof HelpTray) {
337
			ReusableHelpPart helpPart = ((HelpTray)tray).getHelpPart();
338
			if (context != null) {
339
				helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
340
				helpPart.update(context, null, controlInFocus);
341
			}
342
			else {
343
				helpPart.showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true);
344
			}
334
			}
345
		}
335
		}
346
		else {
336
		Rectangle pbounds = activeShell.getBounds();
347
			// someone else was occupying the tray; not supported
337
		f1Window = new ContextHelpWindow(activeShell);
348
		}
338
		f1Window.create();
339
		Shell helpShell = f1Window.getShell();
340
		helpShell.setText(Messages.DefaultHelpUI_wtitle);
341
		helpShell.setSize(300, pbounds.height);
342
		if (context != null)
343
			f1Window.update(context, c);
344
		else
345
			f1Window.showSearch();
346
		if (!Platform.getWS().equals(Platform.WS_GTK))
347
			f1Window.dock(true);
348
		helpShell.addDisposeListener(new DisposeListener() {
349
350
			public void widgetDisposed(DisposeEvent e) {
351
				f1Window = null;
352
			}
353
		});
354
		helpShell.open();
349
	}
355
	}
350
356
351
	/**
357
	/**
(-)src/org/eclipse/help/ui/internal/Messages.java (-2 / +1 lines)
Lines 55-61 Link Here
55
	public static String ReusableHelpPart_openInfoCenterAction_label;
55
	public static String ReusableHelpPart_openInfoCenterAction_label;
56
	public static String ReusableHelpPart_openAction_label;
56
	public static String ReusableHelpPart_openAction_label;
57
	public static String ReusableHelpPart_openInHelpContentsAction_label;
57
	public static String ReusableHelpPart_openInHelpContentsAction_label;
58
	public static String ReusableHelpPart_closeAction_tooltip;
59
	public static String ReusableHelpPart_copyAction_label;
58
	public static String ReusableHelpPart_copyAction_label;
60
	public static String ReusableHelpPart_bookmarkAction_label;
59
	public static String ReusableHelpPart_bookmarkAction_label;
61
	public static String ReusableHelpPart_status;
60
	public static String ReusableHelpPart_status;
Lines 141-147 Link Here
141
	public static String BrowsersPreferencePage_wgroup;
140
	public static String BrowsersPreferencePage_wgroup;
142
	public static String BrowsersPreferencePage_view;
141
	public static String BrowsersPreferencePage_view;
143
	public static String BrowsersPreferencePage_dgroup;
142
	public static String BrowsersPreferencePage_dgroup;
144
	public static String BrowsersPreferencePage_tray;
143
	public static String BrowsersPreferencePage_window;
145
	public static String InfoCenterPage_url;
144
	public static String InfoCenterPage_url;
146
	public static String InfoCenterPage_invalidURL;
145
	public static String InfoCenterPage_invalidURL;
147
	public static String InfoCenterPage_tocError;
146
	public static String InfoCenterPage_tocError;
(-)src/org/eclipse/help/ui/internal/views/ReusableHelpPart.java (-35 / +2 lines)
Lines 269-275 Link Here
269
		}
269
		}
270
	}
270
	}
271
271
272
	private class HelpPartPage implements IHelpPartPage {
272
	private class HelpPartPage {
273
		private String id;
273
		private String id;
274
274
275
		private String iconId;
275
		private String iconId;
Lines 643-682 Link Here
643
			indexerJob.schedule();
643
			indexerJob.schedule();
644
		}
644
		}
645
	}
645
	}
646
	
646
647
	/**
648
	 * Adds the given page to this part.
649
	 * 
650
	 * @param page the page to add
651
	 */
652
	public void addPage(IHelpPartPage page) {
653
		pages.add(page);		
654
	}
655
	
656
	/**
657
	 * Adds the given part to this one. The part can then be used inside
658
	 * any page and referred to by id.
659
	 * 
660
	 * @param id the part's unique id
661
	 * @param part the part to add
662
	 */
663
	public void addPart(String id, IHelpPart part) {
664
		part.init(this, id, memento);
665
		mform.addPart(part);
666
	}
667
	
668
	/**
669
	 * Creates a new page for this part.
670
	 * 
671
	 * @param id the page's unique id
672
	 * @param text the page's heading, or null for none
673
	 * @param iconId the page's icon
674
	 * @return the newly created page
675
	 */
676
	public IHelpPartPage createPage(String id, String text, String iconId) {
677
		return new HelpPartPage(id, text, iconId);
678
	}
679
	
680
	private void definePages() {
647
	private void definePages() {
681
		pages = new ArrayList();
648
		pages = new ArrayList();
682
		// federated search page
649
		// federated search page
(-)src/org/eclipse/help/ui/internal/views/IHelpPartPage.java (-37 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.help.ui.internal.views;
12
13
import org.eclipse.jface.action.IToolBarManager;
14
import org.eclipse.ui.IMemento;
15
16
public interface IHelpPartPage {
17
	void addPart(String id, boolean flexible);
18
	void addPart(String id, boolean flexible, boolean grabVertical);
19
	boolean canOpen();
20
	void dispose();
21
	IHelpPart findPart(String id);
22
	int getHorizontalMargin();
23
	String getIconId();
24
	String getId();
25
	int getNumberOfFlexibleParts();
26
	String getText();
27
	IToolBarManager getToolBarManager();
28
	int getVerticalSpacing();
29
	void refilter();
30
	void saveState(IMemento memento);
31
	void setFocus();
32
	void setHorizontalMargin(int value);
33
	void setVerticalSpacing(int value);
34
	void setVisible(boolean visible);
35
	void stop();
36
	void toggleRoleFilter();
37
}
(-)src/org/eclipse/help/ui/internal/views/HelpTray.java (-250 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.help.ui.internal.views;
12
13
import org.eclipse.help.ui.internal.Messages;
14
import org.eclipse.jface.action.ContributionItem;
15
import org.eclipse.jface.action.IContributionItem;
16
import org.eclipse.jface.action.ToolBarManager;
17
import org.eclipse.jface.dialogs.DialogTray;
18
import org.eclipse.jface.dialogs.IDialogPage;
19
import org.eclipse.jface.dialogs.IPageChangeProvider;
20
import org.eclipse.jface.dialogs.IPageChangedListener;
21
import org.eclipse.jface.dialogs.PageChangedEvent;
22
import org.eclipse.jface.dialogs.TrayDialog;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.graphics.Color;
25
import org.eclipse.swt.graphics.GC;
26
import org.eclipse.swt.graphics.Image;
27
import org.eclipse.swt.graphics.ImageData;
28
import org.eclipse.swt.graphics.PaletteData;
29
import org.eclipse.swt.graphics.RGB;
30
import org.eclipse.swt.layout.GridData;
31
import org.eclipse.swt.layout.GridLayout;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.swt.widgets.Event;
36
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.swt.widgets.Listener;
38
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.swt.widgets.TabFolder;
40
import org.eclipse.swt.widgets.TabItem;
41
import org.eclipse.swt.widgets.ToolBar;
42
import org.eclipse.swt.widgets.ToolItem;
43
import org.eclipse.ui.PlatformUI;
44
import org.eclipse.ui.forms.HyperlinkGroup;
45
import org.eclipse.ui.forms.widgets.FormToolkit;
46
47
/**
48
 * The tray that appears on the side of dialogs when the user summons context
49
 * help or a cheat sheet follows the user into a dialog.
50
 */
51
public class HelpTray extends DialogTray implements IPageChangedListener {
52
	
53
	private static final int DEFAULT_WIDTH = 210;
54
	private FormToolkit toolkit;
55
	private ReusableHelpPart helpPart;
56
	private Shell shell;
57
	private IContributionItem closeAction;
58
	private Image normal;
59
	private Image hover;
60
	
61
	/**
62
	 * Creates any actions needed by the tray.
63
	 */
64
	private void createActions() {
65
		createImages();
66
		closeAction = new ContributionItem() {
67
			public void fill(ToolBar parent, int index) {
68
				final ToolItem item = new ToolItem(parent, SWT.PUSH);
69
				item.setImage(normal);
70
				item.setHotImage(hover);
71
				item.setToolTipText(Messages.ReusableHelpPart_closeAction_tooltip);
72
				item.addListener(SWT.Selection, new Listener() {
73
					public void handleEvent(Event event) {
74
						// close the tray
75
						TrayDialog dialog = (TrayDialog)shell.getData();
76
						dialog.closeTray();
77
						
78
						// set focus back to shell
79
						shell.setFocus();
80
					}
81
				});
82
			}
83
		};
84
	}
85
	
86
	/**
87
	 * Creates the contents of the tray.
88
	 * 
89
	 * @param parent the parent composite that will contain the tray
90
	 */
91
	protected Control createContents(Composite parent) {
92
		toolkit = new FormToolkit(parent.getDisplay());
93
		toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkGroup.UNDERLINE_HOVER);
94
		toolkit.getColors().initializeSectionToolBarColors();
95
		Composite container = new Composite(parent, SWT.NONE);
96
		GridLayout layout = new GridLayout();
97
		layout.marginWidth = layout.marginHeight = 0;
98
		layout.verticalSpacing = 0;
99
		container.setLayout(layout);
100
		container.addListener(SWT.Dispose, new Listener() {
101
			public void handleEvent(Event event) {
102
				dispose();
103
			}
104
		});
105
		
106
		ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
107
		tbm.createControl(container);
108
		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
109
		gd.grabExcessHorizontalSpace = true;
110
		tbm.getControl().setLayoutData(gd);
111
		Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
112
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
113
		gd.heightHint = 1;
114
		separator.setLayoutData(gd);
115
		helpPart = new ReusableHelpPart(PlatformUI.getWorkbench().getProgressService());
116
		helpPart.init(null, tbm, null, null);
117
		helpPart.setDefaultContextHelpText(Messages.HelpView_defaultText);
118
		helpPart.createControl(container, toolkit);
119
		gd = new GridData(GridData.FILL_BOTH);
120
		gd.widthHint = DEFAULT_WIDTH;
121
		helpPart.getControl().setLayoutData(gd);
122
		
123
		createActions();
124
		tbm.add(closeAction);
125
		
126
		shell = parent.getShell();
127
		hookPageChangeListener(shell);
128
		helpPart.getControl().addListener(SWT.Dispose, new Listener() {
129
			public void handleEvent(Event event) {
130
				unhookPageChangeListener(shell);
131
			}
132
		});
133
		
134
		return container;
135
	}
136
137
	/**
138
	 * Creates any custom needed by the tray, such as the close button.
139
	 */
140
	private void createImages() {
141
		Display display = Display.getCurrent();
142
		int[] shape = new int[] { 
143
				3,  3, 5,  3, 7,  5, 8,  5, 10, 3, 12, 3, 
144
				12, 5, 10, 7, 10, 8, 12,10, 12,12,
145
				10,12, 8, 10, 7, 10, 5, 12, 3, 12,
146
				3, 10, 5,  8, 5,  7, 3,  5
147
		};
148
		
149
		/*
150
		 * Use magenta as transparency color since it is used infrequently.
151
		 */
152
		Color border = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
153
		Color background = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
154
		Color backgroundHot = new Color(display, new RGB(252, 160, 160));
155
		Color transparent = display.getSystemColor(SWT.COLOR_MAGENTA);
156
157
		PaletteData palette = new PaletteData(new RGB[] { transparent.getRGB(), border.getRGB(), background.getRGB(), backgroundHot.getRGB() });
158
		ImageData data = new ImageData(16, 16, 8, palette);
159
		data.transparentPixel = 0;
160
161
		normal = new Image(display, data);
162
		normal.setBackground(transparent);
163
		GC gc = new GC(normal);
164
		gc.setBackground(background);
165
		gc.fillPolygon(shape);
166
		gc.setForeground(border);
167
		gc.drawPolygon(shape);
168
		gc.dispose();
169
170
		hover = new Image(display, data);
171
		hover.setBackground(transparent);
172
		gc = new GC(hover);
173
		gc.setBackground(backgroundHot);
174
		gc.fillPolygon(shape);
175
		gc.setForeground(border);
176
		gc.drawPolygon(shape);
177
		gc.dispose();
178
		
179
		backgroundHot.dispose();
180
	}
181
182
	/**
183
	 * Disposes any resources used by the tray.
184
	 */
185
	private void dispose() {
186
		normal.dispose();
187
		hover.dispose();
188
		toolkit.dispose();
189
		helpPart.dispose();
190
	}
191
192
	/**
193
	 * Returns the ReusableHelpPart contained in the tray.
194
	 * 
195
	 * @return the tray's ReusableHelpPart
196
	 */
197
	public ReusableHelpPart getHelpPart() {
198
		return helpPart;
199
	}
200
	
201
	/**
202
	 * Add the listener that gets notified of page changes (to automatically
203
	 * update context help).
204
	 * 
205
	 * @param parent the Composite to hook the listener to
206
	 */
207
	private void hookPageChangeListener(Composite parent) {
208
		Object data = parent.getData();
209
		if (data instanceof IPageChangeProvider) {
210
			((IPageChangeProvider)data).addPageChangedListener(this);
211
		}
212
	}
213
214
	/**
215
	 * Called whenever the dialog we're inside has changed pages. This updates
216
	 * the context help page if it is visible.
217
	 * 
218
	 * @param event the page change event
219
	 */
220
	public void pageChanged(PageChangedEvent event) {
221
		Object page = event.getSelectedPage();
222
		Control c = null;
223
		if (page instanceof IDialogPage) {
224
			c = ((IDialogPage) page).getControl();
225
		} else {
226
			c = shell.getDisplay().getFocusControl();
227
			if (c instanceof TabFolder) {
228
				TabFolder folder = (TabFolder) c;
229
				TabItem[] selection = folder.getSelection();
230
				if (selection.length == 1) {
231
					c = selection[0].getControl();
232
				}
233
			}
234
		}
235
		helpPart.update(null, null, c);
236
	}
237
	
238
	/**
239
	 * Remove the listener that gets notified of page changes (to automatically
240
	 * update context help).
241
	 * 
242
	 * @param parent the Composite that had the listener
243
	 */
244
	private void unhookPageChangeListener(Composite parent) {
245
		Object data = parent.getData();
246
		if (data instanceof IPageChangeProvider) {
247
			((IPageChangeProvider)data).removePageChangedListener(this);
248
		}
249
	}
250
}
(-)src/org/eclipse/help/ui/internal/browser/BrowsersPreferencePage.java (-5 / +5 lines)
Lines 53-59 Link Here
53
53
54
	private Button whelpAsInfopopButton;
54
	private Button whelpAsInfopopButton;
55
55
56
	private Button dhelpAsTrayButton;
56
	private Button dhelpAsWindowButton;
57
57
58
	private Button dhelpAsInfopopButton;
58
	private Button dhelpAsInfopopButton;
59
59
Lines 181-193 Link Here
181
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
181
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
182
		group.setLayout(layout);
182
		group.setLayout(layout);
183
		group.setText(Messages.BrowsersPreferencePage_dgroup);
183
		group.setText(Messages.BrowsersPreferencePage_dgroup);
184
		dhelpAsTrayButton = new Button(group, SWT.RADIO);
184
		dhelpAsWindowButton = new Button(group, SWT.RADIO);
185
		dhelpAsTrayButton.setText(Messages.BrowsersPreferencePage_tray);
185
		dhelpAsWindowButton.setText(Messages.BrowsersPreferencePage_window);
186
		dhelpAsInfopopButton = new Button(group, SWT.RADIO);
186
		dhelpAsInfopopButton = new Button(group, SWT.RADIO);
187
		dhelpAsInfopopButton.setText(Messages.BrowsersPreferencePage_dinfopop);
187
		dhelpAsInfopopButton.setText(Messages.BrowsersPreferencePage_dinfopop);
188
		boolean dinfopop = HelpBasePlugin.getDefault().getPluginPreferences()
188
		boolean dinfopop = HelpBasePlugin.getDefault().getPluginPreferences()
189
				.getBoolean(IHelpBaseConstants.P_KEY_DIALOG_INFOPOP);
189
				.getBoolean(IHelpBaseConstants.P_KEY_DIALOG_INFOPOP);
190
		dhelpAsTrayButton.setSelection(!dinfopop);
190
		dhelpAsWindowButton.setSelection(!dinfopop);
191
		dhelpAsInfopopButton.setSelection(dinfopop);
191
		dhelpAsInfopopButton.setSelection(dinfopop);
192
192
193
		if (PlatformUI.getWorkbench().getBrowserSupport()
193
		if (PlatformUI.getWorkbench().getBrowserSupport()
Lines 304-310 Link Here
304
304
305
		boolean dinfopop = HelpBasePlugin.getDefault().getPluginPreferences()
305
		boolean dinfopop = HelpBasePlugin.getDefault().getPluginPreferences()
306
				.getDefaultBoolean(IHelpBaseConstants.P_KEY_DIALOG_INFOPOP);
306
				.getDefaultBoolean(IHelpBaseConstants.P_KEY_DIALOG_INFOPOP);
307
		dhelpAsTrayButton.setSelection(!dinfopop);
307
		dhelpAsWindowButton.setSelection(!dinfopop);
308
		dhelpAsInfopopButton.setSelection(dinfopop);
308
		dhelpAsInfopopButton.setSelection(dinfopop);
309
		
309
		
310
		if (openInPlaceButton!=null) {
310
		if (openInPlaceButton!=null) {
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 13-19 Link Here
13
 org.eclipse.help.ui.internal.browser.embedded;x-internal:=true,
13
 org.eclipse.help.ui.internal.browser.embedded;x-internal:=true,
14
 org.eclipse.help.ui.internal.search;x-internal:=true,
14
 org.eclipse.help.ui.internal.search;x-internal:=true,
15
 org.eclipse.help.ui.internal.util;x-internal:=true,
15
 org.eclipse.help.ui.internal.util;x-internal:=true,
16
 org.eclipse.help.ui.internal.views;x-friends:="org.eclipse.ui.cheatsheets"
16
 org.eclipse.help.ui.internal.views;x-internal:=true
17
Require-Bundle: org.eclipse.help.base;bundle-version="[3.1.0,4.0.0)",
17
Require-Bundle: org.eclipse.help.base;bundle-version="[3.1.0,4.0.0)",
18
 org.eclipse.help.appserver;bundle-version="[3.1.0,4.0.0)",
18
 org.eclipse.help.appserver;bundle-version="[3.1.0,4.0.0)",
19
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
19
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
(-)src/org/eclipse/help/ui/internal/views/ContextHelpWindow.java (+396 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sebastian Davids <sdavids@gmx.de> - bug 93374
11
 *******************************************************************************/
12
package org.eclipse.help.ui.internal.views;
13
14
import org.eclipse.core.runtime.Platform;
15
import org.eclipse.help.IContext;
16
import org.eclipse.help.ui.internal.IHelpUIConstants;
17
import org.eclipse.help.ui.internal.Messages;
18
import org.eclipse.jface.action.ToolBarManager;
19
import org.eclipse.jface.dialogs.IDialogPage;
20
import org.eclipse.jface.dialogs.IPageChangeProvider;
21
import org.eclipse.jface.dialogs.IPageChangedListener;
22
import org.eclipse.jface.dialogs.PageChangedEvent;
23
import org.eclipse.jface.window.Window;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ControlEvent;
26
import org.eclipse.swt.events.ControlListener;
27
import org.eclipse.swt.graphics.Rectangle;
28
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridLayout;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
32
import org.eclipse.swt.widgets.Display;
33
import org.eclipse.swt.widgets.Event;
34
import org.eclipse.swt.widgets.Label;
35
import org.eclipse.swt.widgets.Listener;
36
import org.eclipse.swt.widgets.Shell;
37
import org.eclipse.swt.widgets.TabFolder;
38
import org.eclipse.swt.widgets.TabItem;
39
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.forms.HyperlinkGroup;
41
import org.eclipse.ui.forms.widgets.FormToolkit;
42
43
public class ContextHelpWindow extends Window implements IPageChangedListener {
44
	private ReusableHelpPart helpPart;
45
46
	private static final int DOCK_MARGIN = 10;
47
48
	private static final int CLIP_ALLOWANCE = 5;
49
50
	private FormToolkit toolkit;
51
52
	private Listener listener;
53
54
	private ControlListener parentListener;
55
56
	private Rectangle savedPbounds;
57
58
	private Rectangle savedBounds;
59
60
	private boolean parentResizeBlocked = false;
61
62
	public ContextHelpWindow(Shell parent) {
63
		super(parent);
64
		setShellStyle(SWT.CLOSE | SWT.RESIZE);
65
		if (!Platform.getWS().equals(Platform.WS_GTK)) {
66
			parentListener = new ControlListener() {
67
				public void controlMoved(ControlEvent e) {
68
					maintainRelativePosition();
69
				}
70
71
				public void controlResized(ControlEvent e) {
72
					onParentWindowResize();
73
				}
74
			};
75
			listener = new Listener() {
76
				public void handleEvent(Event e) {
77
					switch (e.type) {
78
					case SWT.FocusIn:
79
					case SWT.Selection:
80
						update((Control) e.widget);
81
						break;
82
					case SWT.Move:
83
						if (onWindowMove())
84
							e.doit = false;
85
						break;
86
					case SWT.Resize:
87
						onWindowResize();
88
						break;
89
					}
90
				}
91
			};
92
		}
93
	}
94
	
95
	public void showSearch() {
96
		helpPart.showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true);
97
	}
98
99
	private void maintainRelativePosition() {
100
		if (savedPbounds == null || isDocked())
101
			dock(true);
102
		else {
103
			Rectangle pbounds = getShell().getParent().getBounds();
104
			Rectangle bounds = getShell().getBounds();
105
			int deltaX = pbounds.x - savedPbounds.x;
106
			int deltaY = pbounds.y - savedPbounds.y;
107
			int newX = bounds.x + deltaX;
108
			int newY = bounds.y + deltaY;
109
			boolean doDock = false;
110
			Rectangle dbounds = getShell().getDisplay().getBounds();
111
			if (newX > dbounds.width - bounds.width) {
112
				newX = dbounds.width - bounds.width;
113
				if (pbounds.x + pbounds.width > newX)
114
					doDock = true;
115
			} else if (newX < 0)
116
				doDock = true;
117
			if (newY > dbounds.height - bounds.height) {
118
				newY = dbounds.height - bounds.height;
119
			} else if (newY < 0)
120
				newY = 0;
121
			if (doDock) {
122
				dock(true);
123
				return;
124
			}
125
			getShell().setLocation(newX, newY);
126
			savedPbounds = pbounds;
127
			savedBounds = getShell().getBounds();
128
		}
129
	}
130
131
	protected Control createContents(Composite parent) {
132
		toolkit = new FormToolkit(parent.getDisplay());
133
		toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(
134
				HyperlinkGroup.UNDERLINE_HOVER);
135
		toolkit.getColors().initializeSectionToolBarColors();
136
		Composite container = new Composite(parent, SWT.NULL);
137
		GridLayout layout = new GridLayout();
138
		layout.marginWidth = layout.marginHeight = 0;
139
		layout.verticalSpacing = 0;
140
		container.setLayout(layout);
141
142
		GridData gd;
143
		ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
144
		tbm.createControl(container);
145
		gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
146
		gd.grabExcessHorizontalSpace = true;
147
		tbm.getControl().setLayoutData(gd);
148
		Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
149
		gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
150
		gd.heightHint = 1;
151
		separator.setLayoutData(gd);
152
		helpPart = new ReusableHelpPart(PlatformUI.getWorkbench()
153
				.getProgressService());
154
		helpPart.init(null, tbm, null, null);
155
		helpPart.setDefaultContextHelpText(Messages.HelpView_defaultText); //		
156
		helpPart.createControl(container, toolkit);
157
		helpPart.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
158
		if (!Platform.getWS().equals(Platform.WS_GTK)) 
159
			hookListeners();
160
		helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
161
		container.setLayoutData(new GridData(GridData.FILL_BOTH));
162
		return container;
163
	}
164
165
	private void hookListeners() {
166
		Shell shell = getShell();
167
		shell.addListener(SWT.Move, listener);
168
		shell.addListener(SWT.Resize, listener);
169
		hookPageChangeListener(shell.getParent(), listener);
170
		shell.getParent().addControlListener(parentListener);
171
	}
172
173
	private void unhookListeners() {
174
		Shell shell = getShell();
175
		shell.getParent().removeControlListener(parentListener);
176
		unhookPageChangeListener(shell.getParent(), listener);
177
		shell.removeListener(SWT.Move, listener);
178
		shell.removeListener(SWT.Resize, listener);
179
	}
180
181
	private void hookPageChangeListener(Composite parent, Listener listener) {
182
		Object data = parent.getData();
183
		if (data instanceof IPageChangeProvider) {
184
			((IPageChangeProvider) data).addPageChangedListener(this);
185
		}
186
	}
187
188
	private void unhookPageChangeListener(Composite parent, Listener listener) {
189
		Object data = parent.getData();
190
		if (data instanceof IPageChangeProvider) {
191
			((IPageChangeProvider) data).removePageChangedListener(this);
192
		}
193
	}
194
195
	public void dock(boolean changeSides) {
196
		getShell().setBounds(computeDockedBounds(changeSides));
197
	}
198
199
	public Rectangle computeDockedBounds(boolean changeSides) {
200
		Display d = getShell().getDisplay();
201
		Rectangle dbounds = d.getBounds();
202
		Rectangle pbounds = getShell().getParent().getBounds();
203
204
		int leftMargin = pbounds.x;
205
		int rightMargin = dbounds.width - pbounds.x - pbounds.width;
206
		int centeredLeftMargin = dbounds.width / 2 - pbounds.width / 2;
207
		boolean rightParent = leftMargin > centeredLeftMargin;
208
		int currentX = getShell().getLocation().x;
209
		int newSize = getShell().getSize().x;
210
		boolean leftOK = newSize <= leftMargin + CLIP_ALLOWANCE;
211
		boolean rightOK = newSize <= rightMargin + CLIP_ALLOWANCE;
212
		int x;
213
		// first try to keep the same side
214
		if (currentX < pbounds.x && leftOK && (!changeSides || !rightParent)) {
215
			x = pbounds.x - newSize;
216
		} else if (currentX > pbounds.x && rightOK
217
				&& (!changeSides || rightParent)) {
218
			x = pbounds.x + pbounds.width;
219
		}
220
		// must switch side
221
		else if (changeSides) {
222
			if (rightOK)
223
				x = pbounds.x + pbounds.width;
224
			else if (leftOK)
225
				x = pbounds.x - newSize;
226
			else {
227
				// pick the margin that has more space, reduce size
228
				if (leftMargin > rightMargin) {
229
					newSize = leftMargin;
230
					x = pbounds.x - newSize;
231
				} else {
232
					newSize = rightMargin;
233
					x = dbounds.width - newSize;
234
				}
235
			}
236
		} else {
237
			if (currentX < pbounds.x) {
238
				newSize = leftMargin;
239
				x = pbounds.x - newSize;
240
			} else {
241
				newSize = rightMargin;
242
				x = dbounds.width - newSize;
243
			}
244
		}
245
		savedPbounds = pbounds;
246
		savedBounds = getShell().getBounds();
247
		return new Rectangle(x, pbounds.y, newSize, pbounds.height);
248
	}
249
250
	private boolean onWindowMove() {
251
		if (savedBounds == null) {
252
			savedBounds = getShell().getBounds();
253
			savedPbounds = getShell().getParent().getBounds();
254
			return false;
255
		}
256
		Rectangle bounds = getShell().getBounds();
257
		Rectangle pbounds = getShell().getParent().getBounds();
258
		if (bounds.y != savedBounds.y) {
259
			// vertical move
260
			if (bounds.y + bounds.height == savedBounds.y + savedBounds.height) {
261
				// upper edge resize
262
				if (isDocked()) {
263
					savedBounds = bounds;
264
					savedPbounds = pbounds;
265
					return false;
266
				}
267
			}
268
		}
269
		boolean doDock = false;
270
271
		if (bounds.x < pbounds.x) {
272
			// left
273
			int deltaX = bounds.x - savedBounds.x;
274
			if (deltaX > 0 || bounds.x + bounds.width > pbounds.x) {
275
				// moving closer - check for dock snap
276
				int distance = pbounds.x - bounds.x - bounds.width;
277
				if (Math.abs(distance) <= DOCK_MARGIN)
278
					doDock = true;
279
			}
280
		} else {
281
			// right
282
			int deltaX = bounds.x - savedBounds.x;
283
			if (deltaX < 0 || bounds.x < pbounds.x + pbounds.width) {
284
				// moving closer - check for dock snap
285
				int distance = bounds.x - pbounds.x - pbounds.width;
286
				if (Math.abs(distance) <= DOCK_MARGIN)
287
					doDock = true;
288
			}
289
		}
290
		if (bounds.y + bounds.height < pbounds.y) // above
291
			doDock = false;
292
		if (pbounds.y + pbounds.height < bounds.y) // below
293
			doDock = false;
294
		if (doDock)
295
			dock(false);
296
		savedBounds = getShell().getBounds();
297
		savedPbounds = getShell().getParent().getBounds();
298
		return doDock;
299
	}
300
301
	private void onWindowResize() {
302
		if (isDocked()) {
303
			Rectangle bounds = getShell().getBounds();
304
			Rectangle pbounds = getShell().getParent().getBounds();
305
			if (bounds.height != savedBounds.height) {
306
				Shell parent = (Shell) getShell().getParent();
307
				if ((parent.getStyle() & SWT.RESIZE) != 0) {
308
					parentResizeBlocked = true;
309
					parent.setBounds(pbounds.x, bounds.y, pbounds.width,
310
							bounds.height);
311
					parentResizeBlocked = false;
312
				}
313
			}
314
		}
315
		savedBounds = getShell().getBounds();
316
	}
317
318
	private void onParentWindowResize() {
319
		if (!parentResizeBlocked && isDocked()) {
320
			Rectangle bounds = getShell().getBounds();
321
			Rectangle pbounds = getShell().getParent().getBounds();
322
			if (bounds.x == savedPbounds.x + savedPbounds.width) {
323
				// right
324
				if (savedPbounds.x + savedPbounds.width != pbounds.x
325
						+ pbounds.width)
326
					// right edge moved
327
					dock(false);
328
			} else {
329
			}
330
			getShell().setSize(getShell().getSize().x,
331
					getShell().getParent().getSize().y);
332
		}
333
		savedPbounds = getShell().getParent().getBounds();
334
	}
335
336
	public void update(Control c) {
337
		helpPart.update(null, c);
338
	}
339
340
	public void update(IContext context, Control c) {
341
		helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
342
		helpPart.update(context, null, c);
343
	}
344
345
	public boolean close() {
346
		if (!Platform.getWS().equals(Platform.WS_GTK)) 
347
			unhookListeners();
348
		if (super.close()) {
349
			if (toolkit != null) {
350
				toolkit.dispose();
351
				toolkit = null;
352
			}
353
			if (helpPart != null) {
354
				helpPart.dispose();
355
				helpPart = null;
356
			}
357
			return true;
358
		}
359
		return false;
360
	}
361
362
	private boolean isDocked() {
363
		if (savedPbounds == null)
364
			return false;
365
		return isDocked(savedBounds, savedPbounds);
366
	}
367
368
	private boolean isDocked(Rectangle bounds, Rectangle pbounds) {
369
		if (pbounds.height != bounds.height)
370
			return false;
371
		if (bounds.y + bounds.height < pbounds.y) // above
372
			return false;
373
		if (pbounds.y + pbounds.height < bounds.y) // below
374
			return false;
375
		return bounds.x == pbounds.x + pbounds.width
376
				|| bounds.x == pbounds.x - bounds.width;
377
	}
378
379
	public void pageChanged(PageChangedEvent event) {
380
		Object page = event.getSelectedPage();
381
		Control c = null;
382
		if (page instanceof IDialogPage) {
383
			c = ((IDialogPage) page).getControl();
384
		} else {
385
			c = getShell().getDisplay().getFocusControl();
386
			if (c instanceof TabFolder) {
387
				TabFolder folder = (TabFolder) c;
388
				TabItem[] selection = folder.getSelection();
389
				if (selection.length == 1) {
390
					c = selection[0].getControl();
391
				}
392
			}
393
		}
394
		update(null, c);
395
	}
396
}
(-)cheatsheets/updates.xml (-6 lines)
Lines 31-37 Link Here
31
	<item
31
	<item
32
		href="/org.eclipse.pde.doc.user/guide/pde_creating.htm"
32
		href="/org.eclipse.pde.doc.user/guide/pde_creating.htm"
33
		title="Creating the plug-in project"
33
		title="Creating the plug-in project"
34
		dialog="true"
35
		skip="true">
34
		skip="true">
36
		<action
35
		<action
37
			pluginId="org.eclipse.pde.ui"
36
			pluginId="org.eclipse.pde.ui"
Lines 50-56 Link Here
50
	<item
49
	<item
51
		href="/org.eclipse.pde.doc.user/guide/pde_feature_setup.htm"
50
		href="/org.eclipse.pde.doc.user/guide/pde_feature_setup.htm"
52
		title="Creating the feature project"
51
		title="Creating the feature project"
53
		dialog="true"
54
		skip="true">
52
		skip="true">
55
		<action
53
		<action
56
			pluginId="org.eclipse.pde.ui"
54
			pluginId="org.eclipse.pde.ui"
Lines 85-91 Link Here
85
	<item
83
	<item
86
		href="/org.eclipse.pde.doc.user/guide/pde_site_setup.htm"
84
		href="/org.eclipse.pde.doc.user/guide/pde_site_setup.htm"
87
		title="Creating an update site project"
85
		title="Creating an update site project"
88
		dialog="true"
89
		skip="true">
86
		skip="true">
90
		<action
87
		<action
91
			pluginId="org.eclipse.pde.ui"
88
			pluginId="org.eclipse.pde.ui"
Lines 147-153 Link Here
147
	</item>
144
	</item>
148
	<item
145
	<item
149
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
146
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
150
		dialog="true"
151
		title="Testing the update site">
147
		title="Testing the update site">
152
		<action
148
		<action
153
			pluginId="org.eclipse.ui.ide"
149
			pluginId="org.eclipse.ui.ide"
Lines 172-178 Link Here
172
	</item>
168
	</item>
173
	<item
169
	<item
174
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
170
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
175
		dialog="true"
176
		title="Installing the feature">
171
		title="Installing the feature">
177
		<description>
172
		<description>
178
		   	When ready to test the feature itself, install
173
		   	When ready to test the feature itself, install
Lines 186-192 Link Here
186
	</item>
181
	</item>
187
	<item
182
	<item
188
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
183
		href="/org.eclipse.pde.doc.user/guide/pde_site_previewing.htm"
189
		dialog="true"
190
		title="Verifying the installation">
184
		title="Verifying the installation">
191
		<description>
185
		<description>
192
			Upon restart, select <b>Help-&gt;Software Updates-&gt;Manage Configuration...</b>.
186
			Upon restart, select <b>Help-&gt;Software Updates-&gt;Manage Configuration...</b>.
(-)cheatsheets/rcpapp.xml (-3 lines)
Lines 15-21 Link Here
15
15
16
	<item
16
	<item
17
		href="/org.eclipse.pde.doc.user/guide/rcp_project.htm" 
17
		href="/org.eclipse.pde.doc.user/guide/rcp_project.htm" 
18
		dialog="true"
19
		title="Creating a New Plug-in Project">
18
		title="Creating a New Plug-in Project">
20
		<action
19
		<action
21
			pluginId="org.eclipse.pde.ui"
20
			pluginId="org.eclipse.pde.ui"
Lines 41-47 Link Here
41
    
40
    
42
	<item
41
	<item
43
		href="/org.eclipse.pde.doc.user/guide/product_configuration.htm"
42
		href="/org.eclipse.pde.doc.user/guide/product_configuration.htm"
44
		dialog="true"
45
		title="Defining a product configuration">
43
		title="Defining a product configuration">
46
		<action 
44
		<action 
47
			pluginId="org.eclipse.pde.ui"
45
			pluginId="org.eclipse.pde.ui"
Lines 71-77 Link Here
71
69
72
	<item
70
	<item
73
		href="/org.eclipse.pde.doc.user/guide/product_export.htm"
71
		href="/org.eclipse.pde.doc.user/guide/product_export.htm"
74
		dialog="true"
75
		title="Exporting a Rich Client Application">
72
		title="Exporting a Rich Client Application">
76
		<description>
73
		<description>
77
			The product configuration editor also allows you to export RCP
74
			The product configuration editor also allows you to export RCP
(-)cheatsheets/helloworld.xml (-4 lines)
Lines 16-22 Link Here
16
16
17
	<item
17
	<item
18
		href="/org.eclipse.pde.doc.user/guide/pde_configuring.htm"
18
		href="/org.eclipse.pde.doc.user/guide/pde_configuring.htm"
19
		dialog="true"
20
		title="Configuring PDE">
19
		title="Configuring PDE">
21
		<action
20
		<action
22
			pluginId="org.eclipse.pde.ui"
21
			pluginId="org.eclipse.pde.ui"
Lines 53-59 Link Here
53
	<item
52
	<item
54
		href="/org.eclipse.pde.doc.user/guide/pde_creating.htm" 
53
		href="/org.eclipse.pde.doc.user/guide/pde_creating.htm" 
55
		title="Creating a New Plug-in Project"
54
		title="Creating a New Plug-in Project"
56
		dialog="true"
57
		skip="true">
55
		skip="true">
58
		<action
56
		<action
59
			pluginId="org.eclipse.pde.ui"
57
			pluginId="org.eclipse.pde.ui"
Lines 129-135 Link Here
129
		
127
		
130
	<item
128
	<item
131
		href="/org.eclipse.pde.doc.user/guide/pde_running.htm"
129
		href="/org.eclipse.pde.doc.user/guide/pde_running.htm"
132
		dialog="true"
133
		title="Running the plug-in">
130
		title="Running the plug-in">
134
		<action
131
		<action
135
			pluginId="org.eclipse.pde.ui"
132
			pluginId="org.eclipse.pde.ui"
Lines 151-157 Link Here
151
148
152
	<item
149
	<item
153
		href="/org.eclipse.pde.doc.user/guide/pde_deploy.htm"
150
		href="/org.eclipse.pde.doc.user/guide/pde_deploy.htm"
154
		dialog="true"
155
		title="Deploying a plug-in">
151
		title="Deploying a plug-in">
156
		<action
152
		<action
157
			pluginId="org.eclipse.pde.ui"
153
			pluginId="org.eclipse.pde.ui"
(-)src/org/eclipse/ui/internal/cheatsheets/data/Item.java (-19 / +1 lines)
Lines 15-21 Link Here
15
public class Item extends Intro implements IActionItem, IPerformWhenItem, ISubItemItem {
15
public class Item extends Intro implements IActionItem, IPerformWhenItem, ISubItemItem {
16
	private String title;
16
	private String title;
17
	private boolean skip;
17
	private boolean skip;
18
	private boolean dialog;
19
	private ArrayList itemExtensions;
18
	private ArrayList itemExtensions;
20
	
19
	
21
	private Action action;
20
	private Action action;
Lines 30-40 Link Here
30
		super();
29
		super();
31
	}
30
	}
32
	
31
	
33
	public Item(String title, String description, String href, String contextId, boolean skip, boolean dialog) {
32
	public Item(String title, String description, String href, String contextId, boolean skip) {
34
		super(description, href, contextId);
33
		super(description, href, contextId);
35
		this.title = title;
34
		this.title = title;
36
		this.skip = skip;
35
		this.skip = skip;
37
		this.dialog = dialog;
38
	}
36
	}
39
	
37
	
40
	/**
38
	/**
Lines 61-74 Link Here
61
	}
59
	}
62
60
63
	/**
61
	/**
64
	 * Returns whether or not this item requires opening a dialog.
65
	 * @return whether the item requires opening a dialog
66
	 */
67
	public boolean isDialog() {
68
		return this.dialog;
69
	}
70
	
71
	/**
72
	 * Returns the skip.
62
	 * Returns the skip.
73
	 * @return boolean
63
	 * @return boolean
74
	 */
64
	 */
Lines 77-90 Link Here
77
	}
67
	}
78
68
79
	/**
69
	/**
80
	 * Sets whether or not this item requires opening a dialog.
81
	 * @param dialog whether the item requires opening a dialog
82
	 */
83
	public void setDialog(boolean dialog) {
84
		this.dialog = dialog;
85
	}
86
	
87
	/**
88
	 * @param skip The skip to set.
70
	 * @param skip The skip to set.
89
	 */
71
	 */
90
	public void setSkip(boolean skip) {
72
	public void setSkip(boolean skip) {
(-)src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java (-2 lines)
Lines 55-68 Link Here
55
	 * <!ELEMENT item (description [action|perform-when] | (subitem|repeated-subitem|conditional-subitem)*)>
55
	 * <!ELEMENT item (description [action|perform-when] | (subitem|repeated-subitem|conditional-subitem)*)>
56
	 * <!ATTLIST item
56
	 * <!ATTLIST item
57
	 *   title               CDATA #REQUIRED
57
	 *   title               CDATA #REQUIRED
58
	 *   dialog              ("true" | "false") "false"
59
	 *   skip                ("true" | "false") "false"
58
	 *   skip                ("true" | "false") "false"
60
	 *   contextId           CDATA #IMPLIED
59
	 *   contextId           CDATA #IMPLIED
61
	 *   href                CDATA #IMPLIED
60
	 *   href                CDATA #IMPLIED
62
	 * >
61
	 * >
63
	 */
62
	 */
64
	public static final String ITEM = "item"; //$NON-NLS-1$
63
	public static final String ITEM = "item"; //$NON-NLS-1$
65
	public static final String DIALOG = "dialog"; //$NON-NLS-1$
66
	public static final String SKIP = "skip"; //$NON-NLS-1$
64
	public static final String SKIP = "skip"; //$NON-NLS-1$
67
65
68
	/*
66
	/*
(-)src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java (-2 lines)
Lines 505-512 Link Here
505
					item.setHref(attribute.getNodeValue());
505
					item.setHref(attribute.getNodeValue());
506
				} else if (attributeName.equals(IParserTags.SKIP)) {
506
				} else if (attributeName.equals(IParserTags.SKIP)) {
507
					item.setSkip(attribute.getNodeValue().equals(TRUE_STRING));
507
					item.setSkip(attribute.getNodeValue().equals(TRUE_STRING));
508
				} else if (attributeName.equals(IParserTags.DIALOG)) {
509
					item.setDialog(attribute.getNodeValue().equals(TRUE_STRING));
510
				} else {
508
				} else {
511
					AbstractItemExtensionElement[] ie = handleUnknownItemAttribute(attribute, itemNode);
509
					AbstractItemExtensionElement[] ie = handleUnknownItemAttribute(attribute, itemNode);
512
					if (ie != null)
510
					if (ie != null)
(-)src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java (-150 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.cheatsheets.views;
12
13
import org.eclipse.core.runtime.IPath;
14
import org.eclipse.help.ui.internal.views.IHelpPart;
15
import org.eclipse.help.ui.internal.views.ReusableHelpPart;
16
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.IMenuManager;
18
import org.eclipse.jface.action.IToolBarManager;
19
import org.eclipse.jface.action.Separator;
20
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.ui.IMemento;
24
import org.eclipse.ui.forms.AbstractFormPart;
25
import org.eclipse.ui.forms.widgets.FormToolkit;
26
import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin;
27
import org.eclipse.ui.internal.cheatsheets.Messages;
28
29
/**
30
 * A help part wrapper that contains a cheat sheet. This is used to display
31
 * cheat sheets inside the ReusableHelpPart.
32
 */
33
public class CheatSheetHelpPart extends AbstractFormPart implements IHelpPart {
34
	
35
	public static final String ID = "cheatsheet-page";
36
	
37
	private CheatSheetViewer viewer;
38
	private String id;
39
	
40
	/**
41
	 * Constructs a new part.
42
	 * 
43
	 * @param parent the parent Composite that will contain the widgets
44
	 * @param toolkit the form toolkit to use for creating the widgets
45
	 * @param tbm the toolbar we will contribute to
46
	 * @param id the unique id of the cheatsheet to display in the part
47
	 */
48
	public CheatSheetHelpPart(Composite parent, FormToolkit toolkit, IToolBarManager tbm, String id) {
49
		viewer = new CheatSheetViewer(true);
50
		viewer.setInput(id);
51
		viewer.createPartControl(parent);
52
		contributeToToolBar(tbm);
53
	}
54
55
	/**
56
	 * Contributes any actions we have to the toolbar.
57
	 * 
58
	 * @param tbm the toolbar to contribute to
59
	 */
60
	private void contributeToToolBar(IToolBarManager tbm) {
61
		IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("collapse_expand_all.gif");//$NON-NLS-1$
62
		ImageDescriptor collapseExpandImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path);
63
		CheatSheetExpandRestoreAction expandRestoreAction = new CheatSheetExpandRestoreAction(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP, false, viewer);
64
		expandRestoreAction.setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP);
65
		expandRestoreAction.setImageDescriptor(collapseExpandImage);
66
		tbm.insertBefore("back", expandRestoreAction); //$NON-NLS-1$
67
		tbm.insertBefore("back", new Separator()); //$NON-NLS-1$
68
		viewer.setExpandRestoreAction(expandRestoreAction);
69
	}
70
	
71
	/**
72
	 * This part doesn't require a context menu.
73
	 */
74
	public boolean fillContextMenu(IMenuManager manager) {
75
		return false;
76
	}
77
	
78
	/**
79
	 * Returns the part's top Control.
80
	 */
81
	public Control getControl() {
82
		return viewer.getControl();
83
	}
84
	
85
	/**
86
	 * This part doesn't use any global actions.
87
	 */
88
	public IAction getGlobalAction(String id) {
89
		return null;
90
	}
91
	
92
	/**
93
	 * Returns the part's unique identifier.
94
	 * 
95
	 * @param the unique id for the part
96
	 */
97
	public String getId() {
98
		return id;
99
	}
100
	
101
	/**
102
	 * Returns whether or not this part contains the given Control, which
103
	 * is in focus.
104
	 * 
105
	 * @param control the Control in focus
106
	 */
107
	public boolean hasFocusControl(Control control) {
108
		return viewer.hasFocusControl(control);
109
	}
110
	
111
	/**
112
	 * Initializes the part.
113
	 */
114
	public void init(ReusableHelpPart parent, String id, IMemento memento) {
115
		this.id = id;
116
	}
117
118
	/**
119
	 * No filtering required.
120
	 */
121
	public void refilter() {
122
	}
123
	
124
	/**
125
	 * The cheat sheet automatically saves its state; no action required.
126
	 */
127
	public void saveState(IMemento memento) {
128
	}
129
	
130
	/**
131
	 * Sets the visibility of the part.
132
	 * 
133
	 * @param whether or not the part should be visible
134
	 */
135
	public void setVisible(boolean visible) {
136
		viewer.getControl().setVisible(visible);
137
	}
138
	
139
	/**
140
	 * No action needed for this part here.
141
	 */
142
	public void stop() {
143
	}
144
	
145
	/**
146
	 * No action needed for this part here.
147
	 */
148
	public void toggleRoleFilter() {
149
	}
150
}
(-)src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java (-1 / +1 lines)
Lines 94-100 Link Here
94
	public void createPartControl(Composite parent) {
94
	public void createPartControl(Composite parent) {
95
		CheatSheetStopWatch.startStopWatch("CheatSheetView.createPartControl"); //$NON-NLS-1$
95
		CheatSheetStopWatch.startStopWatch("CheatSheetView.createPartControl"); //$NON-NLS-1$
96
96
97
		viewer = new CheatSheetViewer(false);
97
		viewer = new CheatSheetViewer();
98
		viewer.createPartControl(parent);
98
		viewer.createPartControl(parent);
99
	
99
	
100
		if (!actionBarContributed) {
100
		if (!actionBarContributed) {
(-)src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java (-10 lines)
Lines 333-348 Link Here
333
		return mainItemComposite.isExpanded();
333
		return mainItemComposite.isExpanded();
334
	}
334
	}
335
335
336
	/**
337
     * Returns whether or not cheat sheet viewer containing this item is in
338
     * a modal dialog.
339
     * 
340
     * @return whether the cheat sheet viewer is in a modal dialog
341
	 */
342
	public boolean isInDialogMode() {
343
		return viewer.isInDialogMode();
344
	}
345
	
346
	/*package*/
336
	/*package*/
347
	boolean isSkipped() {
337
	boolean isSkipped() {
348
		return isSkipped;
338
		return isSkipped;
(-)src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java (-115 / +3 lines)
Lines 24-34 Link Here
24
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Platform;
26
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.Status;
27
import org.eclipse.help.ui.internal.views.HelpTray;
28
import org.eclipse.help.ui.internal.views.IHelpPartPage;
29
import org.eclipse.help.ui.internal.views.ReusableHelpPart;
30
import org.eclipse.jface.action.Action;
27
import org.eclipse.jface.action.Action;
31
import org.eclipse.jface.dialogs.TrayDialog;
32
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.osgi.util.NLS;
33
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.events.DisposeEvent;
30
import org.eclipse.swt.events.DisposeEvent;
Lines 39-49 Link Here
39
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Composite;
40
import org.eclipse.swt.widgets.Control;
36
import org.eclipse.swt.widgets.Control;
41
import org.eclipse.swt.widgets.Display;
37
import org.eclipse.swt.widgets.Display;
42
import org.eclipse.swt.widgets.Event;
43
import org.eclipse.swt.widgets.Label;
38
import org.eclipse.swt.widgets.Label;
44
import org.eclipse.swt.widgets.Listener;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.swt.widgets.Widget;
47
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.cheatsheets.ICheatSheetEvent;
40
import org.eclipse.ui.cheatsheets.ICheatSheetEvent;
49
import org.eclipse.ui.cheatsheets.ICheatSheetViewer;
41
import org.eclipse.ui.cheatsheets.ICheatSheetViewer;
Lines 90-113 Link Here
90
	private ArrayList viewItemList = new ArrayList();
82
	private ArrayList viewItemList = new ArrayList();
91
83
92
	//Composites
84
	//Composites
93
	protected Composite control;
85
	private Composite control;
94
86
95
	private Cursor busyCursor;
87
	private Cursor busyCursor;
96
	
88
	
97
	private ErrorPage errorPage;
89
	private ErrorPage errorPage;
98
	private CheatSheetPage cheatSheetPage;
90
	private CheatSheetPage cheatSheetPage;
99
	private Label howToBegin;
91
	private Label howToBegin;
100
	private boolean inDialog;
101
	private Listener listener;
102
92
103
	/**
93
	/**
104
	 * The constructor.
94
	 * The constructor.
105
	 * 
106
	 * @param inDialog whether or not this viewer will be placed in a modal dialog
107
	 */
95
	 */
108
	public CheatSheetViewer(boolean inDialog) {
96
	public CheatSheetViewer() {
109
		currentItemNum = -1;
97
		currentItemNum = -1;
110
		this.inDialog = inDialog;
111
		saveHelper = new CheatSheetSaveHelper();
98
		saveHelper = new CheatSheetSaveHelper();
112
	}
99
	}
113
100
Lines 553-573 Link Here
553
				dispose();
540
				dispose();
554
			}
541
			}
555
		});
542
		});
556
		
557
		/*
558
		 * org.eclipse.help.ui is an optional dependency; only perform this
559
		 * step is this plugin is present.
560
		 */
561
		if (!inDialog && (Platform.getBundle("org.eclipse.help.ui") != null)) {
562
			listener = new Listener() {
563
				public void handleEvent(Event event) {
564
					if (isTrayDialog(event.widget)) {
565
						dialogOpened((TrayDialog)((Shell)event.widget).getData());
566
					}
567
				}
568
			};
569
			Display.getCurrent().addFilter(SWT.Show, listener);
570
		}
571
543
572
		howToBegin = new Label(control, SWT.WRAP);
544
		howToBegin = new Label(control, SWT.WRAP);
573
		howToBegin.setText(Messages.INITIAL_VIEW_DIRECTIONS);
545
		howToBegin.setText(Messages.INITIAL_VIEW_DIRECTIONS);
Lines 583-635 Link Here
583
	}
555
	}
584
556
585
	/**
557
	/**
586
	 * Called when any TrayDialog is opened. The viewer must react by disabling
587
	 * itself and moving the cheat sheet to the dialog's tray if the current item
588
	 * was flagged as one that opens a modal dialog.
589
	 * 
590
	 * @param dialog the dialog that was opened
591
	 */
592
	private void dialogOpened(TrayDialog dialog) {
593
		if (isInDialogItem()) {
594
			final String id = getCheatSheetID();
595
			HelpTray tray = (HelpTray)dialog.getTray();
596
			if (tray == null) {
597
				tray = new HelpTray();
598
				dialog.openTray(tray);
599
			}
600
			ReusableHelpPart helpPart = tray.getHelpPart();
601
			IHelpPartPage page = helpPart.createPage(CheatSheetHelpPart.ID, null, null);
602
			page.setVerticalSpacing(0);
603
			page.setHorizontalMargin(0);
604
			helpPart.addPart(CheatSheetHelpPart.ID, new CheatSheetHelpPart(helpPart.getForm().getForm().getBody(), helpPart.getForm().getToolkit(), page.getToolBarManager(), id));
605
			page.addPart(CheatSheetHelpPart.ID, true);
606
			helpPart.addPage(page);
607
			helpPart.showPage(CheatSheetHelpPart.ID);
608
			
609
			/*
610
			 * Disable the viewer until the tray is closed, then show it again.
611
			 */
612
			control.setVisible(false);
613
			Display.getCurrent().removeFilter(SWT.Show, listener);
614
615
			helpPart.getControl().addListener(SWT.Dispose, new Listener() {
616
				public void handleEvent(Event event) {
617
					control.setVisible(true);
618
					Display.getCurrent().addFilter(SWT.Show, listener);
619
					checkSavedState();
620
				}
621
			});
622
		}
623
	}
624
625
	/**
626
	 * Disposes of this cheat sheet viewer.
558
	 * Disposes of this cheat sheet viewer.
627
	 */
559
	 */
628
	private void dispose() {
560
	private void dispose() {
629
		if (listener != null) {
630
			Display.getCurrent().removeFilter(SWT.Show, listener);
631
		}
632
		internalDispose();
561
		internalDispose();
562
633
		if (busyCursor != null)
563
		if (busyCursor != null)
634
			busyCursor.dispose();
564
			busyCursor.dispose();
635
	}
565
	}
Lines 701-717 Link Here
701
		return (ViewItem) viewItemList.get(index);
631
		return (ViewItem) viewItemList.get(index);
702
	}
632
	}
703
	
633
	
704
	/**
705
	 * Returns whether or not this viewer contains the given Control, which
706
	 * is currently in focus.
707
	 * 
708
	 * @param control the Control currently in focus
709
	 * @return whether this viewer contains the given Control or not
710
	 */
711
	public boolean hasFocusControl(Control control) {
712
		return (control == this.control) || (cheatSheetPage.getForm() == control);
713
	}
714
	
715
	private void initCheatSheetView() {
634
	private void initCheatSheetView() {
716
		CheatSheetStopWatch.startStopWatch("CheatSheetViewer.initCheatSheetView()"); //$NON-NLS-1$
635
		CheatSheetStopWatch.startStopWatch("CheatSheetViewer.initCheatSheetView()"); //$NON-NLS-1$
717
		//Re-initialize list to store items collapsed by expand/restore action on c.s. toolbar.
636
		//Re-initialize list to store items collapsed by expand/restore action on c.s. toolbar.
Lines 802-840 Link Here
802
			cheatSheetPage.dispose();
721
			cheatSheetPage.dispose();
803
		}
722
		}
804
	}
723
	}
805
806
	/**
807
	 * Returns whether or not the currently active item requires opening a
808
	 * modal dialog.
809
	 * 
810
	 * @return whether the current item opens a modal dialog
811
	 */
812
	private boolean isInDialogItem() {
813
		ViewItem item = getViewItemAtIndex(currentItemNum);
814
		return item.getItem().isDialog();
815
	}
816
	
724
	
817
	/**
725
	/**
818
	 * Returns whether or not this cheat sheet viewer is inside a modal
819
	 * dialog.
820
	 * 
821
	 * @return whether this viewer is inside a modal dialog
822
	 */
823
	public boolean isInDialogMode() {
824
		return inDialog;
825
	}
826
	
827
	/**
828
	 * Returns whether the given widget is a TrayDialog.
829
	 * 
830
	 * @param widget the widget to check
831
	 * @return whether or not the widget is a TrayDialog
832
	 */
833
	private boolean isTrayDialog(Widget widget) {
834
		return (widget instanceof Shell && ((Shell)widget).getData() instanceof TrayDialog);
835
	}
836
837
	/**
838
	* Read the contents of the welcome page
726
	* Read the contents of the welcome page
839
	*/
727
	*/
840
	private boolean readFile() {
728
	private boolean readFile() {
(-)src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java (-8 / +1 lines)
Lines 63-76 Link Here
63
	}
63
	}
64
64
65
	private void createButtons(Action action) {
65
	private void createButtons(Action action) {
66
		/*
66
		if (action != null ) {
67
		 * When the cheat sheet is displayed in a dialog's tray, hide
68
		 * the action that was just invoked to open the dialog.
69
		 */
70
		boolean inDialog = isInDialogMode();
71
		boolean isDialogAction = getItem().isDialog();
72
		boolean hideAction = isDialogAction && inDialog;
73
		if (action != null && !hideAction) {
74
			final ImageHyperlink startButton = createButton(buttonComposite, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_BUTTON_START), this, itemColor, Messages.PERFORM_TASK_TOOLTIP);
67
			final ImageHyperlink startButton = createButton(buttonComposite, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_BUTTON_START), this, itemColor, Messages.PERFORM_TASK_TOOLTIP);
75
			page.getToolkit().adapt(startButton, true, true);
68
			page.getToolkit().adapt(startButton, true, true);
76
			startButton.addHyperlinkListener(new HyperlinkAdapter() {
69
			startButton.addHyperlinkListener(new HyperlinkAdapter() {
(-)src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java (-1 / +1 lines)
Lines 37-42 Link Here
37
	 * @return a new cheat sheet viewer
37
	 * @return a new cheat sheet viewer
38
	 */
38
	 */
39
	public static ICheatSheetViewer createCheatSheetView() {
39
	public static ICheatSheetViewer createCheatSheetView() {
40
		return new CheatSheetViewer(false);
40
		return new CheatSheetViewer();
41
	}
41
	}
42
}
42
}
(-)schema/cheatSheetContentFileSpec.html (-8 / +4 lines)
Lines 11-17 Link Here
11
<body>
11
<body>
12
12
13
<h1>Cheat Sheet Content File XML Format</h1>
13
<h1>Cheat Sheet Content File XML Format</h1>
14
<p>Version 3.2</p>
14
<p>Version 3.0</p>
15
<p>This document describes the cheat sheet content file structure as a series of
15
<p>This document describes the cheat sheet content file structure as a series of
16
DTD fragments (machine readable <a href="contentFile.xsd">XML schema</a>).</p>
16
DTD fragments (machine readable <a href="contentFile.xsd">XML schema</a>).</p>
17
<h2><code>cheatsheet</code></h2>
17
<h2><code>cheatsheet</code></h2>
Lines 70-76 Link Here
70
<pre>&lt;!ELEMENT item (description ([action|perform-when] | (subitem|repeated-subitem|conditional-subitem)*))&gt;&nbsp;
70
<pre>&lt;!ELEMENT item (description ([action|perform-when] | (subitem|repeated-subitem|conditional-subitem)*))&gt;&nbsp;
71
&lt;!ATTLIST item&nbsp;
71
&lt;!ATTLIST item&nbsp;
72
&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED
72
&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #REQUIRED
73
&nbsp; dialog  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;true&quot; | &quot;false&quot;) &quot;false&quot;
74
&nbsp; skip   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;true&quot; | &quot;false&quot;) &quot;false&quot;
73
&nbsp; skip   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;true&quot; | &quot;false&quot;) &quot;false&quot;
75
&nbsp; contextId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #IMPLIED&nbsp;
74
&nbsp; contextId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #IMPLIED&nbsp;
76
&nbsp; href &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #IMPLIED
75
&nbsp; href &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CDATA #IMPLIED
Lines 80-88 Link Here
80
follows:</p>
79
follows:</p>
81
<ul type="disc">
80
<ul type="disc">
82
  <li><b>title</b> - The title of the cheat sheet item.
81
  <li><b>title</b> - The title of the cheat sheet item.
83
  <li><b>dialog</b> - dialog=&quot;true&quot; means this step involves opening
84
    a modal dialog. This is a hint to the system that it should allow the user
85
    to continue using the cheat sheet while in the modal dialog.</li>
86
  <li><b>skip</b> - skip=&quot;true&quot; means that the whole step can be
82
  <li><b>skip</b> - skip=&quot;true&quot; means that the whole step can be
87
    skipped; the UI generally shows a button that the user can press to indicate
83
    skipped; the UI generally shows a button that the user can press to indicate
88
    that they are skipping this step</li>
84
    that they are skipping this step</li>
Lines 326-333 Link Here
326
  &lt;intro&gt;
322
  &lt;intro&gt;
327
    &lt;description&gt;Example cheat sheet with two steps.&lt;/description&gt;
323
    &lt;description&gt;Example cheat sheet with two steps.&lt;/description&gt;
328
  &lt;/intro&gt;
324
  &lt;/intro&gt;
329
  &lt;item title=&quot;Step 1&quot; dialog=&quot;true&quot;&gt;
325
  &lt;item title=&quot;Step 1&quot;&gt;
330
     &lt;description&gt;This is a step with an action that involves opening a modal dialog.&lt;/description&gt;
326
     &lt;description&gt;This is a step with an action.&lt;/description&gt;
331
     &lt;action class=&quot;com.xyz.myaction&quot; pluginId=&quot;com.xyz&quot;/&gt;
327
     &lt;action class=&quot;com.xyz.myaction&quot; pluginId=&quot;com.xyz&quot;/&gt;
332
  &lt;/item&gt;
328
  &lt;/item&gt;
333
  &lt;item title=&quot;Step 2&quot;&gt;
329
  &lt;item title=&quot;Step 2&quot;&gt;
Lines 337-343 Link Here
337
333
338
<br>
334
<br>
339
<p class=note id=copyright>
335
<p class=note id=copyright>
340
Copyright (c) 2004, 2005 IBM Corporation and others.<br>
336
Copyright (c) 2004 IBM Corporation and others.<br>
341
All rights reserved. This program and the accompanying materials are made 
337
All rights reserved. This program and the accompanying materials are made 
342
available under the terms of the Eclipse Public License v1.0 which accompanies 
338
available under the terms of the Eclipse Public License v1.0 which accompanies 
343
this distribution, and is available at 
339
this distribution, and is available at 
(-)schema/contentFile.xsd (-2 / +1 lines)
Lines 4-10 Link Here
4
	<xsd:annotation>
4
	<xsd:annotation>
5
		<xsd:documentation xml:lang="en">
5
		<xsd:documentation xml:lang="en">
6
		Schema for cheat sheet content file.
6
		Schema for cheat sheet content file.
7
 		Copyright (c) 2004, 2005 IBM Corporation and others.&lt;br&gt;
7
 		Copyright (c) 2004 IBM Corporation and others.&lt;br&gt;
8
		All rights reserved. This program and the accompanying materials are made 
8
		All rights reserved. This program and the accompanying materials are made 
9
		available under the terms of the Eclipse Public License v1.0 which 
9
		available under the terms of the Eclipse Public License v1.0 which 
10
		accompanies this distribution, and is available at 
10
		accompanies this distribution, and is available at 
Lines 57-63 Link Here
57
	            </xsd:choice>
57
	            </xsd:choice>
58
            </xsd:choice>
58
            </xsd:choice>
59
            <xsd:attribute name="title" type="xsd:string" use="required"/>
59
            <xsd:attribute name="title" type="xsd:string" use="required"/>
60
            <xsd:attribute name="dialog" type="xsd:boolean" use="optional" default="false"/>
61
            <xsd:attribute name="skip" type="xsd:boolean" use="optional" default="false"/>
60
            <xsd:attribute name="skip" type="xsd:boolean" use="optional" default="false"/>
62
            <xsd:attribute name="contextId" type="xsd:string" use="optional"/>
61
            <xsd:attribute name="contextId" type="xsd:string" use="optional"/>
63
            <xsd:attribute name="href" type="xsd:string" use="optional"/>
62
            <xsd:attribute name="href" type="xsd:string" use="optional"/>
(-)META-INF/MANIFEST.MF (-2 / +1 lines)
Lines 17-22 Link Here
17
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
17
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
18
 org.eclipse.help;bundle-version="[3.1.0,4.0.0)",
18
 org.eclipse.help;bundle-version="[3.1.0,4.0.0)",
19
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)",
19
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)",
20
 org.eclipse.help.base;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
20
 org.eclipse.help.base;bundle-version="[3.2.0,4.0.0)";resolution:=optional
21
 org.eclipse.help.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional
22
Eclipse-LazyStart: true
21
Eclipse-LazyStart: true

Return to bug 69732