// Path: core/fr.opensagres.eclipse.jsbuild.ui/src/fr/opensagres/eclipse/jsbuild/internal/ui/JSBuildFileUIPlugin.java
// public class JSBuildFileUIPlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "fr.opensagres.eclipse.jsbuild.ui"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static JSBuildFileUIPlugin plugin;
// 
// 	/**
// 	 * The constructor
// 	 */
// 	public JSBuildFileUIPlugin() {
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// 	 * )
// 	 */
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// 	 * )
// 	 */
// 	public void stop(BundleContext context) throws Exception {
// 		plugin = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 * 
// 	 * @return the shared instance
// 	 */
// 	public static JSBuildFileUIPlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	/**
// 	 * Returns the standard display to be used. The method first checks, if the
// 	 * thread calling this method has an associated display. If so, this display
// 	 * is returned. Otherwise the method returns the default display.
// 	 */
// 	public static Display getStandardDisplay() {
// 		Display display = Display.getCurrent();
// 		if (display == null) {
// 			display = Display.getDefault();
// 		}
// 		return display;
// 	}
// 
// 	/**
// 	 * Returns the {@link IDialogSettings} section with the given name. Creates
// 	 * a new section if one does not exist.
// 	 * 
// 	 * @param name
// 	 * @return the {@link IDialogSettings} section with the given name
// 	 */
// 	public IDialogSettings getDialogSettingsSection(String name) {
// 		IDialogSettings dialogSettings = getDialogSettings();
// 		IDialogSettings section = dialogSettings.getSection(name);
// 		if (section == null) {
// 			section = dialogSettings.addNewSection(name);
// 		}
// 		return section;
// 	}
// 
// 	/**
// 	 * Returns the active workbench window or <code>null</code> if none
// 	 */
// 	public static IWorkbenchWindow getActiveWorkbenchWindow() {
// 		return getDefault().getWorkbench().getActiveWorkbenchWindow();
// 	}
// 
// 	public static IWorkbenchPage getActivePage() {
// 		return getActiveWorkbenchWindow().getActivePage();
// 	}
// 
// }


import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
import fr.opensagres.eclipse.jsbuild.internal.ui.JSBuildFileUIPlugin;
/**
 *  Copyright (c) 2013-2014 Angelo ZERR.
 *  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:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */
package fr.opensagres.eclipse.jsbuild.internal.ui.dialogs;




public class FileSelectionDialog extends ElementTreeSelectionDialog {

	private FileFilter fFilter;
	private String fFilterMessage;
	private boolean fShowAll = false;
	private final static String DIALOG_SETTING = "AntPropertiesFileSelectionDialog.showAll"; //$NON-NLS-1$
	private final static String LAST_CONTAINER = "AntPropertiesFileSelectionDialog.lastContainer"; //$NON-NLS-1$

	public FileSelectionDialog(Shell parent, List<IFile> files, String title,
			String message, String filterExtension, String filterMessage) {
		super(parent, new WorkbenchLabelProvider(),
				new WorkbenchContentProvider());

		setTitle(title);
		setMessage(message);
		fFilter = new FileFilter(files, filterExtension);
		fFilterMessage = filterMessage;
		setInput(ResourcesPlugin.getWorkspace().getRoot());
		setComparator(new ResourceComparator(ResourceComparator.NAME));

		ISelectionStatusValidator validator = new ISelectionStatusValidator() {
			@Override
			public IStatus validate(Object[] selection) {
				if (selection.length == 0) {
					return new Status(IStatus.ERROR,
// Path: core/fr.opensagres.eclipse.jsbuild.ui/src/fr/opensagres/eclipse/jsbuild/internal/ui/JSBuildFileUIPlugin.java
// public class JSBuildFileUIPlugin extends AbstractUIPlugin {
// 
// 	// The plug-in ID
// 	public static final String PLUGIN_ID = "fr.opensagres.eclipse.jsbuild.ui"; //$NON-NLS-1$
// 
// 	// The shared instance
// 	private static JSBuildFileUIPlugin plugin;
// 
// 	/**
// 	 * The constructor
// 	 */
// 	public JSBuildFileUIPlugin() {
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
// 	 * )
// 	 */
// 	public void start(BundleContext context) throws Exception {
// 		super.start(context);
// 		plugin = this;
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
// 	 * )
// 	 */
// 	public void stop(BundleContext context) throws Exception {
// 		plugin = null;
// 		super.stop(context);
// 	}
// 
// 	/**
// 	 * Returns the shared instance
// 	 * 
// 	 * @return the shared instance
// 	 */
// 	public static JSBuildFileUIPlugin getDefault() {
// 		return plugin;
// 	}
// 
// 	/**
// 	 * Returns the standard display to be used. The method first checks, if the
// 	 * thread calling this method has an associated display. If so, this display
// 	 * is returned. Otherwise the method returns the default display.
// 	 */
// 	public static Display getStandardDisplay() {
// 		Display display = Display.getCurrent();
// 		if (display == null) {
// 			display = Display.getDefault();
// 		}
// 		return display;
// 	}
// 
// 	/**
// 	 * Returns the {@link IDialogSettings} section with the given name. Creates
// 	 * a new section if one does not exist.
// 	 * 
// 	 * @param name
// 	 * @return the {@link IDialogSettings} section with the given name
// 	 */
// 	public IDialogSettings getDialogSettingsSection(String name) {
// 		IDialogSettings dialogSettings = getDialogSettings();
// 		IDialogSettings section = dialogSettings.getSection(name);
// 		if (section == null) {
// 			section = dialogSettings.addNewSection(name);
// 		}
// 		return section;
// 	}
// 
// 	/**
// 	 * Returns the active workbench window or <code>null</code> if none
// 	 */
// 	public static IWorkbenchWindow getActiveWorkbenchWindow() {
// 		return getDefault().getWorkbench().getActiveWorkbenchWindow();
// 	}
// 
// 	public static IWorkbenchPage getActivePage() {
// 		return getActiveWorkbenchWindow().getActivePage();
// 	}
// 
// }


// Path: core/fr.opensagres.eclipse.jsbuild.ui/src/fr/opensagres/eclipse/jsbuild/internal/ui/dialogs/FileSelectionDialog.java
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
import fr.opensagres.eclipse.jsbuild.internal.ui.JSBuildFileUIPlugin;

/**
 *  Copyright (c) 2013-2014 Angelo ZERR.
 *  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:
 *  Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
 */
package fr.opensagres.eclipse.jsbuild.internal.ui.dialogs;




public class FileSelectionDialog extends ElementTreeSelectionDialog {

	private FileFilter fFilter;
	private String fFilterMessage;
	private boolean fShowAll = false;
	private final static String DIALOG_SETTING = "AntPropertiesFileSelectionDialog.showAll"; //$NON-NLS-1$
	private final static String LAST_CONTAINER = "AntPropertiesFileSelectionDialog.lastContainer"; //$NON-NLS-1$

	public FileSelectionDialog(Shell parent, List<IFile> files, String title,
			String message, String filterExtension, String filterMessage) {
		super(parent, new WorkbenchLabelProvider(),
				new WorkbenchContentProvider());

		setTitle(title);
		setMessage(message);
		fFilter = new FileFilter(files, filterExtension);
		fFilterMessage = filterMessage;
		setInput(ResourcesPlugin.getWorkspace().getRoot());
		setComparator(new ResourceComparator(ResourceComparator.NAME));

		ISelectionStatusValidator validator = new ISelectionStatusValidator() {
			@Override
			public IStatus validate(Object[] selection) {
				if (selection.length == 0) {
					return new Status(IStatus.ERROR,
							JSBuildFileUIPlugin.PLUGIN_ID, 0, "", null);