KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > composite > explorer > RestartAllAction


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
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.dialogs.MessageDialog;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin;
20 import org.eclipse.ui.internal.cheatsheets.Messages;
21 import org.eclipse.ui.internal.cheatsheets.composite.model.CompositeCheatSheetModel;
22 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheet;
23
24 public class RestartAllAction extends Action {
25
26     private ICompositeCheatSheet model;
27
28     public RestartAllAction(ICompositeCheatSheet model) {
29         this.model = model;
30         this.setText(Messages.RESTART_ALL_MENU);
31         IPath path = CheatSheetPlugin.ICONS_PATH.append(CheatSheetPlugin.T_ELCL).append("restart_all.gif");//$NON-NLS-1$
32
ImageDescriptor restartImage = CheatSheetPlugin.createImageDescriptor(CheatSheetPlugin.getPlugin().getBundle(), path);
33         this.setImageDescriptor(restartImage);
34     }
35     
36     public void run() {
37         if (confirmRestart()) {
38             ((CompositeCheatSheetModel)model).resetAllTasks(null);
39         }
40     }
41     
42     public static boolean confirmRestart() {
43         return MessageDialog.openConfirm(
44                 PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
45                 Messages.COMPOSITE_RESTART_DIALOG_TITLE,
46                 Messages.COMPOSITE_RESTART_CONFIRM_MESSAGE);
47     }
48
49 }
50
Popular Tags