1 11 package org.eclipse.ui.wizards.datatransfer; 12 13 import java.util.List ; 14 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.core.runtime.Platform; 17 import org.eclipse.jface.dialogs.IDialogSettings; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.jface.viewers.StructuredSelection; 20 import org.eclipse.jface.wizard.Wizard; 21 import org.eclipse.ui.IEditorPart; 22 import org.eclipse.ui.IExportWizard; 23 import org.eclipse.ui.IWorkbench; 24 import org.eclipse.ui.IWorkbenchPage; 25 import org.eclipse.ui.PlatformUI; 26 import org.eclipse.ui.ide.IDE; 27 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 28 import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages; 29 import org.eclipse.ui.internal.wizards.datatransfer.WizardFileSystemResourceExportPage1; 30 import org.eclipse.ui.plugin.AbstractUIPlugin; 31 32 53 public class FileSystemExportWizard extends Wizard implements IExportWizard { 54 private IStructuredSelection selection; 55 56 private WizardFileSystemResourceExportPage1 mainPage; 57 58 61 public FileSystemExportWizard() { 62 AbstractUIPlugin plugin = (AbstractUIPlugin) Platform 63 .getPlugin(PlatformUI.PLUGIN_ID); 64 IDialogSettings workbenchSettings = plugin.getDialogSettings(); 65 IDialogSettings section = workbenchSettings 66 .getSection("FileSystemExportWizard"); if (section == null) { 68 section = workbenchSettings.addNewSection("FileSystemExportWizard"); } 70 setDialogSettings(section); 71 } 72 73 76 public void addPages() { 77 super.addPages(); 78 mainPage = new WizardFileSystemResourceExportPage1(selection); 79 addPage(mainPage); 80 } 81 82 83 86 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 87 this.selection = currentSelection; 88 List selectedResources = IDE.computeSelectedResources(currentSelection); 89 if (!selectedResources.isEmpty()) { 90 this.selection = new StructuredSelection(selectedResources); 91 } 92 93 if (selection.isEmpty() && workbench.getActiveWorkbenchWindow() != null) { 95 IWorkbenchPage page = workbench.getActiveWorkbenchWindow() 96 .getActivePage(); 97 if (page != null) { 98 IEditorPart currentEditor = page.getActiveEditor(); 99 if (currentEditor != null) { 100 Object selectedResource = currentEditor.getEditorInput() 101 .getAdapter(IResource.class); 102 if (selectedResource != null) { 103 selection = new StructuredSelection(selectedResource); 104 } 105 } 106 } 107 } 108 109 setWindowTitle(DataTransferMessages.DataTransfer_export); 110 setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportdir_wiz.png")); setNeedsProgressMonitor(true); 112 } 113 114 117 public boolean performFinish() { 118 return mainPage.finish(); 119 } 120 } 121 | Popular Tags |