Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/FaceletUiPlugin.java69
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/CompositeAttributeAssistProcessor.java123
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/MyModelQueryExtension.java84
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor.java277
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java335
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletChangePage.java163
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletInstallPage.java18
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletUninstallPage.java28
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/hover/FaceletHover.java143
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/htmleditor/FaceletELHyperlinkDetector.java50
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java280
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/ValidationReporter.java69
12 files changed, 0 insertions, 1639 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/FaceletUiPlugin.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/FaceletUiPlugin.java
deleted file mode 100644
index 15ed6719a..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/FaceletUiPlugin.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.jsf.designtime.internal.view.model.TagRegistryFactory.TagRegistryFactoryException;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class FaceletUiPlugin extends AbstractUIPlugin
-{
-
- /**
- * The plug-in ID
- */
- public static final String PLUGIN_ID = "org.eclipse.jst.jsf.facelet.ui";
-
- // The shared instance
- private static FaceletUiPlugin plugin;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- @Override
- public void start(final BundleContext context) throws Exception
- {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- @Override
- public void stop(final BundleContext context) throws Exception
- {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static FaceletUiPlugin getDefault()
- {
- return plugin;
- }
-
- /**
- * @param e
- */
- public static void log(final TagRegistryFactoryException e)
- {
- getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "", e));
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/CompositeAttributeAssistProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/CompositeAttributeAssistProcessor.java
deleted file mode 100644
index 13312faec..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/CompositeAttributeAssistProcessor.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.jsf.designtime.DTAppManagerUtil;
-import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter;
-import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler.ViewHandlerException;
-import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter.DTELExpression;
-import org.eclipse.jst.jsf.ui.internal.contentassist.JSFContentAssistProcessor;
-import org.eclipse.jst.jsf.ui.internal.contentassist.el.JSFELContentAssistProcessor;
-
-/**
- * Composes the EL and non-EL attribute value assist processor for JSF. This
- * is necessary mainly because, without the EL partitioning in HTML, both
- * processors would otherwise activate on every attribute.
- *
- * @author cbateman
- *
- */
-public class CompositeAttributeAssistProcessor implements
- IContentAssistProcessor
-{
- private JSFContentAssistProcessor _nonELProcessor;
- private JSFELContentAssistProcessor _elProcessor;
- private char[] _activationChars;
-
- /**
- * Default constructor
- */
- public CompositeAttributeAssistProcessor()
- {
- _nonELProcessor = new JSFContentAssistProcessor();
- _elProcessor = new JSFELContentAssistProcessor();
-
- char[] nonELChars =
- _nonELProcessor.getCompletionProposalAutoActivationCharacters();
- char[] elChars =
- _elProcessor.getCompletionProposalAutoActivationCharacters();
- _activationChars = new char[nonELChars.length+elChars.length];
- System.arraycopy(nonELChars, 0, _activationChars, 0, nonELChars.length);
- System.arraycopy(elChars, 0, _activationChars, nonELChars.length, elChars.length);
-
-
- }
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
- int offset)
- {
- if (isEL(viewer, offset))
- {
- return _elProcessor.computeCompletionProposals(viewer, offset);
- }
- return _nonELProcessor.computeCompletionProposals(viewer, offset);
- }
-
- public IContextInformation[] computeContextInformation(ITextViewer viewer,
- int offset)
- {
- if (isEL(viewer, offset))
- {
- return _elProcessor.computeContextInformation(viewer, offset);
- }
- return _nonELProcessor.computeContextInformation(viewer, offset);
- }
-
- public char[] getCompletionProposalAutoActivationCharacters()
- {
- return _activationChars;
- }
-
- public char[] getContextInformationAutoActivationCharacters()
- {
- // disable this functionality
- return null;
- }
-
- public IContextInformationValidator getContextInformationValidator()
- {
- // disable this functionality
- return null;
- }
-
- public String getErrorMessage()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- private boolean isEL(final ITextViewer viewer, int offset)
- {
- IStructuredDocumentContext context =
- IStructuredDocumentContextFactory.INSTANCE.getContext(viewer, offset);
-
- if (context != null)
- {
- XMLViewDefnAdapter adapter =
- DTAppManagerUtil.getXMLViewDefnAdapter(context);
- if (adapter != null)
- {
- try
- {
- DTELExpression elExpression = adapter.getELExpression(context);
-
- // only return true if we definitively find EL
- if(elExpression != null)
- {
- return true;
- }
- }
- catch (ViewHandlerException e)
- {
- // fall through to false, no el
- }
- }
- }
- // all other cases, return false
- return false;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/MyModelQueryExtension.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/MyModelQueryExtension.java
deleted file mode 100644
index f2b80aad6..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/MyModelQueryExtension.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-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;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory2;
-import org.eclipse.jst.jsf.facelet.core.internal.cm.FaceletDocumentFactory;
-import org.eclipse.jst.jsf.facelet.core.internal.util.ViewUtil;
-import org.eclipse.jst.jsf.facelet.core.internal.util.ViewUtil.PrefixEntry;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.extension.ModelQueryExtension;
-import org.w3c.dom.Element;
-
-/**
- * A model query extension used to help support content assist in html files.
- *
- * @author cbateman
- *
- */
-public class MyModelQueryExtension extends ModelQueryExtension
-{
-
- @Override
- public String[] getAttributeValues(Element ownerElement, String namespace,
- String name)
- {
- // TODO Auto-generated method stub
- return super.getAttributeValues(ownerElement, namespace, name);
- }
-
- @Override
- public CMNode[] getAvailableElementContent(Element parentElement,
- String namespace, int includeOptions)
- {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory2.INSTANCE
- .getContext(parentElement);
- if (context != null)
- {
- final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(context);
-
- if (resolver != null)
- {
- final IProject project = resolver.getProject();
- final FaceletDocumentFactory factory =
- new FaceletDocumentFactory(project);
- final Map<String, PrefixEntry> map =
- ViewUtil.getDocumentNamespaces(parentElement.getOwnerDocument());
- String prefix = null;
- for (final Map.Entry<String, PrefixEntry> entry : map.entrySet())
- {
- if (entry.getValue().getUri().equals(namespace))
- {
- prefix = entry.getValue().getPrefix();
- break;
- }
- }
-
- if (prefix != null)
- {
- CMDocument document =
- factory.createCMDocumentForContext(namespace, prefix);
- if (document != null)
- {
- List<CMNode> nodes = new ArrayList<CMNode>();
- for (final Iterator<?> it = document.getElements().iterator(); it.hasNext();)
- {
- nodes.add((CMNode)it.next());
- }
- return nodes.toArray(new CMNode[0]);
- }
- }
- }
- }
- return new CMNode[0];
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor.java
deleted file mode 100644
index 0b2afd49f..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor.java
+++ /dev/null
@@ -1,277 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.Namespace;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
-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;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
-import org.eclipse.jst.jsf.facelet.core.internal.cm.FaceletDocumentFactory;
-import org.eclipse.jst.jsf.facelet.core.internal.util.ViewUtil;
-import org.eclipse.jst.jsf.facelet.core.internal.util.ViewUtil.PrefixEntry;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
-import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * The main entry point for Facelet content assist in html files.
- * @author cbateman
- *
- */
-public class XHTMLContentAssistProcessor extends AbstractContentAssistProcessor
-{
- private IFile _file;
- private FaceletDocumentFactory _factory;
-
- private final static ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
-
- @Override
- public ICompletionProposal[] computeCompletionProposals(
- final ITextViewer textViewer, final int documentPosition)
- {
- ICompletionProposal[] proposals = null;
- _file = getFile(textViewer, documentPosition);
-
- if (_file != null && shouldContribute(_file))
- {
- _factory = new FaceletDocumentFactory(_file.getProject());
- proposals = super.computeCompletionProposals(textViewer,
- documentPosition);
- }
- return proposals != null ? proposals : NO_PROPOSALS;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected List getAvailableChildElementDeclarations(final Element parent,
- final int childPosition, final int kindOfAction)
- {
- final Map<String, PrefixEntry> namespaces = getDocumentNamespaces(
- _factory, childPosition);
- final List availableChildElements = new ArrayList();
-
- for (final Map.Entry<String, PrefixEntry> entry : namespaces.entrySet())
- {
- final String prefix = entry.getValue().getPrefix();
- final CMDocument cmDocument = _factory.createCMDocumentForContext(
- entry.getValue().getUri(), prefix);
-
- if (cmDocument != null)
- {
- final Iterator it = cmDocument.getElements().iterator();
- while (it.hasNext())
- {
- availableChildElements.add(it.next());
- }
- }
- }
-
- return availableChildElements;
- }
-
- @Override
- protected void addAttributeValueProposals(
- final ContentAssistRequest contentAssistRequest)
- {
- final ITextRegion textRegion = findNameRegionIfIsHTMLRoot(contentAssistRequest);
-
- if (textRegion != null)
- {
- final IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- final NamedNodeMap attributes = node.getAttributes();
- final String attrName = node.getFirstStructuredDocumentRegion()
- .getText(textRegion);
- if (attrName != null)
- {
- final int colonPos = attrName.indexOf(':');
- // must have a colon && it must not be the last char, otherwise
- // there is no localName
- if (colonPos > -1 && colonPos < attrName.length() - 1)
- {
- final String prefix = attrName.substring(0, colonPos);
-
- if ("xmlns".equals(prefix))
- {
- final ITagRegistry tagRegistry = ViewUtil.getHtmlTagRegistry(_file.getProject());
- if (tagRegistry != null)
- {
- final Set<Attr> alreadyUsed = ViewUtil.getDeclaredNamespaces(attributes);
- final Collection<? extends Namespace> namespaces = tagRegistry
- .getAllTagLibraries();
- NAMESPACE_LOOP: for (final Namespace ns : namespaces)
- {
- final String possibleValue = ns.getNSUri();
-
- if (ViewUtil.hasAttributeValue(alreadyUsed, possibleValue))
- {
- continue NAMESPACE_LOOP;
- }
- // we have an attribute of the form xmlns:X in
- // the
- // html root node. Here we can provide value
- // proposals
- // for all of the known namespaces.
- final String rString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- final int rOffset = contentAssistRequest
- .getReplacementBeginPosition();
- final int rLength = contentAssistRequest
- .getReplacementLength();
- final int cursorAfter = possibleValue.length() + 1;
- final String displayString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
-
- final CustomCompletionProposal proposal = new CustomCompletionProposal(
- rString,
- rOffset,
- rLength,
- cursorAfter,
- null,
- displayString,
- null,
- null,
- XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- // now bail, since super only adds annoying identity completions
- // for this case
- return;
- }
- }
- }
- }
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- private ITextRegion findNameRegionIfIsHTMLRoot(
- final ContentAssistRequest contentAssistRequest)
- {
- final IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- if (node.getNodeType() == Node.ELEMENT_NODE
- && "html".equals(node.getNodeName())
- && node.getOwnerDocument().getDocumentElement() == node)
- {
- // Find the attribute region and name for which this position should
- // have a value proposed
- final IStructuredDocumentRegion open = node
- .getFirstStructuredDocumentRegion();
- final ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0)
- {
- return null;
- }
- ITextRegion nameRegion = null;
- while (i >= 0)
- {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
- {
- break;
- }
- }
- return nameRegion;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private Map<String, PrefixEntry> getDocumentNamespaces(
- final FaceletDocumentFactory factory, final int offset)
- {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(fTextViewer, offset);
-
- Document doc = null;
- if (context != null)
- {
- final IDOMContextResolver domContextResolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getDOMContextResolver(context);
-
- doc = domContextResolver.getDOMDocument();
-
- if (doc == null)
- {
- return Collections.EMPTY_MAP;
- }
- }
- return ViewUtil.getDocumentNamespaces(doc);
- }
-
- @Override
- protected CMElementDeclaration getCMElementDeclaration(final Node node)
- {
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- if (node.getPrefix() != null)
- {
- final Element element = (Element) node;
-
- final CMElementDeclaration elementDecl = _factory
- .createCMElementDeclaration(element);
-
- if (elementDecl != null)
- {
- return elementDecl;
- }
- }
- }
-
- return null;
- // return super.getCMElementDeclaration(node);
- }
-
- private boolean shouldContribute(final IFile file)
- {
- return ViewUtil.isFaceletVDLFile(file);
- }
-
- private IFile getFile(final ITextViewer textViewer,
- final int documentPosition)
- {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(textViewer, documentPosition);
-
- if (context != null)
- {
- final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(context);
-
- if (resolver != null)
- {
- final IResource resource = resolver.getResource();
- if (resource != null &&
- resource.getType() == IResource.FILE)
- {
- return (IFile) resource;
- }
- }
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java
deleted file mode 100644
index 47ac5910e..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/contentassist/XHTMLContentAssistProcessor2.java
+++ /dev/null
@@ -1,335 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.ITagElement;
-import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.Namespace;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
-import org.eclipse.jst.jsf.designtime.internal.view.model.TagRegistryFactory.TagRegistryFactoryException;
-import org.eclipse.jst.jsf.facelet.core.internal.registry.FaceletRegistryManager.MyRegistryFactory;
-import org.eclipse.jst.jsf.facelet.ui.internal.FaceletUiPlugin;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-/**
- * Temporary.
- *
- * @author cbateman
- *
- */
-public class XHTMLContentAssistProcessor2 implements IContentAssistProcessor
-{
- private final static ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
-
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,
- int offset)
- {
- List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(viewer, offset);
-
- if (context != null)
- {
- final IDOMContextResolver domContextResolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getDOMContextResolver(context);
-
- final Document doc = domContextResolver.getDOMDocument();
-
- if (doc == null)
- {
- return NO_PROPOSALS;
- }
-
- // get the namespaces that are already declared
- final Map<String, PrefixEntry> documentNamespaces = getDocumentNamespaces(doc);
-
- final ITextRegionContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getTextRegionResolver(context);
-
- if (resolver != null)
- {
- final String regionType = resolver.getRegionType();
-
- if (DOMRegionContext.XML_CONTENT.equals(regionType))
- {
- // TODO: this may be in the open it may occur on the inside
- // of a
- // "<" that doesn't have any further tag name yet
- proposals = getTagCompletionsForDocument(context,
- documentNamespaces, TagPrefix.NO_PREFIX);
- }
- else if (DOMRegionContext.XML_TAG_NAME.equals(regionType))
- {
- final TagPrefix tagPrefix = new TagPrefix(resolver
- .getRegionText());
- proposals = getTagCompletionsForDocument(context,
- documentNamespaces, tagPrefix);
- }
- else
- {
- System.out.println(regionType);
- }
- }
- }
-
- return proposals.toArray(NO_PROPOSALS);
- }
-
- private List<ICompletionProposal> getTagCompletionsForDocument(
- final IStructuredDocumentContext context,
- final Map<String, PrefixEntry> namespaces, final TagPrefix tagPrefix)
- {
- final List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
-
- final IWorkspaceContextResolver wkspaceResolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(context);
- final IProject project = wkspaceResolver.getProject();
-
- MyRegistryFactory factory = new MyRegistryFactory();
- ITagRegistry registry;
- try
- {
- registry = factory.createTagRegistry(project);
- if (registry == null)
- {
- return proposals;
- }
-
- final Collection<? extends Namespace> tagLibs = registry
- .getAllTagLibraries();
-
- for (final Namespace tagLib : tagLibs)
- {
- final PrefixEntry ns = namespaces.get(tagLib.getNSUri());
-
- // if the tag library is not initialized, don't trigger
- // a potentially expensive operation during the content assist
- if (ns != null && tagLib.isInitialized())
- {
- // only add if this namespace's prefix starts with
- // the prefix that the user provided
- if (ns._prefix.startsWith(tagPrefix.getPrefix()))
- {
- final Collection<?> tags = tagLib.getViewElements();
-
- for (final Iterator<?> it = tags.iterator(); it
- .hasNext();)
- {
- final ITagElement tagElement = (ITagElement) it
- .next();
-
- // only add an element it starts with the prefix
- // provided
- if (tagElement.getName().startsWith(
- tagPrefix.getLocalName()))
- {
- final String userPrefix = tagPrefix
- .getUserPrefix();
-
- final String tagName = ns._prefix + ":"
- + tagElement.getName();
- String replacementText = "";
- if ("".equals(userPrefix))
- {
- replacementText = "<" + tagName + "></"
- + tagName + ">";
- }
- else
- {
- replacementText = tagName
- .substring(userPrefix.length());
- }
- proposals.add(new CompletionProposal(
- replacementText, context
- .getDocumentPosition(), 0, 0,
- null, tagName, null, null));
- }
- }
- }
- }
- }
- }
- catch (TagRegistryFactoryException e)
- {
- FaceletUiPlugin.log(e);
- }
-
- return proposals;
- }
-
- private Map<String, PrefixEntry> getDocumentNamespaces(Document doc)
- {
- final Map<String, PrefixEntry> namespaces = new HashMap<String, PrefixEntry>();
-
- Element rootElement = doc.getDocumentElement();
-
- if (rootElement != null)
- {
- NamedNodeMap attrs = rootElement.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++)
- {
- Attr a = (Attr) attrs.item(i);
- PrefixEntry ns = PrefixEntry.parseNamespace(a);
- if (ns != null)
- {
- namespaces.put(ns.getUri(), ns);
- }
- }
- }
-
- return namespaces;
- }
-
- private static class TagPrefix
- {
- public final static TagPrefix NO_PREFIX = new TagPrefix("");
-
- private final String _prefix;
- private final String _localName;
- private final boolean _hasColon;
-
- public TagPrefix(final String tagName)
- {
- int prefixIdx = tagName.indexOf(':');
-
- if (prefixIdx != -1)
- {
- _prefix = tagName.substring(0, prefixIdx);
- _hasColon = true;
- if (tagName.length() > prefixIdx)
- {
- _localName = tagName.substring(prefixIdx + 1);
- }
- else
- {
- _localName = "";
- }
- }
- else
- {
- _hasColon = false;
- _prefix = tagName;
- _localName = "";
- }
- }
-
- public String getUserPrefix()
- {
- String userPrefix = _prefix;
-
- if (_hasColon)
- {
- userPrefix += ":";
- userPrefix += _localName;
- }
-
- return userPrefix;
- }
-
- public String getPrefix()
- {
- return _prefix;
- }
-
- public String getLocalName()
- {
- return _localName;
- }
- }
-
- private static class PrefixEntry
- {
- private final String _uri;
- private final String _prefix;
-
- public static PrefixEntry parseNamespace(Attr attr)
- {
- final String prefix = attr.getPrefix();
-
- if ("xmlns".equals(prefix))
- {
- final String prefixName = attr.getLocalName();
- if (prefixName != null)
- {
- final String uri = attr.getNodeValue();
-
- if (uri != null)
- {
- return new PrefixEntry(uri, prefixName);
- }
- }
- }
-
- return null;
- }
-
- public PrefixEntry(final String uri, final String prefix)
- {
- _uri = uri;
- _prefix = prefix;
- }
-
- public final String getUri()
- {
- return _uri;
- }
-
- public int hashCode()
- {
- return _uri.hashCode();
- }
-
- public boolean equals(Object obj)
- {
- return _uri.equals(obj);
- }
- }
-
- public IContextInformation[] computeContextInformation(ITextViewer viewer,
- int offset)
- {
- return null;
- }
-
- public char[] getCompletionProposalAutoActivationCharacters()
- {
- return null;
- }
-
- public char[] getContextInformationAutoActivationCharacters()
- {
- return null;
- }
-
- public IContextInformationValidator getContextInformationValidator()
- {
- return null;
- }
-
- public String getErrorMessage()
- {
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletChangePage.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletChangePage.java
deleted file mode 100644
index 24996aad4..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletChangePage.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle Corporation.
- * 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:
- * Cameron Bateman - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.facelet.ui.internal.facet;
-
-import org.eclipse.core.databinding.DataBindingContext;
-import org.eclipse.core.databinding.beans.BeansObservables;
-import org.eclipse.core.databinding.observable.value.IObservableValue;
-import org.eclipse.jface.databinding.swt.SWTObservables;
-import org.eclipse.jst.jsf.facelet.core.internal.facet.ChangeActionType;
-import org.eclipse.jst.jsf.facelet.core.internal.facet.FacetChangeModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
-
-/**
- * A common facet change UI page, mainly used for facet install/uninstall.
- *
- * @author cbateman
- *
- */
-public abstract class FaceletChangePage extends AbstractFacetWizardPage
-{
- private Button _chgDefaultSuffix;
- private Button _chgViewHandler;
- private Button _chgConfigureListener;
- private Button _chgWebappLifecycleListener;
-
- private DataBindingContext _bindingContext;
- private FacetChangeModel _dataModel;
-
- /**
- * @param name
- */
- public FaceletChangePage(String name)
- {
- super(name);
- }
-
- public void setConfig(final Object config)
- {
- _dataModel = (FacetChangeModel) config;
- }
-
- /**
- * @return the name of the change based on the actionType enumeration.
- */
- protected String getTextForChangeType()
- {
- final ChangeActionType actionType = _dataModel.getChangeActionType();
-
- switch (actionType)
- {
- case ADD:
- return "Add";
-
- case REMOVE:
- return "Remove";
- }
-
- return "*ERROR*";
- }
-
- private void initDefaultSuffixButton(final Composite parent)
- {
- _chgDefaultSuffix = new Button(parent, SWT.CHECK);
- _chgDefaultSuffix.setText(getTextForChangeType() + " '.xhtml' DEFAULT_SUFFIX parameter");
- _chgDefaultSuffix.setSelection(_dataModel.isChgDefaultSuffix());
- _chgDefaultSuffix.setLayoutData(new RowData());
- IObservableValue modelObservable = BeansObservables.observeValue(
- _dataModel, "chgDefaultSuffix");
-
- _bindingContext.bindValue(SWTObservables
- .observeSelection(_chgDefaultSuffix), modelObservable, null,
- null);
- }
-
- private void initViewHandlerButton(final Composite parent)
- {
- _chgViewHandler = new Button(parent, SWT.CHECK);
- _chgViewHandler.setText(getTextForChangeType() + " Facelet view handler");
- _chgViewHandler.setSelection(_dataModel.isChgViewHandler());
- _chgViewHandler.setLayoutData(new RowData());
- IObservableValue modelObservable = BeansObservables.observeValue(
- _dataModel, "chgViewHandler");
-
- _bindingContext
- .bindValue(SWTObservables.observeSelection(_chgViewHandler),
- modelObservable, null, null);
- }
-
- private void initConfigureListener(final Composite parent)
- {
- _chgConfigureListener = new Button(parent, SWT.CHECK);
- _chgConfigureListener
- .setText(getTextForChangeType() + " configure listener (needed by some Tomcat containers)");
- _chgConfigureListener.setSelection(_dataModel.isChgConfigureListener());
- _chgConfigureListener.setLayoutData(new RowData());
- IObservableValue modelObservable = BeansObservables.observeValue(
- _dataModel, "chgConfigureListener");
-
- _bindingContext.bindValue(SWTObservables
- .observeSelection(_chgConfigureListener), modelObservable,
- null, null);
- }
-
- private void initWebappLifecycleListener(final Composite parent)
- {
- _chgWebappLifecycleListener = new Button(parent, SWT.CHECK);
- _chgWebappLifecycleListener
- .setText(getTextForChangeType() + " web application lifecycle listener (needed by some Tomcat containers)");
- _chgWebappLifecycleListener.setSelection(_dataModel
- .isChgConfigureListener());
- _chgWebappLifecycleListener.setLayoutData(new RowData());
- IObservableValue modelObservable = BeansObservables.observeValue(
- _dataModel, "chgWebAppLifecycleListener");
-
- _bindingContext.bindValue(SWTObservables
- .observeSelection(_chgWebappLifecycleListener),
- modelObservable, null, null);
- }
-
- public void createControl(final Composite parent)
- {
- setTitle("Facelet");
- setMessage("Configure Facelet settings");
-
- _bindingContext = new DataBindingContext();
-
- // WizardPageSupport.create(this, _bindingContext);
-
- final Composite control = new Composite(parent, SWT.NONE);
- final RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
- rowLayout.fill = true;
- control.setLayout(rowLayout);
-
- final Group webXMLGroup = new Group(control, SWT.NONE);
- webXMLGroup.setLayout(rowLayout);
- webXMLGroup.setText("Deployment Descriptor (web.xml) Configuration");
- initDefaultSuffixButton(webXMLGroup);
- initConfigureListener(webXMLGroup);
- initWebappLifecycleListener(webXMLGroup);
-
- final Group facesConfigGroup = new Group(control, SWT.NONE);
- facesConfigGroup.setLayout(rowLayout);
- facesConfigGroup
- .setText("Application (faces-config.xml) Configuration");
- initViewHandlerButton(facesConfigGroup);
-
- setControl(control);
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletInstallPage.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletInstallPage.java
deleted file mode 100644
index 2ef2c5c9a..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletInstallPage.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.facet;
-
-
-/**
- * The UI page for installing the Facelet facet.
- * @author cbateman
- *
- */
-public class FaceletInstallPage extends FaceletChangePage
-{
- /**
- *
- */
- public FaceletInstallPage()
- {
- super("Facelet Install Page");
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletUninstallPage.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletUninstallPage.java
deleted file mode 100644
index f0e0c2fce..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/facet/FaceletUninstallPage.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle Corporation.
- * 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:
- * Cameron Bateman - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.jsf.facelet.ui.internal.facet;
-
-/**
- * The uninstall page for the Facelet facet.
- *
- * @author cbateman
- *
- */
-public class FaceletUninstallPage extends FaceletChangePage
-{
- /**
- *
- */
- public FaceletUninstallPage()
- {
- super("Facelet Uninstall Page");
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/hover/FaceletHover.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/hover/FaceletHover.java
deleted file mode 100644
index 9fe582118..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/hover/FaceletHover.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.hover;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.internal.ITextRegionContextResolver;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.jsf.facelet.core.internal.cm.FaceletDocumentFactory;
-import org.eclipse.jst.jsf.ui.internal.jspeditor.JSFELHover;
-import org.eclipse.wst.html.ui.internal.taginfo.HTMLTagInfoHoverProcessor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * The text hover for Facelets in html documents.
- *
- * @author cbateman
- *
- */
-public class FaceletHover implements ITextHover
-{
- private IProject _project;
- private JSFELHover _elHover;
- private HTMLTagInfoHoverProcessor _htmlHoverProcessor;
-
- /**
- *
- */
- public FaceletHover()
- {
- _elHover = new JSFELHover();
- _htmlHoverProcessor = new MyHTMLTagInfoHoverProcessor();
- }
-
- public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion)
- {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(textViewer, hoverRegion.getOffset());
- String info = null;
- if (isInAttributeValue(context))
- {
- info = _elHover.getHoverInfo(textViewer, hoverRegion);
- }
-
- if (info == null)
- {
- if (context != null)
- {
- _project = getProject(context);
- }
-
- info = _htmlHoverProcessor.getHoverInfo(textViewer, hoverRegion);
- }
-
- return info;
- }
-
- public IRegion getHoverRegion(ITextViewer textViewer, int offset)
- {
- IRegion region = null;
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(textViewer, offset);
-
- // if we are in an attribute value, try to get a region from the
- // el hover first
- if (context != null)
- {
- if (isInAttributeValue(context))
- {
- region = _elHover.getHoverRegion(textViewer, offset);
- }
- }
-
- if (region == null)
- {
- if (context != null)
- {
- _project = getProject(context);
- }
- region = _htmlHoverProcessor.getHoverRegion(textViewer, offset);
- }
-
- return region;
- }
-
- private boolean isInAttributeValue(final IStructuredDocumentContext context)
- {
- final ITextRegionContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getTextRegionResolver(context);
- final String regionType = resolver.getRegionType();
- if (regionType != null
- && (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE || resolver
- .matchesRelative(new String[]
- { DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE })))
- {
- return true;
- }
-
- return false;
- }
-
- private IProject getProject(final IStructuredDocumentContext context)
- {
- final IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getWorkspaceContextResolver(context);
-
- if (resolver != null)
- {
- return resolver.getProject();
- }
- return null;
- }
-
- private class MyHTMLTagInfoHoverProcessor extends HTMLTagInfoHoverProcessor
- {
- @Override
- protected CMElementDeclaration getCMElementDeclaration(Node node)
- {
- if (_project != null && node.getNodeType() == Node.ELEMENT_NODE
- && node.getPrefix() != null)
- {
- final Element element = (Element) node;
- final FaceletDocumentFactory factory = new FaceletDocumentFactory(_project);
-
- final CMElementDeclaration elementDecl = factory
- .createCMElementDeclaration(element);
-
- if (elementDecl != null)
- {
- return elementDecl;
- }
- }
-
- return super.getCMElementDeclaration(node);
- }
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/htmleditor/FaceletELHyperlinkDetector.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/htmleditor/FaceletELHyperlinkDetector.java
deleted file mode 100644
index 703eeeed7..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/htmleditor/FaceletELHyperlinkDetector.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * 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.facelet.ui.internal.htmleditor;
-
-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;
-import org.eclipse.jst.jsf.ui.internal.jspeditor.AbstractELHyperlinkDetector;
-
-/**
- * This HyperlinkDetector creates hyperlinks for symbols in JSF EL expressions
- * inside facelet files.
- */
-public class FaceletELHyperlinkDetector 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, "jsf.facelet") || //$NON-NLS-1$
- hasContentType(filename, "jsf.facelet.composite"); //$NON-NLS-1$
- }
- }
- }
- return enabled;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java
deleted file mode 100644
index b3df14855..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/HTMLValidator.java
+++ /dev/null
@@ -1,280 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.validation;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.common.runtime.internal.view.model.common.Namespace;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IDOMContextResolver;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.jsf.core.internal.JSFCorePlugin;
-import org.eclipse.jst.jsf.designtime.internal.view.model.ITagRegistry;
-import org.eclipse.jst.jsf.facelet.core.internal.util.ViewUtil;
-import org.eclipse.jst.jsf.facelet.ui.internal.FaceletUiPlugin;
-import org.eclipse.jst.jsf.validation.internal.IJSFViewValidator;
-import org.eclipse.jst.jsf.validation.internal.JSFValidatorFactory;
-import org.eclipse.jst.jsf.validation.internal.ValidationPreferences;
-import org.eclipse.jst.jsf.validation.internal.facelet.FaceletDiagnosticFactory;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * The Facelet HTML file validator.
- *
- * @author cbateman
- *
- */
-public class HTMLValidator extends AbstractValidator implements IValidator
-{
- private FaceletDiagnosticFactory _diagnosticFactory = new FaceletDiagnosticFactory();
- /**
- * @param helper
- * @return no rule, null
- */
- public ISchedulingRule getSchedulingRule(final IValidationContext helper)
- {
- // no rule...
- return null;
- }
-
- /**
- * @param helper
- * @param reporter
- * @return status of this validation
- * @throws ValidationException
- */
- public IStatus validateInJob(final IValidationContext helper,
- final IReporter reporter) throws ValidationException
- {
- IStatus status = Status.OK_STATUS;
- try
- {
- validate(helper, reporter);
- }
- catch (final ValidationException e)
- {
- status = new Status(IStatus.ERROR, FaceletUiPlugin.PLUGIN_ID,
- IStatus.ERROR, e.getLocalizedMessage(), e);
- }
- return status;
-
- }
-
- public void cleanup(final IReporter reporter)
- {
- // do nothing
- }
-
- @Override
- public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor){
- ValidationResult vr = new ValidationResult();
- if (resource == null || !(resource instanceof IFile)) {
- return vr;
- }
- IFile currentFile = (IFile) resource;
- if (shouldValidate(currentFile)) {
- validateFile(currentFile, vr.getReporter(monitor));
- }
- return vr;
- }
-
- public void validate(final IValidationContext helper,
- final IReporter reporter) throws ValidationException
- {
- final String[] uris = helper.getURIs();
- final IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- if (uris.length > 0)
- {
- IFile currentFile = null;
-
- for (int i = 0; i < uris.length && !reporter.isCancelled(); i++)
- {
- currentFile = wsRoot.getFile(new Path(uris[i]));
- if (currentFile != null && currentFile.exists())
- {
- if (shouldValidate(currentFile))
- {
- final int percent = (i * 100) / uris.length + 1;
- final IMessage message = new LocalizedMessage(
- IMessage.LOW_SEVERITY, percent + "% " + uris[i]);
- reporter.displaySubtask(this, message);
-
- validateFile(currentFile, reporter);
- }
- }
- }
- }
-
- }
-
- private void validateFile(final IFile file, final IReporter reporter)
- {
- final IJSFViewValidator validator = JSFValidatorFactory
- .createDefaultXMLValidator();
- final ValidationPreferences prefs = new ValidationPreferences(
- JSFCorePlugin.getDefault().getPreferenceStore());
- prefs.load();
-
- IStructuredModel model = null;
- try
- {
- model = StructuredModelManager.getModelManager().getModelForRead(
- file);
-
- final ValidationReporter jsfReporter = new ValidationReporter(this,
- reporter, file, prefs, model);
- validator.validateView(file, jsfReporter);
- // TODO: break off into composite strategies
- validateFaceletHtml(file, jsfReporter);
- }
- catch (final CoreException e)
- {
- JSFCorePlugin.log("Error validating JSF", e);
- }
- catch (final IOException e)
- {
- JSFCorePlugin.log("Error validating JSF", e);
- }
- finally
- {
- if (null != model)
- {
- model.releaseFromRead();
- }
- }
- }
-
- private void validateFaceletHtml(final IFile file,
- final ValidationReporter reporter)
- {
- IStructuredModel model = null;
- try
- {
- model = StructuredModelManager.getModelManager().getModelForRead(
- file);
-
- final IStructuredDocument structuredDoc = model
- .getStructuredDocument();
-
- validateDocument(structuredDoc, reporter, file.getProject());
- }
- catch (final CoreException e)
- {
- JSFCorePlugin.log("Error validating JSF", e);
- }
- catch (final IOException e)
- {
- JSFCorePlugin.log("Error validating JSF", e);
- }
- finally
- {
- if (null != model)
- {
- model.releaseFromRead();
- }
- }
- }
-
- private void validateDocument(IStructuredDocument structuredDoc,
- final ValidationReporter reporter, IProject project)
- {
- validateRoot(structuredDoc, reporter, project);
- }
-
- private void validateRoot(IStructuredDocument structuredDoc,
- ValidationReporter reporter, IProject project)
- {
- final IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
- .getContext(structuredDoc, -1);
- final IDOMContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
- .getDOMContextResolver(context);
- final Document document = resolver.getDOMDocument();
- Element rootElement = document.getDocumentElement();
-
- if ("html".equals(rootElement.getNodeName()))
- {
- final Set<Attr> declaredNamespaces = ViewUtil
- .getDeclaredNamespaces(rootElement.getAttributes());
- final ITagRegistry tagRegistry = ViewUtil
- .getHtmlTagRegistry(project);
- final Collection<? extends Namespace> namespaces;
- if (tagRegistry != null)
- {
- namespaces = tagRegistry.getAllTagLibraries();
- }
- else
- {
- // unexpected
- namespaces = Collections.EMPTY_SET;
- JSFCorePlugin.log(IStatus.ERROR, "Program Error: HTML tag registry not found"); //$NON-NLS-1$
- }
-
- for (final Attr attr : declaredNamespaces)
- {
- // only validate prefix declarations
- if (attr.getPrefix() != null && attr instanceof IDOMAttr)
- {
- final String declaredUri = attr.getValue();
- String findUri = null;
- SEARCH_NAMESPACES: for (final Namespace ns : namespaces)
- {
- if (ns.getNSUri().equals(declaredUri))
- {
- findUri = ns.getNSUri();
- break SEARCH_NAMESPACES;
- }
- }
-
- if (findUri == null)
- {
- final Diagnostic diag = _diagnosticFactory.create_CANNOT_FIND_FACELET_TAGLIB(declaredUri);
- final IDOMAttr domAttr = (IDOMAttr) attr;
- reporter.report(diag, domAttr.getValueRegionStartOffset(), domAttr
- .getValue().length());
- }
- }
- }
- }
- }
-
- private boolean shouldValidate(final IFile model)
- {
- final IContentTypeManager manager = Platform.getContentTypeManager();
- final IContentType contentType = manager
- .getContentType("org.eclipse.wst.html.core.htmlsource");
- return (contentType.isAssociatedWith(model.getName()))
- && ViewUtil.isFaceletVDLFile(model);
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/ValidationReporter.java b/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/ValidationReporter.java
deleted file mode 100644
index 2e87e8233..000000000
--- a/jsf/plugins/org.eclipse.jst.jsf.facelet.ui/src/org/eclipse/jst/jsf/facelet/ui/internal/validation/ValidationReporter.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.eclipse.jst.jsf.facelet.ui.internal.validation;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.jst.jsf.ui.internal.validation.ValidationMessageFactory;
-import org.eclipse.jst.jsf.validation.internal.IJSFViewValidator;
-import org.eclipse.jst.jsf.validation.internal.ValidationPreferences;
-import org.eclipse.jst.jsf.validation.internal.strategy.DiagnosticFactory;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/*package*/class ValidationReporter implements
- IJSFViewValidator.IValidationReporter
-{
- private final IValidator _validator;
- private final IReporter _reporter;
- private final IFile _file;
- private final ValidationMessageFactory _factory;
-
- public ValidationReporter(final IValidator validator,
- final IReporter reporter, final IFile file,
- final ValidationPreferences prefs, final IStructuredModel model)
- {
- _validator = validator;
- _reporter = reporter;
- _file = file;
- _factory = new ValidationMessageFactory(prefs, model);
- }
-
- public void report(final Diagnostic problem, final int start,
- final int length)
- {
- if (shouldReportProblem(problem.getCode()))
- {
- final IMessage message = _factory.createFromDiagnostic(problem,
- start, length, _file);
- if ((message.getSeverity() & IMessage.ALL_MESSAGES) != 0)
- {
- _reporter.addMessage(_validator, message);
- }
- }
- }
-
- /**
- * @param problemCode
- * @return filters out problems to be reported by code
- */
- private boolean shouldReportProblem(final int problemCode)
- {
- switch (problemCode)
- {
- case DiagnosticFactory.CONTAINMENT_ERROR_MISSING_VIEW:
- return false;
- default:
- return true;
- }
- }
-
- public void report(IMessage message)
- {
- // not capable of filtering problems by code... should not be used
- if ((message.getSeverity() & IMessage.ALL_MESSAGES) != 0)
- {
- _reporter.addMessage(_validator, message);
- }
- }
-}

Back to the top