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