1 11 package org.eclipse.ltk.ui.refactoring.actions; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.ltk.internal.ui.refactoring.IRefactoringHelpContextIds; 16 import org.eclipse.ltk.internal.ui.refactoring.scripting.ApplyRefactoringScriptWizard; 17 18 import org.eclipse.jface.action.IAction; 19 import org.eclipse.jface.viewers.ISelection; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 import org.eclipse.jface.wizard.WizardDialog; 22 23 import org.eclipse.ui.IWorkbenchWindow; 24 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 25 import org.eclipse.ui.IWorkbenchWizard; 26 import org.eclipse.ui.PlatformUI; 27 28 37 public final class ApplyRefactoringScriptAction implements IWorkbenchWindowActionDelegate { 38 39 40 private static final int SIZING_WIZARD_HEIGHT= 520; 41 42 43 private static final int SIZING_WIZARD_WIDTH= 470; 44 45 51 private static void showApplyScriptWizard(final IWorkbenchWindow window) { 52 Assert.isNotNull(window); 53 final IWorkbenchWizard wizard= new ApplyRefactoringScriptWizard(); 54 final ISelection selection= window.getSelectionService().getSelection(); 55 if (selection instanceof IStructuredSelection) { 56 final IStructuredSelection structured= (IStructuredSelection) selection; 57 wizard.init(window.getWorkbench(), structured); 58 } else 59 wizard.init(window.getWorkbench(), null); 60 final WizardDialog dialog= new WizardDialog(window.getShell(), wizard); 61 dialog.create(); 62 dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); 63 PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IRefactoringHelpContextIds.REFACTORING_APPLY_SCRIPT_PAGE); 64 dialog.open(); 65 } 66 67 68 private IWorkbenchWindow fWindow= null; 69 70 73 public void dispose() { 74 } 76 77 80 public void init(final IWorkbenchWindow window) { 81 fWindow= window; 82 } 83 84 87 public void run(final IAction action) { 88 if (fWindow != null) { 89 showApplyScriptWizard(fWindow); 90 } 91 } 92 93 96 public void selectionChanged(final IAction action, final ISelection selection) { 97 } 99 } 100 | Popular Tags |