KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > actions > MigrateJarFileAction


1 /*******************************************************************************
2  * Copyright (c) 2005, 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  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.refactoring.actions;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.jface.wizard.WizardDialog;
17
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
20 import org.eclipse.ui.PlatformUI;
21
22 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23 import org.eclipse.jdt.internal.ui.jarimport.JarImportWizard;
24
25 /**
26  * Action to migrate a JAR file.
27  *
28  * @since 3.2
29  */

30 public final class MigrateJarFileAction implements IWorkbenchWindowActionDelegate {
31
32     /** The wizard height */
33     private static final int SIZING_WIZARD_HEIGHT= 610;
34
35     /** The wizard width */
36     private static final int SIZING_WIZARD_WIDTH= 500;
37
38     /** The workbench window, or <code>null</code> */
39     private IWorkbenchWindow fWindow= null;
40
41     /**
42      * {@inheritDoc}
43      */

44     public void dispose() {
45         // Do nothing
46
}
47
48     /**
49      * {@inheritDoc}
50      */

51     public void init(final IWorkbenchWindow window) {
52         fWindow= window;
53     }
54
55     /**
56      * {@inheritDoc}
57      */

58     public void run(final IAction action) {
59         if (fWindow != null) {
60             final JarImportWizard wizard= new JarImportWizard(true);
61             final ISelection selection= fWindow.getSelectionService().getSelection();
62             if (selection instanceof IStructuredSelection)
63                 wizard.init(fWindow.getWorkbench(), (IStructuredSelection) selection);
64             final WizardDialog dialog= new WizardDialog(fWindow.getShell(), wizard);
65             dialog.create();
66             dialog.getShell().setSize(Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x), SIZING_WIZARD_HEIGHT);
67             PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IJavaHelpContextIds.JARIMPORT_WIZARD_PAGE);
68             dialog.open();
69         }
70     }
71
72     /**
73      * {@inheritDoc}
74      */

75     public void selectionChanged(final IAction action, final ISelection selection) {
76         // Do nothing
77
}
78 }
79
Popular Tags