New Localhost query action
authoraxelcl <axelcl>
Sat, 8 Apr 2006 14:46:29 +0000 (14:46 +0000)
committeraxelcl <axelcl>
Sat, 8 Apr 2006 14:46:29 +0000 (14:46 +0000)
Configured accelerator keys for the actions:
Ctrl+F8 opens localhost
Ctrl+Shift+G opens Google
Ctrl+Shift+O opens Online PHP Manual
Configuration is modifiable through Window->Preferences  PHPeclipse Web Development->PHP->HTTP Query

12 files changed:
net.sourceforge.phpeclipse.phphelp/plugin.properties
net.sourceforge.phpeclipse.phphelp/plugin.xml
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/AbstractHTTPQueryAction.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/GoogleAction.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/HTTPQueryAction.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/KodersAction.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/LocalhostAction.java [new file with mode: 0644]
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/PHPHelpAction.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationComposite.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationDialog.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationTableLabelProvider.java
net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/phphelp/PHPHelpPlugin.java

index 75aab0a..76ecb88 100644 (file)
@@ -18,7 +18,7 @@ ActionDefinition.contexthelp.description= Open PHP HTML help in browser
 HTTPQuery.label=HTTP Query
 
 # --------------- General UI ---------------
-preferenceDescription=Configure HTTP Actions for your Wiki texts.
+preferenceDescription=Configure HTTP queries for the web browser
 configurationsList=Configurations
 columnName=Name
 columnId=Id
index 9ada7a3..2e3f816 100644 (file)
@@ -38,7 +38,6 @@
          </action>
       </viewerContribution>
    </extension>
-
    <extension
          point="org.eclipse.ui.editorActions">
       <editorContribution
                class="net.sourceforge.phpdt.phphelp.actions.PHPEclipseShowContextHelp"
                id="net.sourceforge.phpdt.phphelp.actions.PHPEclipseShowContextHelp">
          </action>
+         <action
+               definitionId="net.sourceforge.phpdt.httpquery.localhost"
+               label="Localhost"
+               class="net.sourceforge.phpdt.httpquery.LocalhostAction"
+               id="net.sourceforge.phpdt.httpquery.LocalhostAction">
+         </action>
+         <action
+                      definitionId="net.sourceforge.phpdt.httpquery.google"
+               label="Google.com"
+               class="net.sourceforge.phpdt.httpquery.GoogleAction"
+               id="net.sourceforge.phpdt.httpquery.GoogleAction">
+         </action>
+         <action
+               definitionId="net.sourceforge.phpdt.httpquery.phpmanual"
+               label="PHP Manual"
+               class="net.sourceforge.phpdt.httpquery.PHPHelpAction"
+               id="net.sourceforge.phpdt.httpquery.PHPHelpAction">
+         </action>
       </editorContribution>
    </extension>
-
    <extension point="org.eclipse.ui.contexts">
       <context
         name="%context.editingPHPSource.name"
         parentId="org.eclipse.ui.textEditorScope"
         id="net.sourceforge.phpdt.ui.phpEditorScope" />
    </extension>
-   <extension
-         point="org.eclipse.ui.commands">
-      <category
-            name="%category.source.name"
-            description="%category.source.description"
-            id="net.sourceforge.phpeclipse.ui.category.source">
-      </category>
 
-      <command
-            name="%ActionDefinition.contexthelp.name"
-            description="%ActionDefinition.contexthelp.description"
-            categoryId="net.sourceforge.phpeclipse.ui.category.source"
-            id="net.sourceforge.phpdt.phphelp.actions.contexthelp">
-      </command>
-  </extension>
 
-  <extension
+   <extension
          point="org.eclipse.help.toc">
       <toc
             file="phphelp.xml"
            id="net.sourceforge.phpdt.httpquery.preferences.configurationPreferencePage">
       </page>
    </extension>
-   <extension
-         point="org.eclipse.ui.bindings">
-      <key
-            sequence="Ctrl+Shift+H"
-            contextId="net.sourceforge.phpdt.ui.phpEditorScope"
-            commandId="net.sourceforge.phpdt.phphelp.actions.contexthelp"
-            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
-      </key>
-   </extension>
 
    <extension
          point="org.eclipse.ui.popupMenus">
-     <viewerContribution
+      <viewerContribution
             targetID="#PHPEditorContext"
             id="net.sourceforge.phpdt.phphelp.actions.httpquery">
-           <menu
+         <menu
                        id="httpqueryMenu"
                        label="%HTTPQuery.label"
                        path="rest">
                 </menu>
                 <action
-               label="Koders.com Search"
+                      definitionId="net.sourceforge.phpdt.httpquery.koders"
+               label="Koders.com"
                class="net.sourceforge.phpdt.httpquery.KodersAction"
                menubarPath="httpqueryMenu/additions"
                id="net.sourceforge.phpdt.httpquery.KodersAction">
          </action>
                 <action
-               label="Google Search"
+                      definitionId="net.sourceforge.phpdt.httpquery.google"
+               label="Google.com"
                class="net.sourceforge.phpdt.httpquery.GoogleAction"
                menubarPath="httpqueryMenu/additions"
                id="net.sourceforge.phpdt.httpquery.GoogleAction">
          </action>
          <action
-               label="PHP Online Manual"
+               definitionId="net.sourceforge.phpdt.httpquery.phpmanual"
+               label="PHP Manual"
                class="net.sourceforge.phpdt.httpquery.PHPHelpAction"
                menubarPath="httpqueryMenu/additions"
                id="net.sourceforge.phpdt.httpquery.PHPHelpAction">
          </action>
+         <action
+               definitionId="net.sourceforge.phpdt.httpquery.localhost"
+               label="Localhost"
+               class="net.sourceforge.phpdt.httpquery.LocalhostAction"
+               menubarPath="httpqueryMenu/additions"
+               id="net.sourceforge.phpdt.httpquery.LocalhostAction">
+         </action>
                 <action
                label="HTTP Query..."
                class="net.sourceforge.phpdt.httpquery.HTTPQueryAction"
                id="net.sourceforge.phpdt.httpquery.HTTPQueryAction">
          </action>
       </viewerContribution>
+    </extension>
+    <!--
+    <extension
+         point="org.eclipse.ui.popupMenus">
       <viewerContribution
             targetID="#EditorContext"
-            id="net.sourceforge.phpeclipse.wiki.texteditor.viewercontribution">
+            id="net.sourceforge.phpdt.phphelp.actions.httpquery">
          <menu
                        id="httpqueryMenu"
                        label="%HTTPQuery.label"
                        path="rest">
                 </menu>
                 <action
-               label="Koders.com Search"
+               label="Koders.com"
                class="net.sourceforge.phpdt.httpquery.KodersAction"
                menubarPath="httpqueryMenu/additions"
                id="net.sourceforge.phpdt.httpquery.KodersAction">
          </action>
                 <action
-               label="Google Search"
+               label="Google.com"
                class="net.sourceforge.phpdt.httpquery.GoogleAction"
                menubarPath="httpqueryMenu/additions"
                id="net.sourceforge.phpdt.httpquery.GoogleAction">
          </action>
+         <action
+               label="Localhost"
+               class="net.sourceforge.phpdt.httpquery.LocalhostAction"
+               menubarPath="httpqueryMenu/additions"
+               id="net.sourceforge.phpdt.httpquery.LocalhostAction">
+         </action>
+         <action
+               label="PHP Manual"
+               class="net.sourceforge.phpdt.httpquery.PHPHelpAction"
+               menubarPath="httpqueryMenu/additions"
+               id="net.sourceforge.phpdt.httpquery.PHPHelpAction">
+         </action>
                 <action
                label="HTTP Query..."
                class="net.sourceforge.phpdt.httpquery.HTTPQueryAction"
                id="net.sourceforge.phpdt.httpquery.HTTPQueryAction">
          </action>
       </viewerContribution>
-  </extension>
+
+    </extension>
+-->
+
+    <extension
+         point="org.eclipse.ui.commands">
+      <category
+            name="%category.source.name"
+            description="%category.source.description"
+            id="net.sourceforge.phpeclipse.ui.category.source">
+      </category>
+
+      <command
+            name="%ActionDefinition.contexthelp.name"
+            description="%ActionDefinition.contexthelp.description"
+            categoryId="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpdt.phphelp.actions.contexthelp">
+      </command>
+      <command
+            name="Localhost"
+            description="Open localhost"
+            categoryId="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpdt.httpquery.localhost">
+      </command>
+      <command
+            name="Localhost"
+            description="Open localhost"
+            categoryId="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpdt.httpquery.localhost">
+      </command>
+      <command
+            name="Google"
+            description="Open Google.com"
+            categoryId="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpdt.httpquery.google">
+      </command>
+      <command
+            name="PHP Manual"
+            description="Open PHP Manual"
+            categoryId="net.sourceforge.phpeclipse.ui.category.source"
+            id="net.sourceforge.phpdt.httpquery.phpmanual">
+      </command>
+
+     </extension>
+
+     <extension
+         point="org.eclipse.ui.bindings">
+      <key
+            sequence="Ctrl+Shift+H"
+            contextId="net.sourceforge.phpdt.ui.phpEditorScope"
+            commandId="net.sourceforge.phpdt.phphelp.actions.contexthelp"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+      <key
+            sequence="Ctrl+F8"
+            contextId="net.sourceforge.phpdt.ui.phpEditorScope"
+            commandId="net.sourceforge.phpdt.httpquery.localhost"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+      <key
+            sequence="Ctrl+Shift+G"
+            contextId="net.sourceforge.phpdt.ui.phpEditorScope"
+            commandId="net.sourceforge.phpdt.httpquery.google"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+      <key
+            sequence="Ctrl+Shift+O"
+            contextId="net.sourceforge.phpdt.ui.phpEditorScope"
+            commandId="net.sourceforge.phpdt.httpquery.phpmanual"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
+      </key>
+   </extension>
 </plugin>
index 6d36486..1592734 100644 (file)
@@ -24,7 +24,7 @@ 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)) {
@@ -50,10 +50,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) {
                        }
index e555929..804737e 100644 (file)
@@ -4,19 +4,22 @@ import net.sourceforge.phpdt.httpquery.config.Configuration;
 import net.sourceforge.phpdt.httpquery.config.ConfigurationWorkingCopy;
 import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
 
+public class GoogleAction extends HTTPQueryAction {
 
-public class GoogleAction extends AbstractHTTPQueryAction {
+       public GoogleAction() {
+               super();
+       }
 
-  public GoogleAction() {
-    super();
-  }
-
-  protected Configuration getConfiguration() {
-    ConfigurationWorkingCopy config = new ConfigurationWorkingCopy();
-    config.setName("Google Search");
-    config.setURL("http://www.google.com/search?q=$text.selection");
-    config.setType(PHPHelpPlugin.HTTP_QUERY);
-    return config;
-  }
+       protected Configuration getConfiguration(String name) {
+               Configuration conf = super.getConfiguration("Google.com");
+               if (conf != null) {
+                       return conf;
+               }
+               ConfigurationWorkingCopy config = new ConfigurationWorkingCopy();
+               config.setName("Google.com");
+               config.setURL("http://www.google.com/search?q=$text.selection");
+               config.setType(PHPHelpPlugin.HTTP_QUERY);
+               return config;
+       }
 
 }
\ No newline at end of file
index 50dce47..fe5a211 100644 (file)
@@ -16,35 +16,39 @@ import org.eclipse.ui.dialogs.ListSelectionDialog;
 
 public class HTTPQueryAction extends AbstractHTTPQueryAction {
 
-  public HTTPQueryAction() {
-    super();
-  }
-
-  protected Configuration getConfiguration() {
-    String selectedURL = null;
-
-    List allConfigsList = ConfigurationManager.getInstance().getConfigurations();
-    ArrayList configsList = new ArrayList();
-    for (int i = 0; i < allConfigsList.size(); i++) {
-      IConfiguration temp = (IConfiguration) allConfigsList.get(i);
-      if (temp.getType().equals(PHPHelpPlugin.HTTP_QUERY)) {
-        configsList.add(temp);
-      }
-    }
-    Collections.sort(configsList);
-
-    ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPHelpPlugin.getDefault().getWorkbench()
-        .getActiveWorkbenchWindow().getShell(), configsList, new ListContentProvider(), new LabelProvider(), "Select URL");
-    listSelectionDialog.setTitle("Multiple configuration found");
-    if (listSelectionDialog.open() == Window.OK) {
-      Object[] configurations = listSelectionDialog.getResult();
-      if (configurations != null) {
-        for (int i = 0; i < configurations.length; i++) {
-          return ((Configuration) configurations[i]); // .getURL();
-        }
-      }
-    }
-    return null;
-  }
+       public HTTPQueryAction() {
+               super();
+       }
+
+       protected Configuration getConfiguration(String name) {
+               List allConfigsList = ConfigurationManager.getInstance().getConfigurations();
+               ArrayList configsList = new ArrayList();
+               for (int i = 0; i < allConfigsList.size(); i++) {
+                       IConfiguration temp = (IConfiguration) allConfigsList.get(i);
+                       if (temp.getType().equals(PHPHelpPlugin.HTTP_QUERY)) {
+                               if (name != null && temp.getName().equalsIgnoreCase(name)) {
+                                       return (Configuration) temp;
+                               }
+                               configsList.add(temp);
+                       }
+               }
+               if (name != null) {
+                       return null;
+               }
+               Collections.sort(configsList);
+
+               ListSelectionDialog listSelectionDialog = new ListSelectionDialog(PHPHelpPlugin.getDefault().getWorkbench()
+                               .getActiveWorkbenchWindow().getShell(), configsList, new ListContentProvider(), new LabelProvider(), "Select URL");
+               listSelectionDialog.setTitle("Multiple configuration found");
+               if (listSelectionDialog.open() == Window.OK) {
+                       Object[] configurations = listSelectionDialog.getResult();
+                       if (configurations != null) {
+                               for (int i = 0; i < configurations.length; i++) {
+                                       return ((Configuration) configurations[i]); // .getURL();
+                               }
+                       }
+               }
+               return null;
+       }
 
 }
\ No newline at end of file
index a6b6a99..d9834ef 100644 (file)
@@ -5,15 +5,19 @@ import net.sourceforge.phpdt.httpquery.config.ConfigurationWorkingCopy;
 import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
 
 
-public class KodersAction extends AbstractHTTPQueryAction {
+public class KodersAction extends HTTPQueryAction {
 
   public KodersAction() {
     super();
   }
 
-  protected Configuration getConfiguration() {
+  protected Configuration getConfiguration(String name) {
+       Configuration conf = super.getConfiguration("Koders.com");
+               if (conf != null) {
+                       return conf;
+               }
     ConfigurationWorkingCopy config = new ConfigurationWorkingCopy();
-    config.setName("Koders.com Search");
+    config.setName("Koders.com");
     config.setURL("http://koders.com/?s=$text.selection");
     config.setType(PHPHelpPlugin.HTTP_QUERY);
     return config;
diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/LocalhostAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/LocalhostAction.java
new file mode 100644 (file)
index 0000000..48c6696
--- /dev/null
@@ -0,0 +1,25 @@
+package net.sourceforge.phpdt.httpquery;
+
+import net.sourceforge.phpdt.httpquery.config.Configuration;
+import net.sourceforge.phpdt.httpquery.config.ConfigurationWorkingCopy;
+import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
+
+public class LocalhostAction extends HTTPQueryAction {
+
+       public LocalhostAction() {
+               super();
+       }
+
+       protected Configuration getConfiguration(String name) {
+               Configuration conf = super.getConfiguration("Localhost");
+               if (conf != null) {
+                       return conf;
+               }
+               ConfigurationWorkingCopy config = new ConfigurationWorkingCopy();
+               config.setName("Localhost");
+               config.setURL("http://localhost");
+               config.setType(PHPHelpPlugin.HTTP_QUERY);
+               return config;
+       }
+
+}
\ No newline at end of file
index 86878e9..d5e5423 100644 (file)
@@ -5,15 +5,19 @@ import net.sourceforge.phpdt.httpquery.config.ConfigurationWorkingCopy;
 import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
 
 
-public class PHPHelpAction extends AbstractHTTPQueryAction {
+public class PHPHelpAction extends HTTPQueryAction {
 
   public PHPHelpAction() {
     super();
   }
 
-  protected Configuration getConfiguration() {
+  protected Configuration getConfiguration(String name) {
+       Configuration conf = super.getConfiguration("PHP Manual");
+               if (conf != null) {
+                       return conf;
+               }
     ConfigurationWorkingCopy config = new ConfigurationWorkingCopy();
-    config.setName("PHP Online Manual");
+    config.setName("PHP Manual");
     config.setURL("http://www.php.net/manual/en/function.$php.selection.php");
     config.setType(PHPHelpPlugin.HTTP_QUERY);
     return config;
index 023b508..47ba4b6 100644 (file)
@@ -97,10 +97,10 @@ public class ConfigurationComposite extends Composite {
                colData = new ColumnWeightData(5, 30, true);
                tableLayout.addColumnData(colData);
 
-               TableColumn urlColumn = new TableColumn(table, SWT.NONE);
-               urlColumn.setText(PHPHelpPlugin.getResource("%columnUser"));
-               colData = new ColumnWeightData(5, 30, true);
-               tableLayout.addColumnData(colData);
+//             TableColumn urlColumn = new TableColumn(table, SWT.NONE);
+//             urlColumn.setText(PHPHelpPlugin.getResource("%columnUser"));
+//             colData = new ColumnWeightData(5, 30, true);
+//             tableLayout.addColumnData(colData);
 
                TableColumn localColumn = new TableColumn(table, SWT.NONE);
                localColumn.setText(PHPHelpPlugin.getResource("%columnURL"));
index 68e2e22..634befb 100644 (file)
@@ -37,224 +37,221 @@ import org.eclipse.swt.widgets.Text;
  *
  */
 public class ConfigurationDialog extends Dialog {
-  protected IConfigurationWorkingCopy fConfiguration;
-
-  protected boolean isEdit;
-
-  private Button okButton;
-
-  private Text fUserName;
-
-  private Text fUrl;
-
-  private Text fPassword;
-
-  interface StringModifyListener {
-    public void valueChanged(String s);
-  }
-
-  interface BooleanModifyListener {
-    public void valueChanged(boolean b);
-  }
-
-  interface TypeModifyListener {
-    public void valueChanged(String fType);
-  }
-
-  /**
-   * @param parentShell
-   */
-  public ConfigurationDialog(Shell parentShell, IConfigurationWorkingCopy configuration) {
-    super(parentShell);
-    this.fConfiguration = configuration;
-    isEdit = true;
-  }
-
-  public ConfigurationDialog(Shell parentShell) {
-    super(parentShell);
-    fConfiguration = PHPHelpPlugin.createConfiguration();
-    isEdit = false;
-  }
-
-  protected void configureShell(Shell shell) {
-    super.configureShell(shell);
-    if (isEdit)
-      shell.setText(PHPHelpPlugin.getResource("%editConfig"));
-    else
-      shell.setText(PHPHelpPlugin.getResource("%newConfig"));
-  }
-
-  protected Label createLabel(Composite comp, String txt) {
-    Label label = new Label(comp, SWT.NONE);
-    label.setText(txt);
-    label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
-    return label;
-  }
-
-  protected Text createPassword(Composite comp, String txt, final StringModifyListener listener) {
-    final Text text = new Text(comp, SWT.BORDER | SWT.PASSWORD);
-    if (txt != null)
-      text.setText(txt);
-    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
-    data.widthHint = 150;
-    text.setLayoutData(data);
-    if (listener != null)
-      text.addModifyListener(new ModifyListener() {
-        public void modifyText(ModifyEvent e) {
-          listener.valueChanged(text.getText());
-        }
-      });
-    return text;
-  }
-
-  protected Text createText(Composite comp, String txt, final StringModifyListener listener) {
-    final Text text = new Text(comp, SWT.BORDER);
-    if (txt != null)
-      text.setText(txt);
-    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
-    data.widthHint = 150;
-    text.setLayoutData(data);
-    if (listener != null)
-      text.addModifyListener(new ModifyListener() {
-        public void modifyText(ModifyEvent e) {
-          listener.valueChanged(text.getText());
-        }
-      });
-    return text;
-  }
-
-  protected Combo createTypeCombo(Composite comp, final ArrayList types, String sel, final TypeModifyListener listener) {
-    final Combo combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
-    int size = types.size();
-    String[] items = new String[size];
-    int index = -1;
-    for (int i = 0; i < size; i++) {
-      items[i] = (String)types.get(i);
-      if (items[i].equals(sel))
-        index = i;
-    }
-    combo.setItems(items);
-    if (index >= 0)
-      combo.select(index);
-    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
-    data.widthHint = 150;
-    combo.setLayoutData(data);
-    if (listener != null)
-      combo.addSelectionListener(new SelectionListener() {
-        public void widgetSelected(SelectionEvent e) {
-          listener.valueChanged((String)types.get(combo.getSelectionIndex()));
-        }
-
-        public void widgetDefaultSelected(SelectionEvent e) {
-          widgetSelected(e);
-        }
-      });
-    return combo;
-  }
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
-   */
-  protected Control createDialogArea(Composite parent) {
-    Composite composite = (Composite) super.createDialogArea(parent);
-    ((GridLayout) composite.getLayout()).numColumns = 2;
-
-    //         WorkbenchHelp.setHelp(composite, ContextIds.PREF_DIALOG);
-
-    createLabel(composite, PHPHelpPlugin.getResource("%name"));
-    fUserName = createText(composite, fConfiguration.getName() + "", new StringModifyListener() {
-      public void valueChanged(String name) {
-        fConfiguration.setName(name);
-        validateFields();
-      }
-    });
-
-    Group group = new Group(composite, SWT.NONE);
-    GridLayout layout = new GridLayout(2, false);
-    group.setLayout(layout);
-    GridData data = new GridData(GridData.FILL_HORIZONTAL);
-    data.horizontalSpan = 2;
-
-    group.setLayoutData(data);
-    group.setText(PHPHelpPlugin.getResource("%configGroup"));
-
-    createLabel(group, PHPHelpPlugin.getResource("%user"));
-    fUserName = createText(group, fConfiguration.getUser() + "", new StringModifyListener() {
-      public void valueChanged(String s) {
-        fConfiguration.setUser(s);
-        validateFields();
-      }
-    });
-
-    Composite warningComposite = new Composite(group, SWT.NONE);
-    layout = new GridLayout();
-    layout.numColumns = 2;
-    layout.marginHeight = 0;
-    layout.marginHeight = 0;
-    warningComposite.setLayout(layout);
-    data = new GridData(GridData.FILL_HORIZONTAL);
-    data.horizontalSpan = 3;
-    warningComposite.setLayoutData(data);
-    Label warningLabel = new Label(warningComposite, SWT.NONE);
-    warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
-    warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING));
-    Label warningText = new Label(warningComposite, SWT.WRAP);
-    warningText.setText(PHPHelpPlugin.getResource("%scrambledPassword")); //$NON-NLS-1$
-    data = new GridData(GridData.FILL_HORIZONTAL);
-    data.widthHint = 300;
-    warningText.setLayoutData(data);
-
-    createLabel(group, PHPHelpPlugin.getResource("%password"));
-    fPassword = createPassword(group, fConfiguration.getPassword() + "", new StringModifyListener() {
-      public void valueChanged(String s) {
-        fConfiguration.setPassword(s);
-        validateFields();
-      }
-    });
-
-    createLabel(group, PHPHelpPlugin.getResource("%url"));
-    fUrl = createText(group, fConfiguration.getURL(), new StringModifyListener() {
-      public void valueChanged(String s) {
-        fConfiguration.setURL(s);
-        validateFields();
-      }
-    });
-
-    createLabel(group, PHPHelpPlugin.getResource("%parseType"));
-    createTypeCombo(group, PHPHelpPlugin.getTypes(), fConfiguration.getType(), new TypeModifyListener() {
-      public void valueChanged(String fType) {
-        fConfiguration.setType(fType);
-      }
-    });
-
-    return composite;
-  }
-
-  protected void okPressed() {
-    fConfiguration.save();
-    super.okPressed();
-  }
-
-  protected Control createButtonBar(Composite parent) {
-    Control buttonControl = super.createButtonBar(parent);
-    validateFields();
-    return buttonControl;
-  }
-
-  private void setOKButtonEnabled(boolean curIsEnabled) {
-    if (okButton == null)
-      okButton = getButton(IDialogConstants.OK_ID);
-
-    if (okButton != null)
-      okButton.setEnabled(curIsEnabled);
-  }
-
-  protected void validateFields() {
-    boolean result = true;
-
-    setOKButtonEnabled(result);
-  }
+       protected IConfigurationWorkingCopy fConfiguration;
+
+       protected boolean isEdit;
+
+       private Button okButton;
+
+       private Text fName;
+
+       private Text fUrl;
+
+//     private Text fPassword;
+
+       interface StringModifyListener {
+               public void valueChanged(String s);
+       }
+
+       interface BooleanModifyListener {
+               public void valueChanged(boolean b);
+       }
+
+       interface TypeModifyListener {
+               public void valueChanged(String fType);
+       }
+
+       /**
+        * @param parentShell
+        */
+       public ConfigurationDialog(Shell parentShell, IConfigurationWorkingCopy configuration) {
+               super(parentShell);
+               this.fConfiguration = configuration;
+               isEdit = true;
+       }
+
+       public ConfigurationDialog(Shell parentShell) {
+               super(parentShell);
+               fConfiguration = PHPHelpPlugin.createConfiguration();
+               isEdit = false;
+       }
+
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (isEdit)
+                       shell.setText(PHPHelpPlugin.getResource("%editConfig"));
+               else
+                       shell.setText(PHPHelpPlugin.getResource("%newConfig"));
+       }
+
+       protected Label createLabel(Composite comp, String txt) {
+               Label label = new Label(comp, SWT.NONE);
+               label.setText(txt);
+               label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
+               return label;
+       }
+
+       protected Text createPassword(Composite comp, String txt, final StringModifyListener listener) {
+               final Text text = new Text(comp, SWT.BORDER | SWT.PASSWORD);
+               if (txt != null)
+                       text.setText(txt);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               data.widthHint = 150;
+               text.setLayoutData(data);
+               if (listener != null)
+                       text.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       listener.valueChanged(text.getText());
+                               }
+                       });
+               return text;
+       }
+
+       protected Text createText(Composite comp, String txt, final StringModifyListener listener) {
+               final Text text = new Text(comp, SWT.BORDER);
+               if (txt != null)
+                       text.setText(txt);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               data.widthHint = 150;
+               text.setLayoutData(data);
+               if (listener != null)
+                       text.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       listener.valueChanged(text.getText());
+                               }
+                       });
+               return text;
+       }
+
+       protected Combo createTypeCombo(Composite comp, final ArrayList types, String sel, final TypeModifyListener listener) {
+               final Combo combo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY);
+               int size = types.size();
+               String[] items = new String[size];
+               int index = -1;
+               for (int i = 0; i < size; i++) {
+                       items[i] = (String) types.get(i);
+                       if (items[i].equals(sel))
+                               index = i;
+               }
+               combo.setItems(items);
+               if (index >= 0)
+                       combo.select(index);
+               GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
+               data.widthHint = 150;
+               combo.setLayoutData(data);
+               if (listener != null)
+                       combo.addSelectionListener(new SelectionListener() {
+                               public void widgetSelected(SelectionEvent e) {
+                                       listener.valueChanged((String) types.get(combo.getSelectionIndex()));
+                               }
+
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       widgetSelected(e);
+                               }
+                       });
+               return combo;
+       }
+
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+               ((GridLayout) composite.getLayout()).numColumns = 2;
+
+               // WorkbenchHelp.setHelp(composite, ContextIds.PREF_DIALOG);
+
+               createLabel(composite, PHPHelpPlugin.getResource("%name"));
+               fName = createText(composite, fConfiguration.getName() + "", new StringModifyListener() {
+                       public void valueChanged(String name) {
+                               fConfiguration.setName(name);
+                               validateFields();
+                       }
+               });
+
+               Group group = new Group(composite, SWT.NONE);
+               GridLayout layout = new GridLayout(2, false);
+               group.setLayout(layout);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.horizontalSpan = 2;
+
+               group.setLayoutData(data);
+               group.setText(PHPHelpPlugin.getResource("%configGroup"));
+
+//             createLabel(group, PHPHelpPlugin.getResource("%user"));
+//             fUserName = createText(group, fConfiguration.getUser() + "", new StringModifyListener() {
+//                     public void valueChanged(String s) {
+//                             fConfiguration.setUser(s);
+//                             validateFields();
+//                     }
+//             });
+
+//             Composite warningComposite = new Composite(group, SWT.NONE);
+//             layout = new GridLayout();
+//             layout.numColumns = 2;
+//             layout.marginHeight = 0;
+//             layout.marginHeight = 0;
+//             warningComposite.setLayout(layout);
+//             data = new GridData(GridData.FILL_HORIZONTAL);
+//             data.horizontalSpan = 3;
+//             warningComposite.setLayoutData(data);
+               // Label warningLabel = new Label(warningComposite, SWT.NONE);
+               // warningLabel.setImage(getImage(DLG_IMG_MESSAGE_WARNING));
+               // warningLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING
+               // | GridData.HORIZONTAL_ALIGN_BEGINNING));
+               // Label warningText = new Label(warningComposite, SWT.WRAP);
+               // warningText.setText(PHPHelpPlugin.getResource("%scrambledPassword"));
+               // //$NON-NLS-1$
+               // data = new GridData(GridData.FILL_HORIZONTAL);
+               // data.widthHint = 300;
+               // warningText.setLayoutData(data);
+
+//             createLabel(group, PHPHelpPlugin.getResource("%password"));
+//             fPassword = createPassword(group, fConfiguration.getPassword() + "", new StringModifyListener() {
+//                     public void valueChanged(String s) {
+//                             fConfiguration.setPassword(s);
+//                             validateFields();
+//                     }
+//             });
+
+               createLabel(group, PHPHelpPlugin.getResource("%url"));
+               fUrl = createText(group, fConfiguration.getURL(), new StringModifyListener() {
+                       public void valueChanged(String s) {
+                               fConfiguration.setURL(s);
+                               validateFields();
+                       }
+               });
+
+               createLabel(group, PHPHelpPlugin.getResource("%parseType"));
+               createTypeCombo(group, PHPHelpPlugin.getTypes(), fConfiguration.getType(), new TypeModifyListener() {
+                       public void valueChanged(String fType) {
+                               fConfiguration.setType(fType);
+                       }
+               });
+
+               return composite;
+       }
+
+       protected void okPressed() {
+               fConfiguration.save();
+               super.okPressed();
+       }
+
+       protected Control createButtonBar(Composite parent) {
+               Control buttonControl = super.createButtonBar(parent);
+               validateFields();
+               return buttonControl;
+       }
+
+       private void setOKButtonEnabled(boolean curIsEnabled) {
+               if (okButton == null)
+                       okButton = getButton(IDialogConstants.OK_ID);
+
+               if (okButton != null)
+                       okButton.setEnabled(curIsEnabled);
+       }
+
+       protected void validateFields() {
+               boolean result = true;
+
+               setOKButtonEnabled(result);
+       }
 
 }
\ No newline at end of file
index c050d71..8d7229e 100644 (file)
@@ -74,9 +74,9 @@ public class ConfigurationTableLabelProvider implements ITableLabelProvider {
       return configuration.getName();
     } else if (columnIndex == 1)
       return configuration.getType();
+//    else if (columnIndex == 2)
+//      return configuration.getUser();
     else if (columnIndex == 2)
-      return configuration.getUser();
-    else if (columnIndex == 3)
       return configuration.getURL();
     else
       return "X";
index 3c24502..0b1567a 100644 (file)
@@ -43,14 +43,15 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
 
        public static final String HTTP_QUERY = "HTTP Query";
 
-       public final static String PREF_STRING_CONFIGURATIONS = "__configurations";
+       public final static String PREF_STRING_CONFIGURATIONS = "__configurations1";
 
        public final static String CONFIG_MEMENTO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                        + "<configurations>"
-                       + "<config name=\"PHP Online Manual\" type-id=\"HTTP Query\" url=\"http://www.php.net/manual/en/function.$php.selection.php\"/>"
-                       + "<config name=\"Google Search\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
-                       + "<config name=\"Koders.com Search\" type-id=\"HTTP Query\" url=\"http://koders.com/?s=$text.selection\"/>"
-                       + "<config name=\"Leo.org Translation\" type-id=\"HTTP Query\" url=\"http://dict.leo.org/?search=$text.selection\"/>"
+                       + "<config name=\"PHP Manual\" type-id=\"HTTP Query\" url=\"http://www.php.net/manual/en/function.$php.selection.php\"/>"
+                       + "<config name=\"Google.com\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
+                       + "<config name=\"Koders.com\" type-id=\"HTTP Query\" url=\"http://koders.com/?s=$text.selection\"/>"
+                       + "<config name=\"Leo.org Deutsch/English\" type-id=\"HTTP Query\" url=\"http://dict.leo.org/?search=$text.selection\"/>"
+                       + "<config name=\"Localhost\" type-id=\"HTTP Query\" url=\"http://localhost\"/>"
                        + "</configurations>";
 
        public static final ArrayList CONFIGURATION_TYPES = new ArrayList();
@@ -125,6 +126,7 @@ public class PHPHelpPlugin extends AbstractUIPlugin {
 
        protected void initializeDefaultPreferences(IPreferenceStore store) {
                store.setDefault(PREF_STRING_CONFIGURATIONS, CONFIG_MEMENTO);
+               addType(HTTP_QUERY);
                // windows preferences:
                String windowsSystem = Platform.getWS();