1 package org.simantics.team.ui;
3 import org.eclipse.jface.dialogs.Dialog;
4 import org.eclipse.jface.layout.GridDataFactory;
5 import org.eclipse.jface.layout.GridLayoutFactory;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.widgets.Composite;
8 import org.eclipse.swt.widgets.Control;
9 import org.eclipse.swt.widgets.Display;
10 import org.eclipse.swt.widgets.Label;
11 import org.eclipse.swt.widgets.Shell;
12 import org.eclipse.swt.widgets.Text;
13 import org.eclipse.ui.PlatformUI;
14 import org.simantics.db.exception.DatabaseException;
17 * Dialog for chart properties:
21 public class CommentDialog extends Dialog {
22 public static class Data {
24 public final String title;
25 public String comment;
26 public Data(String title) {
30 public static boolean openCommentDialog(final Data data)
31 throws DatabaseException {
32 final Display display = PlatformUI.getWorkbench().getDisplay();
33 display.syncExec(new Runnable() {
36 CommentDialog d = new CommentDialog(display.getActiveShell(), data);
37 if (Dialog.OK != d.open())
47 public CommentDialog(Shell parentShell, Data data) {
50 setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.BORDER);
53 protected Control createDialogArea(Composite parent) {
54 Composite c = (Composite) super.createDialogArea(parent);
55 GridLayoutFactory.fillDefaults().margins(8, 8).numColumns(9).applyTo(c);
56 GridDataFactory gd1 = GridDataFactory.fillDefaults().span(1, 1);
57 GridDataFactory gd2 = GridDataFactory.fillDefaults().grab(true, false).span(8, 1);
59 lName = new Label(c, 0);
60 lName.setText("Comment:");
62 tName = new Text(c, SWT.BORDER);
63 tName.setEnabled(true);
64 if (null != data.comment)
65 tName.setText(data.comment);
70 protected void okPressed() {
71 data.comment = tName.getText();
75 protected void configureShell(Shell newShell) {
76 super.configureShell(newShell);
77 newShell.setText(data.title);