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.serviceprovider.view.dialogs;
19 import java.util.ArrayList;
23 import oic.simulator.serviceprovider.utils.Constants;
25 import org.eclipse.jface.dialogs.IDialogConstants;
26 import org.eclipse.jface.dialogs.TrayDialog;
27 import org.eclipse.swt.SWT;
28 import org.eclipse.swt.events.SelectionAdapter;
29 import org.eclipse.swt.events.SelectionEvent;
30 import org.eclipse.swt.layout.GridData;
31 import org.eclipse.swt.layout.GridLayout;
32 import org.eclipse.swt.widgets.Button;
33 import org.eclipse.swt.widgets.Composite;
34 import org.eclipse.swt.widgets.Control;
35 import org.eclipse.swt.widgets.Group;
36 import org.eclipse.swt.widgets.Shell;
39 * Dialog for starting and stopping the automatic verifications.
41 public class UpdateResourceInterfaceDialog extends TrayDialog {
42 private Map<String, Boolean> resourceIfStatus;
44 public UpdateResourceInterfaceDialog(Shell shell,
45 Map<String, Boolean> resourceIfStatus) {
47 this.resourceIfStatus = resourceIfStatus;
51 protected void configureShell(Shell shell) {
52 super.configureShell(shell);
56 protected Control createDialogArea(Composite parent) {
57 Composite composite = (Composite) super.createDialogArea(parent);
58 createAutomationGroup(composite);
59 getShell().setText("Resource Interfaces");
64 * Dynamically creates a check-box list for changing the resource interface
67 private void createAutomationGroup(Composite parent) {
68 Group group = new Group(parent, SWT.NONE);
69 group.setLayout(new GridLayout());
70 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
72 group.setLayoutData(gd);
73 group.setText("Resource Interfaces");
75 Set<String> keySet = resourceIfStatus.keySet();
79 ArrayList<String> list = new ArrayList<String>(keySet);
80 for (final String str : list) {
81 final Button checkbox = new Button(group, SWT.CHECK);
82 checkbox.setText(str);
83 checkbox.setSelection(resourceIfStatus.get(str));
85 // Disabling the check-box for baseline interface.
86 if (str.contains(Constants.DEFAULT_SINGLE_RESOURCE_INTERFACE)) {
87 checkbox.setEnabled(false);
90 checkbox.addSelectionListener(new SelectionAdapter() {
93 public void widgetSelected(SelectionEvent e) {
94 Button btn = (Button) e.getSource();
98 String btnText = btn.getText();
99 resourceIfStatus.put(btnText, 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> getResourceInterfaceStatus() {
120 return resourceIfStatus;