KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > preferences > legacy > InitLegacyPreferences


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.preferences.legacy;
12
13 import org.eclipse.core.internal.preferences.exchange.ILegacyPreferences;
14 import org.eclipse.core.internal.runtime.InternalPlatform;
15 import org.eclipse.core.runtime.Platform;
16 import org.eclipse.core.runtime.Plugin;
17
18 /**
19  * Provides initialization of the legacy preferences as described in
20  * the Plugin class.
21  */

22 public class InitLegacyPreferences implements ILegacyPreferences {
23     /**
24      * The method tries to initialize the preferences using the legacy Plugin method.
25      *
26      * @param object - plugin to initialize
27      * @param name - ID of the plugin to be initialized
28      *
29      * @see Plugin#initializeDefaultPluginPreferences
30      *
31      * @since org.eclipse.core.runtime 3.2
32      *
33      * @deprecated Marked deprecated to supress warnings. This class is added to support
34      * backward compatibility only and should not be used in any new code.
35      */

36     public Object JavaDoc init(Object JavaDoc object, String JavaDoc name) {
37         Plugin plugin = null;
38         if (object instanceof Plugin)
39             plugin = (Plugin) object;
40         // No extension exists. Get the plug-in object and call #initializeDefaultPluginPreferences().
41
// We can only call this if the runtime compatibility layer is installed.
42
if (plugin == null && InternalPlatform.getDefault().getBundle(org.eclipse.core.internal.runtime.CompatibilityHelper.PI_RUNTIME_COMPATIBILITY) != null)
43             plugin = Platform.getPlugin(name);
44         if (plugin == null) {
45             if (InternalPlatform.DEBUG_PLUGIN_PREFERENCES)
46                 InternalPlatform.message("No plug-in object available to set plug-in default preference overrides for:" + name); //$NON-NLS-1$
47
return null;
48         }
49         if (InternalPlatform.DEBUG_PLUGIN_PREFERENCES)
50             InternalPlatform.message("Applying plug-in default preference overrides for plug-in: " + plugin.getDescriptor().getUniqueIdentifier()); //$NON-NLS-1$
51

52         plugin.internalInitializeDefaultPluginPreferences();
53         return plugin;
54     }
55
56 }
57
Popular Tags