// Path: src/opaide/OpaIdePlugin.java
// public class OpaIdePlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "opaide"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static OpaIdePlugin plugin;
// 	private static MessageConsole console;
// 	
// 	private OpaBinCompiler opaBinCompiler;
// 	private OpaPreferencesInitializer prefs;
// 		
// 	/**
// 	 * The constructor
// 	 */
// 	public OpaIdePlugin() {
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// 	 */
// 	@Override
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 		this.prefs = new OpaPreferencesInitializer();
// 		this.opaBinCompiler = new OpaBinCompiler(this.prefs);
// 		
// 		IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
// 		MessageConsole myConsole = new MessageConsole("Opa output", null);
// 		conMan.addConsoles(new IConsole[]{ myConsole });
// 		this.console = myConsole;
// 
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// 	 */
// 	public void stop(BundleContext context) throws Exception {
// 		plugin = null;
// 		console = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 *
// 	 * @return the shared instance
// 	 */
// 	public static OpaIdePlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	public OpaBinCompiler getBinCompiler() {
// 		return opaBinCompiler;
// 	}
// 
// 	public OpaPreferencesInitializer getPrefs() {
// 		return prefs;
// 	}
// 	
// 	public static MessageConsole getConsole() {
// 		return console;
// 	}
// 	
// 	private OpaMessagesBank myOpaMessagesBank = new OpaMessagesBank();	
// 	public OpaMessagesBank getOpaMessagesBank(){ return myOpaMessagesBank; };
// 	
// 	public Display getDisplay() {
// 		Display display = Display.getCurrent();
// 	    //may be null if outside the UI thread
// 	    if (display == null) {
// 	    	display = Display.getDefault();
// 	    }
// 	    return display;
// 	}
// 	
// }


import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationSelectionDialog;
import org.eclipse.debug.internal.ui.launchConfigurations.SelectLaunchModesDialog;
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerBrowser;
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerDialog;
import org.eclipse.jdt.internal.debug.ui.actions.ProjectSelectionDialog;
import org.eclipse.jface.preference.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import opaide.OpaIdePlugin;
package opaide.preferences;



public class OpaWorkbenchPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	private IWorkbench workbench;

	public OpaWorkbenchPreferencePage() {
		super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID);
	}
	
	/**
	 * Creates the field editors. Field editors are abstractions of
	 * the common GUI blocks needed to manipulate various types
	 * of preferences. Each field editor knows how to save and
	 * restore itself.
	 */
	public void createFieldEditors() {
		System.out.println("WorkbenchPreferencePage1.createFieldEditors()");
		/*
		IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();	
		LaunchConfigurationSelectionDialog tmp = new LaunchConfigurationSelectionDialog(this.getShell(), ps);
		tmp.open();
		*/

		ExecutableFileFieldEditor opaFileFieldEditor = new ExecutableFileFieldEditor(OpaPreferencesConstants.P_OPA_COMPILER_PATH, "Opa compiler:", true, 
				FileFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent());
		addField(opaFileFieldEditor);
		
		DirectoryFieldEditor opaMLLIBSFieldEditor = new DirectoryFieldEditor(OpaPreferencesConstants.P_OPA_MLSTATELIBS, "MLSTATELIBS env variable:", getFieldEditorParent());
		opaMLLIBSFieldEditor.setEmptyStringAllowed(false);
		opaMLLIBSFieldEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_KEY_STROKE);
		addField(opaMLLIBSFieldEditor);

	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
		this.workbench = workbench;
		setDescription("The preferences page of Opa");
// Path: src/opaide/OpaIdePlugin.java
// public class OpaIdePlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "opaide"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static OpaIdePlugin plugin;
// 	private static MessageConsole console;
// 	
// 	private OpaBinCompiler opaBinCompiler;
// 	private OpaPreferencesInitializer prefs;
// 		
// 	/**
// 	 * The constructor
// 	 */
// 	public OpaIdePlugin() {
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// 	 */
// 	@Override
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 		this.prefs = new OpaPreferencesInitializer();
// 		this.opaBinCompiler = new OpaBinCompiler(this.prefs);
// 		
// 		IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager();
// 		MessageConsole myConsole = new MessageConsole("Opa output", null);
// 		conMan.addConsoles(new IConsole[]{ myConsole });
// 		this.console = myConsole;
// 
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// 	 */
// 	public void stop(BundleContext context) throws Exception {
// 		plugin = null;
// 		console = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 *
// 	 * @return the shared instance
// 	 */
// 	public static OpaIdePlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	public OpaBinCompiler getBinCompiler() {
// 		return opaBinCompiler;
// 	}
// 
// 	public OpaPreferencesInitializer getPrefs() {
// 		return prefs;
// 	}
// 	
// 	public static MessageConsole getConsole() {
// 		return console;
// 	}
// 	
// 	private OpaMessagesBank myOpaMessagesBank = new OpaMessagesBank();	
// 	public OpaMessagesBank getOpaMessagesBank(){ return myOpaMessagesBank; };
// 	
// 	public Display getDisplay() {
// 		Display display = Display.getCurrent();
// 	    //may be null if outside the UI thread
// 	    if (display == null) {
// 	    	display = Display.getDefault();
// 	    }
// 	    return display;
// 	}
// 	
// }


// Path: src/opaide/preferences/OpaWorkbenchPreferencePage.java
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationSelectionDialog;
import org.eclipse.debug.internal.ui.launchConfigurations.SelectLaunchModesDialog;
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerBrowser;
import org.eclipse.debug.internal.ui.sourcelookup.browsers.ProjectSourceContainerDialog;
import org.eclipse.jdt.internal.debug.ui.actions.ProjectSelectionDialog;
import org.eclipse.jface.preference.*;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbench;
import opaide.OpaIdePlugin;

package opaide.preferences;



public class OpaWorkbenchPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	private IWorkbench workbench;

	public OpaWorkbenchPreferencePage() {
		super(org.eclipse.jface.preference.FieldEditorPreferencePage.GRID);
	}
	
	/**
	 * Creates the field editors. Field editors are abstractions of
	 * the common GUI blocks needed to manipulate various types
	 * of preferences. Each field editor knows how to save and
	 * restore itself.
	 */
	public void createFieldEditors() {
		System.out.println("WorkbenchPreferencePage1.createFieldEditors()");
		/*
		IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();	
		LaunchConfigurationSelectionDialog tmp = new LaunchConfigurationSelectionDialog(this.getShell(), ps);
		tmp.open();
		*/

		ExecutableFileFieldEditor opaFileFieldEditor = new ExecutableFileFieldEditor(OpaPreferencesConstants.P_OPA_COMPILER_PATH, "Opa compiler:", true, 
				FileFieldEditor.VALIDATE_ON_KEY_STROKE, getFieldEditorParent());
		addField(opaFileFieldEditor);
		
		DirectoryFieldEditor opaMLLIBSFieldEditor = new DirectoryFieldEditor(OpaPreferencesConstants.P_OPA_MLSTATELIBS, "MLSTATELIBS env variable:", getFieldEditorParent());
		opaMLLIBSFieldEditor.setEmptyStringAllowed(false);
		opaMLLIBSFieldEditor.setValidateStrategy(DirectoryFieldEditor.VALIDATE_ON_KEY_STROKE);
		addField(opaMLLIBSFieldEditor);

	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
		this.workbench = workbench;
		setDescription("The preferences page of Opa");
		setPreferenceStore(OpaIdePlugin.getDefault().getPreferenceStore());