Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.phphelp / src / net / sourceforge / phpdt / phphelp / PHPHelpPlugin.java
index f296936..e388fb1 100644 (file)
  **********************************************************************/
 package net.sourceforge.phpdt.phphelp;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.phpdt.httpquery.config.ConfigurationManager;
+import net.sourceforge.phpdt.httpquery.config.IConfigurationWorkingCopy;
+
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IStatus;
@@ -35,6 +41,21 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
 
        public static final String PHP_CHM_COMMAND = "_php_chm_command";
 
+       public static final String HTTP_QUERY = "HTTP Query";
+
+       public final static String PREF_STRING_CONFIGURATIONS = "__configurations1";
+
+       public final static String CONFIG_MEMENTO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+                       + "<configurations>"
+                       + "<config name=\"PHP Manual\" type-id=\"HTTP Query\" url=\"http://www.php.net/manual/en/function.$php.selection.php\"/>"
+                       + "<config name=\"Google.com\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
+                       + "<config name=\"Koders.com\" type-id=\"HTTP Query\" url=\"http://koders.com/?s=$text.selection\"/>"
+                       + "<config name=\"Leo.org Deutsch/English\" type-id=\"HTTP Query\" url=\"http://dict.leo.org/?search=$text.selection\"/>"
+                       + "<config name=\"Localhost\" type-id=\"HTTP Query\" url=\"http://localhost\"/>"
+                       + "</configurations>";
+
+       public static final ArrayList CONFIGURATION_TYPES = new ArrayList();
+
        /**
         * The id of the PHP plugin (value
         * <code>"net.sourceforge.phpeclipse.phphelp"</code>).
@@ -44,6 +65,8 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
        // The shared instance.
        private static PHPHelpPlugin plugin;
 
+       private static ConfigurationManager manager;
+
        /**
         * The constructor.
         */
@@ -106,6 +129,8 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
        }
 
        protected void initializeDefaultPreferences(IPreferenceStore store) {
+               store.setDefault(PREF_STRING_CONFIGURATIONS, CONFIG_MEMENTO);
+               addType(HTTP_QUERY);
                // windows preferences:
                String windowsSystem = Platform.getWS();
 
@@ -160,13 +185,10 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
        // ColorManager.getDefault().dispose();
        // }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
-        */
        public void start(BundleContext context) throws Exception {
                super.start(context);
+
+               manager = ConfigurationManager.getInstance();
                // IAdapterManager manager = Platform.getAdapterManager();
                // manager.registerAdapters(new PHPElementAdapterFactory(),
                // PHPElement.class);
@@ -181,13 +203,49 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
                // });
        }
 
-       /*
-        * (non-Javadoc)
-        *
-        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
-        */
        public void stop(BundleContext context) throws Exception {
                // ColorManager.getDefault().dispose();
                super.stop(context);
        }
+
+       /**
+        * Returns the translated String found with the given key.
+        * 
+        * @return java.lang.String
+        * @param key
+        *            java.lang.String
+        */
+       public static String getResource(String key) {
+               try {
+                       return Platform.getResourceString(getDefault().getBundle(), key);
+               } catch (Exception e) {
+                       return key;
+               }
+       }
+
+       /**
+        * Return a list of all the existing configurations.
+        * 
+        * @return java.util.List
+        */
+       public static List getConfigurations() {
+               return manager.getConfigurations();
+       }
+
+       /**
+        * Create a new monitor.
+        * 
+        * @return working copy
+        */
+       public static IConfigurationWorkingCopy createConfiguration() {
+               return manager.createConfiguration();
+       }
+
+       public static ArrayList getTypes() {
+               return CONFIGURATION_TYPES;
+       }
+
+       public static void addType(String type) {
+               CONFIGURATION_TYPES.add(type);
+       }
 }
\ No newline at end of file