org.eclipse.jst.jsf.facelet.ui_1.0.1.v201104032306

16:45:53.493 INFO  jd.cli.Main - Decompiling org.eclipse.jst.jsf.facelet.ui_1.0.1.v201104032306.jar
package org.eclipse.jst.jsf.facelet.ui.internal;

import org.eclipse.core.runtime.ILog;
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;

public class FaceletUiPlugin
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.jst.jsf.facelet.ui";
  private static FaceletUiPlugin plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static FaceletUiPlugin getDefault()
  {
    return plugin;
  }
  
  public static void log(TagRegistryFactory.TagRegistryFactoryException e)
  {
    getDefault().getLog().log(new Status(4, "org.eclipse.jst.jsf.facelet.ui", "", e));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.FaceletUiPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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.IDTViewHandler.ViewHandlerException;
import org.eclipse.jst.jsf.designtime.internal.view.XMLViewDefnAdapter;
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;

public class CompositeAttributeAssistProcessor
  implements IContentAssistProcessor
{
  private JSFContentAssistProcessor _nonELProcessor;
  private JSFELContentAssistProcessor _elProcessor;
  private char[] _activationChars;
  
  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()
  {
    return null;
  }
  
  public IContextInformationValidator getContextInformationValidator()
  {
    return null;
  }
  
  public String getErrorMessage()
  {
    return null;
  }
  
  private boolean isEL(ITextViewer viewer, int offset)
  {
    IStructuredDocumentContext context = 
      IStructuredDocumentContextFactory.INSTANCE.getContext(viewer, offset);
    if (context != null)
    {
      XMLViewDefnAdapter adapter = 
        DTAppManagerUtil.getXMLViewDefnAdapter(context);
      if (adapter != null) {
        try
        {
          XMLViewDefnAdapter.DTELExpression elExpression = adapter.getELExpression(context);
          if (elExpression != null) {
            return true;
          }
        }
        catch (IDTViewHandler.ViewHandlerException localViewHandlerException) {}
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.CompositeAttributeAssistProcessor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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 java.util.Map.Entry;
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.CMNamedNodeMap;
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;

public class MyModelQueryExtension
  extends ModelQueryExtension
{
  public String[] getAttributeValues(Element ownerElement, String namespace, String name)
  {
    return super.getAttributeValues(ownerElement, namespace, name);
  }
  
  public CMNode[] getAvailableElementContent(Element parentElement, String namespace, int includeOptions)
  {
    IStructuredDocumentContext context = IStructuredDocumentContextFactory2.INSTANCE
      .getContext(parentElement);
    if (context != null)
    {
      IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
        .getWorkspaceContextResolver(context);
      if (resolver != null)
      {
        IProject project = resolver.getProject();
        FaceletDocumentFactory factory = 
          new FaceletDocumentFactory(project);
        Map<String, ViewUtil.PrefixEntry> map = 
          ViewUtil.getDocumentNamespaces(parentElement.getOwnerDocument());
        String prefix = null;
        for (Map.Entry<String, ViewUtil.PrefixEntry> entry : map.entrySet()) {
          if (((ViewUtil.PrefixEntry)entry.getValue()).getUri().equals(namespace))
          {
            prefix = ((ViewUtil.PrefixEntry)entry.getValue()).getPrefix();
            break;
          }
        }
        if (prefix != null)
        {
          CMDocument document = 
            factory.createCMDocumentForContext(namespace, prefix);
          if (document != null)
          {
            Object nodes = new ArrayList();
            for (Iterator<?> it = document.getElements().iterator(); it.hasNext();) {
              ((List)nodes).add((CMNode)it.next());
            }
            return (CMNode[])((List)nodes).toArray(new CMNode[0]);
          }
        }
      }
    }
    return new CMNode[0];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.MyModelQueryExtension
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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.Map.Entry;
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.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
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;

public class XHTMLContentAssistProcessor
  extends AbstractContentAssistProcessor
{
  private IFile _file;
  private FaceletDocumentFactory _factory;
  private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
  
  public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition)
  {
    ICompletionProposal[] proposals = (ICompletionProposal[])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;
  }
  
  protected List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction)
  {
    Map<String, ViewUtil.PrefixEntry> namespaces = getDocumentNamespaces(
      _factory, childPosition);
    List availableChildElements = new ArrayList();
    for (Map.Entry<String, ViewUtil.PrefixEntry> entry : namespaces.entrySet())
    {
      String prefix = ((ViewUtil.PrefixEntry)entry.getValue()).getPrefix();
      CMDocument cmDocument = _factory.createCMDocumentForContext(
        ((ViewUtil.PrefixEntry)entry.getValue()).getUri(), prefix);
      if (cmDocument != null)
      {
        Iterator it = cmDocument.getElements().iterator();
        while (it.hasNext()) {
          availableChildElements.add(it.next());
        }
      }
    }
    return availableChildElements;
  }
  
  protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest)
  {
    ITextRegion textRegion = findNameRegionIfIsHTMLRoot(contentAssistRequest);
    if (textRegion != null)
    {
      IDOMNode node = (IDOMNode)contentAssistRequest.getNode();
      NamedNodeMap attributes = node.getAttributes();
      String attrName = node.getFirstStructuredDocumentRegion()
        .getText(textRegion);
      if (attrName != null)
      {
        int colonPos = attrName.indexOf(':');
        if ((colonPos > -1) && (colonPos < attrName.length() - 1))
        {
          String prefix = attrName.substring(0, colonPos);
          if ("xmlns".equals(prefix))
          {
            ITagRegistry tagRegistry = ViewUtil.getHtmlTagRegistry(_file.getProject());
            if (tagRegistry != null)
            {
              Set<Attr> alreadyUsed = ViewUtil.getDeclaredNamespaces(attributes);
              Collection<? extends Namespace> namespaces = tagRegistry
                .getAllTagLibraries();
              for (Namespace ns : namespaces)
              {
                String possibleValue = ns.getNSUri();
                if (!ViewUtil.hasAttributeValue(alreadyUsed, possibleValue))
                {
                  String rString = "\"" + possibleValue + "\"";
                  int rOffset = contentAssistRequest
                    .getReplacementBeginPosition();
                  int rLength = contentAssistRequest
                    .getReplacementLength();
                  int cursorAfter = possibleValue.length() + 1;
                  String displayString = "\"" + possibleValue + "\"";
                  
                  CustomCompletionProposal proposal = new CustomCompletionProposal(
                    rString, 
                    rOffset, 
                    rLength, 
                    cursorAfter, 
                    null, 
                    displayString, 
                    null, 
                    null, 
                    800);
                  contentAssistRequest.addProposal(proposal);
                }
              }
            }
            return;
          }
        }
      }
    }
    super.addAttributeValueProposals(contentAssistRequest);
  }
  
  private ITextRegion findNameRegionIfIsHTMLRoot(ContentAssistRequest contentAssistRequest)
  {
    IDOMNode node = (IDOMNode)contentAssistRequest.getNode();
    if ((node.getNodeType() == 1) && 
      ("html".equals(node.getNodeName())) && 
      (node.getOwnerDocument().getDocumentElement() == node))
    {
      IStructuredDocumentRegion open = node
        .getFirstStructuredDocumentRegion();
      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() == "XML_TAG_ATTRIBUTE_NAME") {
          break;
        }
      }
      return nameRegion;
    }
    return null;
  }
  
  private Map<String, ViewUtil.PrefixEntry> getDocumentNamespaces(FaceletDocumentFactory factory, int offset)
  {
    IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
      .getContext(fTextViewer, offset);
    
    Document doc = null;
    if (context != null)
    {
      IDOMContextResolver domContextResolver = IStructuredDocumentContextResolverFactory.INSTANCE
        .getDOMContextResolver(context);
      
      doc = domContextResolver.getDOMDocument();
      if (doc == null) {
        return Collections.EMPTY_MAP;
      }
    }
    return ViewUtil.getDocumentNamespaces(doc);
  }
  
  protected CMElementDeclaration getCMElementDeclaration(Node node)
  {
    if (node.getNodeType() == 1) {
      if (node.getPrefix() != null)
      {
        Element element = (Element)node;
        
        CMElementDeclaration elementDecl = _factory
          .createCMElementDeclaration(element);
        if (elementDecl != null) {
          return elementDecl;
        }
      }
    }
    return null;
  }
  
  private boolean shouldContribute(IFile file)
  {
    return ViewUtil.isFaceletVDLFile(file);
  }
  
  private IFile getFile(ITextViewer textViewer, int documentPosition)
  {
    IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
      .getContext(textViewer, documentPosition);
    if (context != null)
    {
      IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
        .getWorkspaceContextResolver(context);
      if (resolver != null)
      {
        IResource resource = resolver.getResource();
        if ((resource != null) && 
          (resource.getType() == 1)) {
          return (IFile)resource;
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.XHTMLContentAssistProcessor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;

import org.w3c.dom.Attr;

class XHTMLContentAssistProcessor2$PrefixEntry
{
  private final String _uri;
  private final String _prefix;
  
  public static PrefixEntry parseNamespace(Attr attr)
  {
    String prefix = attr.getPrefix();
    if ("xmlns".equals(prefix))
    {
      String prefixName = attr.getLocalName();
      if (prefixName != null)
      {
        String uri = attr.getNodeValue();
        if (uri != null) {
          return new PrefixEntry(uri, prefixName);
        }
      }
    }
    return null;
  }
  
  public XHTMLContentAssistProcessor2$PrefixEntry(String uri, 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);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.XHTMLContentAssistProcessor2.PrefixEntry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;

class XHTMLContentAssistProcessor2$TagPrefix
{
  public static final TagPrefix NO_PREFIX = new TagPrefix("");
  private final String _prefix;
  private final String _localName;
  private final boolean _hasColon;
  
  public XHTMLContentAssistProcessor2$TagPrefix(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 + ":";
      userPrefix = userPrefix + _localName;
    }
    return userPrefix;
  }
  
  public String getPrefix()
  {
    return _prefix;
  }
  
  public String getLocalName()
  {
    return _localName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.XHTMLContentAssistProcessor2.TagPrefix
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.contentassist;

import java.io.PrintStream;
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.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

public class XHTMLContentAssistProcessor2
  implements IContentAssistProcessor
{
  private static final ICompletionProposal[] NO_PROPOSALS = new ICompletionProposal[0];
  
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset)
  {
    List<ICompletionProposal> proposals = new ArrayList();
    IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
      .getContext(viewer, offset);
    if (context != null)
    {
      IDOMContextResolver domContextResolver = IStructuredDocumentContextResolverFactory.INSTANCE
        .getDOMContextResolver(context);
      
      Document doc = domContextResolver.getDOMDocument();
      if (doc == null) {
        return NO_PROPOSALS;
      }
      Map<String, PrefixEntry> documentNamespaces = getDocumentNamespaces(doc);
      
      ITextRegionContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
        .getTextRegionResolver(context);
      if (resolver != null)
      {
        String regionType = resolver.getRegionType();
        if ("XML_CONTENT".equals(regionType))
        {
          proposals = getTagCompletionsForDocument(context, 
            documentNamespaces, TagPrefix.NO_PREFIX);
        }
        else if ("XML_TAG_NAME".equals(regionType))
        {
          TagPrefix tagPrefix = new TagPrefix(resolver
            .getRegionText());
          proposals = getTagCompletionsForDocument(context, 
            documentNamespaces, tagPrefix);
        }
        else
        {
          System.out.println(regionType);
        }
      }
    }
    return (ICompletionProposal[])proposals.toArray(NO_PROPOSALS);
  }
  
  private List<ICompletionProposal> getTagCompletionsForDocument(IStructuredDocumentContext context, Map<String, PrefixEntry> namespaces, TagPrefix tagPrefix)
  {
    List<ICompletionProposal> proposals = new ArrayList();
    
    IWorkspaceContextResolver wkspaceResolver = IStructuredDocumentContextResolverFactory.INSTANCE
      .getWorkspaceContextResolver(context);
    IProject project = wkspaceResolver.getProject();
    
    FaceletRegistryManager.MyRegistryFactory factory = new FaceletRegistryManager.MyRegistryFactory();
    try
    {
      ITagRegistry registry = factory.createTagRegistry(project);
      if (registry == null) {
        return proposals;
      }
      Collection<? extends Namespace> tagLibs = registry
        .getAllTagLibraries();
      for (Namespace tagLib : tagLibs)
      {
        PrefixEntry ns = (PrefixEntry)namespaces.get(tagLib.getNSUri());
        if ((ns != null) && (tagLib.isInitialized())) {
          if (_prefix.startsWith(tagPrefix.getPrefix()))
          {
            Collection<?> tags = tagLib.getViewElements();
            for (Iterator<?> it = tags.iterator(); it
                  .hasNext();)
            {
              ITagElement tagElement = 
                (ITagElement)it.next();
              if (tagElement.getName().startsWith(
                tagPrefix.getLocalName()))
              {
                String userPrefix = tagPrefix
                  .getUserPrefix();
                
                String tagName = _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 (TagRegistryFactory.TagRegistryFactoryException e)
    {
      FaceletUiPlugin.log(e);
    }
    return proposals;
  }
  
  private Map<String, PrefixEntry> getDocumentNamespaces(Document doc)
  {
    Map<String, PrefixEntry> namespaces = new HashMap();
    
    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 static final TagPrefix NO_PREFIX = new TagPrefix("");
    private final String _prefix;
    private final String _localName;
    private final boolean _hasColon;
    
    public TagPrefix(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 + ":";
        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)
    {
      String prefix = attr.getPrefix();
      if ("xmlns".equals(prefix))
      {
        String prefixName = attr.getLocalName();
        if (prefixName != null)
        {
          String uri = attr.getNodeValue();
          if (uri != null) {
            return new PrefixEntry(uri, prefixName);
          }
        }
      }
      return null;
    }
    
    public PrefixEntry(String uri, 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;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.contentassist.XHTMLContentAssistProcessor2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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.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;

public abstract class FaceletChangePage
  extends AbstractFacetWizardPage
{
  private Button _chgDefaultSuffix;
  private Button _chgViewHandler;
  private Button _chgConfigureListener;
  private Button _chgWebappLifecycleListener;
  private DataBindingContext _bindingContext;
  private FacetChangeModel _dataModel;
  
  public FaceletChangePage(String name)
  {
    super(name);
  }
  
  public void setConfig(Object config)
  {
    _dataModel = ((FacetChangeModel)config);
  }
  
  protected String getTextForChangeType()
  {
    ChangeActionType actionType = _dataModel.getChangeActionType();
    switch (actionType)
    {
    case ADD: 
      return "Add";
    case REMOVE: 
      return "Remove";
    }
    return "*ERROR*";
  }
  
  private void initDefaultSuffixButton(Composite parent)
  {
    _chgDefaultSuffix = new Button(parent, 32);
    _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(Composite parent)
  {
    _chgViewHandler = new Button(parent, 32);
    _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(Composite parent)
  {
    _chgConfigureListener = new Button(parent, 32);
    _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(Composite parent)
  {
    _chgWebappLifecycleListener = new Button(parent, 32);
    _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(Composite parent)
  {
    setTitle("Facelet");
    setMessage("Configure Facelet settings");
    
    _bindingContext = new DataBindingContext();
    
    Composite control = new Composite(parent, 0);
    RowLayout rowLayout = new RowLayout(512);
    fill = true;
    control.setLayout(rowLayout);
    
    Group webXMLGroup = new Group(control, 0);
    webXMLGroup.setLayout(rowLayout);
    webXMLGroup.setText("Deployment Descriptor (web.xml) Configuration");
    initDefaultSuffixButton(webXMLGroup);
    initConfigureListener(webXMLGroup);
    initWebappLifecycleListener(webXMLGroup);
    
    Group facesConfigGroup = new Group(control, 0);
    facesConfigGroup.setLayout(rowLayout);
    facesConfigGroup
      .setText("Application (faces-config.xml) Configuration");
    initViewHandlerButton(facesConfigGroup);
    
    setControl(control);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletChangePage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.facet;

public class FaceletInstallPage
  extends FaceletChangePage
{
  public FaceletInstallPage()
  {
    super("Facelet Install Page");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletInstallPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.facet;

public class FaceletUninstallPage
  extends FaceletChangePage
{
  public FaceletUninstallPage()
  {
    super("Facelet Uninstall Page");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.facet.FaceletUninstallPage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.hover;

import org.eclipse.jst.jsf.facelet.core.internal.cm.FaceletDocumentFactory;
import org.eclipse.wst.html.ui.internal.taginfo.HTMLTagInfoHoverProcessor;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

class FaceletHover$MyHTMLTagInfoHoverProcessor
  extends HTMLTagInfoHoverProcessor
{
  private FaceletHover$MyHTMLTagInfoHoverProcessor(FaceletHover paramFaceletHover) {}
  
  protected CMElementDeclaration getCMElementDeclaration(Node node)
  {
    if ((FaceletHover.access$0(this$0) != null) && (node.getNodeType() == 1) && 
      (node.getPrefix() != null))
    {
      Element element = (Element)node;
      FaceletDocumentFactory factory = new FaceletDocumentFactory(FaceletHover.access$0(this$0));
      
      CMElementDeclaration elementDecl = factory
        .createCMElementDeclaration(element);
      if (elementDecl != null) {
        return elementDecl;
      }
    }
    return super.getCMElementDeclaration(node);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.hover.FaceletHover.MyHTMLTagInfoHoverProcessor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
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.w3c.dom.Element;
import org.w3c.dom.Node;

public class FaceletHover
  implements ITextHover
{
  private IProject _project;
  private JSFELHover _elHover;
  private HTMLTagInfoHoverProcessor _htmlHoverProcessor;
  
  public FaceletHover()
  {
    _elHover = new JSFELHover();
    _htmlHoverProcessor = new MyHTMLTagInfoHoverProcessor(null);
  }
  
  public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion)
  {
    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;
    IStructuredDocumentContext context = IStructuredDocumentContextFactory.INSTANCE
      .getContext(textViewer, offset);
    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(IStructuredDocumentContext context)
  {
    ITextRegionContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
      .getTextRegionResolver(context);
    String regionType = resolver.getRegionType();
    if (regionType != null) {
      if (regionType != "XML_TAG_ATTRIBUTE_VALUE")
      {
        if (!resolver.matchesRelative(
          new String[] { "XML_TAG_ATTRIBUTE_VALUE" })) {}
      }
      else {
        return true;
      }
    }
    return false;
  }
  
  private IProject getProject(IStructuredDocumentContext context)
  {
    IWorkspaceContextResolver resolver = IStructuredDocumentContextResolverFactory.INSTANCE
      .getWorkspaceContextResolver(context);
    if (resolver != null) {
      return resolver.getProject();
    }
    return null;
  }
  
  private class MyHTMLTagInfoHoverProcessor
    extends HTMLTagInfoHoverProcessor
  {
    private MyHTMLTagInfoHoverProcessor() {}
    
    protected CMElementDeclaration getCMElementDeclaration(Node node)
    {
      if ((_project != null) && (node.getNodeType() == 1) && 
        (node.getPrefix() != null))
      {
        Element element = (Element)node;
        FaceletDocumentFactory factory = new FaceletDocumentFactory(_project);
        
        CMElementDeclaration elementDecl = factory
          .createCMElementDeclaration(element);
        if (elementDecl != null) {
          return elementDecl;
        }
      }
      return super.getCMElementDeclaration(node);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.jsf.facelet.ui.internal.hover.FaceletHover
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.jsf.facelet.ui.internal.htmleditor;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
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;

public class FaceletELHyperlinkDetector
  extends AbstractELHyperlinkDetector
{
  protected boolean isEnabled(IStructuredDocumentContext context)
  {
    boolean enabled = false;
    if (context != null)
    {
      IWorkspaceContextResolver resolver = 
        IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
      if (resolver != null)
      {
        IReso
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd