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.TrayDialog;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.events.SelectionAdapter;
22 import org.eclipse.swt.events.SelectionEvent;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29 import org.eclipse.swt.widgets.Shell;
31 import java.util.ArrayList;
32 import java.util.Collections;
35 import oic.simulator.clientcontroller.manager.LogManager;
38 * This class shows a dialog for filtering logs based on severity levels.
40 public class FilterDialog extends TrayDialog {
41 private Map<Integer, Boolean> severities;
43 public FilterDialog(Shell shell, Map<Integer, Boolean> severities) {
45 this.severities = severities;
49 protected void configureShell(Shell shell) {
50 super.configureShell(shell);
54 protected Control createDialogArea(Composite parent) {
55 Composite composite = (Composite) super.createDialogArea(parent);
56 createSeverityGroup(composite);
57 getShell().setText("Filter details");
62 * Dynamically creates a check-box list for severity levels for user to
65 private void createSeverityGroup(Composite parent) {
66 Group group = new Group(parent, SWT.NONE);
67 group.setLayout(new GridLayout());
68 GridData gd = new GridData(GridData.FILL_HORIZONTAL);
70 group.setLayoutData(gd);
71 group.setText("Severity Levels");
73 ArrayList<Integer> arrayList = new ArrayList<Integer>(
75 Collections.sort(arrayList);
76 for (final Integer i : arrayList) {
77 final Button checkbox = new Button(group, SWT.CHECK);
78 checkbox.setText(LogManager.getSeverityName(i));
79 checkbox.setSelection(severities.get(i));
80 checkbox.addSelectionListener(new SelectionAdapter() {
83 public void widgetSelected(SelectionEvent e) {
84 severities.put(i, checkbox.getSelection());
91 public boolean isHelpAvailable() {