From 8a1dd402f4b0e84b251a558018fc8cc245784be4 Mon Sep 17 00:00:00 2001 From: axelcl Date: Sat, 8 Apr 2006 14:46:29 +0000 Subject: [PATCH] New Localhost query action 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 --- .../plugin.properties | 2 +- net.sourceforge.phpeclipse.phphelp/plugin.xml | 160 ++++++-- .../phpdt/httpquery/AbstractHTTPQueryAction.java | 6 +- .../sourceforge/phpdt/httpquery/GoogleAction.java | 27 +- .../phpdt/httpquery/HTTPQueryAction.java | 64 ++-- .../sourceforge/phpdt/httpquery/KodersAction.java | 10 +- .../phpdt/httpquery/LocalhostAction.java | 25 ++ .../sourceforge/phpdt/httpquery/PHPHelpAction.java | 10 +- .../preferences/ConfigurationComposite.java | 8 +- .../httpquery/preferences/ConfigurationDialog.java | 435 ++++++++++---------- .../ConfigurationTableLabelProvider.java | 4 +- .../sourceforge/phpdt/phphelp/PHPHelpPlugin.java | 12 +- 12 files changed, 447 insertions(+), 316 deletions(-) create mode 100644 net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/LocalhostAction.java diff --git a/net.sourceforge.phpeclipse.phphelp/plugin.properties b/net.sourceforge.phpeclipse.phphelp/plugin.properties index 75aab0a..76ecb88 100644 --- a/net.sourceforge.phpeclipse.phphelp/plugin.properties +++ b/net.sourceforge.phpeclipse.phphelp/plugin.properties @@ -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 diff --git a/net.sourceforge.phpeclipse.phphelp/plugin.xml b/net.sourceforge.phpeclipse.phphelp/plugin.xml index 9ada7a3..2e3f816 100644 --- a/net.sourceforge.phpeclipse.phphelp/plugin.xml +++ b/net.sourceforge.phpeclipse.phphelp/plugin.xml @@ -38,7 +38,6 @@ - + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/AbstractHTTPQueryAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/AbstractHTTPQueryAction.java index 6d36486..1592734 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/AbstractHTTPQueryAction.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/AbstractHTTPQueryAction.java @@ -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) { } diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/GoogleAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/GoogleAction.java index e555929..804737e 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/GoogleAction.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/GoogleAction.java @@ -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 diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/HTTPQueryAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/HTTPQueryAction.java index 50dce47..fe5a211 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/HTTPQueryAction.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/HTTPQueryAction.java @@ -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 diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/KodersAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/KodersAction.java index a6b6a99..d9834ef 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/KodersAction.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/KodersAction.java @@ -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 index 0000000..48c6696 --- /dev/null +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/LocalhostAction.java @@ -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 diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/PHPHelpAction.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/PHPHelpAction.java index 86878e9..d5e5423 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/PHPHelpAction.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/PHPHelpAction.java @@ -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; diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationComposite.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationComposite.java index 023b508..47ba4b6 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationComposite.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationComposite.java @@ -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")); diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationDialog.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationDialog.java index 68e2e22..634befb 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationDialog.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationDialog.java @@ -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 diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationTableLabelProvider.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationTableLabelProvider.java index c050d71..8d7229e 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationTableLabelProvider.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/httpquery/preferences/ConfigurationTableLabelProvider.java @@ -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"; diff --git a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/phphelp/PHPHelpPlugin.java b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/phphelp/PHPHelpPlugin.java index 3c24502..0b1567a 100644 --- a/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/phphelp/PHPHelpPlugin.java +++ b/net.sourceforge.phpeclipse.phphelp/src/net/sourceforge/phpdt/phphelp/PHPHelpPlugin.java @@ -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 = "" + "" - + "" - + "" - + "" - + "" + + "" + + "" + + "" + + "" + + "" + ""; 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(); -- 1.7.1