1 11 package org.eclipse.pde.internal.ui.wizards.exports; 12 13 import java.io.File ; 14 import java.util.ArrayList ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.ResourcesPlugin; 18 import org.eclipse.core.runtime.IAdaptable; 19 import org.eclipse.jdt.core.IJavaProject; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 import org.eclipse.pde.core.IModel; 22 import org.eclipse.pde.core.plugin.IPluginModelBase; 23 import org.eclipse.pde.core.plugin.PluginRegistry; 24 import org.eclipse.pde.internal.core.PDECore; 25 import org.eclipse.pde.internal.core.WorkspaceModelManager; 26 import org.eclipse.pde.internal.ui.IHelpContextIds; 27 import org.eclipse.pde.internal.ui.PDEUIMessages; 28 import org.eclipse.pde.internal.ui.util.PersistablePluginObject; 29 import org.eclipse.swt.widgets.Control; 30 import org.eclipse.ui.PlatformUI; 31 32 33 public class PluginExportWizardPage extends BaseExportWizardPage { 34 35 public PluginExportWizardPage(IStructuredSelection selection) { 36 super( 37 selection, 38 "pluginExport", PDEUIMessages.ExportWizard_Plugin_pageBlock); 40 setTitle(PDEUIMessages.ExportWizard_Plugin_pageTitle); 41 } 42 43 protected Object getInput() { 44 return PDECore.getDefault().getModelManager(); 45 } 46 47 public Object [] getListElements() { 48 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); 49 ArrayList result = new ArrayList (); 50 for (int i = 0; i < projects.length; i++) { 51 if (!WorkspaceModelManager.isBinaryProject(projects[i]) 52 && WorkspaceModelManager.isPluginProject(projects[i])) { 53 IModel model = PluginRegistry.findModel(projects[i]); 54 if (model != null && isValidModel(model) && hasBuildProperties((IPluginModelBase)model)) { 55 result.add(model); 56 } 57 } 58 } 59 return result.toArray(); 60 } 61 62 protected void hookHelpContext(Control control) { 63 PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.PLUGIN_EXPORT_WIZARD); 64 } 65 66 private boolean hasBuildProperties(IPluginModelBase model) { 67 File file = new File (model.getInstallLocation(),"build.properties"); return file.exists(); 69 } 70 71 74 protected boolean isValidModel(IModel model) { 75 return model != null && model instanceof IPluginModelBase; 76 } 77 78 81 protected IModel findModelFor(IAdaptable object) { 82 if (object instanceof IJavaProject) 83 object = ((IJavaProject)object).getProject(); 84 if (object instanceof IProject) 85 return PluginRegistry.findModel((IProject)object); 86 if (object instanceof PersistablePluginObject) { 87 IPluginModelBase model = PluginRegistry.findModel(((PersistablePluginObject)object).getPluginID()); 88 if (model != null && model.getUnderlyingResource() != null) { 89 return model; 90 } 91 } 92 return null; 93 } 94 95 protected boolean isEnableJarButton() { 96 return getSelectedItems().length <= 1; 97 } 98 99 protected void adjustAdvancedTabsVisibility() { 100 adjustJARSigningTabVisibility(); 101 pageChanged(); 102 } 103 } 104 | Popular Tags |