X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.team.ui%2Fsrc%2Forg%2Fsimantics%2Fteam%2Fui%2FCommentDialog.java;fp=bundles%2Forg.simantics.team.ui%2Fsrc%2Forg%2Fsimantics%2Fteam%2Fui%2FCommentDialog.java;h=2e933d4007d066579d55ef89f83957288b5b536d;hp=2f2471abde707226177533515d27251381e90f25;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.team.ui/src/org/simantics/team/ui/CommentDialog.java b/bundles/org.simantics.team.ui/src/org/simantics/team/ui/CommentDialog.java index 2f2471abd..2e933d400 100644 --- a/bundles/org.simantics.team.ui/src/org/simantics/team/ui/CommentDialog.java +++ b/bundles/org.simantics.team.ui/src/org/simantics/team/ui/CommentDialog.java @@ -1,79 +1,79 @@ -package org.simantics.team.ui; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.simantics.db.exception.DatabaseException; - -/** - * Dialog for chart properties: - * - * Comment: - */ -public class CommentDialog extends Dialog { - public static class Data { - public boolean ok; - public final String title; - public String comment; - public Data(String title) { - this.title = title; - } - } - public static boolean openCommentDialog(final Data data) - throws DatabaseException { - final Display display = PlatformUI.getWorkbench().getDisplay(); - display.syncExec(new Runnable() { - @Override - public void run() { - CommentDialog d = new CommentDialog(display.getActiveShell(), data); - if (Dialog.OK != d.open()) - data.ok = false; - else - data.ok = true; - }}); - return data.ok; - } - Label lName; - Text tName; - Data data; - public CommentDialog(Shell parentShell, Data data) { - super(parentShell); - this.data = data; - setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.BORDER); - } - @Override - protected Control createDialogArea(Composite parent) { - Composite c = (Composite) super.createDialogArea(parent); - GridLayoutFactory.fillDefaults().margins(8, 8).numColumns(9).applyTo(c); - GridDataFactory gd1 = GridDataFactory.fillDefaults().span(1, 1); - GridDataFactory gd2 = GridDataFactory.fillDefaults().grab(true, false).span(8, 1); - // Comment: - lName = new Label(c, 0); - lName.setText("Comment:"); - gd1.applyTo(lName); - tName = new Text(c, SWT.BORDER); - tName.setEnabled(true); - if (null != data.comment) - tName.setText(data.comment); - gd2.applyTo(tName); - return c; - } - @Override - protected void okPressed() { - data.comment = tName.getText(); - super.okPressed(); - } - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText(data.title); - } -} +package org.simantics.team.ui; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.layout.GridLayoutFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.simantics.db.exception.DatabaseException; + +/** + * Dialog for chart properties: + * + * Comment: + */ +public class CommentDialog extends Dialog { + public static class Data { + public boolean ok; + public final String title; + public String comment; + public Data(String title) { + this.title = title; + } + } + public static boolean openCommentDialog(final Data data) + throws DatabaseException { + final Display display = PlatformUI.getWorkbench().getDisplay(); + display.syncExec(new Runnable() { + @Override + public void run() { + CommentDialog d = new CommentDialog(display.getActiveShell(), data); + if (Dialog.OK != d.open()) + data.ok = false; + else + data.ok = true; + }}); + return data.ok; + } + Label lName; + Text tName; + Data data; + public CommentDialog(Shell parentShell, Data data) { + super(parentShell); + this.data = data; + setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.CLOSE | SWT.BORDER); + } + @Override + protected Control createDialogArea(Composite parent) { + Composite c = (Composite) super.createDialogArea(parent); + GridLayoutFactory.fillDefaults().margins(8, 8).numColumns(9).applyTo(c); + GridDataFactory gd1 = GridDataFactory.fillDefaults().span(1, 1); + GridDataFactory gd2 = GridDataFactory.fillDefaults().grab(true, false).span(8, 1); + // Comment: + lName = new Label(c, 0); + lName.setText("Comment:"); + gd1.applyTo(lName); + tName = new Text(c, SWT.BORDER); + tName.setEnabled(true); + if (null != data.comment) + tName.setText(data.comment); + gd2.applyTo(tName); + return c; + } + @Override + protected void okPressed() { + data.comment = tName.getText(); + super.okPressed(); + } + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(data.title); + } +}