X-Git-Url: http://secure.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 41afec5..915af72 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,6 +1,7 @@
package net.sourceforge.phpeclipse.wiki.editor;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
@@ -8,9 +9,11 @@ import java.net.URL;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
@@ -18,10 +21,13 @@ 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.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -43,6 +49,20 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
private static WikiEditorPlugin fgPlugin;
+ public final static String AUTOMATICALLY_CREATED = "";
+
+ public final static String WP_EXTENSION = "wp";
+
+ public final static String XML_START_1 = "\n" + "\n";
+
+ public final static String XML_END = "\n";
+
+ public static final String PREFIX_LOAD = "Load ";
+
+ public static final String PREFIX_STORE = "Store ";
+
public static final String HTTP_QUERY = "HTTP Query";
// public static final String WIKIPEDIA_GET_TEXT = "Load WikipediaEN";
@@ -54,7 +74,23 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
public static final String BLOG_A_HTML = "Blog as HTML Text";
- public static final String[] PREDEFINED_TYPES = { HTTP_QUERY, WIKIPEDIA_SQL, BLOG_A_WIKI, BLOG_A_HTML };
+ public static final String PLOG4U_DE_LOAD = PREFIX_LOAD + "Plog4UDE";
+
+ public static final String PLOG4U_DE_STORE = PREFIX_STORE + "Plog4UDE";
+
+ public static final String PLOG4U_ORG_LOAD = PREFIX_LOAD + "Plog4UORG";
+
+ public static final String PLOG4U_ORG_STORE = PREFIX_STORE + "Plog4UORG";
+
+ public static final String[] PREDEFINED_TYPES = {
+ HTTP_QUERY,
+ WIKIPEDIA_SQL,
+ PLOG4U_DE_LOAD,
+ PLOG4U_DE_STORE,
+ PLOG4U_ORG_LOAD,
+ PLOG4U_ORG_STORE,
+ BLOG_A_WIKI,
+ BLOG_A_HTML };
public static final String[] PREDEFINED_WIKIS = {
"WikibooksDE",
@@ -69,11 +105,18 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
"WikipediaES",
"WikipediaET",
"WikipediaFI",
- "WikipediaFR" };
-
- public static final String PREFIX_LOAD = "Load ";
-
- public static final String PREFIX_STORE = "Store ";
+ "WikipediaFR",
+ "WikipediaHE",
+ "WikipediaIA",
+ "WikipediaIT",
+ "WikipediaJA",
+ "WikipediaNL",
+ "WikipediaPL",
+ "WikipediaPT",
+ "WikipediaRO",
+ "WikipediaSL",
+ "WikipediaSV",
+ "WikipediaZH" };
public static final ArrayList CONFIGURATION_TYPES = new ArrayList();
@@ -94,17 +137,37 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
public final static String EXPORT_CSS_URL = "__export_css_url";
- public final static String PREF_STRING_CONFIGURATIONS = "__configurations2";
+ public final static String PREF_STRING_CONFIGURATIONS = "__configurations4";
+
+ public final static String CONSOLE_OUTPUT = "__console_output";
+
+ public final static String HTTP_TIMEOUT = "http.timeout";
+
+ public final static String HTTP_PROXYHOST = "http.proxyHost";
- public final static String CONFIG_MEMENTO = ""
- + ""
+ public final static String HTTP_PROXYPORT = "http.proxyPort";
+
+ public final static String HTTP_PROXYUSERNAME = "http.proxyUserName";
+
+ public final static String HTTP_PROXYPASSWORD = "http.proxyPassword";
+
+ public final static String CONFIG_MEMENTO = "" + ""
+ ""
+ ""
+ ""
- + ""
- + ""
- + ""
- + ""
+
+ + "" + ""
+ + ""
+ + ""
+
+ + "" + ""
+ + "" + ""
+ ""
+ "";
@@ -273,6 +336,17 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
return fTemplateStore;
}
+ private static boolean isDefined(String test) {
+ if (test != null && test.length() > 0) {
+ for (int i = 0; i < test.length(); i++) {
+ if (!Character.isWhitespace(test.charAt(i))) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
/*
* (non-Javadoc)
*
@@ -280,6 +354,81 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
*/
protected void initializeDefaultPreferences(IPreferenceStore store) {
store.setDefault(PREF_STRING_CONFIGURATIONS, CONFIG_MEMENTO);
+ store.setDefault(CONSOLE_OUTPUT, "true");
+
+ String operatingSystem = Platform.getOS();
+ // operatingSystem ==> maxosx, linux, solaris, win32,...
+ try {
+ InputStream is = getDefault().openStream(new Path("prefs/default_" + operatingSystem + ".properties"));
+ PropertyResourceBundle resourceBundle = new PropertyResourceBundle(is);
+
+ String key = HTTP_TIMEOUT;
+ try {
+ String timeout = resourceBundle.getString(key);
+ int val = Integer.parseInt(timeout);
+ if (val > 0) {
+ val *= 1000;
+ } else {
+ val = 30000;
+ }
+ store.setDefault(key, Integer.toString(val));
+ } catch (Exception e) {
+ store.setDefault(key, "30000"); // 30 seconds timeout
+ }
+
+ key = HTTP_PROXYHOST;
+ try {
+ String proxyHost = resourceBundle.getString(key);
+ if (isDefined(proxyHost)) {
+ store.setDefault(key, proxyHost);
+ } else {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+ } catch (Exception e) {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+
+ key = HTTP_PROXYPORT;
+ try {
+ String proxyPort = resourceBundle.getString(key);
+ if (isDefined(proxyPort)) {
+ // check for integer parse exception:
+ Integer.parseInt(proxyPort);
+ store.setDefault(key, proxyPort);
+ } else {
+ store.setDefault(key, System.getProperty(key, "80"));
+ }
+ } catch (Exception e) {
+ store.setDefault(key, System.getProperty(key, "80"));
+ }
+
+ key = HTTP_PROXYUSERNAME;
+ try {
+ String proxyUserName = resourceBundle.getString(key);
+ if (isDefined(proxyUserName)) {
+ store.setDefault(key, proxyUserName);
+ } else {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+ } catch (Exception e) {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+
+ key = HTTP_PROXYPASSWORD;
+ try {
+ String proxyPassWord = resourceBundle.getString(key);
+ if (isDefined(proxyPassWord)) {
+ store.setDefault(key, proxyPassWord);
+ } else {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+ } catch (Exception e) {
+ store.setDefault(key, System.getProperty(key, ""));
+ }
+
+ } catch (Exception e) {
+ }
+
}
/*
@@ -334,8 +483,8 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
public void reportError(String title, String message) {
try {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- MessageDialog.openError(shell, title, message);
+ // Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ MessageDialog.openError(null, title, message);
} catch (RuntimeException e) {
log(e.getLocalizedMessage(), e);
}
@@ -466,6 +615,13 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
return (IWikipedia) method.invoke(null, new Object[0]);
}
+ /**
+ * Returns the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
// test code
// public static void main(String[] args) {
// try {