1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.viewsupport;
13 import org.eclipse.core.resources.IResourceChangeEvent;
14 import org.eclipse.core.resources.IResourceChangeListener;
15 import org.eclipse.core.resources.IResourceDelta;
17 //import org.eclipse.jface.text.Assert;
18 import org.eclipse.core.runtime.Assert;
19 import org.eclipse.jface.viewers.StructuredViewer;
20 import org.eclipse.swt.widgets.Control;
22 public class FilterUpdater implements IResourceChangeListener {
24 private StructuredViewer fViewer;
26 public FilterUpdater(StructuredViewer viewer) {
27 Assert.isNotNull(viewer);
34 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
36 public void resourceChanged(IResourceChangeEvent event) {
37 IResourceDelta delta = event.getDelta();
41 IResourceDelta[] projDeltas = delta
42 .getAffectedChildren(IResourceDelta.CHANGED);
43 for (int i = 0; i < projDeltas.length; i++) {
44 IResourceDelta pDelta = projDeltas[i];
45 if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
46 final Control ctrl = fViewer.getControl();
47 if (ctrl != null && !ctrl.isDisposed()) {
48 // async is needed due to bug 33783
49 ctrl.getDisplay().asyncExec(new Runnable() {
51 if (!ctrl.isDisposed())
52 fViewer.refresh(false);