2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package oic.simulator.clientcontroller.view.dialogs;
19 import org.eclipse.jface.dialogs.IDialogConstants;
20 import org.eclipse.jface.dialogs.TitleAreaDialog;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.events.ModifyEvent;
23 import org.eclipse.swt.events.ModifyListener;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Button;
27 import org.eclipse.swt.widgets.Combo;
28 import org.eclipse.swt.widgets.Composite;
29 import org.eclipse.swt.widgets.Control;
30 import org.eclipse.swt.widgets.Group;
31 import org.eclipse.swt.widgets.Label;
32 import org.eclipse.swt.widgets.Shell;
33 import org.eclipse.swt.widgets.Text;
35 import java.util.HashMap;
38 import oic.simulator.clientcontroller.utils.Utility;
41 * This dialog is used for generating a PUT request.
43 public class GetRequestDialog extends TitleAreaDialog {
44 private Text queryTxt;
45 private Combo ifTypesCmb;
47 private String otherFilters;
48 private String ifType;
50 private Map<String, String> ifTypes;
52 public GetRequestDialog(Shell parentShell) {
57 public void create() {
59 setTitle("Generate GET Request");
60 setMessage("Dialog which takes query filters and generates a GET request.");
64 protected Control createDialogArea(Composite parent) {
65 Composite compLayout = (Composite) super.createDialogArea(parent);
67 Group paramsGrp = new Group(compLayout, SWT.NONE);
68 paramsGrp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
69 GridLayout layout = new GridLayout(2, false);
70 layout.verticalSpacing = 10;
71 layout.marginTop = 10;
72 paramsGrp.setLayout(layout);
74 Label ifTypeLbl = new Label(paramsGrp, SWT.NONE);
75 ifTypeLbl.setText("Interface Type");
77 ifTypesCmb = new Combo(paramsGrp, SWT.NULL);
78 GridData gd = new GridData();
79 gd.grabExcessHorizontalSpace = true;
80 gd.horizontalAlignment = SWT.FILL;
81 ifTypesCmb.setLayoutData(gd);
82 ifTypesCmb.addModifyListener(new ModifyListener() {
84 public void modifyText(ModifyEvent e) {
85 ifType = ifTypesCmb.getText();
89 // Set the interface types.
90 Map<String, String> ifTypes = Utility.getResourceInterfaces();
91 if (null != ifTypes && !ifTypes.isEmpty()) {
92 this.ifTypes = new HashMap<String, String>();
94 for (Map.Entry<String, String> entry : ifTypes.entrySet()) {
95 key = entry.getValue() + " (" + entry.getKey() + ")";
96 this.ifTypes.put(key, entry.getKey());
101 Label otherFilterLbl = new Label(paramsGrp, SWT.NONE);
102 otherFilterLbl.setText("Other filters");
104 queryTxt = new Text(paramsGrp, SWT.BORDER);
106 gd.grabExcessHorizontalSpace = true;
107 gd.horizontalAlignment = SWT.FILL;
108 queryTxt.setLayoutData(gd);
109 queryTxt.addModifyListener(new ModifyListener() {
111 public void modifyText(ModifyEvent e) {
112 otherFilters = queryTxt.getText();
120 protected boolean isResizable() {
125 public boolean isHelpAvailable() {
130 protected Button createButton(Composite parent, int id, String label,
131 boolean defaultButton) {
132 if (id == IDialogConstants.OK_ID) {
135 return super.createButton(parent, id, label, defaultButton);
138 public String getOtherFilters() {
142 public String getIfType() {
143 if (ifTypes.containsKey(ifType)) {
144 return ifTypes.get(ifType);