Skip to main content
summaryrefslogtreecommitdiffstats
blob: d55f5eab3377fec56b56faa155a1addaabfafbbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/***************************************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others. 
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors: 
 *   IBM Corporation - initial API and implementation
 **************************************************************************************************/
package org.eclipse.jst.jsf.facesconfig.util;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;

/**
 * This class is NOT intended for external use.
 * 
 * @version $Id$
 */
final class FacesConfigRestartServerResourceDeltaVisitor implements IResourceDeltaVisitor {

	/** Set of IProjects. */
	private Set components = new HashSet();

	/**
	 * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
	 */
	public boolean visit(IResourceDelta delta) throws CoreException {

		if (shouldCheckForRestartProject()) {
			int kind = delta.getKind();
			if ((kind == IResourceDelta.ADDED)
					|| (kind == IResourceDelta.REMOVED)
					|| ((kind == IResourceDelta.CHANGED) && ((delta.getFlags() & (IResourceDelta.CONTENT
							| IResourceDelta.TYPE | IResourceDelta.SYNC | IResourceDelta.REPLACED)) != 0))) {
				primCheckForRestartComponent(delta.getResource());
			}
		}

		// Done.
		return true;
	}

	private boolean shouldCheckForRestartProject() {
		//TODO: XN: we don't have preference page for this?
		//return FacesconfigPlugin.getPlugin().getFacesPreferences().getRestart();
		return true;
	}

	private void primCheckForRestartComponent(IResource resource) {
		if (resource.getType() == IResource.FILE) {
			IFile file = (IFile) resource;
			if (FacesConfigUtil.isFacesConfigFile(file)) {
				IVirtualComponent component = ComponentUtilities.findComponent(file);
				if (component != null) {
					components.add(component);
				}
			}
				
		}
	}

	/**
	 * @return the components
	 */
	public Collection getComponents() {
		return components;
	}
}

Back to the top