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;
16 import org.eclipse.jface.util.Assert;
17 import org.eclipse.jface.viewers.StructuredViewer;
18 import org.eclipse.swt.widgets.Control;
20 public class FilterUpdater implements IResourceChangeListener {
22 private StructuredViewer fViewer;
24 public FilterUpdater(StructuredViewer viewer) {
25 Assert.isNotNull(viewer);
32 * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
34 public void resourceChanged(IResourceChangeEvent event) {
35 IResourceDelta delta = event.getDelta();
39 IResourceDelta[] projDeltas = delta
40 .getAffectedChildren(IResourceDelta.CHANGED);
41 for (int i = 0; i < projDeltas.length; i++) {
42 IResourceDelta pDelta = projDeltas[i];
43 if ((pDelta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
44 final Control ctrl = fViewer.getControl();
45 if (ctrl != null && !ctrl.isDisposed()) {
46 // async is needed due to bug 33783
47 ctrl.getDisplay().asyncExec(new Runnable() {
49 if (!ctrl.isDisposed())
50 fViewer.refresh(false);