1 11 package org.eclipse.help.internal; 12 13 import java.io.InputStream ; 14 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Plugin; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.help.internal.context.ContextManager; 19 import org.eclipse.help.internal.extension.ContentExtensionManager; 20 import org.eclipse.help.internal.index.IndexManager; 21 import org.eclipse.help.internal.toc.TocManager; 22 import org.osgi.framework.BundleContext; 23 24 27 public class HelpPlugin extends Plugin { 28 29 public final static String PLUGIN_ID = "org.eclipse.help"; public final static String HELP_DATA_KEY = "HELP_DATA"; public final static String BASE_TOCS_KEY = "baseTOCS"; public final static String IGNORED_TOCS_KEY = "ignoredTOCS"; public final static String IGNORED_INDEXES_KEY = "ignoredIndexes"; 35 private static HelpPlugin plugin; 36 private static Object tocManagerCreateLock = new Object (); 37 38 private TocManager tocManager; 39 private ContextManager contextManager; 40 private ContentExtensionManager contentExtensionManager; 41 private IndexManager indexManager; 42 private IHelpProvider helpProvider; 43 44 public static void logWarning(String message) { 45 Status errorStatus = new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, message, null); 46 logStatus(errorStatus); 47 } 48 49 public static void logError(String message) { 50 Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, null); 51 logStatus(errorStatus); 52 } 53 54 public static void logError(String message, Throwable ex) { 55 if (message == null) { 56 message = ""; } 58 Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, ex); 59 logStatus(errorStatus); 60 } 61 62 private static synchronized void logStatus(IStatus errorStatus) { 63 HelpPlugin.getDefault().getLog().log(errorStatus); 64 } 65 66 69 public static HelpPlugin getDefault() { 70 return plugin; 71 } 72 73 78 public static TocManager getTocManager() { 79 if (getDefault().tocManager == null) { 80 synchronized (tocManagerCreateLock) { 81 if (getDefault().tocManager == null) { 82 getDefault().tocManager = new TocManager(); 83 } 84 } 85 } 86 return getDefault().tocManager; 87 } 88 89 92 public static ContextManager getContextManager() { 93 if (getDefault().contextManager == null) 94 getDefault().contextManager = new ContextManager(); 95 return getDefault().contextManager; 96 } 97 98 101 public static ContentExtensionManager getContentExtensionManager() { 102 if (getDefault().contentExtensionManager == null) 103 getDefault().contentExtensionManager = new ContentExtensionManager(); 104 return getDefault().contentExtensionManager; 105 } 106 107 public static IndexManager getIndexManager() { 108 if (getDefault().indexManager == null) 109 getDefault().indexManager = new IndexManager(); 110 return getDefault().indexManager; 111 } 112 113 116 public IHelpProvider getHelpProvider() { 117 return helpProvider; 118 } 119 120 124 public void setHelpProvider(IHelpProvider helpProvider) { 125 this.helpProvider = helpProvider; 126 } 127 128 131 public void start(BundleContext context) throws Exception { 132 super.start(context); 133 plugin = this; 134 } 135 136 139 public void stop(BundleContext context) throws Exception { 140 plugin = null; 141 super.stop(context); 142 } 143 144 147 public static interface IHelpProvider { 148 public InputStream getHelpContent(String href, String locale); 149 } 150 } 151 | Popular Tags |