KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > macbundler > MacBundleWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.macbundler;
12
13 import java.io.IOException JavaDoc;
14 import java.net.MalformedURLException JavaDoc;
15 import java.net.URL JavaDoc;
16
17 import org.eclipse.jdt.internal.launching.macosx.MacOSXLaunchingPlugin;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.jface.wizard.Wizard;
21 import org.eclipse.ui.*;
22 import org.eclipse.ui.IExportWizard;
23
24
25 public class MacBundleWizard extends Wizard implements IExportWizard, BundleAttributes {
26     
27     IWorkbench fWorkbench;
28     IStructuredSelection fSelection;
29     BundleDescription fBundleDescription= new BundleDescription();
30
31     public MacBundleWizard() {
32         setDefaultPageImageDescriptor(createWizardImageDescriptor("exportapp_wiz.gif")); //$NON-NLS-1$
33
setWindowTitle(Util.getString("MacBundleWizard.title")); //$NON-NLS-1$
34
}
35
36     /* (non-Javadoc)
37      * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
38      */

39     public void init(IWorkbench workbench, IStructuredSelection selection) {
40         fWorkbench= workbench;
41         fSelection= selection;
42     }
43     
44     IStructuredSelection getSelection() {
45         return fSelection;
46     }
47
48     /*
49      * (non-Javadoc)
50      * Method declared on IWizard.
51      */

52     public void addPages() {
53         super.addPages();
54         addPage(new BundleWizardPage1(fBundleDescription));
55         addPage(new BundleWizardPage2(fBundleDescription));
56         addPage(new BundleWizardPage3(fBundleDescription));
57     }
58
59     /* (non-Javadoc)
60      * @see org.eclipse.jface.wizard.Wizard#performFinish()
61      */

62     public boolean performFinish() {
63         try {
64             BundleBuilder bb= new BundleBuilder();
65             bb.createBundle(fBundleDescription, null);
66         } catch (IOException JavaDoc e) {
67             // NeedWork Auto-generated catch block
68
e.printStackTrace();
69         }
70         return true;
71     }
72
73     private static ImageDescriptor createWizardImageDescriptor(String JavaDoc name) {
74         try {
75             URL JavaDoc baseUrl= MacOSXLaunchingPlugin.getDefault().getBundle().getEntry("/icons/full/wizban/"); //$NON-NLS-1$
76
if (baseUrl != null)
77                 return ImageDescriptor.createFromURL(new URL JavaDoc(baseUrl, name));
78         } catch (MalformedURLException JavaDoc e) {
79             // fall through
80
}
81         return ImageDescriptor.getMissingImageDescriptor();
82     }
83 }
84
Popular Tags