View Javadoc

1   /* 
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2006</p>
22   * <p>Company: OntoText Lab. / SIRMA </p>
23   */
24  
25  package org.semanticgov.ui.wsdl;
26  
27  import org.eclipse.core.resources.IResourceChangeEvent;
28  import org.eclipse.core.resources.IResourceChangeListener;
29  import org.eclipse.core.resources.IResourceDelta;
30  
31  public class WSDLResourceListener implements IResourceChangeListener {
32  
33  	public void resourceChanged(IResourceChangeEvent event) {
34  		if (isResourceMarkerChange(event.getDelta())) {
35  			return;
36  		}
37  		switch (event.getType()) {
38  		case IResourceChangeEvent.PRE_CLOSE:
39  			WSDLCache.getCache().reinit();
40  			break;
41  		case IResourceChangeEvent.PRE_DELETE:
42  			WSDLCache.getCache().reinit();
43  			break;
44  		case IResourceChangeEvent.POST_CHANGE:
45  			WSDLCache.getCache().reinit();
46  			break;
47  		}
48  	}
49  
50  	private boolean isResourceMarkerChange(IResourceDelta delta) {
51  		if (delta == null) {
52  			return false;
53  		}
54  		if ((delta.getFlags() & IResourceDelta.MARKERS) == IResourceDelta.MARKERS) {
55  			return true;
56  		}
57  		IResourceDelta[] deltas = delta.getAffectedChildren();
58  		if (deltas != null) {
59  			for (int i = 0; i < deltas.length; i++) {
60  				if (isResourceMarkerChange(deltas[i])) {
61  					return true;
62  				}
63  			}
64  		}
65  		return false;
66  	}
67  }