/*******************************************************************************
 * Copyright (c) 2015 Pivotal, Inc.
 * 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:
 *     Pivotal, Inc. - initial API and implementation
 *******************************************************************************/
package org.springsource.ide.eclipse.commons.livexp.core;

import org.springsource.ide.eclipse.commons.livexp.util.Filter;
import org.springsource.ide.eclipse.commons.livexp.util.Filters;

/**
 * Model for a 'filter' box.
 *
 * @author Kris De Volder
 */
public abstract class FilterBoxModel<T> {

	/**
	 * Represents the text widget where user can type something.
	 */
	private final LiveVariable<String> text = new LiveVariable<String>("");

	private LiveExpression<Filter<T>> filter = null; // lazy created

	public synchronized LiveExpression<Filter<T>> getFilter() {
		if (filter==null) {
			Filter<T> initialFilter = Filters.acceptAll();
			filter = new LiveExpression<Filter<T>>(initialFilter) {
				protected Filter<T> compute() {
					return createFilterForInput(text.getValue());
				}
			};
		}
		filter.dependsOn(text);
		return filter;
	}

	public LiveVariable<String> getText() {
		return text;
	}


	protected abstract Filter<T> createFilterForInput(String text);
}

@@ -571,16 +571,82 @@
 .core;%0A%0A
+import org.springsource.ide.eclipse.commons.livexp.ui.Disposable;%0A
 import o
@@ -872,16 +872,38 @@
 Model%3CT%3E
+ implements Disposable
  %7B%0A%0A%09/**
@@ -1513,16 +1513,109 @@
 xt;%0A%09%7D%0A%0A
+%09public void dispose() %7B%0A%09%09if (filter!=null) %7B%0A%09%09%09filter.dispose();%0A%09%09%09filter = null;%0A%09%09%7D%0A%09%7D%0A
 %0A%09protec

Make FilterBoxModel disposable