1 11 package org.eclipse.help.internal.base; 12 13 import java.io.File ; 14 import java.net.URL ; 15 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Platform; 18 import org.eclipse.core.runtime.Plugin; 19 import org.eclipse.core.runtime.Status; 20 import org.eclipse.osgi.service.datalocation.Location; 21 import org.osgi.framework.BundleContext; 22 23 26 public class HelpBasePlugin extends Plugin { 27 28 public final static String PLUGIN_ID = "org.eclipse.help.base"; private static HelpBasePlugin plugin; 30 private File configurationDirectory; 31 private BundleContext context; 32 33 private IHelpActivitySupport helpActivitySupport = new IHelpActivitySupport() { 34 public boolean isEnabled(String href) { 35 return true; 36 } 37 public boolean isRoleEnabled(String href) { 38 return true; 39 } 40 public boolean isEnabledTopic(String href, String locale) { 41 return true; 42 } 43 public void enableActivities(String href) { 44 } 45 public boolean isFilteringEnabled() { 46 return false; 47 } 48 public void setFilteringEnabled(boolean enabled) { 49 } 50 public boolean isUserCanToggleFiltering() { 51 return false; 52 } 53 public String getShowAllMessage() { 54 return null; 55 } 56 public String getDocumentMessage(boolean embedded) { 57 return null; 58 } 59 public boolean getDocumentMessageUsesLiveHelp(boolean embedded) { 60 return false; 61 } 62 public String getLocalScopeCheckboxLabel() { 63 return null; 64 } 65 }; 66 67 public static synchronized void logError(String message, Throwable ex) { 68 if (message == null) { 69 message = ""; } 71 Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, ex); 72 HelpBasePlugin.getDefault().getLog().log(errorStatus); 73 } 74 75 public static synchronized void logStatus(IStatus errorStatus) { 76 HelpBasePlugin.getDefault().getLog().log(errorStatus); 77 } 78 79 public static HelpBasePlugin getDefault() { 80 return plugin; 81 } 82 83 public void stop(BundleContext context) throws Exception { 84 plugin.savePluginPreferences(); 85 BaseHelpSystem.shutdown(); 86 this.context = null; 87 plugin = null; 88 super.stop(context); 89 } 90 91 public void start(BundleContext context) throws Exception { 92 super.start(context); 93 plugin = this; 94 this.context = context; 95 96 Location location = Platform.getConfigurationLocation(); 98 if (location != null) { 99 URL configURL = location.getURL(); 100 if (configURL != null && configURL.getProtocol().startsWith("file")) { configurationDirectory = new File (configURL.getFile(), PLUGIN_ID); 102 } 103 } 104 if (configurationDirectory == null) { 105 configurationDirectory = getStateLocation().toFile(); 106 } 107 BaseHelpSystem.startup(); 108 } 109 110 public static File getConfigurationDirectory() { 111 return getDefault().configurationDirectory; 112 } 113 114 public static IHelpActivitySupport getActivitySupport() { 115 return getDefault().helpActivitySupport; 116 } 117 118 public static void setActivitySupport(IHelpActivitySupport activitySupport) { 119 getDefault().helpActivitySupport = activitySupport; 120 } 121 122 public static BundleContext getBundleContext() { 123 return getDefault().context; 124 } 125 } 126 | Popular Tags |