1) Fixed issue #844: Short form of ternary operator (since PHP 5.3).
[phpeclipse.git] / net.sourceforge.phpeclipse.phphelp / src / net / sourceforge / phpdt / httpquery / HTTPQueryAction.java
1 package net.sourceforge.phpdt.httpquery;
2
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.List;
6
7 import net.sourceforge.phpdt.httpquery.config.Configuration;
8 import net.sourceforge.phpdt.httpquery.config.ConfigurationManager;
9 import net.sourceforge.phpdt.httpquery.config.IConfiguration;
10 import net.sourceforge.phpdt.internal.ui.viewsupport.ListContentProvider;
11 import net.sourceforge.phpdt.phphelp.PHPHelpPlugin;
12
13 import org.eclipse.jface.viewers.LabelProvider;
14 import org.eclipse.jface.window.Window;
15 import org.eclipse.ui.dialogs.ListSelectionDialog;
16
17 public class HTTPQueryAction extends AbstractHTTPQueryAction {
18
19         public HTTPQueryAction() {
20                 super();
21         }
22
23         protected Configuration getConfiguration(String name) {
24                 List allConfigsList = ConfigurationManager.getInstance()
25                                 .getConfigurations();
26                 ArrayList configsList = new ArrayList();
27                 for (int i = 0; i < allConfigsList.size(); i++) {
28                         IConfiguration temp = (IConfiguration) allConfigsList.get(i);
29                         if (temp.getType().equals(PHPHelpPlugin.HTTP_QUERY)) {
30                                 if (name != null && temp.getName().equalsIgnoreCase(name)) {
31                                         return (Configuration) temp;
32                                 }
33                                 configsList.add(temp);
34                         }
35                 }
36                 if (name != null) {
37                         return null;
38                 }
39                 Collections.sort(configsList);
40
41                 ListSelectionDialog listSelectionDialog = new ListSelectionDialog(
42                                 PHPHelpPlugin.getDefault().getWorkbench()
43                                                 .getActiveWorkbenchWindow().getShell(), configsList,
44                                 new ListContentProvider(), new LabelProvider(), "Select URL");
45                 listSelectionDialog.setTitle("Multiple configuration found");
46                 if (listSelectionDialog.open() == Window.OK) {
47                         Object[] configurations = listSelectionDialog.getResult();
48                         if (configurations != null) {
49                                 for (int i = 0; i < configurations.length; i++) {
50                                         return ((Configuration) configurations[i]); // .getURL();
51                                 }
52                         }
53                 }
54                 return null;
55         }
56
57 }