X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java index 88dff81..41afec5 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java @@ -1,17 +1,21 @@ package net.sourceforge.phpeclipse.wiki.editor; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.sql.SQLException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.MissingResourceException; import java.util.ResourceBundle; -import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy; +import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia; import net.sourceforge.phpeclipse.wiki.internal.ConfigurationManager; +import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy; import net.sourceforge.phpeclipse.wiki.sql.WikipediaDB; import org.eclipse.core.runtime.CoreException; @@ -41,15 +45,37 @@ public class WikiEditorPlugin extends AbstractUIPlugin { public static final String HTTP_QUERY = "HTTP Query"; - public static final String WIKIPEDIA_GET_TEXT = "Wikipedia-Load Text"; - + // public static final String WIKIPEDIA_GET_TEXT = "Load WikipediaEN"; + // + // public static final String WIKIPEDIA_SET_TEXT = "Store WikipediaEN"; public static final String WIKIPEDIA_SQL = "Wikipedia SQL access"; - + public static final String BLOG_A_WIKI = "Blog as Wiki Text"; public static final String BLOG_A_HTML = "Blog as HTML Text"; - public static final String[] CONFIGURATION_TYPES = { HTTP_QUERY, WIKIPEDIA_GET_TEXT, WIKIPEDIA_SQL, BLOG_A_WIKI, BLOG_A_HTML }; + public static final String[] PREDEFINED_TYPES = { HTTP_QUERY, WIKIPEDIA_SQL, BLOG_A_WIKI, BLOG_A_HTML }; + + public static final String[] PREDEFINED_WIKIS = { + "WikibooksDE", + "WikibooksEN", + "WikinewsDE", + "WikinewsEN", + "WikipediaAR", + "WikipediaCA", + "WikipediaDE", + "WikipediaEN", + "WikipediaEO", + "WikipediaES", + "WikipediaET", + "WikipediaFI", + "WikipediaFR" }; + + public static final String PREFIX_LOAD = "Load "; + + public static final String PREFIX_STORE = "Store "; + + public static final ArrayList CONFIGURATION_TYPES = new ArrayList(); //image paths public static final String ICON_PATH = "icons/full/"; //$NON-NLS-1$ @@ -68,15 +94,17 @@ public class WikiEditorPlugin extends AbstractUIPlugin { public final static String EXPORT_CSS_URL = "__export_css_url"; - public final static String PREF_STRING_CONFIGURATIONS = "configurations"; + public final static String PREF_STRING_CONFIGURATIONS = "__configurations2"; public final static String CONFIG_MEMENTO = "" + "" + "" + "" + "" - + "" - + "" + + "" + + "" + + "" + + "" + "" + ""; @@ -172,6 +200,16 @@ public class WikiEditorPlugin extends AbstractUIPlugin { super(descriptor); initializeImages(); fgPlugin = this; + for (int i = 0; i < PREDEFINED_TYPES.length; i++) { + CONFIGURATION_TYPES.add(PREDEFINED_TYPES[i]); + } + + for (int i = 0; i < PREDEFINED_WIKIS.length; i++) { + CONFIGURATION_TYPES.add(PREFIX_LOAD + PREDEFINED_WIKIS[i]); + } + for (int i = 0; i < PREDEFINED_WIKIS.length; i++) { + CONFIGURATION_TYPES.add(PREFIX_STORE + PREDEFINED_WIKIS[i]); + } manager = ConfigurationManager.getInstance(); try { fResourceBundle = ResourceBundle.getBundle("net.sourceforge.phpeclipse.wiki.editor.WikiEditorMessages"); @@ -374,10 +412,14 @@ public class WikiEditorPlugin extends AbstractUIPlugin { return manager.createConfiguration(); } - public static String[] getTypes() { + public static ArrayList getTypes() { return CONFIGURATION_TYPES; } + public static void addType(String type) { + CONFIGURATION_TYPES.add(type); + } + /* * (non-Javadoc) * @@ -392,4 +434,55 @@ public class WikiEditorPlugin extends AbstractUIPlugin { } super.shutdown(); } + + public static void log(int severity, String message) { + Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null); + log(status); + } + + public static void log(IStatus status) { + getDefault().getLog().log(status); + } + + public static void log(Throwable e) { + log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$ + } + + /** + * Get a IWikpedia singleton instance through reflection (i.e. Method#invoke() ) + * + * @param wikiLocale + * @return + * @throws NoSuchMethodException + * @throws IllegalAccessException + * @throws ClassNotFoundException + * @throws InvocationTargetException + */ + public static IWikipedia getWikiInstance(String wikiLocale) throws NoSuchMethodException, IllegalAccessException, + ClassNotFoundException, InvocationTargetException { + String className = "net.sourceforge.phpeclipse.wiki.actions.mediawiki.config." + wikiLocale; + Class cls = Class.forName(className); + Method method = cls.getMethod("getInstance", new Class[0]); + return (IWikipedia) method.invoke(null, new Object[0]); + } + + // test code + // public static void main(String[] args) { + // try { + // getWikiInstance("WikipediaEN"); + // } catch (NoSuchMethodException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (IllegalAccessException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (ClassNotFoundException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } catch (InvocationTargetException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + } \ No newline at end of file