912f7d7dc2aeec4277367caaf87193bb0d992c61
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / view / dialogs / AddInterfaceTypeDialog.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package oic.simulator.serviceprovider.view.dialogs;
18
19 import java.util.List;
20
21 import org.eclipse.jface.dialogs.TrayDialog;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.ModifyEvent;
24 import org.eclipse.swt.events.ModifyListener;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
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.Label;
31 import org.eclipse.swt.widgets.Shell;
32
33 /**
34  * This class shows a dialog for filtering logs based on severity levels.
35  */
36 public class AddInterfaceTypeDialog extends TrayDialog {
37
38     private Combo        ifTypesCmb;
39     private String       value;
40     private List<String> ifTypes;
41
42     public AddInterfaceTypeDialog(Shell shell, List<String> ifTypes) {
43         super(shell);
44         this.ifTypes = ifTypes;
45     }
46
47     @Override
48     protected void configureShell(Shell shell) {
49         super.configureShell(shell);
50     }
51
52     @Override
53     protected Control createDialogArea(Composite parent) {
54         Composite composite = (Composite) super.createDialogArea(parent);
55         getShell().setText("Add Interface Type");
56
57         Composite content = new Composite(parent, SWT.NULL);
58         GridLayout gridLayout = new GridLayout();
59         content.setLayout(gridLayout);
60         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
61         content.setLayoutData(gd);
62
63         Label lbl = new Label(content, SWT.NONE);
64         lbl.setText("Select Interface Type");
65
66         ifTypesCmb = new Combo(content, SWT.NULL);
67         gd = new GridData(SWT.FILL, SWT.FILL, true, true);
68         ifTypesCmb.setLayoutData(gd);
69
70         ifTypesCmb.addModifyListener(new ModifyListener() {
71             @Override
72             public void modifyText(ModifyEvent e) {
73                 value = ifTypesCmb.getText();
74             }
75         });
76
77         initList();
78
79         return composite;
80     }
81
82     private void initList() {
83         if (null != ifTypesCmb && null != ifTypes && !ifTypes.isEmpty()) {
84             ifTypesCmb.setItems(ifTypes.toArray(new String[1]));
85         }
86     }
87
88     @Override
89     public boolean isHelpAvailable() {
90         return false;
91     }
92
93     public String getValue() {
94         return value;
95     }
96 }