kchong | ee4b4cf | 2007-05-02 17:49:40 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2001, 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 | *******************************************************************************/ |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.xsd.ui.internal.refactor.actions; |
| 12 | |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 13 | |
| 14 | import org.eclipse.jface.viewers.ISelection; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 15 | import org.eclipse.swt.widgets.Menu; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 16 | import org.eclipse.ui.IEditorPart; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 17 | import org.eclipse.ui.IWorkbenchPartSite; |
kchong | 2be71b3 | 2006-04-11 16:32:03 +0000 | [diff] [blame] | 18 | import org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper; |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 19 | import org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 20 | import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup; |
| 21 | import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupActionDelegate; |
| 22 | import org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupSubMenu; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 23 | import org.eclipse.xsd.XSDSchema; |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 24 | |
| 25 | public class XSDRefactorGroupActionDelegate extends RefactorGroupActionDelegate { |
| 26 | |
| 27 | public XSDRefactorGroupActionDelegate() { |
| 28 | super(); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Fills the menu with applicable refactor sub-menues |
| 33 | * @param menu The menu to fill |
| 34 | */ |
| 35 | protected void fillMenu(Menu menu) { |
| 36 | if (fSelection == null) { |
| 37 | return; |
| 38 | } |
| 39 | if (workbenchPart != null) { |
| 40 | IWorkbenchPartSite site = workbenchPart.getSite(); |
| 41 | if (site == null) |
| 42 | return; |
| 43 | |
| 44 | IEditorPart editor = site.getPage().getActiveEditor(); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 45 | if (editor != null) { |
| 46 | XSDSchema schema = (XSDSchema)editor.getAdapter(XSDSchema.class); |
| 47 | ISelectionMapper mapper = (ISelectionMapper)editor.getAdapter(ISelectionMapper.class); |
| 48 | if (schema != null) |
| 49 | { |
| 50 | ISelection selection = mapper != null ? mapper.mapSelection(fSelection) : fSelection; |
| 51 | RefactorActionGroup refactorMenuGroup = new XSDRefactorActionGroup(selection, schema); |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 52 | RefactorGroupSubMenu subMenu = new RefactorGroupSubMenu(refactorMenuGroup); |
| 53 | subMenu.fill(menu, -1); |
kchong | 38cbf17 | 2006-03-29 03:38:21 +0000 | [diff] [blame] | 54 | } |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } |
| 58 | |
| 59 | } |
csalter | ce82000 | 2006-01-10 07:53:46 +0000 | [diff] [blame] | 60 | } |