/*
 * Created on 2004-08-13
 *
 * Part of the Symbian development plug-in for Eclipse
 * Copyright (C) Mikołaj Zalewski, 2004
 */
package pl.zalewski.mikolaj.symbdev.widgets;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import pl.zalewski.mikolaj.symbdev.SymbdevPlugin;

/**
 * @author mikolaj
 *
 * A dialog with a label and a ComboBox to choose the Win32 tool
 */
public class ChooseWin32ToolDialog extends Dialog {

	/**
	 * Constructs the dialog
	 * @param parentShell parent shell
	 * @param label the text to display in the label
	 */
	public ChooseWin32ToolDialog(Shell parentShell, String label, boolean allowNone) {
		super(parentShell);
		labelText=label;
		this.allowNone=allowNone;
	}
	
	protected Control createDialogArea(Composite parent)
	{
	  	GridData data;
	  	Composite panel=new Composite(parent, SWT.NONE);
	  	
		GridLayout layout= new GridLayout();
		layout.numColumns=1;
		panel.setLayout(layout);
		
		Label l=new Label(panel, SWT.NONE);
		l.setText(labelText);
		
		combo=new Win32ToolCombo(panel, SWT.NONE, allowNone);
		combo.setResultId(result);
		
		return panel;
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
	protected void okPressed() {
		result=combo.getResultId();
		super.okPressed();
	}
	public int getResult()
	{
		return result;
	}
	
	public void setResult(int id)
	{
		if (combo!=null)
			combo.setResultId(id);
		result=id;
	}

	protected void configureShell(Shell shell) {
	  	super.configureShell(shell);
 		shell.setText(SymbdevPlugin.MESSAGE_TITLE);
	}  	
	
	String labelText;
	boolean allowNone;
	Win32ToolCombo combo;
	int result=-1;
}
