1 package oic.simulator.serviceprovider.view;
3 import java.text.DateFormat;
6 import org.eclipse.jface.dialogs.Dialog;
7 import org.eclipse.jface.dialogs.IDialogConstants;
8 import org.eclipse.swt.SWT;
9 import org.eclipse.swt.graphics.Image;
10 import org.eclipse.swt.layout.GridData;
11 import org.eclipse.swt.layout.GridLayout;
12 import org.eclipse.swt.layout.RowData;
13 import org.eclipse.swt.layout.RowLayout;
14 import org.eclipse.swt.widgets.Button;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Label;
18 import org.eclipse.swt.widgets.Shell;
19 import org.eclipse.swt.widgets.Text;
21 public class LogDetailsDialog extends Dialog {
22 private final String severity;
23 private final Date date;
24 private final String message;
25 private final Image severityIcon;
27 public LogDetailsDialog(Shell parentShell, String severity,
28 Image severityIcon, Date date, String message) {
30 this.severity = severity;
31 this.severityIcon = severityIcon;
32 this.message = message;
37 protected boolean isResizable() {
42 protected void configureShell(Shell shell) {
43 super.configureShell(shell);
47 protected Control createDialogArea(Composite parent) {
48 getShell().setText("Logged event details");
50 Composite container = (Composite) super.createDialogArea(parent);
52 GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
53 container.setLayoutData(layoutData);
54 container.setLayout(new GridLayout(2, false));
58 Label l1 = new Label(container, SWT.NONE);
59 l1.setText("Severity:");
64 Composite y = new Composite(container, SWT.NONE);
66 gd.grabExcessHorizontalSpace = true;
68 y.setLayout(new RowLayout(SWT.HORIZONTAL));
70 Label l2 = new Label(y, SWT.NONE);
71 l2.setImage(severityIcon);
72 l2.setLayoutData(new RowData());
73 Label l3 = new Label(y, SWT.NONE);
75 l3.setLayoutData(new RowData());
77 Label l4 = new Label(container, SWT.NONE);
83 Label l5 = new Label(container, SWT.NONE);
84 DateFormat dateFormat = DateFormat.getDateTimeInstance(
85 DateFormat.SHORT, DateFormat.SHORT);
86 l5.setText(dateFormat.format(date));
88 gd.grabExcessHorizontalSpace = true;
91 new Label(container, SWT.NONE); // separator
93 Label l6 = new Label(container, SWT.NONE);
94 l6.setText("Message details");
96 gd.horizontalSpan = 2;
99 Text text = new Text(container, SWT.MULTI | SWT.READ_ONLY
100 | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
101 if (message != null) {
102 text.setText(message);
104 text.setText("No description available");
106 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
107 gd.horizontalSpan = 2;
110 text.setLayoutData(gd);
116 protected Button createButton(Composite parent, int id, String label,
117 boolean defaultButton) {
118 if (id == IDialogConstants.CANCEL_ID) {
121 return super.createButton(parent, id, label, defaultButton);