1 11 package org.eclipse.pde.internal.core.plugin; 12 13 import org.eclipse.core.runtime.PlatformObject; 14 import org.eclipse.pde.core.plugin.IPlugin; 15 import org.eclipse.pde.core.plugin.IPluginModel; 16 import org.eclipse.pde.core.plugin.IPluginModelBase; 17 import org.eclipse.pde.core.plugin.PluginRegistry; 18 19 public class PluginReference extends PlatformObject { 20 private String fId; 21 22 private transient IPlugin fPlugin; 23 24 public PluginReference() { 25 } 26 27 public PluginReference(String id) { 28 fId = id; 29 } 30 31 public PluginReference(IPlugin plugin) { 32 fId = plugin.getId(); 33 fPlugin = plugin; 34 } 35 36 public String getId() { 37 return fId; 38 } 39 40 public IPlugin getPlugin() { 41 if (fPlugin == null && fId != null) { 42 IPluginModelBase model = PluginRegistry.findModel(fId); 43 fPlugin = model instanceof IPluginModel ? ((IPluginModel)model).getPlugin() : null; 44 } 45 return fPlugin; 46 } 47 48 public String toString() { 49 if (fPlugin != null) { 50 return fPlugin.getTranslatedName(); 51 } 52 return fId != null ? fId : "?"; } 54 55 public boolean isResolved() { 56 return getPlugin() != null; 57 } 58 59 62 public void reconnect(IPluginModelBase model) { 63 IPlugin plugin = null; 65 if (model instanceof IPluginModel) { 66 plugin = ((IPluginModel) model).getPlugin(); 67 } 68 fPlugin = plugin; 73 } 74 75 } 76 | Popular Tags |