KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > views > actions > RemoveAllAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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 package org.eclipse.ant.internal.ui.views.actions;
12
13
14 import org.eclipse.ant.internal.ui.AntUIImages;
15 import org.eclipse.ant.internal.ui.IAntUIConstants;
16 import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
17 import org.eclipse.ant.internal.ui.views.AntView;
18 import org.eclipse.jface.action.Action;
19 import org.eclipse.jface.dialogs.MessageDialog;
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.texteditor.IUpdate;
22
23 public class RemoveAllAction extends Action implements IUpdate {
24     private AntView view;
25     
26     public RemoveAllAction(AntView view) {
27         super(AntViewActionMessages.RemoveAllAction_Remove_All, AntUIImages.getImageDescriptor(IAntUIConstants.IMG_REMOVE_ALL));
28         setDescription(AntViewActionMessages.RemoveAllAction_Remove_All);
29         setToolTipText(AntViewActionMessages.RemoveAllAction_Remove_All);
30         this.view= view;
31         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAntUIHelpContextIds.REMOVE_ALL_ACTION);
32     }
33     
34     public void run() {
35         boolean proceed = MessageDialog.openQuestion(view.getViewSite().getShell(), AntViewActionMessages.RemoveAllAction_0, AntViewActionMessages.RemoveAllAction_1);
36         if (proceed) {
37             view.removeAllProjects();
38         }
39     }
40
41     /* (non-Javadoc)
42      * @see org.eclipse.ui.texteditor.IUpdate#update()
43      */

44     public void update() {
45         setEnabled(view.getViewer().getTree().getItemCount() != 0);
46     }
47 }
48
Popular Tags