KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > product > ProductExportAction


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.pde.internal.ui.editor.product;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.jface.action.Action;
16 import org.eclipse.jface.viewers.IStructuredSelection;
17 import org.eclipse.jface.viewers.StructuredSelection;
18 import org.eclipse.jface.window.Window;
19 import org.eclipse.jface.wizard.WizardDialog;
20 import org.eclipse.pde.core.IModel;
21 import org.eclipse.pde.internal.ui.PDEPlugin;
22 import org.eclipse.pde.internal.ui.editor.PDEFormEditor;
23 import org.eclipse.pde.internal.ui.wizards.ResizableWizardDialog;
24 import org.eclipse.pde.internal.ui.wizards.exports.ProductExportWizard;
25 import org.eclipse.ui.PlatformUI;
26
27 public class ProductExportAction extends Action {
28
29     private IProject fProject;
30     
31     private IStructuredSelection fSelection;
32     
33     public ProductExportAction(PDEFormEditor editor) {
34         IResource resource = null;
35         if (editor != null)
36             resource = ((IModel) editor.getAggregateModel()).getUnderlyingResource();
37         fSelection = resource != null ? new StructuredSelection(resource) : new StructuredSelection();
38         fProject = editor.getCommonProject();
39     }
40     
41     public ProductExportAction(IStructuredSelection selection) {
42         fSelection = selection;
43         fProject = null;
44     }
45     
46     public void run() {
47         ProductExportWizard wizard = new ProductExportWizard(fProject);
48         wizard.init(PlatformUI.getWorkbench(), fSelection);
49         WizardDialog wd = new ResizableWizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
50         wd.create();
51         notifyResult(wd.open() == Window.OK);
52     }
53     
54 }
55
Popular Tags