package jp.co.cybec.laxide.wizards;

import java.util.Map;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;

/**
 * ビルドクラス ファイル名：LetsAjaxBuilder.java
 * 
 * @author nakamura 作成時刻：10:33:35
 * 
 */
public class LetsAjaxBuilder extends IncrementalProjectBuilder {

	public static final String BUILDER_ID = "jp.co.cybec.laxide.wizards.LetsAJAXBuilder";

	protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
			throws CoreException {

		if (kind == FULL_BUILD) {
			fullBuild(monitor);
		} else {
			IResourceDelta delta = getDelta(getProject());
			if (delta == null) {
				fullBuild(monitor);
			} else {
				incrementalBuild(delta, monitor);
			}
		}
		return null;
	}

	/** フルビルド */
	private void fullBuild(IProgressMonitor monitor) {

		MessageDialog.openInformation(null, "ビルド", "フルビルド");

		try {
			getProject().accept(new LetsAjaxResourceVisitor());
		} catch (CoreException e) {
			e.printStackTrace();
		}

		// ビルド

	}

	/** インクリメンタル・ビルド */
	private void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) {

		try {
			delta.accept(new LetsAjaxDeltaVisitor());
		} catch (CoreException e) {
			e.printStackTrace();
		}

		// ビルド

	}
}