+ public MultiLineTextFieldDialog(String title, String acceptLabel, String cancelLabel, String input)
+ {
+ super(true, title, acceptLabel, cancelLabel);
+ this.input = input;
+ }
+
+ @Override
+ protected void setupWidgets(Composite parent)
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ parent.setLayout(layout);
+ GridData gd = new GridData();
+ Label l = new Label(parent, SWT.NONE);
+ l.setText(input);
+ gd.verticalAlignment = SWT.TOP;
+ l.setLayoutData(gd);
+ gd = new GridData();
+ textField = new Text(parent, SWT.V_SCROLL);
+ textField.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.verticalAlignment = SWT.FILL;
+ }
+
+ @Override
+ protected void buildResult()
+ {
+ result = new String[] { textField.getText() };
+ }
+ }
+
+ /**
+ * @return The String entered if the dialog was accepted, null if the dialog was cancelled.
+ */
+ public static String openMultiLineTextDialog(String title, String acceptLabel, String cancelLabel, String input)
+ {
+ String[] result = new MultiLineTextFieldDialog(title, acceptLabel, cancelLabel, input).open();
+ return result == null ? null : result[0];