Skip to main content
summaryrefslogtreecommitdiffstats
blob: 79faa8f6d0e2bebf12d5aaaec6be70709d4e0633 (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
/*******************************************************************************
 * Copyright (c) 2010 Oracle Corporation and others.
 * 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:
 *     Oracle Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.ui.internal.jspeditor;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;

/**
 * This HyperlinkDetector creates hyperlinks for symbols in JSF EL expressions
 * inside jsp files.
 */
public class JSPELHyperlinkDetector extends AbstractELHyperlinkDetector {

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.jst.jsf.ui.internal.jspeditor.AbstractELHyperlinkDetector#isEnabled(org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext)
	 */
	@Override
	protected boolean isEnabled(IStructuredDocumentContext context) {
		boolean enabled = false;
		if (context != null) {
			IWorkspaceContextResolver resolver =
				IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
			if (resolver != null) {
				IResource resource = resolver.getResource();
				if (resource instanceof IFile) {
					IFile file = (IFile)resource;
					String filename = file.getFullPath().toString();
					enabled = hasContentType(filename, "org.eclipse.jst.jsp.core.jspsource"); //$NON-NLS-1$
				}
			}
		}
		return enabled;
	}

}

Back to the top