KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > ui > actions > ImportActionGroup


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.jdt.ui.actions;
12
13 import org.eclipse.jdt.ui.IContextMenuConstants;
14 import org.eclipse.jface.action.IMenuManager;
15 import org.eclipse.jface.action.Separator;
16 import org.eclipse.ui.IViewPart;
17 import org.eclipse.ui.IWorkbenchWindow;
18 import org.eclipse.ui.actions.ActionGroup;
19 import org.eclipse.ui.actions.ExportResourcesAction;
20 import org.eclipse.ui.actions.ImportResourcesAction;
21
22 /**
23  * Action group to add the Import and Export action to a view part's
24  * context menu.
25  *
26  * <p>
27  * This class may be instantiated; it is not intended to be subclassed.
28  * </p>
29  *
30  * @since 2.0
31  */

32 public class ImportActionGroup extends ActionGroup {
33
34     private static final String JavaDoc GROUP_IMPORT= "group.import"; //$NON-NLS-1$
35

36     private ImportResourcesAction fImportAction;
37     private ExportResourcesAction fExportAction;
38
39     /**
40      * Creates a new <code>ImportActionGroup</code>. The group
41      * requires that the selection provided by the part's selection provider
42      * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
43      *
44      * @param part the view part that owns this action group
45      */

46     public ImportActionGroup(IViewPart part) {
47         IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow();
48         fImportAction= new ImportResourcesAction(workbenchWindow);
49         fExportAction= new ExportResourcesAction(workbenchWindow);
50     }
51     
52     /* (non-Javadoc)
53      * Method declared in ActionGroup
54      */

55     public void fillContextMenu(IMenuManager menu) {
56         menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new Separator(GROUP_IMPORT));
57         menu.appendToGroup(GROUP_IMPORT, fImportAction);
58         menu.appendToGroup(GROUP_IMPORT, fExportAction);
59         super.fillContextMenu(menu);
60     }
61     
62     /**
63      * {@inheritDoc}
64      */

65     public void dispose() {
66         fImportAction.dispose();
67         fExportAction.dispose();
68         super.dispose();
69     }
70 }
71
Popular Tags