]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/ui/actions/ImportActionGroup.java
Some talks, mostly identical.
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / ui / actions / ImportActionGroup.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 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.jface.action.IMenuManager;
14 import org.eclipse.jface.action.Separator;
15
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 import org.eclipse.jdt.ui.IContextMenuConstants;
23
24 /**
25  * Action group to add the Import and Export action to a view part's
26  * context menu.
27  *
28  * <p>
29  * This class may be instantiated; it is not intended to be subclassed.
30  * </p>
31  *
32  * @since 2.0
33  *
34  * @noextend This class is not intended to be subclassed by clients.
35  */
36 public class ImportActionGroup extends ActionGroup {
37
38         private static final String GROUP_IMPORT= "group.import"; //$NON-NLS-1$
39
40         private ImportResourcesAction fImportAction;
41         private ExportResourcesAction fExportAction;
42
43         /**
44          * Creates a new <code>ImportActionGroup</code>. The group
45          * requires that the selection provided by the part's selection provider
46          * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
47          *
48          * @param part the view part that owns this action group
49          */
50         public ImportActionGroup(IViewPart part) {
51                 IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow();
52                 fImportAction= new ImportResourcesAction(workbenchWindow);
53                 fExportAction= new ExportResourcesAction(workbenchWindow);
54         }
55
56         /* (non-Javadoc)
57          * Method declared in ActionGroup
58          */
59         @Override
60         public void fillContextMenu(IMenuManager menu) {
61                 menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new Separator(GROUP_IMPORT));
62                 menu.appendToGroup(GROUP_IMPORT, fImportAction);
63                 menu.appendToGroup(GROUP_IMPORT, fExportAction);
64                 super.fillContextMenu(menu);
65         }
66
67         /**
68          * {@inheritDoc}
69          */
70         @Override
71         public void dispose() {
72                 fImportAction.dispose();
73                 fExportAction.dispose();
74                 super.dispose();
75         }
76 }