/******************************************************************************* * Copyright (c) 2006 Jeff Mesnil * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package net.jmesnil.jmx.ui.internal.dialogs; import net.jmesnil.jmx.ui.internal.Messages; import net.jmesnil.jmx.ui.internal.controls.AttributeControlFactory; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; 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.Label; import org.eclipse.swt.widgets.Shell; public class OperationInvocationResultDialog extends Dialog { private Object result; public OperationInvocationResultDialog(Shell parentShell, Object result) { super(parentShell); setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX); this.result = result; } @Override protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText(Messages.InvocationResultDialog_title); } @Override protected Control createDialogArea(final Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); composite.setLayout(new GridLayout()); Control resultControl = AttributeControlFactory.createControl( composite, result); if (resultControl == null) { Label label = new Label(composite, SWT.NONE); label.setText("" + result); //$NON-NLS-1$ } else { resultControl.setLayoutData(new GridData(GridData.FILL_BOTH)); } return composite; } public static void open(Shell shell, Object result) { Dialog dialog = new OperationInvocationResultDialog(shell, result); dialog.open(); } }