1 11 12 package org.eclipse.ui.internal.cheatsheets.composite.explorer; 13 14 import org.eclipse.core.runtime.IPath; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.ui.PlatformUI; 18 import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin; 19 import org.eclipse.ui.internal.cheatsheets.Messages; 20 import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask; 21 import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetModel; 22 import org.eclipse.ui.internal.cheatsheets.composite.model.TaskStateUtilities; 23 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask; 24 25 28 29 public class ResetTaskAction extends Action { 30 private AbstractTask task; 31 32 public ResetTaskAction(ICompositeCheatSheetTask task) { 33 this.task = (AbstractTask) task; 34 this.setText(Messages.COMPOSITE_MENU_RESET); 35 IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("return_to_start.gif"); ImageDescriptor restartImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path); 37 this.setImageDescriptor(restartImage); 38 } 39 40 public void run() { 41 AbstractTask[] restartTasks = TaskStateUtilities.getRestartTasks(task); 42 if (restartTasks.length == 0) return; 43 TreeLabelProvider labelProvider = new TreeLabelProvider(); 44 ConfirmRestartDialog dlg = new ConfirmRestartDialog( 45 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), restartTasks, labelProvider); 46 dlg.open(); 47 labelProvider.dispose(); 48 if (dlg.getReturnCode() == ConfirmRestartDialog.OK) { 49 CompositeCheatSheetModel model = (CompositeCheatSheetModel) restartTasks[0].getCompositeCheatSheet(); 50 model.resetTasks(restartTasks); 51 } 52 } 53 54 } 55 | Popular Tags |