/*******************************************************************************
 * Copyright (c) 2013 MEDEVIT <office@medevit.at>. 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
 * 
 * Contributors: MEDEVIT <office@medevit.at> - initial API and implementation
 ******************************************************************************/
package ch.elexis.core.ui.dialogs.base;

import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class InputDialog extends org.eclipse.jface.dialogs.InputDialog {
	private final int style;
	
	private final static int HEIGHT_MULTILINE = 100;
	
	/**
	 * Extends the existing jface InputDialog with custom style functionality
	 * 
	 * @param parentShell
	 * @param dialogTitle
	 * @param dialogMessage
	 * @param initialValue
	 * @param validator
	 * @param style
	 */
	public InputDialog(Shell parentShell, String dialogTitle, String dialogMessage,
		String initialValue, IInputValidator validator, int style){
		super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
		this.style = style;
	}
	
	@Override
	protected int getInputTextStyle(){
		return style;
	}
	

	@Override
	protected Control createDialogArea(Composite parent){
		Control c = super.createDialogArea(parent);
		
		// multi line
		if ((getInputTextStyle() & SWT.MULTI) != 0) {
			Text text = getText();
			if (text != null) {
				Object layoutData = text.getLayoutData();
				if (layoutData instanceof GridData) {
					((GridData) layoutData).heightHint = HEIGHT_MULTILINE;
				}
			}
		}
		
		return c;
	}
}

@@ -921,16 +921,18 @@
 ialog %7B%0A
+%09%0A
 %09private
@@ -949,16 +949,40 @@
  style;%0A
+%09private int widthHint;%0A
 %09%0A%09priva
@@ -1486,24 +1486,47 @@
 le = style;%0A
+%09%09this.widthHint = -1;%0A
 %09%7D%0A%09%0A%09@Overr
@@ -1585,16 +1585,81 @@
 le;%0A%09%7D%0A%09
+%0A%09public void setWidthHint(int hint)%7B%0A%09%09this.widthHint = hint;%0A%09%7D
 %0A%0A%09@Over
@@ -1964,24 +1964,24 @@
 GridData) %7B%0A
-
 %09%09%09%09%09((GridD
@@ -2028,16 +2028,104 @@
 TILINE;%0A
+%09%09%09%09%09if (widthHint != -1) %7B%0A%09%09%09%09%09%09((GridData) layoutData).widthHint = widthHint;%0A%09%09%09%09%09%7D%0A
 %09%09%09%09%7D%0A%09%09

add setting width hint to InputDialog