| /******************************************************************************* |
| * Copyright (c) 2000, 2017 IBM Corporation and others. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.dltk.internal.ui.actions; |
| |
| import org.eclipse.dltk.ui.IContextMenuConstants; |
| import org.eclipse.jface.action.GroupMarker; |
| import org.eclipse.jface.action.IMenuManager; |
| import org.eclipse.jface.action.Separator; |
| import org.eclipse.ui.IViewPart; |
| import org.eclipse.ui.IWorkbenchWindow; |
| import org.eclipse.ui.actions.ActionGroup; |
| import org.eclipse.ui.actions.ExportResourcesAction; |
| import org.eclipse.ui.actions.ImportResourcesAction; |
| import org.eclipse.ui.navigator.ICommonMenuConstants; |
| |
| |
| /** |
| * Action group to add the Import and Export action to a view part's context |
| * menu. |
| * |
| * <p> |
| * This class may be instantiated; it is not intended to be subclassed. |
| * </p> |
| * |
| * |
| */ |
| public class ImportActionGroup extends ActionGroup { |
| |
| private static final String GROUP_IMPORT= "group.import"; //$NON-NLS-1$ |
| |
| private ImportResourcesAction fImportAction; |
| private ExportResourcesAction fExportAction; |
| |
| /** |
| * Creates a new <code>ImportActionGroup</code>. The group |
| * requires that the selection provided by the part's selection provider |
| * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>. |
| * |
| * @param part the view part that owns this action group |
| */ |
| public ImportActionGroup(IViewPart part) { |
| IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow(); |
| fImportAction= new ImportResourcesAction(workbenchWindow); |
| fExportAction= new ExportResourcesAction(workbenchWindow); |
| } |
| |
| @Override |
| public void fillContextMenu(IMenuManager menu) { |
| menu.appendToGroup(IContextMenuConstants.GROUP_REORGANIZE, new Separator(GROUP_IMPORT)); |
| menu.appendToGroup(GROUP_IMPORT, new GroupMarker(ICommonMenuConstants.GROUP_PORT)); |
| menu.appendToGroup(GROUP_IMPORT, fImportAction); |
| menu.appendToGroup(GROUP_IMPORT, fExportAction); |
| super.fillContextMenu(menu); |
| } |
| |
| @Override |
| public void dispose() { |
| fImportAction.dispose(); |
| fExportAction.dispose(); |
| super.dispose(); |
| } |
| } |