KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > edit > ui > action > DeleteAction


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2002-2005 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: DeleteAction.java,v 1.3 2005/06/08 06:20:52 nickb Exp $
16  */

17 package org.eclipse.emf.edit.ui.action;
18
19
20 import java.util.Collection JavaDoc;
21
22 import org.eclipse.ui.IEditorPart;
23 import org.eclipse.ui.IWorkbenchPart;
24
25 import org.eclipse.emf.common.command.Command;
26 import org.eclipse.emf.edit.command.RemoveCommand;
27 import org.eclipse.emf.edit.domain.EditingDomain;
28 import org.eclipse.emf.edit.domain.IEditingDomainProvider;
29 import org.eclipse.emf.edit.ui.EMFEditUIPlugin;
30
31
32 /**
33  * A delete action is implemented by creating a {@link RemoveCommand}.
34  */

35 public class DeleteAction extends CommandActionHandler
36 {
37   public DeleteAction(EditingDomain domain)
38   {
39     super(domain, EMFEditUIPlugin.INSTANCE.getString("_UI_Delete_menu_item"));
40   }
41
42   public DeleteAction()
43   {
44     super(null, EMFEditUIPlugin.INSTANCE.getString("_UI_Delete_menu_item"));
45   }
46
47   public Command createCommand(Collection JavaDoc selection)
48   {
49     return RemoveCommand.create(domain, selection);
50   }
51
52   /**
53    * @deprecated As of EMF 2.1.0, replaced by {@link #setActiveWorkbenchPart}.
54    */

55   public void setActiveEditor(IEditorPart editorPart)
56   {
57     setActiveWorkbenchPart(editorPart);
58   }
59
60   /**
61    * @since 2.1.0
62    */

63   public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart)
64   {
65     if (workbenchPart instanceof IEditingDomainProvider)
66     {
67       domain = ((IEditingDomainProvider)workbenchPart).getEditingDomain();
68     }
69   }
70 }
71
Popular Tags