1 11 package org.eclipse.ltk.internal.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 33 public final class ApplyRefactoringScriptAction implements IWorkbenchWindowActionDelegate { 34 35 36 private static final int SIZING_WIZARD_HEIGHT= 520; 37 38 39 private static final int SIZING_WIZARD_WIDTH= 470; 40 41 47 public static void showApplyScriptWizard(final IWorkbenchWindow window) { 48 Assert.isNotNull(window); 49 final IWorkbenchWizard wizard= new ApplyRefactoringScriptWizard(); 50 final ISelection selection= window.getSelectionService().getSelection(); 51 if (selection instanceof IStructuredSelection) { 52 final IStructuredSelection structured= (IStructuredSelection) selection; 53 wizard.init(window.getWorkbench(), structured); 54 } else 55 wizard.init(window.getWorkbench(), null); 56 final WizardDialog dialog= new WizardDialog(window.getShell(), wizard); 57 dialog.create(); 58 dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT); 59 PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IRefactoringHelpContextIds.REFACTORING_APPLY_SCRIPT_PAGE); 60 dialog.open(); 61 } 62 63 64 private IWorkbenchWindow fWindow= null; 65 66 69 public void dispose() { 70 } 72 73 76 public void init(final IWorkbenchWindow window) { 77 fWindow= window; 78 } 79 80 83 public void run(final IAction action) { 84 if (fWindow != null) { 85 showApplyScriptWizard(fWindow); 86 } 87 } 88 89 92 public void selectionChanged(final IAction action, final ISelection selection) { 93 } 95 } 96 | Popular Tags |