### 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.5 diff -u -r1.5 CVS_1.xml --- cheatsheets/CVS_1.xml 9 Dec 2005 21:16:46 -0000 1.5 +++ cheatsheets/CVS_1.xml 13 Dec 2005 19:36:05 -0000 @@ -18,8 +18,7 @@ + title="Load the Destination into your Workspace"> 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. @@ -27,8 +26,7 @@ + title="Merge Details"> 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.jdt Index: cheatsheets/HelloWorldSWT.xml =================================================================== RCS file: /home/eclipse/org.eclipse.jdt/cheatsheets/HelloWorldSWT.xml,v retrieving revision 1.9 diff -u -r1.9 HelloWorldSWT.xml --- cheatsheets/HelloWorldSWT.xml 9 Dec 2005 21:16:46 -0000 1.9 +++ cheatsheets/HelloWorldSWT.xml 13 Dec 2005 19:36:06 -0000 @@ -33,7 +33,6 @@ Since you are creating a standalone SWT application, you need to download @@ -59,7 +58,6 @@ 1. Select your Java project and from the context menu select Properties. @@ -95,7 +92,6 @@ - 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); + } +} #P org.eclipse.pde Index: cheatsheets/updates.xml =================================================================== RCS file: /home/eclipse/org.eclipse.pde/cheatsheets/updates.xml,v retrieving revision 1.9 diff -u -r1.9 updates.xml --- cheatsheets/updates.xml 9 Dec 2005 21:16:45 -0000 1.9 +++ cheatsheets/updates.xml 13 Dec 2005 19:36:12 -0000 @@ -31,7 +31,6 @@ When ready to test the feature itself, install @@ -186,7 +181,6 @@ 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.5 diff -u -r1.5 rcpapp.xml --- cheatsheets/rcpapp.xml 9 Dec 2005 21:16:45 -0000 1.5 +++ cheatsheets/rcpapp.xml 13 Dec 2005 19:36:12 -0000 @@ -15,7 +15,6 @@ 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.7 diff -u -r1.7 helloworld.xml --- cheatsheets/helloworld.xml 9 Dec 2005 21:16:45 -0000 1.7 +++ cheatsheets/helloworld.xml 13 Dec 2005 19:36:12 -0000 @@ -16,7 +16,6 @@ * */ 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.16 diff -u -r1.16 CheatSheetParser.java --- src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java 9 Dec 2005 21:19:51 -0000 1.16 +++ src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java 13 Dec 2005 19:36:12 -0000 @@ -505,8 +505,6 @@ 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/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 --- src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetHelpPart.java 9 Dec 2005 21:19:51 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,150 +0,0 @@ -/******************************************************************************* - * 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() { - } -} 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.29 diff -u -r1.29 CheatSheetView.java --- src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java 9 Dec 2005 21:19:51 -0000 1.29 +++ src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetView.java 13 Dec 2005 19:36:12 -0000 @@ -94,7 +94,7 @@ public void createPartControl(Composite parent) { CheatSheetStopWatch.startStopWatch("CheatSheetView.createPartControl"); //$NON-NLS-1$ - viewer = new CheatSheetViewer(false); + viewer = new CheatSheetViewer(); 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.35 diff -u -r1.35 ViewItem.java --- src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java 9 Dec 2005 21:19:51 -0000 1.35 +++ src/org/eclipse/ui/internal/cheatsheets/views/ViewItem.java 13 Dec 2005 19:36:12 -0000 @@ -333,16 +333,6 @@ 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.34 diff -u -r1.34 CheatSheetViewer.java --- src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java 9 Dec 2005 21:19:51 -0000 1.34 +++ src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java 13 Dec 2005 19:36:12 -0000 @@ -24,11 +24,7 @@ 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; @@ -39,11 +35,7 @@ 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; @@ -90,24 +82,19 @@ private ArrayList viewItemList = new ArrayList(); //Composites - protected Composite control; + private 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(boolean inDialog) { + public CheatSheetViewer() { currentItemNum = -1; - this.inDialog = inDialog; saveHelper = new CheatSheetSaveHelper(); } @@ -553,21 +540,6 @@ 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); @@ -583,53 +555,11 @@ } /** - * 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(); } @@ -701,17 +631,6 @@ 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. @@ -802,39 +721,8 @@ 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.28 diff -u -r1.28 CoreItem.java --- src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java 9 Dec 2005 21:19:51 -0000 1.28 +++ src/org/eclipse/ui/internal/cheatsheets/views/CoreItem.java 13 Dec 2005 19:36:12 -0000 @@ -63,14 +63,7 @@ } private void createButtons(Action action) { - /* - * 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) { + if (action != null ) { 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: 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.5 diff -u -r1.5 CheatSheetViewerFactory.java --- src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java 9 Dec 2005 21:19:51 -0000 1.5 +++ src/org/eclipse/ui/cheatsheets/CheatSheetViewerFactory.java 13 Dec 2005 19:36:12 -0000 @@ -37,6 +37,6 @@ * @return a new cheat sheet viewer */ public static ICheatSheetViewer createCheatSheetView() { - return new CheatSheetViewer(false); + return new CheatSheetViewer(); } } Index: schema/cheatSheetContentFileSpec.html =================================================================== RCS file: /home/eclipse/org.eclipse.ui.cheatsheets/schema/cheatSheetContentFileSpec.html,v retrieving revision 1.15 diff -u -r1.15 cheatSheetContentFileSpec.html --- schema/cheatSheetContentFileSpec.html 9 Dec 2005 21:19:51 -0000 1.15 +++ schema/cheatSheetContentFileSpec.html 13 Dec 2005 19:36:12 -0000 @@ -11,7 +11,7 @@

Cheat Sheet Content File XML Format

-

Version 3.2

+

Version 3.0

This document describes the cheat sheet content file structure as a series of DTD fragments (machine readable XML schema).

cheatsheet

@@ -70,7 +70,6 @@
<!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
@@ -80,9 +79,6 @@
 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
  • @@ -326,8 +322,8 @@ <intro> <description>Example cheat sheet with two steps.</description> </intro> - <item title="Step 1" dialog="true"> - <description>This is a step with an action that involves opening a modal dialog.</description> + <item title="Step 1"> + <description>This is a step with an action.</description> <action class="com.xyz.myaction" pluginId="com.xyz"/> </item> <item title="Step 2"> @@ -337,7 +333,7 @@