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 org.eclipse.jface.dialogs.Dialog;
20 import org.eclipse.jface.dialogs.IDialogConstants;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.graphics.Image;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.layout.RowData;
26 import org.eclipse.swt.layout.RowLayout;
27 import org.eclipse.swt.widgets.Button;
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 import org.eclipse.swt.widgets.Text;
34 import java.text.DateFormat;
35 import java.util.Date;
38 * This class shows detailed information about a log. The dialog will be opened
39 * on double-clicking a log entry in the log view.
41 public class LogDetailsDialog extends Dialog {
42 private final String severity;
43 private final Date date;
44 private final String message;
45 private final Image severityIcon;
47 public LogDetailsDialog(Shell parentShell, String severity,
48 Image severityIcon, Date date, String message) {
50 this.severity = severity;
51 this.severityIcon = severityIcon;
52 this.message = message;
57 protected boolean isResizable() {
62 protected void configureShell(Shell shell) {
63 super.configureShell(shell);
67 protected Control createDialogArea(Composite parent) {
68 getShell().setText("Logged event details");
70 Composite container = (Composite) super.createDialogArea(parent);
72 GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
73 container.setLayoutData(layoutData);
74 container.setLayout(new GridLayout(2, false));
78 Label l1 = new Label(container, SWT.NONE);
79 l1.setText("Severity:");
84 Composite y = new Composite(container, SWT.NONE);
86 gd.grabExcessHorizontalSpace = true;
88 y.setLayout(new RowLayout(SWT.HORIZONTAL));
90 Label l2 = new Label(y, SWT.NONE);
91 l2.setImage(severityIcon);
92 l2.setLayoutData(new RowData());
93 Label l3 = new Label(y, SWT.NONE);
95 l3.setLayoutData(new RowData());
97 Label l4 = new Label(container, SWT.NONE);
101 l4.setLayoutData(gd);
103 Label l5 = new Label(container, SWT.NONE);
104 DateFormat dateFormat = DateFormat.getDateTimeInstance(
105 DateFormat.SHORT, DateFormat.SHORT);
106 l5.setText(dateFormat.format(date));
108 gd.grabExcessHorizontalSpace = true;
109 l5.setLayoutData(gd);
111 new Label(container, SWT.NONE); // separator
113 Label l6 = new Label(container, SWT.NONE);
114 l6.setText("Message details");
116 gd.horizontalSpan = 2;
117 l6.setLayoutData(gd);
119 Text text = new Text(container, SWT.MULTI | SWT.READ_ONLY
120 | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
121 if (message != null) {
122 text.setText(message);
124 text.setText("No description available");
126 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
127 gd.horizontalSpan = 2;
130 text.setLayoutData(gd);
136 protected Button createButton(Composite parent, int id, String label,
137 boolean defaultButton) {
138 if (id == IDialogConstants.CANCEL_ID) {
141 return super.createButton(parent, id, label, defaultButton);