RefreshJob loads max 10 articles at a time; there's a delay of 1 second for the next...
[phpeclipse.git] / net.sourceforge.phpeclipse.phphelp / src / net / sourceforge / phpdt / phphelp / actions / PHPEclipseShowContextHelp.java
index 834d108..c822bb1 100644 (file)
@@ -7,15 +7,19 @@ http://www.eclipse.org/legal/cpl-v10.html
 
 Contributors:
     IBM Corporation - Initial implementation
-    Klaus Hartlage - www.eclipseproject.de
+    www.phpeclipse.de
 **********************************************************************/
 package net.sourceforge.phpdt.phphelp.actions;
 
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor;
-import org.eclipse.help.IHelp;
-import org.eclipse.help.IHelpResource;
+
 import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextSelection;
@@ -74,12 +78,26 @@ public class PHPEclipseShowContextHelp extends ActionDelegate implements IEditor
   }
 
   public static void openContextHelp(String word) {
-    IHelp help = WorkbenchHelp.getHelpSupport();
-    if (help != null) {
-      IHelpResource helpResource = new PHPFunctionHelpResource(word);
-      WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
+    IPreferenceStore store = PHPHelpPlugin.getDefault().getPreferenceStore();
+    if (store.getBoolean(PHPHelpPlugin.PHP_CHM_ENABLED)) {
+      String[] arguments = { store.getString(PHPHelpPlugin.PHP_CHM_FILE), word };
+      MessageFormat form = new MessageFormat(store.getString(PHPHelpPlugin.PHP_CHM_COMMAND));
+      try {
+        Runtime runtime = Runtime.getRuntime();
+        String command = form.format(arguments);
+
+        runtime.exec(command);
+      } catch (IOException e) {
+      }
     } else {
-      //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
+//      IHelp help = WorkbenchHelp.getHelpSupport();
+//      if (help != null) {
+        PHPFunctionHelpResource helpResource = new PHPFunctionHelpResource(word);
+        WorkbenchHelp.displayHelpResource(helpResource.getHref());
+        //getHelpSupport().displayHelpResource(helpResource);
+//      } else {
+        //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
+//      }
     }
   }