1 11 package org.eclipse.pde.internal.core; 12 13 import java.io.File ; 14 import java.net.URL ; 15 import java.util.StringTokenizer ; 16 import java.util.Vector ; 17 18 import org.eclipse.core.runtime.Preferences; 19 import org.eclipse.pde.core.plugin.IPluginModelBase; 20 21 public class ExternalModelManager extends AbstractModelManager { 22 23 private IPluginModelBase[] fModels = new IPluginModelBase[0]; 24 25 protected IPluginModelBase[] getAllModels() { 26 return fModels; 27 } 28 29 protected void initializeModels(IPluginModelBase[] models) { 30 fModels = models; 31 Preferences pref = PDECore.getDefault().getPluginPreferences(); 32 String saved = pref.getString(ICoreConstants.CHECKED_PLUGINS); 33 if (saved.equals(ICoreConstants.VALUE_SAVED_ALL)) { 34 for (int i = 0; i < fModels.length; i++) 35 fModels[i].setEnabled(true); 36 } else if (!saved.equals(ICoreConstants.VALUE_SAVED_NONE)) { 37 Vector result = new Vector (); 38 StringTokenizer stok = new StringTokenizer (saved); 39 while (stok.hasMoreTokens()) { 40 result.add(stok.nextToken()); 41 } 42 for (int i = 0; i < fModels.length; i++) { 43 fModels[i].setEnabled(!result.contains(fModels[i].getPluginBase().getId())); 44 } 45 } 46 } 47 48 public void setModels(IPluginModelBase[] models) { 49 fModels = models; 50 } 51 52 protected URL [] getPluginPaths() { 53 Preferences pref = PDECore.getDefault().getPluginPreferences(); 54 URL [] base = PluginPathFinder.getPluginPaths(pref.getString(ICoreConstants.PLATFORM_PATH)); 55 56 String value = pref.getString(ICoreConstants.ADDITIONAL_LOCATIONS); 57 StringTokenizer tokenizer = new StringTokenizer (value, ","); 59 if (tokenizer.countTokens() == 0) 60 return base; 61 62 File [] extraLocations = new File [tokenizer.countTokens()]; 63 for (int i = 0; i < extraLocations.length; i++) { 64 String location = tokenizer.nextToken(); 65 File dir = new File (location, "plugins"); if (!dir.exists() || !dir.isDirectory()) 67 dir = new File (location); 68 extraLocations[i] = dir; 69 } 70 URL [] additional = PluginPathFinder.scanLocations(extraLocations); 71 72 if (additional.length == 0) 73 return base; 74 75 URL [] result = new URL [base.length + additional.length]; 76 System.arraycopy(base, 0, result, 0, base.length); 77 System.arraycopy(additional, 0, result, base.length, additional.length); 78 79 return result; 80 } 81 82 } 83 | Popular Tags |