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.TrayDialog;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.events.SelectionAdapter;
23 import org.eclipse.swt.events.SelectionEvent;
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.Composite;
28 import org.eclipse.swt.widgets.Control;
29 import org.eclipse.swt.widgets.Group;
30 import org.eclipse.swt.widgets.Shell;
32 import java.util.ArrayList;
36 import oic.simulator.clientcontroller.utils.Constants;
39 * Dialog for starting and stopping the automatic verifications.
41 public class VerificationDialog extends TrayDialog {
42 private Map<String, Boolean> automationStatus;
44 public VerificationDialog(Shell shell, Map<String, Boolean> automationStatus) {
46 this.automationStatus = automationStatus;
50 protected void configureShell(Shell shell) {
51 super.configureShell(shell);
55 protected Control createDialogArea(Composite parent) {
56 Composite composite = (Composite) super.createDialogArea(parent);
57 createAutomationGroup(composite);
58 getShell().setText("Automation Settings");
63 * Dynamically creates a check-box list for enabling/disabling different
66 private void createAutomationGroup(Composite parent) {
67 Group group = new Group(parent, SWT.NONE);
68 group.setLayout(new GridLayout());
69 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
71 group.setLayoutData(gd);
72 group.setText("Automation Levels");
74 Set<String> keySet = automationStatus.keySet();
78 ArrayList<String> list = new ArrayList<String>(
79 automationStatus.keySet());
80 for (final String str : list) {
81 final Button checkbox = new Button(group, SWT.CHECK);
82 checkbox.setText(str);
83 checkbox.setSelection(automationStatus.get(str));
84 checkbox.addSelectionListener(new SelectionAdapter() {
87 public void widgetSelected(SelectionEvent e) {
88 Button btn = (Button) e.getSource();
92 String btnText = btn.getText();
93 if (btnText.equalsIgnoreCase(Constants.GET)) {
94 automationStatus.put(Constants.GET, btn.getSelection());
95 } else if (btnText.equalsIgnoreCase(Constants.PUT)) {
96 automationStatus.put(Constants.PUT, btn.getSelection());
97 } else if (btnText.equalsIgnoreCase(Constants.POST)) {
98 automationStatus.put(Constants.POST, btn.getSelection());
106 protected Button createButton(Composite parent, int id, String label,
107 boolean defaultButton) {
108 if (id == IDialogConstants.CANCEL_ID) {
111 return super.createButton(parent, id, label, defaultButton);
115 public boolean isHelpAvailable() {
119 public Map<String, Boolean> getAutomationStatus() {
120 return automationStatus;