1) Fixed issue #776.
[phpeclipse.git] / net.sourceforge.phpeclipse.phphelp / src / net / sourceforge / phpdt / httpquery / AbstractHTTPQueryAction.java
index 6d36486..2191117 100644 (file)
@@ -24,19 +24,22 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
                super();
        }
 
-       abstract protected Configuration getConfiguration();
+       abstract protected Configuration getConfiguration(String name);
 
        public void setActiveEditor(IAction action, IEditorPart targetEditor) {
-               if (targetEditor != null && (targetEditor instanceof AbstractTextEditor)) {
+               if (targetEditor != null
+                               && (targetEditor instanceof AbstractTextEditor)) {
                        editor = (AbstractTextEditor) targetEditor;
                }
        }
 
        public void run(IAction action) {
-               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               IWorkbenchWindow window = PlatformUI.getWorkbench()
+                               .getActiveWorkbenchWindow();
                if (editor == null) {
                        IEditorPart targetEditor = window.getActivePage().getActiveEditor();
-                       if (targetEditor != null && (targetEditor instanceof AbstractTextEditor)) {
+                       if (targetEditor != null
+                                       && (targetEditor instanceof AbstractTextEditor)) {
                                editor = (AbstractTextEditor) targetEditor;
                        }
                }
@@ -50,10 +53,12 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
                                } else {
                                        page.bringToTop(part);
                                }
-                               Configuration config = getConfiguration();
+                               Configuration config = getConfiguration(null);
                                String templateString = generateUrl(config, config.getURL());
                                if (templateString != null && !templateString.equals("")) {
                                        ((BrowserView) part).setUrl(templateString);
+                               } else {
+                                       ((BrowserView) part).setUrl(config.getURL());
                                }
                        } catch (Exception e) {
                        }
@@ -64,11 +69,13 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
        }
 
        public IDocument getDocument() {
-               IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+               IDocument doc = editor.getDocumentProvider().getDocument(
+                               editor.getEditorInput());
                return doc;
        }
 
-       public static String getSelectedText(AbstractTextEditor editor, IDocument document, int initialPos) {
+       public static String getSelectedText(AbstractTextEditor editor,
+                       IDocument document, int initialPos) {
                try {
                        int pos = initialPos;
                        int line = document.getLineOfOffset(pos);
@@ -76,9 +83,9 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
                        int end = start + document.getLineInformation(line).getLength();
 
                        /*
-                        * The line does not include \n or \r so pos can be > end. Making pos =
-                        * end in this case is safe for the purposes of determining the TextRegion
-                        * at the cursor position
+                        * The line does not include \n or \r so pos can be > end. Making
+                        * pos = end in this case is safe for the purposes of determining
+                        * the TextRegion at the cursor position
                         */
                        if (pos > end) {
                                pos = end;
@@ -103,7 +110,8 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
                                }
                        }
                        if (textStart != (-1) && textEnd != (-1) && textStart < textEnd) {
-                               return new String(word.toCharArray(), textStart, textEnd - textStart);
+                               return new String(word.toCharArray(), textStart, textEnd
+                                               - textStart);
                        }
                } catch (Exception e) {
 
@@ -113,7 +121,8 @@ public abstract class AbstractHTTPQueryAction implements IEditorActionDelegate {
 
        public String generateUrl(Configuration config, String template) {
                IDocument doc = getDocument();
-               ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
+               ITextSelection selection = (ITextSelection) editor
+                               .getSelectionProvider().getSelection();
                int pos = selection.getOffset();
                int len = selection.getLength();
                String wikiTitle;