1 11 package org.eclipse.pde.internal.ui.editor.feature; 12 13 import java.util.ArrayList ; 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.pde.core.plugin.*; 16 import org.eclipse.pde.internal.core.feature.*; 17 import org.eclipse.pde.internal.core.ifeature.*; 18 import org.eclipse.pde.internal.ui.*; 19 import org.eclipse.swt.widgets.*; 20 import org.eclipse.ui.help.*; 21 22 public class NewFeatureRequireWizardPage extends ReferenceWizardPage { 23 public static final String KEY_TITLE = "FeatureEditor.RequiresSection.newPlugin.title"; public static final String KEY_DESC = "FeatureEditor.RequiresSection.newPlugin.desc"; public static final String KEY_ADDING = "FeatureEditor.RequiresSection.newPlugin.adding"; public static final String KEY_UPDATING = 27 "FeatureEditor.RequiresSection.newPlugin.updating"; 29 public NewFeatureRequireWizardPage(IFeatureModel model) { 30 super(model, true); 31 setTitle(PDEPlugin.getResourceString(KEY_TITLE)); 32 setDescription(PDEPlugin.getResourceString(KEY_DESC)); 33 } 34 35 protected boolean isOnTheList(IPluginModelBase candidate) { 36 IPluginBase plugin = candidate.getPluginBase(); 37 if (candidate.isFragmentModel()) return true; 38 IFeatureImport[] imports = model.getFeature().getImports(); 39 40 for (int i = 0; i < imports.length; i++) { 41 IFeatureImport fimport = imports[i]; 42 if (plugin.getId().equals(fimport.getId())) 43 return true; 44 } 45 IFeaturePlugin [] fplugins = model.getFeature().getPlugins(); 47 for (int i=0; i<fplugins.length; i++) { 48 IFeaturePlugin fplugin = fplugins[i]; 49 if (plugin.getId().equals(fplugin.getId())) 50 return true; 51 } 52 return false; 53 } 54 55 protected void doAdd(Object [] candidates, IProgressMonitor monitor) throws CoreException { 56 monitor.beginTask( 57 PDEPlugin.getResourceString(KEY_ADDING), 58 candidates.length + 1); 59 IFeature feature = model.getFeature(); 60 ArrayList added = new ArrayList (); 61 for (int i = 0; i < candidates.length; i++) { 62 IPluginModelBase candidate = (IPluginModelBase) candidates[i]; 63 IPluginBase pluginBase = candidate.getPluginBase(); 64 if (candidate.isFragmentModel()) continue; 65 monitor.subTask(pluginBase.getTranslatedName()); 66 FeatureImport fimport = (FeatureImport) model.getFactory().createImport(); 67 fimport.setPlugin((IPlugin)candidate.getPluginBase()); 68 fimport.setId(pluginBase.getId()); 69 added.add(fimport); 70 monitor.worked(1); 71 } 72 monitor.subTask(""); monitor.setTaskName(PDEPlugin.getResourceString(KEY_UPDATING)); 74 feature.addImports((IFeatureImport[])added.toArray(new IFeatureImport[added.size()])); 75 monitor.worked(1); 76 } 77 78 public void createControl(Composite parent) { 79 super.createControl(parent); 80 WorkbenchHelp.setHelp(getControl(), IHelpContextIds.FEATURE_ADD_REQUIRED_WIZARD); 81 } 82 83 } 84 | Popular Tags |