package com.hangum.tadpole.monitoring.core.dialogs.monitoring; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import com.hangum.tadpole.commons.util.JSONUtil; import com.hangum.tadpole.engine.query.dao.system.monitoring.MonitoringResultDAO; /** * Snapshot dialog * * @author hangum * */ public class ShowSnapshotDialog extends Dialog { private MonitoringResultDAO resultDAO; private Text textSnapshot; /** * Create the dialog. * @param parentShell */ public ShowSnapshotDialog(Shell parentShell, MonitoringResultDAO dao) { super(parentShell); setShellStyle(SWT.MAX | SWT.RESIZE | SWT.TITLE); this.resultDAO = dao; } @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Snapshot data"); //$NON-NLS-1$ } /** * Create contents of the dialog. * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); GridLayout gridLayout = (GridLayout) container.getLayout(); gridLayout.verticalSpacing = 5; gridLayout.horizontalSpacing = 5; gridLayout.marginWidth = 5; gridLayout.marginHeight = 5; Composite composite = new Composite(container, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); composite.setLayout(new GridLayout(1, false)); textSnapshot = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.CANCEL | SWT.MULTI); textSnapshot.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); initUI(); return container; } private void initUI() { textSnapshot.setText(JSONUtil.getPretty(resultDAO.getSnapshot())); } /** * Create contents of the button bar. * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, "Close", true); } /** * Return the initial size of the dialog. */ @Override protected Point getInitialSize() { return new Point(450, 500); } }