| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2000, 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.actions; |
| 13 | |
| 14 | import org.eclipse.core.runtime.Assert; |
| 15 | import org.eclipse.jface.action.Action; |
| 16 | import org.eclipse.ui.PlatformUI; |
| 17 | import org.eclipse.ui.actions.WorkingSetFilterActionGroup; |
| 18 | import org.eclipse.ui.internal.IWorkbenchHelpContextIds; |
| 19 | import org.eclipse.ui.internal.WorkbenchMessages; |
| 20 | |
| 21 | /** |
| 22 | * Clears the selected working set in the working set action group. |
| 23 | * |
| 24 | * @since 2.1 |
| 25 | */ |
| 26 | public class ClearWorkingSetAction extends Action { |
| 27 | private WorkingSetFilterActionGroup actionGroup; |
| 28 | |
| 29 | /** |
| 30 | * Creates a new instance of the receiver. |
| 31 | * |
| 32 | * @param actionGroup the action group this action is created in |
| 33 | */ |
| 34 | public ClearWorkingSetAction(WorkingSetFilterActionGroup actionGroup) { |
| 35 | super(WorkbenchMessages.ClearWorkingSetAction_text); |
| 36 | Assert.isNotNull(actionGroup); |
| 37 | setToolTipText(WorkbenchMessages.ClearWorkingSetAction_toolTip); |
| 38 | setEnabled(actionGroup.getWorkingSet() != null); |
| 39 | PlatformUI.getWorkbench().getHelpSystem().setHelp(this, |
| 40 | IWorkbenchHelpContextIds.CLEAR_WORKING_SET_ACTION); |
| 41 | this.actionGroup = actionGroup; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Overrides method from Action |
| 46 | * |
| 47 | * @see Action#run |
| 48 | */ |
| 49 | public void run() { |
| 50 | actionGroup.setWorkingSet(null); |
| 51 | } |
| 52 | } |