### Eclipse Workspace Patch 1.0
#P org.eclipse.platform
Index: cheatsheets/CVS_1.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.platform/cheatsheets/CVS_1.xml,v
retrieving revision 1.4
diff -u -r1.4 CVS_1.xml
--- cheatsheets/CVS_1.xml 14 Jul 2004 21:26:08 -0000 1.4
+++ cheatsheets/CVS_1.xml 9 Dec 2005 20:40:00 -0000
@@ -18,7 +18,8 @@
-
+ title="Load the Destination into your Workspace"
+ dialog="true">
Select the project and choose Replace With > 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.
@@ -26,7 +27,8 @@
-
+ title="Merge Details"
+ dialog="true">
Select the project, choose Team > 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.
#P org.eclipse.ui.cheatsheets
Index: src/org/eclipse/ui/internal/cheatsheets/data/Item.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/Item.java,v
retrieving revision 1.6
diff -u -r1.6 Item.java
--- src/org/eclipse/ui/internal/cheatsheets/data/Item.java 1 Mar 2005 20:45:46 -0000 1.6
+++ src/org/eclipse/ui/internal/cheatsheets/data/Item.java 9 Dec 2005 20:40:01 -0000
@@ -15,6 +15,7 @@
public class Item extends Intro implements IActionItem, IPerformWhenItem, ISubItemItem {
private String title;
private boolean skip;
+ private boolean dialog;
private ArrayList itemExtensions;
private Action action;
@@ -29,10 +30,11 @@
super();
}
- public Item(String title, String description, String href, String contextId, boolean skip) {
+ public Item(String title, String description, String href, String contextId, boolean skip, boolean dialog) {
super(description, href, contextId);
this.title = title;
this.skip = skip;
+ this.dialog = dialog;
}
/**
@@ -59,6 +61,14 @@
}
/**
+ * Returns whether or not this item requires opening a dialog.
+ * @return whether the item requires opening a dialog
+ */
+ public boolean isDialog() {
+ return this.dialog;
+ }
+
+ /**
* Returns the skip.
* @return boolean
*/
@@ -67,6 +77,14 @@
}
/**
+ * Sets whether or not this item requires opening a dialog.
+ * @param dialog whether the item requires opening a dialog
+ */
+ public void setDialog(boolean dialog) {
+ this.dialog = dialog;
+ }
+
+ /**
* @param skip The skip to set.
*/
public void setSkip(boolean skip) {
Index: src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java,v
retrieving revision 1.9
diff -u -r1.9 IParserTags.java
--- src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java 1 Mar 2005 20:45:46 -0000 1.9
+++ src/org/eclipse/ui/internal/cheatsheets/data/IParserTags.java 9 Dec 2005 20:40:01 -0000
@@ -55,12 +55,14 @@
*
*
*/
public static final String ITEM = "item"; //$NON-NLS-1$
+ public static final String DIALOG = "dialog"; //$NON-NLS-1$
public static final String SKIP = "skip"; //$NON-NLS-1$
/*
Index: src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java,v
retrieving revision 1.15
diff -u -r1.15 CheatSheetParser.java
--- src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java 8 May 2005 06:23:05 -0000 1.15
+++ src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java 9 Dec 2005 20:40:01 -0000
@@ -505,6 +505,8 @@
item.setHref(attribute.getNodeValue());
} else if (attributeName.equals(IParserTags.SKIP)) {
item.setSkip(attribute.getNodeValue().equals(TRUE_STRING));
+ } else if (attributeName.equals(IParserTags.DIALOG)) {
+ item.setDialog(attribute.getNodeValue().equals(TRUE_STRING));
} else {
AbstractItemExtensionElement[] ie = handleUnknownItemAttribute(attribute, itemNode);
if (ie != null)
Index: src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java,v
retrieving revision 1.4
diff -u -r1.4 CheatSheetViewerFactory.java
--- src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java 1 Mar 2005 20:45:46 -0000 1.4
+++ src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java 9 Dec 2005 20:40:01 -0000
@@ -37,6 +37,6 @@
* @return a new cheat sheet viewer
*/
public static ICheatSheetViewer createCheatSheetView() {
- return new CheatSheetViewer();
+ return new CheatSheetViewer(false);
}
}
Index: schema/cheatSheetContentFileSpec.html
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html,v
retrieving revision 1.14
diff -u -r1.14 cheatSheetContentFileSpec.html
--- schema/cheatSheetContentFileSpec.html 1 Mar 2005 20:45:46 -0000 1.14
+++ schema/cheatSheetContentFileSpec.html 9 Dec 2005 20:40:01 -0000
@@ -11,7 +11,7 @@
Cheat Sheet Content File XML Format
-Version 3.0
+Version 3.2
This document describes the cheat sheet content file structure as a series of
DTD fragments (machine readable XML schema).
cheatsheet
@@ -70,6 +70,7 @@
<!ELEMENT item (description ([action|perform-when] | (subitem|repeated-subitem|conditional-subitem)*))>
<!ATTLIST item
title CDATA #REQUIRED
+ dialog ("true" | "false") "false"
skip ("true" | "false") "false"
contextId CDATA #IMPLIED
href CDATA #IMPLIED
@@ -79,6 +80,9 @@
follows:
- title - The title of the cheat sheet item.
+
- dialog - dialog="true" means this step involves opening
+ a modal dialog. This is a hint to the system that it should allow the user
+ to continue using the cheat sheet while in the modal dialog.
- skip - skip="true" means that the whole step can be
skipped; the UI generally shows a button that the user can press to indicate
that they are skipping this step
@@ -322,8 +326,8 @@
<intro>
<description>Example cheat sheet with two steps.</description>
</intro>
- <item title="Step 1">
- <description>This is a step with an action.</description>
+ <item title="Step 1" dialog="true">
+ <description>This is a step with an action that involves opening a modal dialog.</description>
<action class="com.xyz.myaction" pluginId="com.xyz"/>
</item>
<item title="Step 2">
@@ -333,7 +337,7 @@
-Copyright (c) 2004 IBM Corporation and others.
+Copyright (c) 2004, 2005 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0 which accompanies
this distribution, and is available at
Index: schema/contentFile.xsd
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/schema/contentFile.xsd,v
retrieving revision 1.5
diff -u -r1.5 contentFile.xsd
--- schema/contentFile.xsd 20 Apr 2005 14:55:21 -0000 1.5
+++ schema/contentFile.xsd 9 Dec 2005 20:40:01 -0000
@@ -4,7 +4,7 @@
Schema for cheat sheet content file.
- Copyright (c) 2004 IBM Corporation and others.<br>
+ Copyright (c) 2004, 2005 IBM Corporation and others.<br>
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0 which
accompanies this distribution, and is available at
@@ -57,6 +57,7 @@
+
Index: src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java,v
retrieving revision 1.28
diff -u -r1.28 CheatSheetView.java
--- src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java 13 Nov 2005 08:38:00 -0000 1.28
+++ src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java 9 Dec 2005 20:40:01 -0000
@@ -94,7 +94,7 @@
public void createPartControl(Composite parent) {
CheatSheetStopWatch.startStopWatch("CheatSheetView.createPartControl"); //$NON-NLS-1$
- viewer = new CheatSheetViewer();
+ viewer = new CheatSheetViewer(false);
viewer.createPartControl(parent);
if (!actionBarContributed) {
Index: src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java,v
retrieving revision 1.34
diff -u -r1.34 ViewItem.java
--- src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java 16 May 2005 15:57:57 -0000 1.34
+++ src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java 9 Dec 2005 20:40:01 -0000
@@ -333,6 +333,16 @@
return mainItemComposite.isExpanded();
}
+ /**
+ * Returns whether or not cheat sheet viewer containing this item is in
+ * a modal dialog.
+ *
+ * @return whether the cheat sheet viewer is in a modal dialog
+ */
+ public boolean isInDialogMode() {
+ return viewer.isInDialogMode();
+ }
+
/*package*/
boolean isSkipped() {
return isSkipped;
Index: src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java,v
retrieving revision 1.33
diff -u -r1.33 CheatSheetViewer.java
--- src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java 13 Nov 2005 08:38:00 -0000 1.33
+++ src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java 9 Dec 2005 20:40:01 -0000
@@ -24,7 +24,11 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.help.ui.internal.views.HelpTray;
+import org.eclipse.help.ui.internal.views.IHelpPartPage;
+import org.eclipse.help.ui.internal.views.ReusableHelpPart;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
@@ -35,7 +39,11 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.cheatsheets.ICheatSheetEvent;
import org.eclipse.ui.cheatsheets.ICheatSheetViewer;
@@ -82,19 +90,24 @@
private ArrayList viewItemList = new ArrayList();
//Composites
- private Composite control;
+ protected Composite control;
private Cursor busyCursor;
private ErrorPage errorPage;
private CheatSheetPage cheatSheetPage;
private Label howToBegin;
+ private boolean inDialog;
+ private Listener listener;
/**
* The constructor.
+ *
+ * @param inDialog whether or not this viewer will be placed in a modal dialog
*/
- public CheatSheetViewer() {
+ public CheatSheetViewer(boolean inDialog) {
currentItemNum = -1;
+ this.inDialog = inDialog;
saveHelper = new CheatSheetSaveHelper();
}
@@ -540,6 +553,21 @@
dispose();
}
});
+
+ /*
+ * org.eclipse.help.ui is an optional dependency; only perform this
+ * step is this plugin is present.
+ */
+ if (!inDialog && (Platform.getBundle("org.eclipse.help.ui") != null)) {
+ listener = new Listener() {
+ public void handleEvent(Event event) {
+ if (isTrayDialog(event.widget)) {
+ dialogOpened((TrayDialog)((Shell)event.widget).getData());
+ }
+ }
+ };
+ Display.getCurrent().addFilter(SWT.Show, listener);
+ }
howToBegin = new Label(control, SWT.WRAP);
howToBegin.setText(Messages.INITIAL_VIEW_DIRECTIONS);
@@ -555,11 +583,53 @@
}
/**
+ * Called when any TrayDialog is opened. The viewer must react by disabling
+ * itself and moving the cheat sheet to the dialog's tray if the current item
+ * was flagged as one that opens a modal dialog.
+ *
+ * @param dialog the dialog that was opened
+ */
+ private void dialogOpened(TrayDialog dialog) {
+ if (isInDialogItem()) {
+ final String id = getCheatSheetID();
+ HelpTray tray = (HelpTray)dialog.getTray();
+ if (tray == null) {
+ tray = new HelpTray();
+ dialog.openTray(tray);
+ }
+ ReusableHelpPart helpPart = tray.getHelpPart();
+ IHelpPartPage page = helpPart.createPage(CheatSheetHelpPart.ID, null, null);
+ page.setVerticalSpacing(0);
+ page.setHorizontalMargin(0);
+ helpPart.addPart(CheatSheetHelpPart.ID, new CheatSheetHelpPart(helpPart.getForm().getForm().getBody(), helpPart.getForm().getToolkit(), page.getToolBarManager(), id));
+ page.addPart(CheatSheetHelpPart.ID, true);
+ helpPart.addPage(page);
+ helpPart.showPage(CheatSheetHelpPart.ID);
+
+ /*
+ * Disable the viewer until the tray is closed, then show it again.
+ */
+ control.setVisible(false);
+ Display.getCurrent().removeFilter(SWT.Show, listener);
+
+ helpPart.getControl().addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {
+ control.setVisible(true);
+ Display.getCurrent().addFilter(SWT.Show, listener);
+ checkSavedState();
+ }
+ });
+ }
+ }
+
+ /**
* Disposes of this cheat sheet viewer.
*/
private void dispose() {
+ if (listener != null) {
+ Display.getCurrent().removeFilter(SWT.Show, listener);
+ }
internalDispose();
-
if (busyCursor != null)
busyCursor.dispose();
}
@@ -631,6 +701,17 @@
return (ViewItem) viewItemList.get(index);
}
+ /**
+ * Returns whether or not this viewer contains the given Control, which
+ * is currently in focus.
+ *
+ * @param control the Control currently in focus
+ * @return whether this viewer contains the given Control or not
+ */
+ public boolean hasFocusControl(Control control) {
+ return (control == this.control) || (cheatSheetPage.getForm() == control);
+ }
+
private void initCheatSheetView() {
CheatSheetStopWatch.startStopWatch("CheatSheetViewer.initCheatSheetView()"); //$NON-NLS-1$
//Re-initialize list to store items collapsed by expand/restore action on c.s. toolbar.
@@ -721,8 +802,39 @@
cheatSheetPage.dispose();
}
}
+
+ /**
+ * Returns whether or not the currently active item requires opening a
+ * modal dialog.
+ *
+ * @return whether the current item opens a modal dialog
+ */
+ private boolean isInDialogItem() {
+ ViewItem item = getViewItemAtIndex(currentItemNum);
+ return item.getItem().isDialog();
+ }
/**
+ * Returns whether or not this cheat sheet viewer is inside a modal
+ * dialog.
+ *
+ * @return whether this viewer is inside a modal dialog
+ */
+ public boolean isInDialogMode() {
+ return inDialog;
+ }
+
+ /**
+ * Returns whether the given widget is a TrayDialog.
+ *
+ * @param widget the widget to check
+ * @return whether or not the widget is a TrayDialog
+ */
+ private boolean isTrayDialog(Widget widget) {
+ return (widget instanceof Shell && ((Shell)widget).getData() instanceof TrayDialog);
+ }
+
+ /**
* Read the contents of the welcome page
*/
private boolean readFile() {
Index: src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java,v
retrieving revision 1.27
diff -u -r1.27 CoreItem.java
--- src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java 3 Jun 2005 19:34:07 -0000 1.27
+++ src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java 9 Dec 2005 20:40:01 -0000
@@ -63,7 +63,14 @@
}
private void createButtons(Action action) {
- if (action != null ) {
+ /*
+ * When the cheat sheet is displayed in a dialog's tray, hide
+ * the action that was just invoked to open the dialog.
+ */
+ boolean inDialog = isInDialogMode();
+ boolean isDialogAction = getItem().isDialog();
+ boolean hideAction = isDialogAction && inDialog;
+ if (action != null && !hideAction) {
final ImageHyperlink startButton = createButton(buttonComposite, CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_BUTTON_START), this, itemColor, Messages.PERFORM_TASK_TOOLTIP);
page.getToolkit().adapt(startButton, true, true);
startButton.addHyperlinkListener(new HyperlinkAdapter() {
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF,v
retrieving revision 1.9
diff -u -r1.9 MANIFEST.MF
--- META-INF/MANIFEST.MF 6 Dec 2005 16:44:31 -0000 1.9
+++ META-INF/MANIFEST.MF 9 Dec 2005 20:40:01 -0000
@@ -17,5 +17,6 @@
org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
org.eclipse.help;bundle-version="[3.1.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)",
- org.eclipse.help.base;bundle-version="[3.2.0,4.0.0)";resolution:=optional
+ org.eclipse.help.base;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
+ org.eclipse.help.ui;bundle-version="[3.2.0,4.0.0)";resolution:=optional
Eclipse-LazyStart: true
Index: src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java
===================================================================
RCS file: src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java
diff -N src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.cheatsheets.views;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.help.ui.internal.views.IHelpPart;
+import org.eclipse.help.ui.internal.views.ReusableHelpPart;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.forms.AbstractFormPart;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin;
+import org.eclipse.ui.internal.cheatsheets.Messages;
+
+/**
+ * A help part wrapper that contains a cheat sheet. This is used to display
+ * cheat sheets inside the ReusableHelpPart.
+ */
+public class CheatSheetHelpPart extends AbstractFormPart implements IHelpPart {
+
+ public static final String ID = "cheatsheet-page";
+
+ private CheatSheetViewer viewer;
+ private String id;
+
+ /**
+ * Constructs a new part.
+ *
+ * @param parent the parent Composite that will contain the widgets
+ * @param toolkit the form toolkit to use for creating the widgets
+ * @param tbm the toolbar we will contribute to
+ * @param id the unique id of the cheatsheet to display in the part
+ */
+ public CheatSheetHelpPart(Composite parent, FormToolkit toolkit, IToolBarManager tbm, String id) {
+ viewer = new CheatSheetViewer(true);
+ viewer.setInput(id);
+ viewer.createPartControl(parent);
+ contributeToToolBar(tbm);
+ }
+
+ /**
+ * Contributes any actions we have to the toolbar.
+ *
+ * @param tbm the toolbar to contribute to
+ */
+ private void contributeToToolBar(IToolBarManager tbm) {
+ IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("collapse_expand_all.gif");//$NON-NLS-1$
+ ImageDescriptor collapseExpandImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path);
+ CheatSheetExpandRestoreAction expandRestoreAction = new CheatSheetExpandRestoreAction(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP, false, viewer);
+ expandRestoreAction.setToolTipText(Messages.COLLAPSE_ALL_BUT_CURRENT_TOOLTIP);
+ expandRestoreAction.setImageDescriptor(collapseExpandImage);
+ tbm.insertBefore("back", expandRestoreAction); //$NON-NLS-1$
+ tbm.insertBefore("back", new Separator()); //$NON-NLS-1$
+ viewer.setExpandRestoreAction(expandRestoreAction);
+ }
+
+ /**
+ * This part doesn't require a context menu.
+ */
+ public boolean fillContextMenu(IMenuManager manager) {
+ return false;
+ }
+
+ /**
+ * Returns the part's top Control.
+ */
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ /**
+ * This part doesn't use any global actions.
+ */
+ public IAction getGlobalAction(String id) {
+ return null;
+ }
+
+ /**
+ * Returns the part's unique identifier.
+ *
+ * @param the unique id for the part
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns whether or not this part contains the given Control, which
+ * is in focus.
+ *
+ * @param control the Control in focus
+ */
+ public boolean hasFocusControl(Control control) {
+ return viewer.hasFocusControl(control);
+ }
+
+ /**
+ * Initializes the part.
+ */
+ public void init(ReusableHelpPart parent, String id, IMemento memento) {
+ this.id = id;
+ }
+
+ /**
+ * No filtering required.
+ */
+ public void refilter() {
+ }
+
+ /**
+ * The cheat sheet automatically saves its state; no action required.
+ */
+ public void saveState(IMemento memento) {
+ }
+
+ /**
+ * Sets the visibility of the part.
+ *
+ * @param whether or not the part should be visible
+ */
+ public void setVisible(boolean visible) {
+ viewer.getControl().setVisible(visible);
+ }
+
+ /**
+ * No action needed for this part here.
+ */
+ public void stop() {
+ }
+
+ /**
+ * No action needed for this part here.
+ */
+ public void toggleRoleFilter() {
+ }
+}
#P org.eclipse.jdt
Index: cheatsheets/HelloWorldSWT.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt/cheatsheets/HelloWorldSWT.xml,v
retrieving revision 1.8
diff -u -r1.8 HelloWorldSWT.xml
--- cheatsheets/HelloWorldSWT.xml 27 Nov 2005 18:28:03 -0000 1.8
+++ cheatsheets/HelloWorldSWT.xml 9 Dec 2005 20:40:01 -0000
@@ -33,6 +33,7 @@
-
Since you are creating a standalone SWT application, you need to download
@@ -58,6 +59,7 @@
-
1. Select your Java project and from the context menu select Properties.
@@ -92,6 +95,7 @@
-
- bug 93374
- *******************************************************************************/
-package org.eclipse.help.ui.internal.views;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.help.IContext;
-import org.eclipse.help.ui.internal.IHelpUIConstants;
-import org.eclipse.help.ui.internal.Messages;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.dialogs.IPageChangeProvider;
-import org.eclipse.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.PageChangedEvent;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.HyperlinkGroup;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-
-public class ContextHelpWindow extends Window implements IPageChangedListener {
- private ReusableHelpPart helpPart;
-
- private static final int DOCK_MARGIN = 10;
-
- private static final int CLIP_ALLOWANCE = 5;
-
- private FormToolkit toolkit;
-
- private Listener listener;
-
- private ControlListener parentListener;
-
- private Rectangle savedPbounds;
-
- private Rectangle savedBounds;
-
- private boolean parentResizeBlocked = false;
-
- public ContextHelpWindow(Shell parent) {
- super(parent);
- setShellStyle(SWT.CLOSE | SWT.RESIZE);
- if (!Platform.getWS().equals(Platform.WS_GTK)) {
- parentListener = new ControlListener() {
- public void controlMoved(ControlEvent e) {
- maintainRelativePosition();
- }
-
- public void controlResized(ControlEvent e) {
- onParentWindowResize();
- }
- };
- listener = new Listener() {
- public void handleEvent(Event e) {
- switch (e.type) {
- case SWT.FocusIn:
- case SWT.Selection:
- update((Control) e.widget);
- break;
- case SWT.Move:
- if (onWindowMove())
- e.doit = false;
- break;
- case SWT.Resize:
- onWindowResize();
- break;
- }
- }
- };
- }
- }
-
- public void showSearch() {
- helpPart.showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true);
- }
-
- private void maintainRelativePosition() {
- if (savedPbounds == null || isDocked())
- dock(true);
- else {
- Rectangle pbounds = getShell().getParent().getBounds();
- Rectangle bounds = getShell().getBounds();
- int deltaX = pbounds.x - savedPbounds.x;
- int deltaY = pbounds.y - savedPbounds.y;
- int newX = bounds.x + deltaX;
- int newY = bounds.y + deltaY;
- boolean doDock = false;
- Rectangle dbounds = getShell().getDisplay().getBounds();
- if (newX > dbounds.width - bounds.width) {
- newX = dbounds.width - bounds.width;
- if (pbounds.x + pbounds.width > newX)
- doDock = true;
- } else if (newX < 0)
- doDock = true;
- if (newY > dbounds.height - bounds.height) {
- newY = dbounds.height - bounds.height;
- } else if (newY < 0)
- newY = 0;
- if (doDock) {
- dock(true);
- return;
- }
- getShell().setLocation(newX, newY);
- savedPbounds = pbounds;
- savedBounds = getShell().getBounds();
- }
- }
-
- protected Control createContents(Composite parent) {
- toolkit = new FormToolkit(parent.getDisplay());
- toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(
- HyperlinkGroup.UNDERLINE_HOVER);
- toolkit.getColors().initializeSectionToolBarColors();
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.marginWidth = layout.marginHeight = 0;
- layout.verticalSpacing = 0;
- container.setLayout(layout);
-
- GridData gd;
- ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
- tbm.createControl(container);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
- gd.grabExcessHorizontalSpace = true;
- tbm.getControl().setLayoutData(gd);
- Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.heightHint = 1;
- separator.setLayoutData(gd);
- helpPart = new ReusableHelpPart(PlatformUI.getWorkbench()
- .getProgressService());
- helpPart.init(null, tbm, null, null);
- helpPart.setDefaultContextHelpText(Messages.HelpView_defaultText); //
- helpPart.createControl(container, toolkit);
- helpPart.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- if (!Platform.getWS().equals(Platform.WS_GTK))
- hookListeners();
- helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
- return container;
- }
-
- private void hookListeners() {
- Shell shell = getShell();
- shell.addListener(SWT.Move, listener);
- shell.addListener(SWT.Resize, listener);
- hookPageChangeListener(shell.getParent(), listener);
- shell.getParent().addControlListener(parentListener);
- }
-
- private void unhookListeners() {
- Shell shell = getShell();
- shell.getParent().removeControlListener(parentListener);
- unhookPageChangeListener(shell.getParent(), listener);
- shell.removeListener(SWT.Move, listener);
- shell.removeListener(SWT.Resize, listener);
- }
-
- private void hookPageChangeListener(Composite parent, Listener listener) {
- Object data = parent.getData();
- if (data instanceof IPageChangeProvider) {
- ((IPageChangeProvider) data).addPageChangedListener(this);
- }
- }
-
- private void unhookPageChangeListener(Composite parent, Listener listener) {
- Object data = parent.getData();
- if (data instanceof IPageChangeProvider) {
- ((IPageChangeProvider) data).removePageChangedListener(this);
- }
- }
-
- public void dock(boolean changeSides) {
- getShell().setBounds(computeDockedBounds(changeSides));
- }
-
- public Rectangle computeDockedBounds(boolean changeSides) {
- Display d = getShell().getDisplay();
- Rectangle dbounds = d.getBounds();
- Rectangle pbounds = getShell().getParent().getBounds();
-
- int leftMargin = pbounds.x;
- int rightMargin = dbounds.width - pbounds.x - pbounds.width;
- int centeredLeftMargin = dbounds.width / 2 - pbounds.width / 2;
- boolean rightParent = leftMargin > centeredLeftMargin;
- int currentX = getShell().getLocation().x;
- int newSize = getShell().getSize().x;
- boolean leftOK = newSize <= leftMargin + CLIP_ALLOWANCE;
- boolean rightOK = newSize <= rightMargin + CLIP_ALLOWANCE;
- int x;
- // first try to keep the same side
- if (currentX < pbounds.x && leftOK && (!changeSides || !rightParent)) {
- x = pbounds.x - newSize;
- } else if (currentX > pbounds.x && rightOK
- && (!changeSides || rightParent)) {
- x = pbounds.x + pbounds.width;
- }
- // must switch side
- else if (changeSides) {
- if (rightOK)
- x = pbounds.x + pbounds.width;
- else if (leftOK)
- x = pbounds.x - newSize;
- else {
- // pick the margin that has more space, reduce size
- if (leftMargin > rightMargin) {
- newSize = leftMargin;
- x = pbounds.x - newSize;
- } else {
- newSize = rightMargin;
- x = dbounds.width - newSize;
- }
- }
- } else {
- if (currentX < pbounds.x) {
- newSize = leftMargin;
- x = pbounds.x - newSize;
- } else {
- newSize = rightMargin;
- x = dbounds.width - newSize;
- }
- }
- savedPbounds = pbounds;
- savedBounds = getShell().getBounds();
- return new Rectangle(x, pbounds.y, newSize, pbounds.height);
- }
-
- private boolean onWindowMove() {
- if (savedBounds == null) {
- savedBounds = getShell().getBounds();
- savedPbounds = getShell().getParent().getBounds();
- return false;
- }
- Rectangle bounds = getShell().getBounds();
- Rectangle pbounds = getShell().getParent().getBounds();
- if (bounds.y != savedBounds.y) {
- // vertical move
- if (bounds.y + bounds.height == savedBounds.y + savedBounds.height) {
- // upper edge resize
- if (isDocked()) {
- savedBounds = bounds;
- savedPbounds = pbounds;
- return false;
- }
- }
- }
- boolean doDock = false;
-
- if (bounds.x < pbounds.x) {
- // left
- int deltaX = bounds.x - savedBounds.x;
- if (deltaX > 0 || bounds.x + bounds.width > pbounds.x) {
- // moving closer - check for dock snap
- int distance = pbounds.x - bounds.x - bounds.width;
- if (Math.abs(distance) <= DOCK_MARGIN)
- doDock = true;
- }
- } else {
- // right
- int deltaX = bounds.x - savedBounds.x;
- if (deltaX < 0 || bounds.x < pbounds.x + pbounds.width) {
- // moving closer - check for dock snap
- int distance = bounds.x - pbounds.x - pbounds.width;
- if (Math.abs(distance) <= DOCK_MARGIN)
- doDock = true;
- }
- }
- if (bounds.y + bounds.height < pbounds.y) // above
- doDock = false;
- if (pbounds.y + pbounds.height < bounds.y) // below
- doDock = false;
- if (doDock)
- dock(false);
- savedBounds = getShell().getBounds();
- savedPbounds = getShell().getParent().getBounds();
- return doDock;
- }
-
- private void onWindowResize() {
- if (isDocked()) {
- Rectangle bounds = getShell().getBounds();
- Rectangle pbounds = getShell().getParent().getBounds();
- if (bounds.height != savedBounds.height) {
- Shell parent = (Shell) getShell().getParent();
- if ((parent.getStyle() & SWT.RESIZE) != 0) {
- parentResizeBlocked = true;
- parent.setBounds(pbounds.x, bounds.y, pbounds.width,
- bounds.height);
- parentResizeBlocked = false;
- }
- }
- }
- savedBounds = getShell().getBounds();
- }
-
- private void onParentWindowResize() {
- if (!parentResizeBlocked && isDocked()) {
- Rectangle bounds = getShell().getBounds();
- Rectangle pbounds = getShell().getParent().getBounds();
- if (bounds.x == savedPbounds.x + savedPbounds.width) {
- // right
- if (savedPbounds.x + savedPbounds.width != pbounds.x
- + pbounds.width)
- // right edge moved
- dock(false);
- } else {
- }
- getShell().setSize(getShell().getSize().x,
- getShell().getParent().getSize().y);
- }
- savedPbounds = getShell().getParent().getBounds();
- }
-
- public void update(Control c) {
- helpPart.update(null, c);
- }
-
- public void update(IContext context, Control c) {
- helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
- helpPart.update(context, null, c);
- }
-
- public boolean close() {
- if (!Platform.getWS().equals(Platform.WS_GTK))
- unhookListeners();
- if (super.close()) {
- if (toolkit != null) {
- toolkit.dispose();
- toolkit = null;
- }
- if (helpPart != null) {
- helpPart.dispose();
- helpPart = null;
- }
- return true;
- }
- return false;
- }
-
- private boolean isDocked() {
- if (savedPbounds == null)
- return false;
- return isDocked(savedBounds, savedPbounds);
- }
-
- private boolean isDocked(Rectangle bounds, Rectangle pbounds) {
- if (pbounds.height != bounds.height)
- return false;
- if (bounds.y + bounds.height < pbounds.y) // above
- return false;
- if (pbounds.y + pbounds.height < bounds.y) // below
- return false;
- return bounds.x == pbounds.x + pbounds.width
- || bounds.x == pbounds.x - bounds.width;
- }
-
- public void pageChanged(PageChangedEvent event) {
- Object page = event.getSelectedPage();
- Control c = null;
- if (page instanceof IDialogPage) {
- c = ((IDialogPage) page).getControl();
- } else {
- c = getShell().getDisplay().getFocusControl();
- if (c instanceof TabFolder) {
- TabFolder folder = (TabFolder) c;
- TabItem[] selection = folder.getSelection();
- if (selection.length == 1) {
- c = selection[0].getControl();
- }
- }
- }
- update(null, c);
- }
-}
\ No newline at end of file
Index: src/org/eclipse/help/ui/internal/Messages.properties
===================================================================
RCS file: /home/eclipse/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties,v
retrieving revision 1.12
diff -u -r1.12 Messages.properties
--- src/org/eclipse/help/ui/internal/Messages.properties 14 Jun 2005 21:25:12 -0000 1.12
+++ src/org/eclipse/help/ui/internal/Messages.properties 9 Dec 2005 20:40:01 -0000
@@ -71,6 +71,7 @@
ReusableHelpPart_internalWebBrowserError=Error while opening internal web browser
ReusableHelpPart_openInHelpContentsAction_label=Open in Help &Contents
ReusableHelpPart_copyAction_label=&Copy
+ReusableHelpPart_closeAction_tooltip=Close
ReusableHelpPart_bookmarkAction_label=&Add Bookmark
ReusableHelpPart_internalBrowserTitle=Help
ReusableHelpPart_status = {0} - {1}
Index: src/org/eclipse/help/ui/internal/DefaultHelpUI.java
===================================================================
RCS file: /home/eclipse/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/DefaultHelpUI.java,v
retrieving revision 1.33
diff -u -r1.33 DefaultHelpUI.java
--- src/org/eclipse/help/ui/internal/DefaultHelpUI.java 28 Nov 2005 03:43:06 -0000 1.33
+++ src/org/eclipse/help/ui/internal/DefaultHelpUI.java 9 Dec 2005 20:40:01 -0000
@@ -11,7 +11,6 @@
import java.net.URL;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.help.IContext;
import org.eclipse.help.browser.IBrowser;
@@ -20,14 +19,14 @@
import org.eclipse.help.internal.base.IHelpBaseConstants;
import org.eclipse.help.ui.internal.util.ErrorUtil;
import org.eclipse.help.ui.internal.views.ContextHelpPart;
-import org.eclipse.help.ui.internal.views.ContextHelpWindow;
+import org.eclipse.help.ui.internal.views.HelpTray;
import org.eclipse.help.ui.internal.views.HelpView;
+import org.eclipse.help.ui.internal.views.ReusableHelpPart;
+import org.eclipse.jface.dialogs.DialogTray;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -55,7 +54,6 @@
public class DefaultHelpUI extends AbstractHelpUI {
private ContextHelpDialog f1Dialog = null;
- private ContextHelpWindow f1Window = null;
private static DefaultHelpUI instance;
private static final String HELP_VIEW_ID = "org.eclipse.help.ui.HelpView"; //$NON-NLS-1$
@@ -160,9 +158,9 @@
// check the dialog
if (activeShell != null) {
Object data = activeShell.getData();
- if (data instanceof Window) {
+ if (data instanceof TrayDialog) {
IContext context = ContextHelpPart.findHelpContext(c);
- displayContextAsHelpPane(activeShell, context);
+ displayContextAsHelpTray(activeShell, context);
return;
}
}
@@ -199,7 +197,7 @@
if (activeShell != null) {
Object data = activeShell.getData();
if (data instanceof Window) {
- displayContextAsHelpPane(activeShell, null);
+ displayContextAsHelpTray(activeShell, null);
return;
}
}
@@ -277,7 +275,7 @@
if (activeShell != null) {
Object data = activeShell.getData();
if (data instanceof Window && (!dinfopop || noInfopop)) {
- displayContextAsHelpPane(activeShell, context);
+ displayContextAsHelpTray(activeShell, context);
return;
}
}
@@ -322,36 +320,28 @@
f1Dialog.open();
}
- private void displayContextAsHelpPane(Shell activeShell, IContext context) {
- Control c = activeShell.getDisplay().getFocusControl();
- if (f1Window != null) {
- Shell parentShell = activeShell;
- if (activeShell.getData() instanceof ContextHelpWindow)
- parentShell = (Shell) activeShell.getParent();
- if (f1Window.getShell().getParent().equals(parentShell)) {
- f1Window.update(context, c);
- return;
+ private void displayContextAsHelpTray(Shell activeShell, IContext context) {
+ Control controlInFocus = activeShell.getDisplay().getFocusControl();
+ TrayDialog dialog = (TrayDialog)activeShell.getData();
+
+ DialogTray tray = dialog.getTray();
+ if (tray == null) {
+ tray = new HelpTray();
+ dialog.openTray(tray);
+ }
+ if (tray instanceof HelpTray) {
+ ReusableHelpPart helpPart = ((HelpTray)tray).getHelpPart();
+ if (context != null) {
+ helpPart.showPage(IHelpUIConstants.HV_CONTEXT_HELP_PAGE);
+ helpPart.update(context, null, controlInFocus);
}
- }
- Rectangle pbounds = activeShell.getBounds();
- f1Window = new ContextHelpWindow(activeShell);
- f1Window.create();
- Shell helpShell = f1Window.getShell();
- helpShell.setText(Messages.DefaultHelpUI_wtitle);
- helpShell.setSize(300, pbounds.height);
- if (context != null)
- f1Window.update(context, c);
- else
- f1Window.showSearch();
- if (!Platform.getWS().equals(Platform.WS_GTK))
- f1Window.dock(true);
- helpShell.addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- f1Window = null;
+ else {
+ helpPart.showPage(IHelpUIConstants.HV_FSEARCH_PAGE, true);
}
- });
- helpShell.open();
+ }
+ else {
+ // someone else was occupying the tray; not supported
+ }
}
/**
Index: src/org/eclipse/help/ui/internal/Messages.java
===================================================================
RCS file: /home/eclipse/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java,v
retrieving revision 1.7
diff -u -r1.7 Messages.java
--- src/org/eclipse/help/ui/internal/Messages.java 14 Jun 2005 21:25:11 -0000 1.7
+++ src/org/eclipse/help/ui/internal/Messages.java 9 Dec 2005 20:40:01 -0000
@@ -55,6 +55,7 @@
public static String ReusableHelpPart_openInfoCenterAction_label;
public static String ReusableHelpPart_openAction_label;
public static String ReusableHelpPart_openInHelpContentsAction_label;
+ public static String ReusableHelpPart_closeAction_tooltip;
public static String ReusableHelpPart_copyAction_label;
public static String ReusableHelpPart_bookmarkAction_label;
public static String ReusableHelpPart_status;
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /home/eclipse/org.eclipse.help.ui/META-INF/MANIFEST.MF,v
retrieving revision 1.7
diff -u -r1.7 MANIFEST.MF
--- META-INF/MANIFEST.MF 22 Nov 2005 22:17:19 -0000 1.7
+++ META-INF/MANIFEST.MF 9 Dec 2005 20:40:01 -0000
@@ -13,7 +13,7 @@
org.eclipse.help.ui.internal.browser.embedded;x-internal:=true,
org.eclipse.help.ui.internal.search;x-internal:=true,
org.eclipse.help.ui.internal.util;x-internal:=true,
- org.eclipse.help.ui.internal.views;x-internal:=true
+ org.eclipse.help.ui.internal.views;x-friends:="org.eclipse.ui.cheatsheets"
Require-Bundle: org.eclipse.help.base;bundle-version="[3.1.0,4.0.0)",
org.eclipse.help.appserver;bundle-version="[3.1.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
Index: src/org/eclipse/help/ui/internal/views/HelpTray.java
===================================================================
RCS file: src/org/eclipse/help/ui/internal/views/HelpTray.java
diff -N src/org/eclipse/help/ui/internal/views/HelpTray.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/help/ui/internal/views/HelpTray.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.ui.internal.views;
+
+import org.eclipse.help.ui.internal.IHelpUIConstants;
+import org.eclipse.help.ui.internal.Messages;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.dialogs.DialogTray;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IPageChangeProvider;
+import org.eclipse.jface.dialogs.IPageChangedListener;
+import org.eclipse.jface.dialogs.PageChangedEvent;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.PaletteData;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.HyperlinkGroup;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * The tray that appears on the side of dialogs when the user summons context
+ * help or a cheat sheet follows the user into a dialog.
+ */
+public class HelpTray extends DialogTray implements IPageChangedListener {
+
+ private static final int DEFAULT_WIDTH = 210;
+ private FormToolkit toolkit;
+ private ReusableHelpPart helpPart;
+ private Shell shell;
+ private IContributionItem closeAction;
+ private Image normal;
+ private Image hover;
+
+ /**
+ * Creates any actions needed by the tray.
+ */
+ private void createActions() {
+ createImages();
+ closeAction = new ContributionItem() {
+ public void fill(ToolBar parent, int index) {
+ final ToolItem item = new ToolItem(parent, SWT.PUSH);
+ item.setImage(normal);
+ item.setHotImage(hover);
+ item.setToolTipText(Messages.ReusableHelpPart_closeAction_tooltip);
+ item.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ TrayDialog dialog = (TrayDialog)shell.getData();
+ dialog.closeTray();
+ }
+ });
+ }
+ };
+ }
+
+ /**
+ * Creates the contents of the tray.
+ *
+ * @param parent the parent composite that will contain the tray
+ */
+ protected Control createContents(Composite parent) {
+ toolkit = new FormToolkit(parent.getDisplay());
+ toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkGroup.UNDERLINE_HOVER);
+ toolkit.getColors().initializeSectionToolBarColors();
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ layout.verticalSpacing = 0;
+ container.setLayout(layout);
+ container.addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {
+ dispose();
+ }
+ });
+
+ ToolBarManager tbm = new ToolBarManager(SWT.FLAT);
+ tbm.createControl(container);
+ GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gd.grabExcessHorizontalSpace = true;
+ tbm.getControl().setLayoutData(gd);
+ Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.heightHint = 1;
+ separator.setLayoutData(gd);
+ helpPart = new ReusableHelpPart(PlatformUI.getWorkbench().getProgressService());
+ helpPart.init(null, tbm, null, null);
+ helpPart.setDefaultContextHelpText(Messages.HelpView_defaultText);
+ helpPart.createControl(container, toolkit);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = DEFAULT_WIDTH;
+ helpPart.getControl().setLayoutData(gd);
+
+ createActions();
+ tbm.add(closeAction);
+
+ shell = parent.getShell();
+ hookPageChangeListener(shell);
+ helpPart.getControl().addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {
+ unhookPageChangeListener(shell);
+ }
+ });
+
+ return container;
+ }
+
+ /**
+ * Creates any custom needed by the tray, such as the close button.
+ */
+ private void createImages() {
+ Display display = Display.getCurrent();
+ int[] shape = new int[] {
+ 3, 3, 5, 3, 7, 5, 8, 5, 10, 3, 12, 3,
+ 12, 5, 10, 7, 10, 8, 12,10, 12,12,
+ 10,12, 8, 10, 7, 10, 5, 12, 3, 12,
+ 3, 10, 5, 8, 5, 7, 3, 5
+ };
+
+ /*
+ * Use magenta as transparency color since it is used infrequently.
+ */
+ Color border = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
+ Color background = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+ Color backgroundHot = new Color(display, new RGB(252, 160, 160));
+ Color transparent = display.getSystemColor(SWT.COLOR_MAGENTA);
+
+ PaletteData palette = new PaletteData(new RGB[] { transparent.getRGB(), border.getRGB(), background.getRGB(), backgroundHot.getRGB() });
+ ImageData data = new ImageData(16, 16, 8, palette);
+ data.transparentPixel = 0;
+
+ normal = new Image(display, data);
+ normal.setBackground(transparent);
+ GC gc = new GC(normal);
+ gc.setBackground(background);
+ gc.fillPolygon(shape);
+ gc.setForeground(border);
+ gc.drawPolygon(shape);
+ gc.dispose();
+
+ hover = new Image(display, data);
+ hover.setBackground(transparent);
+ gc = new GC(hover);
+ gc.setBackground(backgroundHot);
+ gc.fillPolygon(shape);
+ gc.setForeground(border);
+ gc.drawPolygon(shape);
+ gc.dispose();
+
+ backgroundHot.dispose();
+ }
+
+ /**
+ * Disposes any resources used by the tray.
+ */
+ private void dispose() {
+ normal.dispose();
+ hover.dispose();
+ toolkit.dispose();
+ helpPart.dispose();
+ }
+
+ /**
+ * Returns the ReusableHelpPart contained in the tray.
+ *
+ * @return the tray's ReusableHelpPart
+ */
+ public ReusableHelpPart getHelpPart() {
+ return helpPart;
+ }
+
+ /**
+ * Add the listener that gets notified of page changes (to automatically
+ * update context help).
+ *
+ * @param parent the Composite to hook the listener to
+ */
+ private void hookPageChangeListener(Composite parent) {
+ Object data = parent.getData();
+ if (data instanceof IPageChangeProvider) {
+ ((IPageChangeProvider)data).addPageChangedListener(this);
+ }
+ }
+
+ /**
+ * Called whenever the dialog we're inside has changed pages. This updates
+ * the context help page if it is visible.
+ *
+ * @param event the page change event
+ */
+ public void pageChanged(PageChangedEvent event) {
+ if (IHelpUIConstants.HV_CONTEXT_HELP_PAGE.equals(helpPart.getCurrentPageId())) {
+ Object page = event.getSelectedPage();
+ Control c = null;
+ if (page instanceof IDialogPage) {
+ c = ((IDialogPage) page).getControl();
+ } else {
+ c = shell.getDisplay().getFocusControl();
+ if (c instanceof TabFolder) {
+ TabFolder folder = (TabFolder) c;
+ TabItem[] selection = folder.getSelection();
+ if (selection.length == 1) {
+ c = selection[0].getControl();
+ }
+ }
+ }
+ helpPart.update(null, null, c);
+ }
+ }
+
+ /**
+ * Remove the listener that gets notified of page changes (to automatically
+ * update context help).
+ *
+ * @param parent the Composite that had the listener
+ */
+ private void unhookPageChangeListener(Composite parent) {
+ Object data = parent.getData();
+ if (data instanceof IPageChangeProvider) {
+ ((IPageChangeProvider)data).removePageChangedListener(this);
+ }
+ }
+}
Index: src/org/eclipse/help/ui/internal/views/IHelpPartPage.java
===================================================================
RCS file: src/org/eclipse/help/ui/internal/views/IHelpPartPage.java
diff -N src/org/eclipse/help/ui/internal/views/IHelpPartPage.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/help/ui/internal/views/IHelpPartPage.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.help.ui.internal.views;
+
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.ui.IMemento;
+
+public interface IHelpPartPage {
+ void addPart(String id, boolean flexible);
+ void addPart(String id, boolean flexible, boolean grabVertical);
+ boolean canOpen();
+ void dispose();
+ IHelpPart findPart(String id);
+ int getHorizontalMargin();
+ String getIconId();
+ String getId();
+ int getNumberOfFlexibleParts();
+ String getText();
+ IToolBarManager getToolBarManager();
+ int getVerticalSpacing();
+ void refilter();
+ void saveState(IMemento memento);
+ void setFocus();
+ void setHorizontalMargin(int value);
+ void setVerticalSpacing(int value);
+ void setVisible(boolean visible);
+ void stop();
+ void toggleRoleFilter();
+}
#P org.eclipse.pde
Index: cheatsheets/updates.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde/cheatsheets/updates.xml,v
retrieving revision 1.8
diff -u -r1.8 updates.xml
--- cheatsheets/updates.xml 17 Jun 2004 19:42:28 -0000 1.8
+++ cheatsheets/updates.xml 9 Dec 2005 20:40:02 -0000
@@ -31,6 +31,7 @@
-
-
-
When ready to test the feature itself, install
@@ -181,6 +186,7 @@
-
Upon restart, select Help->Software Updates->Manage Configuration....
Index: cheatsheets/rcpapp.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde/cheatsheets/rcpapp.xml,v
retrieving revision 1.4
diff -u -r1.4 rcpapp.xml
--- cheatsheets/rcpapp.xml 24 Jun 2005 01:54:06 -0000 1.4
+++ cheatsheets/rcpapp.xml 9 Dec 2005 20:40:02 -0000
@@ -15,6 +15,7 @@
-
The product configuration editor also allows you to export RCP
Index: cheatsheets/helloworld.xml
===================================================================
RCS file: /home/eclipse/org.eclipse.pde/cheatsheets/helloworld.xml,v
retrieving revision 1.6
diff -u -r1.6 helloworld.xml
--- cheatsheets/helloworld.xml 19 Oct 2005 00:21:08 -0000 1.6
+++ cheatsheets/helloworld.xml 9 Dec 2005 20:40:02 -0000
@@ -16,6 +16,7 @@
-