01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.macbundler;
11:
12: import java.io.IOException;
13: import java.net.MalformedURLException;
14: import java.net.URL;
15:
16: import org.eclipse.jdt.internal.launching.macosx.MacOSXLaunchingPlugin;
17: import org.eclipse.jface.resource.ImageDescriptor;
18: import org.eclipse.jface.viewers.IStructuredSelection;
19: import org.eclipse.jface.wizard.Wizard;
20: import org.eclipse.ui.*;
21: import org.eclipse.ui.IExportWizard;
22:
23: public class MacBundleWizard extends Wizard implements IExportWizard,
24: BundleAttributes {
25:
26: IWorkbench fWorkbench;
27: IStructuredSelection fSelection;
28: BundleDescription fBundleDescription = new BundleDescription();
29:
30: public MacBundleWizard() {
31: setDefaultPageImageDescriptor(createWizardImageDescriptor("exportapp_wiz.png")); //$NON-NLS-1$
32: setWindowTitle(Util.getString("MacBundleWizard.title")); //$NON-NLS-1$
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
37: */
38: public void init(IWorkbench workbench,
39: 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 e) {
67: // NeedWork Auto-generated catch block
68: e.printStackTrace();
69: }
70: return true;
71: }
72:
73: private static ImageDescriptor createWizardImageDescriptor(
74: String name) {
75: try {
76: URL baseUrl = MacOSXLaunchingPlugin.getDefault()
77: .getBundle().getEntry("/icons/full/wizban/"); //$NON-NLS-1$
78: if (baseUrl != null)
79: return ImageDescriptor.createFromURL(new URL(baseUrl,
80: name));
81: } catch (MalformedURLException e) {
82: // fall through
83: }
84: return ImageDescriptor.getMissingImageDescriptor();
85: }
86: }
|