Enable word wrapping with preference key editor.wrap.words (false by default)
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / editor / WikiEditorPlugin.java
1 package net.sourceforge.phpeclipse.wiki.editor;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.lang.reflect.InvocationTargetException;
6 import java.lang.reflect.Method;
7 import java.net.MalformedURLException;
8 import java.net.URL;
9 import java.sql.SQLException;
10 import java.text.MessageFormat;
11 import java.util.ArrayList;
12 import java.util.Hashtable;
13 import java.util.List;
14 import java.util.MissingResourceException;
15 import java.util.PropertyResourceBundle;
16 import java.util.ResourceBundle;
17
18 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
19 import net.sourceforge.phpeclipse.wiki.internal.ConfigurationManager;
20 import net.sourceforge.phpeclipse.wiki.internal.IConfigurationWorkingCopy;
21 import net.sourceforge.phpeclipse.wiki.sql.WikipediaDB;
22
23 import org.eclipse.core.resources.IFile;
24 import org.eclipse.core.resources.IProject;
25 import org.eclipse.core.resources.IResource;
26 import org.eclipse.core.resources.IWorkspace;
27 import org.eclipse.core.resources.ResourcesPlugin;
28 import org.eclipse.core.runtime.IAdapterFactory;
29 import org.eclipse.core.runtime.IAdapterManager;
30 import org.eclipse.core.runtime.IExtension;
31 import org.eclipse.core.runtime.IPluginDescriptor;
32 import org.eclipse.core.runtime.IStatus;
33 import org.eclipse.core.runtime.Path;
34 import org.eclipse.core.runtime.Platform;
35 import org.eclipse.core.runtime.Status;
36 import org.eclipse.jface.dialogs.MessageDialog;
37 import org.eclipse.jface.preference.IPreferenceStore;
38 import org.eclipse.jface.resource.ImageDescriptor;
39 import org.eclipse.jface.text.templates.ContextTypeRegistry;
40 import org.eclipse.jface.text.templates.persistence.TemplateStore;
41 import org.eclipse.swt.graphics.Image;
42 import org.eclipse.swt.widgets.Display;
43 import org.eclipse.ui.IContributorResourceAdapter;
44 import org.eclipse.ui.IPersistableElement;
45 import org.eclipse.ui.IWorkbenchPage;
46 import org.eclipse.ui.IWorkbenchWindow;
47 import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
48 import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
49 import org.eclipse.ui.plugin.AbstractUIPlugin;
50 import org.eclipse.ui.views.properties.IPropertySource;
51 import org.osgi.framework.BundleContext;
52
53 public class WikiEditorPlugin extends AbstractUIPlugin {
54
55   private static WikiEditorPlugin fgPlugin;
56
57   public final static String AUTOMATICALLY_CREATED = "<!-- automatically created -->";
58
59   public final static String WP_EXTENSION = "wp";
60
61   public final static String XML_START_1 = "<?xml version=\"1.0\" encoding=\"";
62
63   public final static String XML_START_2 = "\" ?>\n" + "<mediawiki version=\"0.1\">\n";
64
65   public final static String XML_END = "\n</mediawiki>";
66
67   public static final String PREFIX_LOAD = "Load ";
68
69   public static final String PREFIX_STORE = "Store ";
70
71   public static final String HTTP_QUERY = "HTTP Query";
72
73   //  public static final String WIKIPEDIA_GET_TEXT = "Load WikipediaEN";
74   //
75   //  public static final String WIKIPEDIA_SET_TEXT = "Store WikipediaEN";
76   public static final String WIKIPEDIA_SQL = "Wikipedia SQL access";
77
78   public static final String BLOG_A_WIKI = "Blog as Wiki Text";
79
80   public static final String BLOG_A_HTML = "Blog as HTML Text";
81
82   public static final String PLOG4U_DE_LOAD = PREFIX_LOAD + "Plog4UDE";
83
84   public static final String PLOG4U_DE_STORE = PREFIX_STORE + "Plog4UDE";
85
86   public static final String PLOG4U_ORG_LOAD = PREFIX_LOAD + "Plog4UORG";
87
88   public static final String PLOG4U_ORG_STORE = PREFIX_STORE + "Plog4UORG";
89
90   public static final String[] PREDEFINED_TYPES = {
91       HTTP_QUERY,
92       WIKIPEDIA_SQL,
93       PLOG4U_DE_LOAD,
94       PLOG4U_DE_STORE,
95       PLOG4U_ORG_LOAD,
96       PLOG4U_ORG_STORE,
97       BLOG_A_WIKI,
98       BLOG_A_HTML };
99
100   public static final String[] PREDEFINED_WIKIS = {
101       "WikibooksDE",
102       "WikibooksEN",
103       "WikinewsDE",
104       "WikinewsEN",
105       "WikipediaAR",
106       "WikipediaCA",
107       "WikipediaDE",
108       "WikipediaEN",
109       "WikipediaEO",
110       "WikipediaES",
111       "WikipediaET",
112       "WikipediaFI",
113       "WikipediaFR",
114       "WikipediaHE",
115       "WikipediaIA",
116       "WikipediaIT",
117       "WikipediaJA",
118       "WikipediaNL",
119       "WikipediaPL",
120       "WikipediaPT",
121       "WikipediaRO",
122       "WikipediaSL",
123       "WikipediaSV",
124       "WikipediaZH" };
125
126   public static final ArrayList CONFIGURATION_TYPES = new ArrayList();
127
128   //image paths
129   public static final String ICON_PATH = "icons/full/"; //$NON-NLS-1$
130
131   public final static String PLUGIN_ID = "net.sourceforge.phpeclipse.wiki";
132
133   public final static String HTML_OUTPUT_PATH = "__static_wiki_folder";
134
135   public final static String WIKI_TEXTS_BASE_PATH = "__wiki_texts_base_path";
136
137   public final static String LOCAL_TEMPLATE_FILE_NAME = "__local_template_file_name";
138
139   public final static String EXPORT_TEMPLATE_FILE_NAME = "__export_template_file_name";
140
141   public final static String LOCAL_CSS_URL = "__local_css_url";
142
143   public final static String EXPORT_CSS_URL = "__export_css_url";
144
145   public final static String PREF_STRING_CONFIGURATIONS = "__configurations4";
146
147   public final static String CONSOLE_OUTPUT = "__console_output";
148
149   public final static String HTTP_TIMEOUT = "http.timeout";
150
151   public final static String HTTP_PROXYHOST = "http.proxyHost";
152
153   public final static String HTTP_PROXYPORT = "http.proxyPort";
154
155   public final static String HTTP_PROXYUSERNAME = "http.proxyUserName";
156
157   public final static String HTTP_PROXYPASSWORD = "http.proxyPassword";
158
159   /**
160    * A named preference that controls whether the 'wrap words' feature is enabled.
161    * <p>
162    * Value is of type <code>Boolean</code>.
163    * </p>
164    */
165   public final static String EDITOR_WRAP_WORDS = "editor.wrap.words"; //$NON-NLS-1$
166
167   public final static String CONFIG_MEMENTO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configurations>"
168       + "<config name=\"Google Search\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
169       + "<config name=\"Koders.com Search\" type-id=\"HTTP Query\" url=\"http://koders.com/?s=$text.selection\"/>"
170       + "<config name=\"Leo.org Translation\" type-id=\"HTTP Query\" url=\"http://dict.leo.org/?search=$text.selection\"/>"
171
172       + "<config name=\"Plog4U.de Download\" type-id=\"" + PLOG4U_DE_LOAD
173       + "\" url=\"http://www.plog4u.de/index.php/Spezial:Export\"/>" + "<config name=\"Plog4U.org Download\" type-id=\""
174       + PLOG4U_ORG_LOAD + "\" url=\"http://www.plog4u.org/index.php/Special:Export\"/>"
175       + "<config name=\"Plog4U.de Upload\" type-id=\"" + PLOG4U_DE_STORE + "\" url=\"http://www.plog4u.de/index.php\"/>"
176       + "<config name=\"Plog4U.org Upload\" type-id=\"" + PLOG4U_ORG_STORE + "\" url=\"http://www.plog4u.org/index.php\"/>"
177
178       + "<config name=\"WikipediaEN Download\" type-id=\"" + PREFIX_LOAD
179       + "WikipediaEN\" url=\"http://en.wikipedia.org/wiki/Special:Export\"/>" + "<config name=\"WikibooksEN Download\" type-id=\""
180       + PREFIX_LOAD + "WikibooksEN\" url=\"http://en.wikibooks.org/wiki/Special:Export\"/>"
181       + "<config name=\"WikipediaEN Upload\" type-id=\"" + PREFIX_STORE
182       + "WikipediaEN\" url=\"http://en.wikipedia.org/w/index.php\"/>" + "<config name=\"WikibooksEN Upload\" type-id=\""
183       + PREFIX_STORE + "WikibooksEN\" url=\"http://en.wikibooks.org/w/index.php\"/>"
184       + "<config name=\"Wikipedia-SQL\" type-id=\"Wikipedia SQL access\" user=\"root\" url=\"jdbc:mysql://localhost/wikidb\"/>"
185       + "</configurations>";
186
187   public static WikipediaDB fWikiDB = null;
188
189   private static ConfigurationManager manager;
190
191   //
192   //  public static final String IMG_MONITOR_ON = "monitorOn";
193   //
194   //  public static final String IMG_MONITOR_OFF = "monitorOff";
195
196   /**
197    * Creates an image and places it in the image registry.
198    * 
199    * @param id
200    *          the identifier for the image
201    * @param baseURL
202    *          the base URL for the image
203    */
204   protected static void createImageDescriptor(WikiEditorPlugin plugin, String id, URL baseURL) {
205     // Delegate to the plugin instance to avoid concurrent class loading problems
206     plugin.privateCreateImageDescriptor(id, baseURL);
207   }
208
209   public static WikiEditorPlugin getDefault() {
210     return fgPlugin;
211   }
212
213   /**
214    * Returns the image descriptor for the given image ID. Returns null if there is no such image.
215    * 
216    * @param id
217    *          the identifier for the image to retrieve
218    * @return the image associated with the given ID
219    */
220   public static ImageDescriptor getImageDescriptor(String id) {
221     // Delegate to the plugin instance to avoid concurrent class loading problems
222     return getDefault().privateGetImageDescriptor(id);
223   }
224
225   /**
226    * Convenience method to get an image descriptor for an extension
227    * 
228    * @param extension
229    *          the extension declaring the image
230    * @param subdirectoryAndFilename
231    *          the path to the image
232    * @return the image
233    */
234   public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) {
235     IPluginDescriptor pluginDescriptor = extension.getDeclaringPluginDescriptor();
236     URL path = pluginDescriptor.getInstallURL();
237     URL fullPathString = null;
238     try {
239       fullPathString = new URL(path, subdirectoryAndFilename);
240       return ImageDescriptor.createFromURL(fullPathString);
241     } catch (MalformedURLException e) {
242     }
243     return null;
244   }
245
246   public static String getResourceString(String key) {
247     ResourceBundle bundle = WikiEditorPlugin.getDefault().getResourceBundle();
248     try {
249       return (bundle != null) ? bundle.getString(key) : key;
250     } catch (MissingResourceException e) {
251       return key;
252     }
253   }
254
255   /**
256    * Returns the standard display to be used. The method first checks, if the thread calling this method has an associated display.
257    * If so, this display is returned. Otherwise the method returns the default display.
258    */
259   public static Display getStandardDisplay() {
260     Display display = Display.getCurrent();
261     if (display == null) {
262       display = Display.getDefault();
263     }
264     return display;
265   }
266
267   private ContributionContextTypeRegistry fContextTypeRegistry;
268
269   private ResourceBundle fResourceBundle;
270
271   private ContributionTemplateStore fTemplateStore;
272
273   private Hashtable imageDescriptors = new Hashtable(20);
274
275   public WikiEditorPlugin(IPluginDescriptor descriptor) {
276     super(descriptor);
277     initializeImages();
278     fgPlugin = this;
279     for (int i = 0; i < PREDEFINED_TYPES.length; i++) {
280       CONFIGURATION_TYPES.add(PREDEFINED_TYPES[i]);
281     }
282
283     for (int i = 0; i < PREDEFINED_WIKIS.length; i++) {
284       CONFIGURATION_TYPES.add(PREFIX_LOAD + PREDEFINED_WIKIS[i]);
285     }
286     for (int i = 0; i < PREDEFINED_WIKIS.length; i++) {
287       CONFIGURATION_TYPES.add(PREFIX_STORE + PREDEFINED_WIKIS[i]);
288     }
289     manager = ConfigurationManager.getInstance();
290     try {
291       fResourceBundle = ResourceBundle.getBundle("net.sourceforge.phpeclipse.wiki.editor.WikiEditorMessages");
292     } catch (MissingResourceException x) {
293       fResourceBundle = null;
294     }
295   }
296
297   /**
298    * Creates an image and places it in the image registry.
299    */
300   protected void createImageDescriptor(String id, URL baseURL) {
301     URL url = null;
302     try {
303       url = new URL(baseURL, ICON_PATH + id);
304     } catch (MalformedURLException e) {
305     }
306     ImageDescriptor desc = ImageDescriptor.createFromURL(url);
307     imageDescriptors.put(id, desc);
308   }
309
310   public IWorkbenchPage getActivePage() {
311     IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
312     if (window != null)
313       return window.getActivePage();
314     return null;
315   }
316
317   public ContextTypeRegistry getContextTypeRegistry() {
318     if (fContextTypeRegistry == null) {
319       fContextTypeRegistry = new ContributionContextTypeRegistry();
320       fContextTypeRegistry.addContextType("net.sourceforge.phpeclipse.wiki.editor.templates");
321     }
322     return fContextTypeRegistry;
323   }
324
325   public Image getImage(String key) {
326     Image image = getImageRegistry().get(key);
327     if (image == null) {
328       ImageDescriptor d = getImageDescriptor(key);
329       image = d.createImage();
330       getImageRegistry().put(key, image);
331     }
332     return image;
333   }
334
335   public ResourceBundle getResourceBundle() {
336     return fResourceBundle;
337   }
338
339   public TemplateStore getTemplateStore() {
340     if (fTemplateStore == null) {
341       fTemplateStore = new ContributionTemplateStore(getContextTypeRegistry(), getDefault().getPreferenceStore(), "templates");
342       try {
343         fTemplateStore.load();
344       } catch (IOException e) {
345         e.printStackTrace();
346       }
347     }
348
349     return fTemplateStore;
350   }
351
352   private static boolean isDefined(String test) {
353     if (test != null && test.length() > 0) {
354       for (int i = 0; i < test.length(); i++) {
355         if (!Character.isWhitespace(test.charAt(i))) {
356           return false;
357         }
358       }
359     }
360     return true;
361   }
362
363   /*
364    * (non-Javadoc)
365    * 
366    * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
367    */
368   protected void initializeDefaultPreferences(IPreferenceStore store) {
369     store.setDefault(PREF_STRING_CONFIGURATIONS, CONFIG_MEMENTO);
370     store.setDefault(CONSOLE_OUTPUT, "true");
371
372     String operatingSystem = Platform.getOS();
373     // operatingSystem ==> maxosx, linux, solaris, win32,...
374     try {
375       InputStream is = getDefault().openStream(new Path("prefs/default_" + operatingSystem + ".properties"));
376       PropertyResourceBundle resourceBundle = new PropertyResourceBundle(is);
377
378       String key = EDITOR_WRAP_WORDS;
379       try {
380         String wordWrap = resourceBundle.getString(key);
381         Boolean b = Boolean.valueOf(wordWrap);
382         if (b.booleanValue()) { 
383           store.setDefault(key, "true");
384         } else {
385           store.setDefault(key, "false");
386         }
387       } catch (Exception e) {
388         store.setDefault(key, "false");
389       }
390
391       key = HTTP_TIMEOUT;
392       try {
393         String timeout = resourceBundle.getString(key);
394         int val = Integer.parseInt(timeout);
395         if (val > 0) {
396           val *= 1000;
397         } else {
398           val = 30000;
399         }
400         store.setDefault(key, Integer.toString(val));
401       } catch (Exception e) {
402         store.setDefault(key, "30000"); // 30 seconds timeout
403       }
404
405       key = HTTP_PROXYHOST;
406       try {
407         String proxyHost = resourceBundle.getString(key);
408         if (isDefined(proxyHost)) {
409           store.setDefault(key, proxyHost);
410         } else {
411           store.setDefault(key, System.getProperty(key, ""));
412         }
413       } catch (Exception e) {
414         store.setDefault(key, System.getProperty(key, ""));
415       }
416
417       key = HTTP_PROXYPORT;
418       try {
419         String proxyPort = resourceBundle.getString(key);
420         if (isDefined(proxyPort)) {
421           // check for integer parse exception:
422           Integer.parseInt(proxyPort);
423           store.setDefault(key, proxyPort);
424         } else {
425           store.setDefault(key, System.getProperty(key, "80"));
426         }
427       } catch (Exception e) {
428         store.setDefault(key, System.getProperty(key, "80"));
429       }
430
431       key = HTTP_PROXYUSERNAME;
432       try {
433         String proxyUserName = resourceBundle.getString(key);
434         if (isDefined(proxyUserName)) {
435           store.setDefault(key, proxyUserName);
436         } else {
437           store.setDefault(key, System.getProperty(key, ""));
438         }
439       } catch (Exception e) {
440         store.setDefault(key, System.getProperty(key, ""));
441       }
442
443       key = HTTP_PROXYPASSWORD;
444       try {
445         String proxyPassWord = resourceBundle.getString(key);
446         if (isDefined(proxyPassWord)) {
447           store.setDefault(key, proxyPassWord);
448         } else {
449           store.setDefault(key, System.getProperty(key, ""));
450         }
451       } catch (Exception e) {
452         store.setDefault(key, System.getProperty(key, ""));
453       }
454
455     } catch (Exception e) {
456     }
457
458   }
459
460   /*
461    * Initializes the table of images used in this plugin. The plugin is provided because this method is called before the plugin
462    * staic variable has been set. See the comment on the getPlugin() method for a description of why this is required.
463    */
464   private void initializeImages() {
465     URL baseURL = getDescriptor().getInstallURL();
466
467     //  special
468     createImageDescriptor("glyphs/glyph1.gif", baseURL); //$NON-NLS-1$
469     createImageDescriptor("glyphs/glyph2.gif", baseURL); //$NON-NLS-1$
470     createImageDescriptor("glyphs/glyph3.gif", baseURL); //$NON-NLS-1$
471     createImageDescriptor("glyphs/glyph4.gif", baseURL); //$NON-NLS-1$
472     createImageDescriptor("glyphs/glyph5.gif", baseURL); //$NON-NLS-1$
473     createImageDescriptor("glyphs/glyph6.gif", baseURL); //$NON-NLS-1$
474     createImageDescriptor("glyphs/glyph7.gif", baseURL); //$NON-NLS-1$
475     createImageDescriptor("glyphs/glyph8.gif", baseURL); //$NON-NLS-1$
476
477   }
478
479   public void log(String message) {
480     getDefault().getLog().log(new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, null));
481   }
482
483   public void log(String message, Exception e) {
484     getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Caught exception", e));
485   }
486
487   public void logAndReport(String title, String message, Exception e) {
488     log(message, e);
489     reportError(title, message);
490   }
491
492   private void privateCreateImageDescriptor(String id, URL baseURL) {
493     URL url = null;
494     try {
495       url = new URL(baseURL, ICON_PATH + id);
496     } catch (MalformedURLException e) {
497     }
498     ImageDescriptor desc = ImageDescriptor.createFromURL(url);
499     imageDescriptors.put(id, desc);
500   }
501
502   private ImageDescriptor privateGetImageDescriptor(String id) {
503     if (!imageDescriptors.containsKey(id)) {
504       URL baseURL = WikiEditorPlugin.getDefault().getDescriptor().getInstallURL();
505       createImageDescriptor(getDefault(), id, baseURL);
506     }
507     return (ImageDescriptor) imageDescriptors.get(id);
508   }
509
510   public void reportError(String title, String message) {
511     try {
512       //      Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
513       MessageDialog.openError(null, title, message);
514     } catch (RuntimeException e) {
515       log(e.getLocalizedMessage(), e);
516     }
517   }
518
519   //  public void startup() throws CoreException {
520   //    super.startup();
521   //  }
522
523   /**
524    * Returns the translated String found with the given key.
525    * 
526    * @return java.lang.String
527    * @param key
528    *          java.lang.String
529    */
530   public static String getResource(String key) {
531     try {
532       return Platform.getResourceString(getDefault().getBundle(), key);
533     } catch (Exception e) {
534       return key;
535     }
536   }
537
538   /**
539    * Returns the translated String found with the given key, and formatted with the given object.
540    * 
541    * @param key
542    *          java.lang.String
543    * @param obj
544    *          java.lang.Object[]
545    * @return java.lang.String
546    */
547   public static String getResource(String key, Object[] obj) {
548     try {
549       return MessageFormat.format(getResource(key), obj);
550     } catch (Exception e) {
551       return key;
552     }
553   }
554
555   /**
556    * Returns the translated String found with the given key, and formatted with the given object.
557    * 
558    * @param key
559    *          java.lang.String
560    * @param s
561    *          java.lang.String
562    * @return java.lang.String
563    */
564   public static String getResource(String key, String s) {
565     try {
566       return MessageFormat.format(getResource(key), new String[] { s });
567     } catch (Exception e) {
568       return key;
569     }
570   }
571
572   /**
573    * Return a list of all the existing configurations.
574    * 
575    * @return java.util.List
576    */
577   public static List getConfigurations() {
578     return manager.getConfigurations();
579   }
580
581   /**
582    * Create a new monitor.
583    * 
584    * @return working copy
585    */
586   public static IConfigurationWorkingCopy createConfiguration() {
587     return manager.createConfiguration();
588   }
589
590   public static ArrayList getTypes() {
591     return CONFIGURATION_TYPES;
592   }
593
594   public static void addType(String type) {
595     CONFIGURATION_TYPES.add(type);
596   }
597
598   /*
599    * (non - Javadoc) Method declared in Plugin
600    */
601   public void start(BundleContext context) throws Exception {
602     super.start(context);
603   }
604
605   /*
606    * @see org.eclipse.core.runtime.Plugin#stop
607    */
608   public void stop(BundleContext context) throws Exception {
609     try {
610       if (fWikiDB != null) {
611         try {
612           fWikiDB.shutdown();
613         } catch (SQLException e) {
614         }
615       }
616     } finally {
617       super.stop(context);
618     }
619   }
620
621   public static void log(int severity, String message) {
622     Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null);
623     log(status);
624   }
625
626   public static void log(IStatus status) {
627     getDefault().getLog().log(status);
628   }
629
630   public static void log(Throwable e) {
631     log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
632   }
633
634   /**
635    * Get a IWikpedia singleton instance through reflection (i.e. Method#invoke() )
636    * 
637    * @param wikiLocale
638    * @return
639    * @throws NoSuchMethodException
640    * @throws IllegalAccessException
641    * @throws ClassNotFoundException
642    * @throws InvocationTargetException
643    */
644   public static IWikipedia getWikiInstance(String wikiLocale) throws NoSuchMethodException, IllegalAccessException,
645       ClassNotFoundException, InvocationTargetException {
646     String className = "net.sourceforge.phpeclipse.wiki.actions.mediawiki.config." + wikiLocale;
647     Class cls = Class.forName(className);
648     Method method = cls.getMethod("getInstance", new Class[0]);
649     return (IWikipedia) method.invoke(null, new Object[0]);
650   }
651
652   /**
653    * Returns the workspace instance.
654    */
655   public static IWorkspace getWorkspace() {
656     return ResourcesPlugin.getWorkspace();
657   }
658
659   // test code
660   //  public static void main(String[] args) {
661   //    try {
662   //      getWikiInstance("WikipediaEN");
663   //    } catch (NoSuchMethodException e) {
664   //      // TODO Auto-generated catch block
665   //      e.printStackTrace();
666   //    } catch (IllegalAccessException e) {
667   //      // TODO Auto-generated catch block
668   //      e.printStackTrace();
669   //    } catch (ClassNotFoundException e) {
670   //      // TODO Auto-generated catch block
671   //      e.printStackTrace();
672   //    } catch (InvocationTargetException e) {
673   //      // TODO Auto-generated catch block
674   //      e.printStackTrace();
675   //    }
676   //  }
677
678 }