diff options
Diffstat (limited to 'org.eclipse.ui.cheatsheets')
33 files changed, 1005 insertions, 384 deletions
diff --git a/org.eclipse.ui.cheatsheets/icons/obj16/task_choice.gif b/org.eclipse.ui.cheatsheets/icons/obj16/task_choice.gif Binary files differnew file mode 100644 index 000000000..11e6e5cb1 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/icons/obj16/task_choice.gif diff --git a/org.eclipse.ui.cheatsheets/icons/obj16/task_sequence.gif b/org.eclipse.ui.cheatsheets/icons/obj16/task_sequence.gif Binary files differnew file mode 100644 index 000000000..082e49fbe --- /dev/null +++ b/org.eclipse.ui.cheatsheets/icons/obj16/task_sequence.gif diff --git a/org.eclipse.ui.cheatsheets/icons/obj16/task_set.gif b/org.eclipse.ui.cheatsheets/icons/obj16/task_set.gif Binary files differnew file mode 100644 index 000000000..d3d10f5aa --- /dev/null +++ b/org.eclipse.ui.cheatsheets/icons/obj16/task_set.gif diff --git a/org.eclipse.ui.cheatsheets/icons/ovr16/task_skipped.gif b/org.eclipse.ui.cheatsheets/icons/ovr16/task_skipped.gif Binary files differnew file mode 100644 index 000000000..2a8fc224c --- /dev/null +++ b/org.eclipse.ui.cheatsheets/icons/ovr16/task_skipped.gif diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ICompositeCheatSheetTask.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ICompositeCheatSheetTask.java index 09737ca96..3bb7412ec 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ICompositeCheatSheetTask.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ICompositeCheatSheetTask.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 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 @@ -11,8 +11,6 @@ package org.eclipse.ui.cheatsheets; -import java.net.MalformedURLException; -import java.net.URL; import java.util.Dictionary; /** @@ -34,9 +32,13 @@ public interface ICompositeCheatSheetTask { */ public static final int IN_PROGRESS = 1; /** + * The constant that indicates that the task has been skipped. + */ + public static final int SKIPPED = 2; + /** * The constant that indicates that the task has been completed. */ - public static final int COMPLETED = 2; + public static final int COMPLETED = 3; /** * @return the unique identifier of this task. */ @@ -46,9 +48,7 @@ public interface ICompositeCheatSheetTask { */ public String getName(); /** - * Returns the kind of the task editor. Tasks without - * editor kind are 'informational' tasks because they - * cannot be 'completed'. + * Returns the kind of the task editor or task group. * @return task editor kind or <code>null</code> if no editor * is assoticated with this task. */ @@ -67,12 +67,23 @@ public interface ICompositeCheatSheetTask { * @see org.eclipse.ui.forms.widgets.FormText */ public String getDescription(); + /** - * Returns an array of subtasks that are children of this task. - * The array will be empty if this is a leaf task. + * Gets the text to be displayed when this task is completed + * @return a plain String, or XML markup that can + * be understood by FormText widget. + * @see org.eclipse.ui.forms.widgets.FormText + */ + public String getCompletionMessage(); + + /** + * Get the subtasks of this task. Each subtask may be + * a task group or editable task. If the task is an editable task + * there will be no children and an empty array will be returned. * @return an array of subtasks for this task */ public ICompositeCheatSheetTask [] getSubtasks(); + /** * get the tasks which are required to be completed * before this task is started. @@ -81,60 +92,20 @@ public interface ICompositeCheatSheetTask { * empty if this tasks is independent of other tasks. */ public ICompositeCheatSheetTask [] getRequiredTasks(); - - /** - * Get the state of this task - * @return NOT_STARTED, IN_PROGRESS or COMPLETED. - */ - public int getState(); - - /** - * Returns the percentage of this task that has been - * completed. - * @return A task that has not been - * started yet has '0' as result. A task that has been - * completed must return '100' as a result. Anything - * in between represents a task in various stages of - * completion. - */ - public int getPercentageComplete(); - - /** - * Set the percentage of the task that has been completed - * @param percentageComplete an integer between 0 and 100 - */ - public void setPercentageComplete(int percentageComplete); - - /** - * Advance the state of this task - */ - public void advanceState(); - - /** - * Gets the text to be displayed when this task is completed - * @return a plain String, or XML markup that can - * be understood by FormText widget. - * @see org.eclipse.ui.forms.widgets.FormText - */ - public String getCompletionMessage(); - + /** - * Determine whether this task can be started. - * @return true unless this task depends on a required task that has - * not been completed. + * Determine whether the required tasks for this task have + * all been completed. + * @return true if there are noi required tasks or all required + * tasks have been completed. */ - public boolean isStartable(); + public boolean requiredTasksCompleted(); /** - * Gets a URL which can be used to open the content file for this - * task if the content file can be specified by a path relative to - * the content file for the composite cheat sheet which contains it. - * @param path a relative path - * @throws MalformedURLException - * @return a URL which represents a location relative to the - * location of the content file for the composite cheat sheet. + * Get the state of this task + * @return NOT_STARTED, IN_PROGRESS, SKIPPED or COMPLETED. */ - public URL getInputUrl(String path) throws MalformedURLException; + public int getState(); /** * Get the enclosing composite cheat sheet diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/IEditableTask.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/IEditableTask.java new file mode 100644 index 000000000..01a59fc24 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/IEditableTask.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2006 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.cheatsheets; + +import java.net.MalformedURLException; +import java.net.URL; + +/** + * An editable task within a composite cheatsheet. An editable task is associated + * with a task editor and the task editor is responsible for completing the task. + * <p> + * This interface is not intended to be implemented by clients. + * </p> + * @since 3.2 + */ + +public interface IEditableTask extends ICompositeCheatSheetTask { + + /** + * Set the state of this task to COMPLETED + */ + public void complete(); + + /** + * Gets a URL which can be used to open the content file for this + * task if the content file can be specified by a path relative to + * the content file for the composite cheat sheet which contains it. + * @param path a relative path + * @throws MalformedURLException + * @return a URL which represents a location relative to the + * location of the content file for the composite cheat sheet. + */ + public URL getInputUrl(String path) throws MalformedURLException; + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskGroup.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskGroup.java new file mode 100644 index 000000000..2e062b608 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskGroup.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2005, 2006 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.cheatsheets; + +/** + * A group of tasks within a composite cheatsheet. Each taskGroup will have + * children. It does not have an editor and its state is determined from the + * state of its children. + * * <p> + * This interface is not intended to be implemented by clients. + * </p> + * @since 3.2 + */ + +public interface ITaskGroup extends ICompositeCheatSheetTask { + + /** + * A task kind of <b>set</b> indicates that this task is complete when + * all subtasks have been completed. + */ + public static final String SET = "set"; //$NON-NLS-1$ + + /** + * A task kind of <b>set</b> indicates that this task is complete when + * all subtasks have been completed. The subtasks must be completed in + * order. + */ + public static final String SEQUENCE = "sequence"; //$NON-NLS-1$ + + /** + * A task kind of <b>choice</b> indicates that this task is complete when + * any of its children has been completed. + */ + public static final String CHOICE = "choice"; //$NON-NLS-1$ + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskEditor.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/TaskEditor.java index 389c735c2..139c4f9a6 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskEditor.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/TaskEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 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 @@ -24,37 +24,36 @@ import org.eclipse.ui.forms.widgets.FormToolkit; * @since 3.2 */ -public interface ITaskEditor { +public abstract class TaskEditor { /** * Creates the widget * @param parent * @param toolkit */ - public void createControl(Composite parent, FormToolkit toolkit); + public abstract void createControl(Composite parent, FormToolkit toolkit); /** * @return the Control created by a previous call to CreateControl() */ - public Control getControl(); + public abstract Control getControl(); /** * Starts editing the provided task. The editor is responsible - * for setting the 'percentage complete' state of the task and - * saving its state. createControl() will always be called before setInput(). + * for saving its state. createControl() will always be called before setInput(). + * @param task The task associated with this editor + * @param memento The state of this task saved from a previous invocation. * The memento will be <b>null</b> if the task has not been previously started * or if it is being restarted. If the editor is being restored from a previous * session the memento will contain the last saved state. - * @param task The task associated with this editor - * @param memento The state of this task saved from a previous invocation, may be null. */ - public void setInput(ICompositeCheatSheetTask task, IMemento memento); + public abstract void setInput(IEditableTask task, IMemento memento); /** * Saves the object state within a memento. * * @param memento a memento to receive the object state */ - public void saveState(IMemento memento); + public abstract void saveState(IMemento memento); } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskExplorer.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/TaskExplorer.java index 30bbe1ac1..8ebeb426b 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/ITaskExplorer.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/cheatsheets/TaskExplorer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 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 @@ -18,18 +18,18 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.forms.widgets.FormToolkit; /** - * Classes that implement this interface are responsible for rendering the + * Classes that extend this class are responsible for rendering the * hierarchy of tasks in the composite cheat sheet. They must support task * selection via the selection provider, be able to accept focus, and create * control when asked. */ -public interface ITaskExplorer { +public abstract class TaskExplorer { /** * @return the id of this TaskExplorer which must match the id used in the * extension point */ - String getId(); + public abstract String getId(); /** * Create a control which will display the structure of the composite cheat @@ -38,19 +38,19 @@ public interface ITaskExplorer { * @param parent * @param toolkit */ - void createControl(Composite parent, FormToolkit toolkit); + public abstract void createControl(Composite parent, FormToolkit toolkit); /** * Get the control created by a previous call to createControl * * @return the task explorer control */ - Control getControl(); + public abstract Control getControl(); /** * Called when the explorer gains focus. */ - void setFocus(); + public abstract void setFocus(); /** * Get the selection provider for this explorer. The selections returned by @@ -58,7 +58,7 @@ public interface ITaskExplorer { * * @return the selection provider for the task explorer */ - ISelectionProvider getSelectionProvider(); + public abstract ISelectionProvider getSelectionProvider(); /** * Sets the composite cheat sheet to be displayed. createControl will @@ -66,13 +66,13 @@ public interface ITaskExplorer { * * @param compositeCheatSheet */ - void setCompositeCheatSheet(ICompositeCheatSheet compositeCheatSheet); + public abstract void setCompositeCheatSheet(ICompositeCheatSheet compositeCheatSheet); /** * Called after this explorer is no longer in use. Any resources should be * disposed of at this point. */ - void dispose(); + public abstract void dispose(); /** * Called when the state of a task changes and the representation of the @@ -80,7 +80,7 @@ public interface ITaskExplorer { * * @param task */ - void taskUpdated(ICompositeCheatSheetTask task); + public abstract void taskUpdated(ICompositeCheatSheetTask task); /** * Called to set the provided selection and optionally reveal it @@ -91,5 +91,5 @@ public interface ITaskExplorer { * @param reveal if <code>true</code>, expose the task if hidden; * otherwise, just select. */ - void setSelection(ISelection selection, boolean reveal); -}
\ No newline at end of file + public abstract void setSelection(ISelection selection, boolean reveal); +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.java index 1ca5e6725..c74a9ef40 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.java @@ -116,6 +116,7 @@ public final class Messages extends NLS { public static String COMPOSITE_PAGE_REVIEW_TASK; public static String COMPOSITE_PAGE_GOTO_TASK; public static String COMPOSITE_PAGE_START_TASK; + public static String COMPOSITE_PAGE_SKIP_TASK; public static String COMPOSITE_PAGE_BLOCKED; public static String COMPOSITE_PAGE_TASK_NOT_COMPLETE; public static String EXPLORER_PULLDOWN_MENU; @@ -123,6 +124,7 @@ public final class Messages extends NLS { public static String COMPOSITE_RESTART_CONFIRM_MESSAGE; public static String RESTART_ALL_MENU; public static String RESTART_MENU; + public static String ERROR_EDITABLE_TASK_WITH_CHILDREN; static { NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.properties b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.properties index d9323bf60..814a47d16 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.properties +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/Messages.properties @@ -151,7 +151,7 @@ SELECTION_DIALOG_OPEN_FROM_FILE = Open cheat sheet from content file # Composite Cheatsheets ERROR_MULTIPLE_ERRORS = Multiple errors detected. ERROR_PARSING_ROOT_NODE_TYPE = Root node is not ''{0}''. -COMPLETED_TASK = Completed task ''{0}''. +COMPLETED_TASK = Task ''{0}'' has been completed. ERROR_PARSING_DUPLICATE_TASK_ID = Duplicate task id ''{0}''. ERROR_PARSING_NO_VALUE = Parameter has no value. ERROR_PARSING_NO_NAME = Parameter has no name. @@ -162,10 +162,12 @@ ERROR_PARSING_INVALID_ID = Invalid id ''{0}'' in dependency. ERROR_PARSING_CYCLE_DETECTED = Cycle detected in task dependencies. ERROR_PARSING_CYCLE_CONTAINS = Cycle includes task with Id ''{0}'' ERROR_SAVING_STATE_REFERENCE = Error saving reference to state file +ERROR_EDITABLE_TASK_WITH_CHILDREN = The editable task ''{0}'' may not have child tasks. COMPOSITE_PAGE_REVIEW_TASK = Review this task COMPOSITE_PAGE_GOTO_TASK = Go to task ''{0}'' COMPOSITE_PAGE_START_TASK = Start working on this task +COMPOSITE_PAGE_SKIP_TASK = Skip this task COMPOSITE_PAGE_BLOCKED = This task cannot be started until all prerequisite tasks are completed. COMPOSITE_PAGE_TASK_NOT_COMPLETE = Task ''{0}'' is not complete COMPOSITE_RESTART_DIALOG_TITLE = Restart Composite Cheat Sheet diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeContentProvider.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeContentProvider.java index 4662a9c70..1cbaf6e5b 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeContentProvider.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeContentProvider.java @@ -13,8 +13,8 @@ package org.eclipse.ui.internal.cheatsheets.composite.explorer; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; import org.eclipse.ui.cheatsheets.ICompositeCheatSheet; +import org.eclipse.ui.cheatsheets.ITaskGroup; class TreeContentProvider implements ITreeContentProvider { public Object[] getChildren(Object parentElement) { @@ -22,8 +22,8 @@ class TreeContentProvider implements ITreeContentProvider { final Object[] rootTask = {((ICompositeCheatSheet) parentElement).getRootTask()}; return rootTask; } - if (parentElement instanceof ICompositeCheatSheetTask) - return ((ICompositeCheatSheetTask) parentElement).getSubtasks(); + if (parentElement instanceof ITaskGroup) + return ((ITaskGroup) parentElement).getSubtasks(); return new Object[0]; } @@ -34,8 +34,8 @@ class TreeContentProvider implements ITreeContentProvider { public boolean hasChildren(Object element) { if (element instanceof ICompositeCheatSheet) return true; - if (element instanceof ICompositeCheatSheetTask) - return ((ICompositeCheatSheetTask) element).getSubtasks().length > 0; + if (element instanceof ITaskGroup) + return ((ITaskGroup) element).getSubtasks().length > 0; return false; } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java index 5a914242f..b4db191b8 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeLabelProvider.java @@ -23,6 +23,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; +import org.eclipse.ui.cheatsheets.ITaskGroup; import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.composite.views.TaskEditorManager; import org.osgi.framework.Bundle; @@ -62,15 +63,22 @@ public class TreeLabelProvider extends LabelProvider { } public String getText(Object obj) { - if (obj instanceof ICompositeCheatSheetTask) - return ((ICompositeCheatSheetTask) obj).getName(); - return obj.toString(); + String result; + if (obj instanceof ICompositeCheatSheetTask) { + result = ((ICompositeCheatSheetTask) obj).getName(); + } else { + result = obj.toString(); + } + if (result == null) { + result = ""; //$NON-NLS-1$ + } + return result; } public Image getImage(Object obj) { if (obj instanceof ICompositeCheatSheetTask) { ICompositeCheatSheetTask task = (ICompositeCheatSheetTask) obj; - return lookupImage(task.getKind(), task.getState(), task.isStartable()); + return lookupImage(task.getKind(), task.getState(), task.requiredTasksCompleted()); } return super.getImage(obj); } @@ -98,27 +106,60 @@ public class TreeLabelProvider extends LabelProvider { return images.getImage(BLOCKED); } + /** + * Create a set of images for a task which may be [redefined. + * @param kind + * @return + */ private ImageSet createImages(String kind) { ImageSet images = new ImageSet(); - ImageDescriptor desc = TaskEditorManager.getInstance().getImageDescriptor(kind); + ImageDescriptor desc; + desc = getPredefinedImageDescriptor(kind); + if (desc == null) { + desc = TaskEditorManager.getInstance().getImageDescriptor(kind); + } if (desc != null) { images.put(ICompositeCheatSheetTask.NOT_STARTED, desc.createImage()); - ImageDescriptor inProgress = createImageDescriptor("icons/ovr16/task_in_progress.gif"); //$NON-NLS-1$ - OverlayIcon icon = new OverlayIcon(desc, new ImageDescriptor[][] { - {}, { inProgress } }); - images.put(ICompositeCheatSheetTask.IN_PROGRESS, icon.createImage()); - ImageDescriptor complete = createImageDescriptor("icons/ovr16/task_complete.gif"); //$NON-NLS-1$ - icon = new OverlayIcon(desc, new ImageDescriptor[][] { - {}, { complete } }); - images.put(ICompositeCheatSheetTask.COMPLETED, icon.createImage()); - ImageDescriptor blocked = createImageDescriptor("icons/ovr16/task_blocked.gif"); //$NON-NLS-1$ - icon = new OverlayIcon(desc, new ImageDescriptor[][] { - {}, { blocked } }); - images.put(BLOCKED, icon.createImage()); + + createImageWithOverlay(ICompositeCheatSheetTask.IN_PROGRESS, + "icons/ovr16/task_in_progress.gif", //$NON-NLS-1$ + images, + desc); + createImageWithOverlay(ICompositeCheatSheetTask.SKIPPED, + "icons/ovr16/task_skipped.gif", //$NON-NLS-1$ + images, + desc); + createImageWithOverlay(BLOCKED, + "icons/ovr16/task_blocked.gif", //$NON-NLS-1$ + images, + desc); + createImageWithOverlay(ICompositeCheatSheetTask.COMPLETED, + "icons/ovr16/task_complete.gif", //$NON-NLS-1$ + images, + desc); + } return images; } + private ImageDescriptor getPredefinedImageDescriptor(String kind) { + if (ITaskGroup.SET.equals(kind)) { + return createImageDescriptor("icons/obj16/task_set.gif"); //$NON-NLS-1$ + } else if (ITaskGroup.CHOICE.equals(kind)) { + return createImageDescriptor("icons/obj16/task_choice.gif"); //$NON-NLS-1$ + } else if (ITaskGroup.SEQUENCE.equals(kind)) { + return createImageDescriptor("icons/obj16/task_sequence.gif"); //$NON-NLS-1$ + } + return null; + } + + private void createImageWithOverlay(int state, String imagePath, ImageSet images, ImageDescriptor baseDescriptor) { + ImageDescriptor descriptor = createImageDescriptor(imagePath); + OverlayIcon icon = new OverlayIcon(baseDescriptor, new ImageDescriptor[][] { + {}, { descriptor } }); + images.put(state, icon.createImage()); + } + private ImageDescriptor createImageDescriptor(String relativePath) { Bundle bundle = CheatSheetPlugin.getPlugin().getBundle(); URL url = Platform.find(bundle, new Path(relativePath)); diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeTaskExplorer.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeTaskExplorer.java index ddfccd612..f9a9d028c 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeTaskExplorer.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/explorer/TreeTaskExplorer.java @@ -20,11 +20,11 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Tree; import org.eclipse.ui.cheatsheets.ICompositeCheatSheet; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; -import org.eclipse.ui.cheatsheets.ITaskExplorer; +import org.eclipse.ui.cheatsheets.TaskExplorer; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags; -public class TreeTaskExplorer implements ITaskExplorer { +public class TreeTaskExplorer extends TaskExplorer { private TreeViewer viewer; diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CheatSheetTask.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java index de58a8bc1..ed40a2e79 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CheatSheetTask.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/AbstractTask.java @@ -15,52 +15,51 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Dictionary; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; import org.eclipse.ui.cheatsheets.ICompositeCheatSheet; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; -import org.eclipse.ui.cheatsheets.ITaskEditor; +import org.eclipse.ui.internal.cheatsheets.composite.parser.ITaskParseStrategy; /** - * A single task within a composite cheatsheet. + * A single task within a composite cheatsheet. This class encapsulates the + * behavior common to editable tasks and taskGroups */ -public class CheatSheetTask implements ICompositeCheatSheetTask { - private CompositeCheatSheetModel model; - private int state = NOT_STARTED; +public abstract class AbstractTask implements ICompositeCheatSheetTask { + protected CompositeCheatSheetModel model; + protected int state = NOT_STARTED; private String id; private String name; - private String kind; + protected String kind; private Dictionary parameters; - - private String description; + private String description; + private String completionMessage; - private ArrayList subtasks; - private ArrayList requiredTasks; private ArrayList successorTasks; - private int percentageComplete; + private boolean skippable; - private ITaskEditor editor; + private TaskGroup parent; - private static final ICompositeCheatSheetTask[] EMPTY = new ICompositeCheatSheetTask[0]; + protected static final ICompositeCheatSheetTask[] EMPTY = new ICompositeCheatSheetTask[0]; - public CheatSheetTask(CompositeCheatSheetModel model, String id, String name, String kind, - Dictionary parameters, String description) { + public AbstractTask(CompositeCheatSheetModel model, String id, String name, String kind) { this.model = model; this.id = id; this.name = name; this.kind = kind; - this.parameters = parameters; - this.description = description; + this.parameters = new Hashtable(); + this.description = name; requiredTasks = new ArrayList(); } @@ -87,10 +86,13 @@ public class CheatSheetTask implements ICompositeCheatSheetTask { public void setDescription(String description) { this.description = description; } + + public void setCompletionMessage(String completionMessage) { + this.completionMessage = completionMessage; + } - public ICompositeCheatSheetTask[] getSubtasks() { - if (subtasks==null) return EMPTY; - return (ICompositeCheatSheetTask[])subtasks.toArray(new ICompositeCheatSheetTask[subtasks.size()]); + public String getCompletionMessage() { + return completionMessage; } public ICompositeCheatSheetTask[] getRequiredTasks() { @@ -102,17 +104,6 @@ public class CheatSheetTask implements ICompositeCheatSheetTask { if (successorTasks==null) return EMPTY; return (ICompositeCheatSheetTask[])successorTasks.toArray(new ICompositeCheatSheetTask[successorTasks.size()]); } - - public int getPercentageComplete() { - return percentageComplete; - } - - public void addSubtask(ICompositeCheatSheetTask task) { - if (subtasks==null) - subtasks = new ArrayList(); - subtasks.add(task); - - } public void addRequiredTask(ICompositeCheatSheetTask task) { if (requiredTasks==null) @@ -126,54 +117,30 @@ public class CheatSheetTask implements ICompositeCheatSheetTask { successorTasks.add(task); } - public void setPercentageComplete(int percentageComplete) { - if (percentageComplete>=0 && percentageComplete<=100) { - this.percentageComplete = percentageComplete; - model.notifyStateChanged(this); - } - } - public int getState() { return state; } - - public void advanceState() { - if (state==NOT_STARTED) - state = IN_PROGRESS; - else if (state==IN_PROGRESS) { - completeTask(); - } - model.notifyStateChanged(this); - } - private void completeTask() { + public void complete() { // Find out all successor tasks which were blocked List blockedTasks = new ArrayList(); ICompositeCheatSheetTask[] successorTasks = getSuccessorTasks(); for (int i = 0; i < successorTasks.length; i++) { - if (!successorTasks[i].isStartable()) { + if (!successorTasks[i].requiredTasksCompleted()) { blockedTasks.add(successorTasks[i]); } } - state = COMPLETED; // Did any tasks get unblocked for (Iterator iter = blockedTasks.iterator(); iter.hasNext();) { ICompositeCheatSheetTask nextTask = (ICompositeCheatSheetTask)iter.next(); - if (nextTask.isStartable()) { + if (nextTask.requiredTasksCompleted()) { model.notifyStateChanged(nextTask); } } + setState(COMPLETED); } - public void setCompletionMessage(String completionMessage) { - this.completionMessage = completionMessage; - } - - public String getCompletionMessage() { - return completionMessage; - } - - public boolean isStartable() { + public boolean requiredTasksCompleted() { boolean startable = true; ICompositeCheatSheetTask[] requiredTasks = getRequiredTasks(); for (int i = 0; i < requiredTasks.length; i++) { @@ -192,21 +159,37 @@ public class CheatSheetTask implements ICompositeCheatSheetTask { public void setState(int state) { this.state = state; model.notifyStateChanged(this); + if (parent != null) { + parent.checkState(); + } } public URL getInputUrl(String path) throws MalformedURLException { return new URL(model.getContentUrl(), path); } - public void setEditor(ITaskEditor editor) { - this.editor = editor; + public ICompositeCheatSheet getCompositeCheatSheet() { + return model; } + + public abstract ITaskParseStrategy getParserStrategy(); - public ITaskEditor getEditor() { - return editor; + public abstract ICompositeCheatSheetTask[] getSubtasks(); + + public void setSkippable(boolean skippable) { + this.skippable = skippable; } - public ICompositeCheatSheet getCompositeCheatSheet() { - return model; + public boolean isSkippable() { + return skippable; } + + protected void setParent(TaskGroup parent) { + this.parent = parent; + } + + public TaskGroup getParent() { + return parent; + } + } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java index 1d2166ddf..ad2997db6 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetModel.java @@ -18,11 +18,10 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.cheatsheets.ICheatSheetManager; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; import org.eclipse.ui.cheatsheets.ICompositeCheatSheet; -import org.eclipse.ui.cheatsheets.ITaskEditor; +import org.eclipse.ui.cheatsheets.TaskEditor; import org.eclipse.ui.internal.cheatsheets.data.ICheatSheet; import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; - public class CompositeCheatSheetModel extends Observable implements ICompositeCheatSheet, ICheatSheet{ private String name; @@ -44,7 +43,6 @@ public class CompositeCheatSheetModel extends Observable implements ICompositeCh this.description = description; this.explorerId = explorerId; this.dependencies = new TaskDependencies(); - // TODO initialize the CheatSheetManager } public String getName() { @@ -116,16 +114,20 @@ public class CompositeCheatSheetModel extends Observable implements ICompositeCh * Reset the state of a task and it's children */ private void resetTask(ICompositeCheatSheetTask task) { - CheatSheetTask csTask = (CheatSheetTask)task; - csTask.setState(0); - csTask.setPercentageComplete(0); - ITaskEditor editor = csTask.getEditor(); - if (editor != null) { - editor.setInput(task, null); - } - ICompositeCheatSheetTask[] subtasks = csTask.getSubtasks(); - for (int i = 0; i < subtasks.length; i++) { - resetTask(subtasks[i]); + if (task instanceof EditableTask) { + EditableTask editable = (EditableTask)task; + editable.setState(ICompositeCheatSheetTask.NOT_STARTED); + TaskEditor editor = editable.getEditor(); + if (editor != null) { + editor.setInput(editable, null); + } + } else if (task instanceof TaskGroup) { + TaskGroup group = (TaskGroup)task; + ICompositeCheatSheetTask[] subtasks = group.getSubtasks(); + for (int i = 0; i < subtasks.length; i++) { + resetTask(subtasks[i]); + } + group.setState(ICompositeCheatSheetTask.NOT_STARTED); } } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java index 32b061559..e485e6046 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/CompositeCheatSheetSaveHelper.java @@ -20,7 +20,7 @@ import org.eclipse.ui.IMemento; import org.eclipse.ui.XMLMemento; import org.eclipse.ui.cheatsheets.ICheatSheetManager; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; -import org.eclipse.ui.cheatsheets.ITaskEditor; +import org.eclipse.ui.cheatsheets.TaskEditor; import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags; import org.eclipse.ui.internal.cheatsheets.data.CheatSheetSaveHelper; @@ -30,7 +30,7 @@ import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; /** * Class to save and restore composite cheatsheet state using a memento * There is a child memento for each task which contains keys for the - * state and percentage complete. There is also a grandchild memento for + * state complete. There is also a grandchild memento for * each task that has been started. */ @@ -51,7 +51,7 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { return Status.OK_STATUS; } taskMementoMap = createTaskMap(readMemento); - loadTaskState(taskMementoMap, (CheatSheetTask)model.getRootTask()); + loadTaskState(taskMementoMap, (AbstractTask)model.getRootTask()); loadCheatsheetManagerData(readMemento, model.getCheatSheetManager()); return Status.OK_STATUS; } @@ -68,7 +68,7 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { return map; } - private void loadTaskState(Map taskMap, CheatSheetTask task) { + private void loadTaskState(Map taskMap, AbstractTask task) { ICompositeCheatSheetTask[] children = task.getSubtasks(); IMemento memento = (IMemento)taskMap.get(task.getId()); if (memento != null) { @@ -76,13 +76,12 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { if (state != null) { task.setState(Integer.parseInt(state)); } - String percentage = memento.getString(ICompositeCheatsheetTags.PERCENTAGE_COMPLETE); - if (percentage != null) { - task.setPercentageComplete(Integer.parseInt(percentage)); - } } - for (int i = 0; i < children.length; i++) { - loadTaskState(taskMap, (CheatSheetTask) children[i]); + if (task instanceof TaskGroup) { + for (int i = 0; i < children.length; i++) { + loadTaskState(taskMap, (AbstractTask) children[i]); + } + ((TaskGroup)task).checkState(); } } @@ -107,7 +106,7 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { public IStatus saveCompositeState(CompositeCheatSheetModel model) { XMLMemento writeMemento = XMLMemento.createWriteRoot(ICompositeCheatsheetTags.COMPOSITE_CHEATSHEET_STATE); writeMemento.putString(IParserTags.ID, model.getId()); - saveTaskState(writeMemento, (CheatSheetTask)model.getRootTask()); + saveTaskState(writeMemento, (AbstractTask)model.getRootTask()); saveCheatSheetManagerData(writeMemento, model.getCheatSheetManager()); taskMementoMap = createTaskMap(writeMemento); return CheatSheetPlugin.getPlugin().saveMemento(writeMemento, model.getId() + DOT_XML); @@ -127,14 +126,12 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { } } - private void saveTaskState(IMemento writeMemento, CheatSheetTask task) { + private void saveTaskState(IMemento writeMemento, AbstractTask task) { IMemento childMemento = writeMemento.createChild(ICompositeCheatsheetTags.TASK); childMemento.putString(ICompositeCheatsheetTags.TASK_ID, task.getId()); childMemento.putString(ICompositeCheatsheetTags.STATE, Integer.toString(task.getState())); - childMemento.putString(ICompositeCheatsheetTags.PERCENTAGE_COMPLETE, Integer.toString(task.getPercentageComplete())); - - ICompositeCheatSheetTask[] subtasks = task.getSubtasks(); - ITaskEditor editor = task.getEditor(); + + TaskEditor editor = getEditor(task); if (editor != null) { IMemento taskDataMemento = childMemento.createChild(ICompositeCheatsheetTags.TASK_DATA); editor.saveState(taskDataMemento); @@ -146,11 +143,19 @@ public class CompositeCheatSheetSaveHelper extends CheatSheetSaveHelper { previousDataMemento.putMemento(taskData); } } + ICompositeCheatSheetTask[] subtasks = task.getSubtasks(); for (int i = 0; i < subtasks.length; i++) { - saveTaskState(writeMemento, (CheatSheetTask)subtasks[i]); + saveTaskState(writeMemento, (AbstractTask)subtasks[i]); } } + private TaskEditor getEditor(AbstractTask task) { + if (task instanceof EditableTask) { + return ((EditableTask)task).getEditor(); + } + return null; + } + public IMemento getTaskMemento(String id) { if (taskMementoMap == null) { return null; diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java new file mode 100644 index 000000000..e37ee3682 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/EditableTask.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.model; + +/** + * The concrete implementation of an editable task + */ + +import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; +import org.eclipse.ui.cheatsheets.IEditableTask; +import org.eclipse.ui.cheatsheets.TaskEditor; +import org.eclipse.ui.internal.cheatsheets.composite.parser.EditableTaskParseStrategy; +import org.eclipse.ui.internal.cheatsheets.composite.parser.ITaskParseStrategy; + +public class EditableTask extends AbstractTask implements IEditableTask { + + private TaskEditor editor; + + private ITaskParseStrategy parserStrategy; + + public EditableTask(CompositeCheatSheetModel model, String id, String name, String kind) { + super(model, id, name, kind); + parserStrategy = new EditableTaskParseStrategy(); + } + + public ITaskParseStrategy getParserStrategy() { + return parserStrategy; + } + + public ICompositeCheatSheetTask[] getSubtasks() { + return EMPTY; + } + + public void setStarted() { + if (state==NOT_STARTED) { + setState(IN_PROGRESS); + } + } + + public void setEditor(TaskEditor editor) { + this.editor = editor; + } + + public TaskEditor getEditor() { + return editor; + } + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java index e9687511e..a2ba26199 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/SuccesorTaskFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 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 @@ -11,17 +11,21 @@ package org.eclipse.ui.internal.cheatsheets.composite.model; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; +import org.eclipse.ui.cheatsheets.ITaskGroup; public class SuccesorTaskFinder { - private CheatSheetTask csTask; - ICompositeCheatSheetTask bestSuccessor; - ICompositeCheatSheetTask bestPredecessor; + private AbstractTask currentTask; + ICompositeCheatSheetTask bestLaterTask; + ICompositeCheatSheetTask bestEarlierTask; private boolean seenThisTask; public SuccesorTaskFinder(ICompositeCheatSheetTask task) { - csTask = (CheatSheetTask)task; + currentTask = (AbstractTask)task; } /** @@ -38,44 +42,82 @@ public class SuccesorTaskFinder { */ public ICompositeCheatSheetTask[] getRecommendedSuccessors() { - bestSuccessor = null; - bestPredecessor = null; + // TODO this code could be moved to TaskGroup + if (ITaskGroup.CHOICE.equals(currentTask.getKind())) { + // For a choice if more than one child is runnable return it + List runnableChoices = findRunnableChoices(); + if (runnableChoices.size() != 0) { + return (ICompositeCheatSheetTask[])runnableChoices.toArray + ( new ICompositeCheatSheetTask[runnableChoices.size()]); + } + } + return getBestSuccessor(); + } + + private List findRunnableChoices() { + List result; + result = new ArrayList(); + if (isStartable(currentTask)) { + ICompositeCheatSheetTask[] subtasks = currentTask.getSubtasks(); + for (int i = 0; i < subtasks.length; i++) { + if (isStartable(subtasks[i])) { + result.add(subtasks[i]); + } + } + } + return result; + } + + private boolean isStartable(ICompositeCheatSheetTask task) { + int state = task.getState(); + return (state != ICompositeCheatSheetTask.COMPLETED && + state != ICompositeCheatSheetTask.SKIPPED && + task.requiredTasksCompleted()); + } + + private ICompositeCheatSheetTask[] getBestSuccessor() { + bestLaterTask = null; + bestEarlierTask = null; seenThisTask = false; - searchRunnableChildren(csTask.getCompositeCheatSheet().getRootTask()); + searchRunnableChildren(currentTask.getCompositeCheatSheet().getRootTask()); // If there is a task which is found later in the tree return // that, otherwise an earlier task. - if (bestSuccessor != null) { - return new ICompositeCheatSheetTask[] {bestSuccessor}; + if (bestLaterTask != null) { + return new ICompositeCheatSheetTask[] {bestLaterTask}; } - if (bestPredecessor != null) { - return new ICompositeCheatSheetTask[] {bestPredecessor}; + if (bestEarlierTask != null) { + return new ICompositeCheatSheetTask[] {bestEarlierTask}; } return new ICompositeCheatSheetTask[0]; - } + } private void searchRunnableChildren(ICompositeCheatSheetTask task) { - if (bestSuccessor != null) { + // Don't search completed tasks or their children + // and stop searching if we've already found the best successor + if (task.getState() == ICompositeCheatSheetTask.COMPLETED || + bestLaterTask != null) { return; } - if (task == csTask) { + if (task == currentTask) { seenThisTask = true; - } - - if (task.getKind() != null && task.isStartable() - && task.getState() != ICompositeCheatSheetTask.COMPLETED) { - if (seenThisTask) { - if (bestSuccessor == null) { - bestSuccessor = task; - } - } else { - if (bestPredecessor == null) { - bestPredecessor = task; + } else { + if ( isStartable(task)) { + if (seenThisTask) { + if (bestLaterTask == null) { + bestLaterTask = task; + } + } else { + if (bestEarlierTask == null) { + bestEarlierTask = task; + } } } } - ICompositeCheatSheetTask[] subtasks = task.getSubtasks(); - for (int i = 0; i < subtasks.length; i++) { - searchRunnableChildren(subtasks[i]); - } + if (task instanceof TaskGroup) { + ICompositeCheatSheetTask[] subtasks = ((TaskGroup)task).getSubtasks(); + for (int i = 0; i < subtasks.length; i++) { + searchRunnableChildren(subtasks[i]); + } + } } } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskChoiceCompletionStrategy.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskChoiceCompletionStrategy.java new file mode 100644 index 000000000..a281d1b83 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskChoiceCompletionStrategy.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.model; + +import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; + +public class TaskChoiceCompletionStrategy implements TaskGroup.CompletionStrategy { + + /** + * Determine the state based on the state of the children, which is + * NOT_STARTED if all children are not started + * COMPLETED if one children is completed or skipped + * IN_PROGRESS otherwise + * @return + */ + public int computeState(TaskGroup taskGroup) { + boolean noChildrenStarted = true; + boolean atLeastOneChildCompleted = false; + ICompositeCheatSheetTask[] children = taskGroup.getSubtasks(); + for (int i = 0; i < children.length; i++) { + switch(children[i].getState()) { + case ICompositeCheatSheetTask.NOT_STARTED: + break; + case ICompositeCheatSheetTask.IN_PROGRESS: + noChildrenStarted = false; + break; + case ICompositeCheatSheetTask.SKIPPED: + break; + case ICompositeCheatSheetTask.COMPLETED: + noChildrenStarted = false; + atLeastOneChildCompleted = true; + break; + } + } + if (atLeastOneChildCompleted || children.length == 0) { + return ICompositeCheatSheetTask.COMPLETED; + } + if (taskGroup.getState() == ICompositeCheatSheetTask.SKIPPED) { + return ICompositeCheatSheetTask.SKIPPED; + } + if (noChildrenStarted) { + return ICompositeCheatSheetTask.NOT_STARTED; + } + return ICompositeCheatSheetTask.IN_PROGRESS; + } +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java index 109599546..d6e2f12ea 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskDependencies.java @@ -32,16 +32,16 @@ import org.eclipse.ui.internal.cheatsheets.composite.parser.IStatusContainer; public class TaskDependencies { private class Dependency { - private CheatSheetTask sourceTask; + private AbstractTask sourceTask; private String requiredTaskId; - public Dependency(CheatSheetTask sourceTask, String requiredTaskId) { + public Dependency(AbstractTask sourceTask, String requiredTaskId) { this.sourceTask = sourceTask; this.requiredTaskId = requiredTaskId; } - public CheatSheetTask getSourceTask() { + public AbstractTask getSourceTask() { return sourceTask; } @@ -54,15 +54,15 @@ public class TaskDependencies { private Map taskIdMap = new HashMap(); - public void saveId(CheatSheetTask task) { + public void saveId(AbstractTask task) { String id = task.getId(); if (id != null) { taskIdMap.put(id, task); } } - public CheatSheetTask getTask(String id) { - return (CheatSheetTask)taskIdMap.get(id); + public AbstractTask getTask(String id) { + return (AbstractTask)taskIdMap.get(id); } public TaskDependencies() { @@ -74,7 +74,7 @@ public class TaskDependencies { * @param sourceTask a task which cannot be started until another task is completed * @param requiredTaskId the id of the task which must be completed first */ - public void addDependency(CheatSheetTask sourceTask, String requiredTaskId) { + public void addDependency(AbstractTask sourceTask, String requiredTaskId) { dependencies.add(new Dependency(sourceTask, requiredTaskId)); } @@ -86,8 +86,8 @@ public class TaskDependencies { public void resolveDependencies(IStatusContainer status) { for (Iterator dependencyIterator = dependencies.iterator(); dependencyIterator.hasNext();) { Dependency dep = (Dependency)dependencyIterator.next(); - CheatSheetTask sourceTask = dep.getSourceTask(); - CheatSheetTask requiredTask = getTask(dep.requiredTaskId); + AbstractTask sourceTask = dep.getSourceTask(); + AbstractTask requiredTask = getTask(dep.requiredTaskId); if (requiredTask == null) { String message = NLS.bind(Messages.ERROR_PARSING_INVALID_ID, (new Object[] {dep.getRequiredTaskId()})); status.addStatus(IStatus.ERROR, message, null); @@ -114,7 +114,7 @@ public class TaskDependencies { Set tasks = new HashSet(); // Combine steps 1 + 2 for (Iterator idIterator = taskIdMap.values().iterator(); idIterator.hasNext(); ) { - CheatSheetTask nextTask = (CheatSheetTask)idIterator.next(); + AbstractTask nextTask = (AbstractTask)idIterator.next(); if (nextTask.getRequiredTasks().length > 0) { tasks.add(nextTask); } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java new file mode 100644 index 000000000..2d190dac0 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskGroup.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.model; + +import java.util.ArrayList; +import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; +import org.eclipse.ui.cheatsheets.ITaskGroup; +import org.eclipse.ui.internal.cheatsheets.composite.parser.ITaskParseStrategy; +import org.eclipse.ui.internal.cheatsheets.composite.parser.TaskGroupParseStrategy; + +public class TaskGroup extends AbstractTask implements ITaskGroup { + + public interface CompletionStrategy { + public int computeState(TaskGroup taskGroup); + } + + private ITaskParseStrategy parserStrategy; + + private ArrayList subtasks; + + private CompletionStrategy completionStrategy; + + public TaskGroup(CompositeCheatSheetModel model, String id, String name, String kind) { + super(model, id, name, kind); + if (kind == null) { + this.kind = ITaskGroup.SET; + } + parserStrategy = new TaskGroupParseStrategy(); + completionStrategy = determineCompletionStrategy(kind); + } + + private CompletionStrategy determineCompletionStrategy(String kind) { + if (ITaskGroup.CHOICE.equals(kind)) { + return new TaskChoiceCompletionStrategy(); + } + return new TaskSetCompletionStrategy(); + } + + public ITaskParseStrategy getParserStrategy() { + return parserStrategy; + } + + public ICompositeCheatSheetTask[] getSubtasks() { + if (subtasks==null) return EMPTY; + return (ICompositeCheatSheetTask[])subtasks.toArray(new ICompositeCheatSheetTask[subtasks.size()]); + } + + public void addSubtask(ICompositeCheatSheetTask task) { + if (subtasks==null) { + subtasks = new ArrayList(); + } + subtasks.add(task); + ((AbstractTask)task).setParent(this); + } + + /** + * Called when the state of a child has changed or when the model + * has been restored. + */ + public void checkState() { + int newState = computeState(); + if (newState != state) { + setState(newState); + } + } + + /** + * Determine the state based on the state of the children, which + * will use a different computation depending on whether this is a set, + * sequence or choice. + */ + public int computeState() { + return completionStrategy.computeState(this); + } + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskSetCompletionStrategy.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskSetCompletionStrategy.java new file mode 100644 index 000000000..f35c5fb70 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/model/TaskSetCompletionStrategy.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.model; + +import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; + +public class TaskSetCompletionStrategy implements TaskGroup.CompletionStrategy { + + /** + * Determine the state based on the state of the children, which is + * NOT_STARTED if all children are not started + * COMPLETED if all children are completed or skipped + * IN_PROGRESS otherwise + * @return + */ + public int computeState(TaskGroup taskGroup) { + boolean noChildrenStarted = true; + boolean allChildrenCompleted = true; + ICompositeCheatSheetTask[] children = taskGroup.getSubtasks(); + for (int i = 0; i < children.length; i++) { + switch(children[i].getState()) { + case ICompositeCheatSheetTask.NOT_STARTED: + allChildrenCompleted = false; + break; + case ICompositeCheatSheetTask.IN_PROGRESS: + noChildrenStarted = false; + allChildrenCompleted = false; + break; + case ICompositeCheatSheetTask.COMPLETED: + case ICompositeCheatSheetTask.SKIPPED: + noChildrenStarted = false; + break; + } + } + if (allChildrenCompleted) { + return ICompositeCheatSheetTask.COMPLETED; + } + if (taskGroup.getState() == ICompositeCheatSheetTask.SKIPPED) { + return ICompositeCheatSheetTask.SKIPPED; + } + if (noChildrenStarted) { + return ICompositeCheatSheetTask.NOT_STARTED; + } + return ICompositeCheatSheetTask.IN_PROGRESS; + } +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java index 52e8aef0c..660de042d 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/CompositeCheatSheetParser.java @@ -14,8 +14,6 @@ package org.eclipse.ui.internal.cheatsheets.composite.parser; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.util.Hashtable; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -25,8 +23,10 @@ import org.eclipse.core.runtime.Status; import org.eclipse.osgi.util.NLS; import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource; import org.eclipse.ui.internal.cheatsheets.Messages; -import org.eclipse.ui.internal.cheatsheets.composite.model.CheatSheetTask; +import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetModel; +import org.eclipse.ui.internal.cheatsheets.composite.model.EditableTask; +import org.eclipse.ui.internal.cheatsheets.composite.model.TaskGroup; import org.eclipse.ui.internal.cheatsheets.data.CheatSheetParserException; import org.eclipse.ui.internal.cheatsheets.data.IParserTags; import org.w3c.dom.Document; @@ -170,7 +170,7 @@ public class CompositeCheatSheetParser implements IStatusContainer { throw new CheatSheetParserException(message); } - String title = ""; //$NON-NLS-1$ + String name = ""; //$NON-NLS-1$ String explorerId = ICompositeCheatsheetTags.TREE; NamedNodeMap attributes = rootnode.getAttributes(); @@ -178,15 +178,15 @@ public class CompositeCheatSheetParser implements IStatusContainer { for (int x = 0; x < attributes.getLength(); x++) { Node attribute = attributes.item(x); String attributeName = attribute.getNodeName(); - if ( attributeName != null && attributeName.equals(IParserTags.TITLE)) { - title= attribute.getNodeValue(); + if ( attributeName != null && attributeName.equals(ICompositeCheatsheetTags.NAME)) { + name= attribute.getNodeValue(); } if (attributeName.equals(ICompositeCheatsheetTags.EXPLORER)) { explorerId= attribute.getNodeValue(); } } } - CompositeCheatSheetModel compositeCS = new CompositeCheatSheetModel(title, title, explorerId); + CompositeCheatSheetModel compositeCS = new CompositeCheatSheetModel(name, name, explorerId); parseCompositeCheatSheetChildren(rootnode, compositeCS); @@ -211,8 +211,8 @@ public class CompositeCheatSheetParser implements IStatusContainer { NodeList childNodes = compositeCSNode.getChildNodes(); for (int index = 0; index < childNodes.getLength(); index++) { Node nextNode = childNodes.item(index); - if (nextNode.getNodeName() == ICompositeCheatsheetTags.TASK) { - CheatSheetTask task = parseTask(nextNode, model); + if (isAbstractTask(nextNode.getNodeName()) ) { + AbstractTask task = parseAbstractTask(nextNode, model); if (model.getRootTask() == null ) { model.setRootTask(task); parseTaskChildren(nextNode, task, model); @@ -222,29 +222,49 @@ public class CompositeCheatSheetParser implements IStatusContainer { } } } + + public static boolean isAbstractTask(String nodeName) { + return nodeName == ICompositeCheatsheetTags.TASK || + nodeName == ICompositeCheatsheetTags.TASK_GROUP; + } - private void parseTaskChildren(Node parentNode, CheatSheetTask parentTask, CompositeCheatSheetModel model) { + private void parseTaskChildren(Node parentNode, AbstractTask parentTask, CompositeCheatSheetModel model) { NodeList childNodes = parentNode.getChildNodes(); + ITaskParseStrategy strategy = parentTask.getParserStrategy(); + strategy.init(); for (int index = 0; index < childNodes.getLength(); index++) { Node childNode = childNodes.item(index); - String nodeName = childNode.getNodeName(); - if (nodeName == ICompositeCheatsheetTags.TASK) { - CheatSheetTask task = parseTask(childNode, model); - parentTask.addSubtask(task); - parseTaskChildren(childNode, task, model); - } else if (nodeName == IParserTags.PARAM) { - addParameter(parentTask, childNode.getAttributes()); - } else if (nodeName == IParserTags.INTRO) { - parentTask.setDescription(parseTextMarkup(childNode, parentTask)); - } else if (nodeName == ICompositeCheatsheetTags.ON_COMPLETION) { - parentTask.setCompletionMessage(parseTextMarkup(childNode, parentTask)); - } else if (nodeName == ICompositeCheatsheetTags.DEPENDS_ON) { - parseDependency(childNode, parentTask, model); + if (childNode.getNodeType() == Node.ELEMENT_NODE) { + String nodeName = childNode.getNodeName(); + if (nodeName == IParserTags.PARAM) { + addParameter(parentTask, childNode.getAttributes()); + } else if (nodeName == IParserTags.INTRO) { + parentTask.setDescription(parseTextMarkup(childNode, parentTask, this)); + } else if (nodeName == ICompositeCheatsheetTags.ON_COMPLETION) { + parentTask.setCompletionMessage(parseTextMarkup(childNode, parentTask, this)); + } else if (nodeName == ICompositeCheatsheetTags.DEPENDS_ON) { + parseDependency(childNode, parentTask, model); + } else if (CompositeCheatSheetParser.isAbstractTask(nodeName)) { + if (parentTask instanceof TaskGroup) { + AbstractTask task = parseAbstractTask(childNode, model); + ((TaskGroup)parentTask).addSubtask(task); + parseTaskChildren(childNode, task, model); + } + } else { + if (!strategy.parseElementNode(childNode, parentNode, parentTask, this)) { + String message = NLS + .bind( + Messages.WARNING_PARSING_UNKNOWN_ELEMENT, + (new Object[] { nodeName, + parentNode.getNodeName() })); + addStatus(IStatus.WARNING, message, null); + } + } } } } - private void parseDependency(Node taskNode, CheatSheetTask task, CompositeCheatSheetModel model) { + private void parseDependency(Node taskNode, AbstractTask task, CompositeCheatSheetModel model) { NamedNodeMap attributes = taskNode.getAttributes(); if (attributes != null) { Node taskAttribute = attributes.getNamedItem(ICompositeCheatsheetTags.TASK); @@ -257,7 +277,7 @@ public class CompositeCheatSheetParser implements IStatusContainer { } } - private void addParameter(CheatSheetTask parentTask, NamedNodeMap attributes) { + private void addParameter(AbstractTask parentTask, NamedNodeMap attributes) { String name = null; String value = null; @@ -287,12 +307,13 @@ public class CompositeCheatSheetParser implements IStatusContainer { } - private CheatSheetTask parseTask(Node taskNode, CompositeCheatSheetModel model) { - CheatSheetTask task; + private AbstractTask parseAbstractTask(Node taskNode, CompositeCheatSheetModel model) { + AbstractTask task; NamedNodeMap attributes = taskNode.getAttributes(); String kind = null; - String title = null; + String name = null; String id = null; + boolean skippable = false; if (attributes != null) { for (int x = 0; x < attributes.getLength(); x++) { Node attribute = attributes.item(x); @@ -302,19 +323,24 @@ public class CompositeCheatSheetParser implements IStatusContainer { if (attributeName.equals(ICompositeCheatsheetTags.KIND)) { kind = attribute.getNodeValue(); } - if (attributeName.equals(IParserTags.TITLE)) { - title= attribute.getNodeValue(); + if (attributeName.equals(ICompositeCheatsheetTags.NAME)) { + name= attribute.getNodeValue(); } if (attributeName.equals(IParserTags.ID)) { - id= attribute.getNodeValue(); + id = attribute.getNodeValue(); + } + if (attributeName.equals(IParserTags.SKIP)) { + skippable = "true".equalsIgnoreCase(attribute.getNodeValue()); //$NON-NLS-1$ } } } - Hashtable params = new Hashtable(); + if (id == null) { id = autoGenerateId(); } - task= new CheatSheetTask(model, id, title, kind, params, title); + String nodeName = taskNode.getNodeName(); + task = createTask(nodeName, model, kind, id, name); + task.setSkippable(skippable); if (model.getDependencies().getTask(id) != null) { String message = NLS.bind(Messages.ERROR_PARSING_DUPLICATE_TASK_ID, (new Object[] {id})); @@ -323,16 +349,28 @@ public class CompositeCheatSheetParser implements IStatusContainer { model.getDependencies().saveId(task); } - String completionMessage = NLS.bind(Messages.COMPLETED_TASK, (new Object[] {title})); + return task; + } + + private AbstractTask createTask(String nodeKind, CompositeCheatSheetModel model, String kind, String id, String name) { + AbstractTask task; + if (ICompositeCheatsheetTags.TASK_GROUP.equals(nodeKind)) { + task = new TaskGroup(model, id, name, kind); + } else { + task = new EditableTask(model, id, name, kind); + } + String completionMessage = NLS.bind(Messages.COMPLETED_TASK, (new Object[] {name})); task.setCompletionMessage(completionMessage); return task; } private String autoGenerateId() { - return "AutogenID" + nextTaskId++; //$NON-NLS-1$ + return "TaskId_" + nextTaskId++; //$NON-NLS-1$ } - public String parseTextMarkup(Node descriptionNode, CheatSheetTask parentTask) { + public static String parseTextMarkup(Node descriptionNode, + AbstractTask parentTask, + IStatusContainer status) { NodeList nodes = descriptionNode.getChildNodes(); StringBuffer text = new StringBuffer(); for (int i = 0; i < nodes.getLength(); i++) { @@ -353,7 +391,7 @@ public class CompositeCheatSheetParser implements IStatusContainer { Messages.WARNING_PARSING_DESCRIPTION_UNKNOWN_ELEMENT, (new Object[] { parentTask.getName(), node.getNodeName() })); - addStatus(IStatus.WARNING, message, null); + status.addStatus(IStatus.WARNING, message, null); } } } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/EditableTaskParseStrategy.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/EditableTaskParseStrategy.java new file mode 100644 index 000000000..d2f771811 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/EditableTaskParseStrategy.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.parser; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.osgi.util.NLS; +import org.eclipse.ui.internal.cheatsheets.Messages; +import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; +import org.w3c.dom.Node; + +public class EditableTaskParseStrategy implements ITaskParseStrategy { + + private boolean editableChildErrorReported; + + public void init() { + editableChildErrorReported = false; + } + + public boolean parseElementNode(Node childNode, Node parentNode, + AbstractTask parentTask, IStatusContainer status) { + boolean isElementHandled = true; + String nodeName = childNode.getNodeName(); + if (CompositeCheatSheetParser.isAbstractTask(nodeName)) { + if (!editableChildErrorReported ){ + editableChildErrorReported = true; + String message = NLS + .bind( + Messages.ERROR_EDITABLE_TASK_WITH_CHILDREN, + (new Object[] { parentTask.getName()})); + status.addStatus(IStatus.ERROR, message, null); + } + } else { + isElementHandled = false; + } + return isElementHandled; + } + + public void validate(IStatusContainer status) { + // TODO Add validation + } + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ICompositeCheatsheetTags.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ICompositeCheatsheetTags.java index ba1928c5a..14a7ac80d 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ICompositeCheatsheetTags.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ICompositeCheatsheetTags.java @@ -21,6 +21,7 @@ public interface ICompositeCheatsheetTags { public static final String COMPOSITE_CHEATSHEET= "compositeCheatsheet"; //$NON-NLS-1$ public static final String COMPOSITE_CHEATSHEET_STATE= "compositeCheatSheetState"; //$NON-NLS-1$ public static final String TASK = "task"; //$NON-NLS-1$ + public static final String TASK_GROUP = "taskGroup"; //$NON-NLS-1$ public static final String EXPLORER = "explorer"; //$NON-NLS-1$ public static final String NAME = "name"; //$NON-NLS-1$ public static final String VALUE = "value"; //$NON-NLS-1$ @@ -28,7 +29,6 @@ public interface ICompositeCheatsheetTags { public static final String ON_COMPLETION = "onCompletion"; //$NON-NLS-1$ public static final String DEPENDS_ON = "dependsOn"; //$NON-NLS-1$ public static final String STATE = "state"; //$NON-NLS-1$ - public static final String PERCENTAGE_COMPLETE = "percentageComplete"; //$NON-NLS-1$ // Attribute values public static final String TREE = "tree"; //$NON-NLS-1$ diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ITaskParseStrategy.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ITaskParseStrategy.java new file mode 100644 index 000000000..9114815cc --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/ITaskParseStrategy.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.parser; + +import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; +import org.w3c.dom.Node; + +/** + * Interface which encapsulates the parsing logic specific to different + * task kinds. + */ + +public interface ITaskParseStrategy { + + /** + * Called before parsing a new set of children + */ + public void init(); + + /** + * Parse a child node of this task + * @param childNode The child node + * @param parentNode The task node + * @param parentTask The task object + * @param status Used to add error messages. + * @return True if this element is a valid child + */ + public boolean parseElementNode(Node childNode, Node parentNode, AbstractTask parentTask, IStatusContainer status); + + /** + * Called afer all the children have been parsed to check for missing children + */ + public void validate(IStatusContainer status); + + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/TaskGroupParseStrategy.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/TaskGroupParseStrategy.java new file mode 100644 index 000000000..28c9b52a0 --- /dev/null +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/parser/TaskGroupParseStrategy.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2006 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.composite.parser; + +import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; +import org.w3c.dom.Node; + +public class TaskGroupParseStrategy implements ITaskParseStrategy { + + public void init() { + } + + public boolean parseElementNode(Node childNode, Node parentNode, + AbstractTask parentTask, IStatusContainer status) + { + // Task children are handled by CompositeCheatSheetParser + return false; + } + + public void validate(IStatusContainer status) { + // TODO Add validation + } + + +} diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java index 6415b08e8..3283cd86b 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java @@ -22,15 +22,15 @@ import org.eclipse.ui.cheatsheets.CheatSheetListener; import org.eclipse.ui.cheatsheets.CheatSheetViewerFactory; import org.eclipse.ui.cheatsheets.ICheatSheetEvent; import org.eclipse.ui.cheatsheets.ICheatSheetViewer; -import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; -import org.eclipse.ui.cheatsheets.ITaskEditor; +import org.eclipse.ui.cheatsheets.IEditableTask; +import org.eclipse.ui.cheatsheets.TaskEditor; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags; import org.eclipse.ui.internal.cheatsheets.views.CheatSheetViewer; -public class CheatsheetTaskEditor implements ITaskEditor { +public class CheatsheetTaskEditor extends TaskEditor { private ICheatSheetViewer viewer; - private ICompositeCheatSheetTask task; + private IEditableTask task; public void createControl(Composite parent, FormToolkit toolkit) { viewer = CheatSheetViewerFactory.createCheatSheetView(); @@ -42,7 +42,7 @@ public class CheatsheetTaskEditor implements ITaskEditor { } - public void setInput(ICompositeCheatSheetTask task, IMemento memento) { + public void setInput(IEditableTask task, IMemento memento) { this.task = task; Dictionary params = task.getParameters(); String id = (String)params.get(ICompositeCheatsheetTags.CHEATSHEET_TASK_ID); @@ -54,14 +54,15 @@ public class CheatsheetTaskEditor implements ITaskEditor { viewer.setInput(id, task.getName(), url); } catch (MalformedURLException e) { e.printStackTrace(); + return; } } else { viewer.setInput(id); - CheatSheetViewer cheatSheetViewer = (CheatSheetViewer)viewer; - cheatSheetViewer.addListener(new TaskListener()); - if (memento == null) { - cheatSheetViewer.restart(); - } + } + CheatSheetViewer cheatSheetViewer = (CheatSheetViewer)viewer; + cheatSheetViewer.addListener(new TaskListener()); + if (memento == null) { + cheatSheetViewer.restart(); } } @@ -72,12 +73,12 @@ public class CheatsheetTaskEditor implements ITaskEditor { public void cheatSheetEvent(ICheatSheetEvent event) { if (event.getEventType() == ICheatSheetEvent.CHEATSHEET_COMPLETED) { - task.advanceState(); + task.complete(); } } } public void saveState(IMemento memento) { - // TODO Implement state save + // TODO Implement state save to memento } } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java index 526cfb43e..3fdf4a30f 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CompositeCheatSheetPage.java @@ -38,8 +38,9 @@ import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.cheatsheets.ICompositeCheatSheetTask; -import org.eclipse.ui.cheatsheets.ITaskEditor; -import org.eclipse.ui.cheatsheets.ITaskExplorer; +import org.eclipse.ui.cheatsheets.IEditableTask; +import org.eclipse.ui.cheatsheets.TaskEditor; +import org.eclipse.ui.cheatsheets.TaskExplorer; import org.eclipse.ui.forms.FormColors; import org.eclipse.ui.forms.ManagedForm; import org.eclipse.ui.forms.events.HyperlinkAdapter; @@ -50,9 +51,10 @@ import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource; import org.eclipse.ui.internal.cheatsheets.Messages; import org.eclipse.ui.internal.cheatsheets.actions.IMenuContributor; -import org.eclipse.ui.internal.cheatsheets.composite.model.CheatSheetTask; +import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetModel; import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetSaveHelper; +import org.eclipse.ui.internal.cheatsheets.composite.model.EditableTask; import org.eclipse.ui.internal.cheatsheets.composite.model.SuccesorTaskFinder; import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags; import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader; @@ -72,13 +74,14 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi private PageBook explorerContainer; private PageBook taskEditorContainer; private CompositeCheatSheetModel model; - private ITaskExplorer currentExplorer; + private TaskExplorer currentExplorer; private ScrolledFormText descriptionPanel; private ScrolledFormText completePanel; private CompositeCheatSheetSaveHelper saveHelper; private static final String START_HREF = "__start__"; //$NON-NLS-1$ + private static final String SKIP_HREF = "__skip__"; //$NON-NLS-1$ private ICompositeCheatSheetTask selectedTask; public CompositeCheatSheetPage(CompositeCheatSheetModel model) { @@ -186,7 +189,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi } private void setCurrentExplorerFromId(String explorerId) { - ITaskExplorer explorer = getTaskExplorer(explorerId); + TaskExplorer explorer = getTaskExplorer(explorerId); if (explorer!=null) { explorer.setCompositeCheatSheet(this.model); explorer.setFocus(); @@ -196,10 +199,10 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi private void setExplorerVisible(String id) { Control [] excontrols = explorerContainer.getChildren(); - ITaskExplorer explorer=null; + TaskExplorer explorer=null; for (int i=0; i<excontrols.length; i++) { Control excontrol = excontrols[i]; - explorer = (ITaskExplorer)excontrol.getData(ICompositeCheatsheetTags.EXPLORER); + explorer = (TaskExplorer)excontrol.getData(ICompositeCheatsheetTags.EXPLORER); if (explorer.getId().equals(id)) { explorerContainer.showPage(excontrol); setCurrentExplorer(explorer); @@ -208,7 +211,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi } } - private void setCurrentExplorer(ITaskExplorer explorer) { + private void setCurrentExplorer(TaskExplorer explorer) { if (currentExplorer!=null) { currentExplorer.getSelectionProvider().removeSelectionChangedListener(this); } @@ -217,14 +220,14 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi updateForSelection(currentExplorer.getSelectionProvider().getSelection()); } - private ITaskExplorer getTaskExplorer(String id) { + private TaskExplorer getTaskExplorer(String id) { Control [] excontrols = explorerContainer.getChildren(); - ITaskExplorer explorer=null; + TaskExplorer explorer=null; for (int i=0; i<excontrols.length; i++) { Control excontrol = excontrols[i]; Object data = excontrol.getData(ICompositeCheatsheetTags.EXPLORER); - if (data instanceof ITaskExplorer) { - explorer = (ITaskExplorer)data; + if (data instanceof TaskExplorer) { + explorer = (TaskExplorer)data; if (explorer.getId().equals(id)) { return explorer; } @@ -261,19 +264,26 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi break; case ICompositeCheatSheetTask.IN_PROGRESS: // In progress, show the task editor - showTaskEditor(task); + if (task instanceof IEditableTask) { + showTaskEditor((EditableTask) task); + } else { + showDescription(task); + } break; case ICompositeCheatSheetTask.COMPLETED: + case ICompositeCheatSheetTask.SKIPPED: // complete task - show the completion panel showComplete(task); break; } } - private void showTaskEditor(ICompositeCheatSheetTask task) { + private void showTaskEditor(EditableTask task) { startIfSelected(task); - ITaskEditor editor = getTaskEditor(task); - setCurrentEditor(editor.getControl().getParent()); + TaskEditor editor = getTaskEditor(task); + if (editor != null) { + setCurrentEditor(editor.getControl().getParent()); + } } public void saveState() { @@ -291,16 +301,9 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi text.setFont("header", JFaceResources.getHeaderFont()); //$NON-NLS-1$ text.setColor("title", mform.getToolkit().getColors().getColor(FormColors.TITLE)); //$NON-NLS-1$ text.setImage("start", CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_START)); //$NON-NLS-1$ + text.setImage("skip", CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_BUTTON_SKIP)); //$NON-NLS-1$ descriptionPanel.setFormText(text); - text.addHyperlinkListener(new HyperlinkAdapter() { - public void linkActivated(HyperlinkEvent e) { - if (e.getHref().equals(START_HREF)) { - ICompositeCheatSheetTask task = (ICompositeCheatSheetTask)descriptionPanel.getData(ICompositeCheatsheetTags.TASK); - task.advanceState(); - startIfSelected(task); - } - } - }); + text.addHyperlinkListener(new DescriptionLinkListener()); } else { text = descriptionPanel.getFormText(); } @@ -314,34 +317,24 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi buf.append("<p>"); //$NON-NLS-1$ buf.append(desc); buf.append("</p>"); //$NON-NLS-1$ - } - else + } else { buf.append(desc); - if (task.getKind()!=null) { - if (task.isStartable()) { - buf.append("<p/>"); //$NON-NLS-1$ - buf.append("<p><a href=\""); //$NON-NLS-1$ - buf.append(START_HREF); - buf.append("\">"); //$NON-NLS-1$ - buf.append("<img href=\"start\"/> "); //$NON-NLS-1$ - buf.append(Messages.COMPOSITE_PAGE_START_TASK); - buf.append("</a></p>"); //$NON-NLS-1$ + } + + if (!task.requiredTasksCompleted()) { + showBlockedTasks(task, buf); + } else { + if (task instanceof IEditableTask) { + addStartHyperlink(buf); } else { - buf.append("<p/>"); //$NON-NLS-1$ - buf.append("<p>"); //$NON-NLS-1$ - buf.append("<b>"); //$NON-NLS-1$ - buf.append(Messages.COMPOSITE_PAGE_BLOCKED); - buf.append("</b>"); //$NON-NLS-1$ - buf.append("</p>"); //$NON-NLS-1$// Add the list of blocking tasks - - ICompositeCheatSheetTask[] requiredTasks = task.getRequiredTasks(); - for (int i = 0; i < requiredTasks.length; i++) { - addIfIncomplete(buf, requiredTasks[i]); - } - buf.append("<p>"); //$NON-NLS-1$ - buf.append("</p>"); //$NON-NLS-1$ + showSuccesorTaskLinks(task, buf); + } + AbstractTask abstractTask = (AbstractTask)task; + if (abstractTask.isSkippable()) { + addSkipHyperlink(buf); } } + buf.append("</form>"); //$NON-NLS-1$ text.setText(buf.toString(), true, false); @@ -349,6 +342,42 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi descriptionPanel.reflow(true); setCurrentEditor(descriptionPanel); } + + private void showBlockedTasks(final ICompositeCheatSheetTask task, StringBuffer buf) { + buf.append("<p/>"); //$NON-NLS-1$ + buf.append("<p>"); //$NON-NLS-1$ + buf.append("<b>"); //$NON-NLS-1$ + buf.append(Messages.COMPOSITE_PAGE_BLOCKED); + buf.append("</b>"); //$NON-NLS-1$ + buf.append("</p>"); //$NON-NLS-1$// Add the list of blocking tasks + + ICompositeCheatSheetTask[] requiredTasks = task.getRequiredTasks(); + for (int i = 0; i < requiredTasks.length; i++) { + addIfIncomplete(buf, requiredTasks[i]); + } + buf.append("<p>"); //$NON-NLS-1$ + buf.append("</p>"); //$NON-NLS-1$ + } + + private void addSkipHyperlink(StringBuffer buf) { + buf.append("<p/>"); //$NON-NLS-1$ + buf.append("<p><a href=\""); //$NON-NLS-1$ + buf.append(SKIP_HREF); + buf.append("\">"); //$NON-NLS-1$ + buf.append("<img href=\"skip\"/> "); //$NON-NLS-1$ + buf.append(Messages.COMPOSITE_PAGE_SKIP_TASK); + buf.append("</a></p>"); //$NON-NLS-1$ + } + + private void addStartHyperlink(StringBuffer buf) { + buf.append("<p/>"); //$NON-NLS-1$ + buf.append("<p><a href=\""); //$NON-NLS-1$ + buf.append(START_HREF); + buf.append("\">"); //$NON-NLS-1$ + buf.append("<img href=\"start\"/> "); //$NON-NLS-1$ + buf.append(Messages.COMPOSITE_PAGE_START_TASK); + buf.append("</a></p>"); //$NON-NLS-1$ + } private void addIfIncomplete(StringBuffer buf, ICompositeCheatSheetTask task) { if (task.getState() != ICompositeCheatSheetTask.COMPLETED) { @@ -364,7 +393,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi */ private void startIfSelected(ICompositeCheatSheetTask task) { if (task == selectedTask) { - ITaskEditor editor = getTaskEditor(task); + TaskEditor editor = getTaskEditor(task); if (editor!=null) { setCurrentEditor(editor.getControl()); } @@ -375,26 +404,55 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi taskEditorContainer.showPage(c); } + private final class DescriptionLinkListener extends HyperlinkAdapter { + public void linkActivated(HyperlinkEvent e) { + String ref = (String)e.getHref(); + if (ref.equals(START_HREF)) { + Object data = descriptionPanel.getData(ICompositeCheatsheetTags.TASK); + if (data instanceof EditableTask) { + EditableTask task = (EditableTask)data; + task.setStarted(); + startIfSelected(task); + } + } + if (ref.equals(SKIP_HREF)) { + Object data = descriptionPanel.getData(ICompositeCheatsheetTags.TASK); + if (data instanceof AbstractTask) { + AbstractTask task = (AbstractTask)data; + task.setState(ICompositeCheatSheetTask.SKIPPED); + } + } + checkForTaskLink(ref); + } + } + private final class CompletionHyperlinkAdapter extends HyperlinkAdapter { public void linkActivated(HyperlinkEvent e) { String ref = (String)e.getHref(); if (ref.startsWith(REVIEW_TAG)) { String review = ref.substring(REVIEW_TAG.length()); - CheatSheetTask reviewTask = + AbstractTask reviewTask = model.getDependencies().getTask(review); - showTaskEditor(reviewTask); - } - if (ref.startsWith(NEXT_TASK_TAG)) { - String next = ref.substring(NEXT_TASK_TAG.length()); - CheatSheetTask nextTask = - model.getDependencies().getTask(next); - currentExplorer.setSelection - (new StructuredSelection(nextTask), true); + if (reviewTask instanceof EditableTask) { + showTaskEditor((EditableTask) reviewTask); + } } + checkForTaskLink(ref); + } + } + + private void checkForTaskLink(String ref) { + if (ref.startsWith(NEXT_TASK_TAG)) { + String next = ref.substring(NEXT_TASK_TAG.length()); + AbstractTask nextTask = + model.getDependencies().getTask(next); + currentExplorer.setSelection + (new StructuredSelection(nextTask), true); } } + private void showComplete(ICompositeCheatSheetTask task) { if (completePanel==null) { completePanel = new ScrolledFormText(taskEditorContainer, false); @@ -421,27 +479,32 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi buf.append(desc); } - // Add the links to the next tasks - ICompositeCheatSheetTask[] successorTasks = new SuccesorTaskFinder(task).getRecommendedSuccessors(); - for (int i = 0; i < successorTasks.length; i++) { - addSuccessorTask(buf, successorTasks[i]); - } + showSuccesorTaskLinks(task, buf); - // Add a link to redisplay the editor - buf.append("<p/>"); //$NON-NLS-1$ - buf.append("<p><a href=\""); //$NON-NLS-1$ - buf.append(REVIEW_TAG); - buf.append(task.getId()); - buf.append("\">"); //$NON-NLS-1$ - buf.append(Messages.COMPOSITE_PAGE_REVIEW_TASK); - String string = "</a></p>"; //$NON-NLS-1$ - buf.append(string); + if (task instanceof IEditableTask) { + // Add a link to redisplay the editor + buf.append("<p/>"); //$NON-NLS-1$ + buf.append("<p><a href=\""); //$NON-NLS-1$ + buf.append(REVIEW_TAG); + buf.append(task.getId()); + buf.append("\">"); //$NON-NLS-1$ + buf.append(Messages.COMPOSITE_PAGE_REVIEW_TASK); + buf.append("</a></p>"); //$NON-NLS-1$ + } buf.append("</form>"); //$NON-NLS-1$ completePanel.setText(buf.toString()); completePanel.reflow(true); setCurrentEditor(completePanel); } + + private void showSuccesorTaskLinks(ICompositeCheatSheetTask task, StringBuffer buf) { + // Add the links to the next tasks + ICompositeCheatSheetTask[] successorTasks = new SuccesorTaskFinder(task).getRecommendedSuccessors(); + for (int i = 0; i < successorTasks.length; i++) { + addSuccessorTask(buf, successorTasks[i]); + } + } private void addSuccessorTask(StringBuffer buf, ICompositeCheatSheetTask task) { buf.append("<p/>"); //$NON-NLS-1$ @@ -456,19 +519,19 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi /* * Get the task editor for this task. If no editor exists create one */ - private ITaskEditor getTaskEditor(ICompositeCheatSheetTask task) { - if (task instanceof CheatSheetTask) { - CheatSheetTask csTask = (CheatSheetTask)task; - if (csTask.getEditor() == null) { + private TaskEditor getTaskEditor(ICompositeCheatSheetTask task) { + if (task instanceof EditableTask) { + EditableTask editable = (EditableTask)task; + if (editable.getEditor() == null) { // Create a new editor using the extension point data - ITaskEditor editor = TaskEditorManager.getInstance().getEditor(task.getKind()); + TaskEditor editor = TaskEditorManager.getInstance().getEditor(task.getKind()); if (editor != null) { editor.createControl(taskEditorContainer, mform.getToolkit()); - editor.setInput(task, model.getTaskMemento(task.getId())); - csTask.setEditor(editor); + editor.setInput(editable, model.getTaskMemento(task.getId())); + editable.setEditor(editor); } } - return csTask.getEditor(); + return editable.getEditor(); } return null; @@ -497,7 +560,7 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi private int contributeRestartItem(Menu menu, int index) { MenuItem item = new MenuItem(menu, SWT.PUSH, index++); item.setText(Messages.RESTART_ALL_MENU); - // TODO set the image + item.setImage(CheatSheetPlugin.getPlugin().getImage(ICheatSheetResource.CHEATSHEET_ITEM_BUTTON_RESTART)); item.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (model != null) { @@ -506,6 +569,8 @@ public class CompositeCheatSheetPage extends Page implements ISelectionChangedLi Messages.COMPOSITE_RESTART_DIALOG_TITLE, Messages.COMPOSITE_RESTART_CONFIRM_MESSAGE)) { model.resetAllTasks(); + currentExplorer.setSelection + (new StructuredSelection(model.getRootTask()), true); } } } diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java index d19e8f649..0f2a44dfd 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java @@ -21,7 +21,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.cheatsheets.ITaskEditor; +import org.eclipse.ui.cheatsheets.TaskEditor; import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource; import org.eclipse.ui.internal.cheatsheets.Messages; @@ -42,11 +42,11 @@ public class TaskEditorManager { return instance; } - public ITaskEditor getEditor(String editorKind) { + public TaskEditor getEditor(String editorKind) { CheatSheetRegistryReader.TaskEditorNode editorInfo = CheatSheetRegistryReader.getInstance().findTaskEditor(editorKind); if (editorInfo != null) { - ITaskEditor editorInstance = null; + TaskEditor editorInstance = null; Class extClass = null; String className = editorInfo.getClassName(); try { @@ -61,7 +61,7 @@ public class TaskEditorManager { if (extClass != null) { Constructor c = extClass.getConstructor(new Class[0]); Object[] parameters = new Object[0]; - editorInstance = (ITaskEditor) c.newInstance(parameters); + editorInstance = (TaskEditor) c.newInstance(parameters); } } catch (Exception e) { String message = NLS.bind(Messages.ERROR_CREATING_CLASS, (new Object[] {className})); diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskExplorerManager.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskExplorerManager.java index 8ad6fdba7..eb6af5e7b 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskExplorerManager.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskExplorerManager.java @@ -24,7 +24,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.cheatsheets.ITaskExplorer; +import org.eclipse.ui.cheatsheets.TaskExplorer; import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource; import org.eclipse.ui.internal.cheatsheets.Messages; @@ -47,11 +47,11 @@ private static TaskExplorerManager instance; return instance; } - public ITaskExplorer getExplorer(String explorerKind) { + public TaskExplorer getExplorer(String explorerKind) { CheatSheetRegistryReader.TaskExplorerNode explorerInfo = CheatSheetRegistryReader.getInstance().findTaskExplorer(explorerKind); if (explorerInfo != null) { - ITaskExplorer explorerInstance = null; + TaskExplorer explorerInstance = null; Class extClass = null; String className = explorerInfo.getClassName(); try { @@ -66,7 +66,7 @@ private static TaskExplorerManager instance; if (extClass != null) { Constructor c = extClass.getConstructor(new Class[0]); Object[] parameters = new Object[0]; - explorerInstance = (ITaskExplorer) c.newInstance(parameters); + explorerInstance = (TaskExplorer) c.newInstance(parameters); } } catch (Exception e) { String message = NLS.bind(Messages.ERROR_CREATING_CLASS, (new Object[] {className})); diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java index c379614e3..15e1fc8e6 100644 --- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java +++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java @@ -242,11 +242,10 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor { FormToolkit.ensureVisible(currentItem.getMainItemComposite()); } else if (indexNextItem == viewItemList.size()) { - saveCurrentSheet(); - showIntroItem(); if (!currentItem.isCompletionMessageExpanded()) { // The event will already have been fired getManager().fireEvent(ICheatSheetEvent.CHEATSHEET_COMPLETED); } + showIntroItem(); } saveCurrentSheet(); |