/*******************************************************************************
 * Copyright (c) 2013 Liviu Ionescu.
 * 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:
 *     Liviu Ionescu - initial version
 *******************************************************************************/

package ilg.gnuarmeclipse.managedbuild.cross;

import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;

public class AdditionalToolsManagedOptionValueHandler extends
		ManagedOptionValueHandler {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler#handleValue
	 * (IConfiguration,IToolChain,IOption,String,int)
	 */
	@SuppressWarnings("unused")
	public boolean handleValue(IBuildObject configuration,
			IHoldsOptions holder, IOption option, String extraArgument,
			int event) {

		// ManagedOptionValueHandlerDebug.dump(configuration, holder, option,
		// extraArgument, event);

		if (event == EVENT_APPLY) {
			if (configuration instanceof FolderInfo) {
				FolderInfo oFolderInfo;
				oFolderInfo = (FolderInfo) configuration;
				// oFolderInfo.setDirty(true); //does not update interface :-(
				// TODO: find the proper sequence to update the interface
				System.out.println("should update configuration window!");
				// PlatformUI.getWorkbench().getModalDialogShellProvider().getShell().redraw();

				return false; // should we return true?

			} else if (configuration instanceof ResourceConfiguration) {
				// TODO: find the proper sequence to update the interface
				System.out
						.println("should update resource configuration window!");

				return false; // should we return true?

			} else {
				System.out.println("unexpected instanceof configuration "
						+ configuration.getClass().getCanonicalName());
			}

		}
		// The event was not handled, thus return false
		return false;
	}

}

@@ -848,16 +848,85 @@
 erInfo;%0A
+import org.eclipse.cdt.managedbuilder.internal.core.MultiFolderInfo;%0A
 import o
@@ -1798,32 +1798,35 @@
 e interface%0A%09%09%09%09
+// 
 System.out.print
@@ -1843,37 +1843,26 @@
  update 
-configuration window!
+FolderInfo
 %22);%0A%09%09%09%09
@@ -2113,24 +2113,27 @@
 terface%0A%09%09%09%09
+// 
 System.out%0A%09
@@ -2135,16 +2135,18 @@
 out%0A%09%09%09%09
+//
 %09%09.print
@@ -2167,38 +2167,264 @@
 ate 
-r
+R
 esource
- configuration window!
+Configuration%22);%0A%0A%09%09%09%09return false; // should we return true?%0A%0A%09%09%09%7D else if (configuration instanceof MultiFolderInfo) %7B%0A%09%09%09%09// TODO: find the proper sequence to update the interface%0A%09%09%09%09// System.out%0A%09%09%09%09//%09%09.println(%22should update MultiFolderInfo
 %22);%0A

add MultiFolderInfo to additional tools (although it does nothing)