/** * Returns a string representation of the plug-in, suitable * for debugging purposes only. */ @Override public String toString() { Bundle myBundle = getBundle(); if (myBundle == null) return ""; //$NON-NLS-1$ String name = myBundle.getSymbolicName(); return name == null ? new Long(myBundle.getBundleId()).toString() : name; }
/** * Returns a URL for the given path. Returns <code>null</code> if the URL * could not be computed or created. * * @param path path relative to plug-in installation location * @return a URL for the given path or <code>null</code> * @deprecated use {@link FileLocator#find(Bundle, IPath, Map)} */ @Deprecated public final URL find(IPath path) { return FileLocator.find(getBundle(), path, null); }
/** * Returns an input stream for the specified file. The file path * must be specified relative this the plug-in's installation location. * * @param file path relative to plug-in installation location * @return an input stream * @exception IOException if the given path cannot be found in this plug-in * * @see #openStream(IPath,boolean) * @deprecated use {@link FileLocator#openStream(Bundle, IPath, boolean)} */ @Deprecated public final InputStream openStream(IPath file) throws IOException { return FileLocator.openStream(getBundle(), file, false); }
/** * Returns the plug-in descriptor for this plug-in runtime object. * * @return the plug-in descriptor for this plug-in runtime object * @deprecated * <code>IPluginDescriptor</code> was refactored in Eclipse 3.0. * The <code>getDescriptor()</code> method may only be called by plug-ins * which explicitly require the org.eclipse.core.runtime.compatibility plug-in. * See the comments on {@link IPluginDescriptor} and its methods for details. */ @Deprecated public final IPluginDescriptor getDescriptor() { if (descriptor != null) return descriptor; return initializeDescriptor(getBundle().getSymbolicName()); }
/** * Returns the DebugOptions instance * * @since 3.5 * @return Either the DebugOptions instance or <code>null</code> if this plug-in does not have a bundle */ private DebugOptions getDebugOptions() { Bundle debugBundle = getBundle(); if (debugBundle == null) return null; if (debugTracker == null) { BundleContext context = debugBundle.getBundleContext(); if (context == null) return null; debugTracker = new ServiceTracker<DebugOptions,DebugOptions>(context, DebugOptions.class.getName(), null); debugTracker.open(); } return this.debugTracker.getService(); }
/** * Returns a URL for the given path. Returns <code>null</code> if the URL * could not be computed or created. * * @param path file path relative to plug-in installation location * @param override map of override substitution arguments to be used for * any $arg$ path elements. The map keys correspond to the substitution * arguments (eg. "$nl$" or "$os$"). The resulting * values must be of type java.lang.String. If the map is <code>null</code>, * or does not contain the required substitution argument, the default * is used. * @return a URL for the given path or <code>null</code> * @deprecated use {@link FileLocator#find(Bundle, IPath, Map)} */ @Deprecated public final URL find(IPath path, Map<String,String> override) { return FileLocator.find(getBundle(), path, override); }
/** * Returns an input stream for the specified file. The file path * must be specified relative to this plug-in's installation location. * Optionally, the path specified may contain $arg$ path elements that can * be used as substitution arguments. If this option is used then the $arg$ * path elements are processed in the same way as {@link #find(IPath, Map)}. * <p> * The caller must close the returned stream when done. * </p> * * @param file path relative to plug-in installation location * @param substituteArgs <code>true</code> to process substitution arguments, * and <code>false</code> for the file exactly as specified without processing any * substitution arguments. * @return an input stream * @exception IOException if the given path cannot be found in this plug-in * @deprecated use {@link FileLocator#openStream(Bundle, IPath, boolean)} */ @Deprecated public final InputStream openStream(IPath file, boolean substituteArgs) throws IOException { return FileLocator.openStream(getBundle(), file, substituteArgs); }
/** * Returns the log for this plug-in. If no such log exists, one is created. * * @return the log for this plug-in * XXX change this into a LogMgr service that would keep track of the map. See if it can be a service factory. */ public final ILog getLog() { return InternalPlatform.getDefault().getLog(getBundle()); }
/** * Returns the location in the local file system of the * plug-in state area for this plug-in. * If the plug-in state area did not exist prior to this call, * it is created. * <p> * The plug-in state area is a file directory within the * platform's metadata area where a plug-in is free to create files. * The content and structure of this area is defined by the plug-in, * and the particular plug-in is solely responsible for any files * it puts there. It is recommended for plug-in preference settings and * other configuration parameters. * </p> * @throws IllegalStateException, when the system is running with no data area (-data @none), * or when a data area has not been set yet. * @return a local file system path * XXX Investigate the usage of a service factory (see also platform.getStateLocation) */ public final IPath getStateLocation() throws IllegalStateException { return InternalPlatform.getDefault().getStateLocation(getBundle(), true); }
final Bundle bundleCopy = getBundle(); if (preferences != null) { if (InternalPlatform.DEBUG_PLUGIN_PREFERENCES)
/** * Sets whether this plug-in is in debug mode. * By default plug-ins are not in debug mode. A plug-in can put itself * into debug mode or the user can set a debug option to do so. * <p> * Note that the plug-in's debug flag is initialized when the * plug-in is started. The result of calling this method before the plug-in * has started is unspecified. * </p> * * @param value whether or not this plug-in is in debug mode * XXX deprecate use the service and cache as needed */ public void setDebugging(boolean value) { Bundle debugBundle = getBundle(); if (debugBundle == null) { this.debug = value; return; } String key = debugBundle.getSymbolicName() + "/debug"; //$NON-NLS-1$ final DebugOptions options = getDebugOptions(); if (options == null) this.debug = value; else { if (!options.isDebugEnabled()) options.setDebugEnabled(true); options.setOption(key, value ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); } }
/** * Returns whether this plug-in is in debug mode. * By default plug-ins are not in debug mode. A plug-in can put itself * into debug mode or the user can set an execution option to do so. * <p> * Note that the plug-in's debug flag is initialized when the * plug-in is started. The result of calling this method before the plug-in * has started is unspecified. * </p> * * @return whether this plug-in is in debug mode * XXX deprecate use the service and cache as needed */ public boolean isDebugging() { Bundle debugBundle = getBundle(); if (debugBundle == null) return debug; String key = debugBundle.getSymbolicName() + "/debug"; //$NON-NLS-1$ // first check if platform debugging is enabled final DebugOptions debugOptions = getDebugOptions(); if (debugOptions == null) return debug; // if platform debugging is enabled, check to see if this plugin is enabled for debugging return debugOptions.isDebugEnabled() ? InternalPlatform.getDefault().getBooleanOption(key, false) : false; }
/** * Logs an error message and Throwable for a plugin. * @param plugin in which the error happened * @param message error message * @param t throwable */ public static void logError(final Plugin plugin, final Object message, final Throwable t) { final String pluginString = plugin.getBundle().getSymbolicName() +"("+ plugin.getBundle().getVersion()+ ")"; logger.error(message+" in plugin: " + pluginString, t); }
/** * Return a logger based upon the Plugin. * @param plugin * @return * * @since 1.0.0 */ public static Logger getEclipseLogger(Plugin plugin) { return getEclipseLogger(plugin.getBundle()); }
/** * @deprecated Use {@link #addSaveParticipant(String, ISaveParticipant)} instead */ @Deprecated @Override public ISavedState addSaveParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException { Assert.isNotNull(plugin, "Plugin must not be null"); //$NON-NLS-1$ Assert.isNotNull(participant, "Participant must not be null"); //$NON-NLS-1$ return saveManager.addParticipant(plugin.getBundle().getSymbolicName(), participant); }
@Deprecated @Override public void removeSaveParticipant(Plugin plugin) { Assert.isNotNull(plugin, "Plugin must not be null"); //$NON-NLS-1$ saveManager.removeParticipant(plugin.getBundle().getSymbolicName()); }
public static IPath findPathInPlugin(Plugin srcPlugin, String fileName) throws IOException { URL bundleUrl = srcPlugin.getBundle().getResource(fileName); URL fileUrl = FileLocator.toFileURL(bundleUrl); Path filePath = new Path(fileUrl.getPath()); return filePath; }
/** * @deprecated Use {@link #addSaveParticipant(String, ISaveParticipant)} instead */ @Deprecated @Override public ISavedState addSaveParticipant(Plugin plugin, ISaveParticipant participant) throws CoreException { Assert.isNotNull(plugin, "Plugin must not be null"); //$NON-NLS-1$ Assert.isNotNull(participant, "Participant must not be null"); //$NON-NLS-1$ return saveManager.addParticipant(plugin.getBundle().getSymbolicName(), participant); }
@Override public URL getResource(String fileName, ClassLoader loader) { if (fileName == null) { throw new IllegalArgumentException("null fileName"); } Plugin p = plugIn == null ? CorePlugin.getDefault() : plugIn; if (p == null && loader == null) { throw new IllegalArgumentException("null loader"); } return (p == null) ? loader.getResource(fileName) : FileLocator.find(p.getBundle(), new Path(fileName), null); }
/** * Returns the log for this plug-in. If no such log exists, one is created. * * @return the log for this plug-in * XXX change this into a LogMgr service that would keep track of the map. See if it can be a service factory. */ public final ILog getLog() { return InternalPlatform.getDefault().getLog(getBundle()); }