1 11 package org.eclipse.core.resources; 12 13 import org.eclipse.core.internal.resources.*; 14 import org.eclipse.core.internal.utils.Messages; 15 import org.eclipse.core.runtime.*; 16 import org.eclipse.core.runtime.jobs.IJobManager; 17 import org.eclipse.core.runtime.jobs.Job; 18 import org.osgi.framework.BundleActivator; 19 import org.osgi.framework.BundleContext; 20 21 29 public final class ResourcesPlugin extends Plugin { 30 34 public static final String PI_RESOURCES = "org.eclipse.core.resources"; 36 39 40 44 public static final String PT_BUILDERS = "builders"; 46 50 public static final String PT_NATURES = "natures"; 52 56 public static final String PT_MARKERS = "markers"; 58 62 public static final String PT_FILE_MODIFICATION_VALIDATOR = "fileModificationValidator"; 64 70 public static final String PT_MOVE_DELETE_HOOK = "moveDeleteHook"; 72 78 public static final String PT_TEAM_HOOK = "teamHook"; 80 86 public static final String PT_REFRESH_PROVIDERS = "refreshProviders"; 88 94 public static final String PT_MODEL_PROVIDERS = "modelProviders"; 96 102 public static final Object FAMILY_AUTO_BUILD = new Object (); 103 104 110 public static final Object FAMILY_AUTO_REFRESH = new Object (); 111 112 121 public static final Object FAMILY_MANUAL_BUILD = new Object (); 122 123 141 public static final String PREF_ENCODING = "encoding"; 143 147 private static final String PREF_DESCRIPTION_PREFIX = "description."; 149 153 public static final String PREF_MAX_NOTIFICATION_DELAY = "maxnotifydelay"; 155 163 public static final String PREF_AUTO_BUILDING = PREF_DESCRIPTION_PREFIX + "autobuilding"; 165 173 public static final String PREF_BUILD_ORDER = PREF_DESCRIPTION_PREFIX + "buildorder"; 175 180 public static final String PREF_DEFAULT_BUILD_ORDER = PREF_DESCRIPTION_PREFIX + "defaultbuildorder"; 182 191 public static final String PREF_MAX_BUILD_ITERATIONS = PREF_DESCRIPTION_PREFIX + "maxbuilditerations"; 193 201 public static final String PREF_FILE_STATE_LONGEVITY = PREF_DESCRIPTION_PREFIX + "filestatelongevity"; 203 211 public static final String PREF_MAX_FILE_STATE_SIZE = PREF_DESCRIPTION_PREFIX + "maxfilestatesize"; 213 221 public static final String PREF_MAX_FILE_STATES = PREF_DESCRIPTION_PREFIX + "maxfilestates"; 230 public static final String PREF_SNAPSHOT_INTERVAL = PREF_DESCRIPTION_PREFIX + "snapshotinterval"; 232 237 public static final String PREF_DISABLE_LINKING = PREF_DESCRIPTION_PREFIX + "disableLinking"; 239 244 public static final String PREF_AUTO_REFRESH = "refresh.enabled"; 246 249 private static ResourcesPlugin plugin; 250 251 255 private static Workspace workspace = null; 256 257 265 public ResourcesPlugin() { 266 plugin = this; 267 } 268 269 283 private static void constructWorkspace() throws CoreException { 284 new LocalMetaArea().createMetaArea(); 285 } 286 287 300 public static String getEncoding() { 301 String enc = getPlugin().getPluginPreferences().getString(PREF_ENCODING); 302 if (enc == null || enc.length() == 0) { 303 enc = System.getProperty("file.encoding"); } 305 return enc; 306 } 307 308 313 public static ResourcesPlugin getPlugin() { 314 return plugin; 315 } 316 317 324 public static IWorkspace getWorkspace() { 325 if (workspace == null) 326 throw new IllegalStateException (Messages.resources_workspaceClosed); 327 return workspace; 328 } 329 330 335 public void stop(BundleContext context) throws Exception { 336 super.stop(context); 337 if (workspace == null) 338 return; 339 getPlugin().savePluginPreferences(); 341 workspace.close(null); 342 343 workspace = null; 346 } 347 348 353 public void start(BundleContext context) throws Exception { 354 super.start(context); 355 if (!new LocalMetaArea().hasSavedWorkspace()) { 356 constructWorkspace(); 357 } 358 Workspace.DEBUG = ResourcesPlugin.getPlugin().isDebugging(); 359 workspace = new Workspace(); 362 PlatformURLResourceConnection.startup(workspace.getRoot().getLocation()); 363 IStatus result = workspace.open(null); 364 if (!result.isOK()) 365 getLog().log(result); 366 } 367 } 368 | Popular Tags |