Author: vrubezhny
Date: 2009-11-16 09:14:23 -0500 (Mon, 16 Nov 2009)
New Revision: 18696
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
Log:
JBIDE-5149: Make OpenOn work for styleClass="|"
JBIDE-5119: Refactor PageContextFactory to improve performance of context creation.
The CSSStyleSheet gathering is re-developed.
New Hyperlink is added.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/META-INF/MANIFEST.MF 2009-11-16
14:14:23 UTC (rev 18696)
@@ -12,7 +12,10 @@
org.jboss.tools.common.text.ext,
org.jboss.tools.jst.text.ext,
org.jboss.tools.jsf.text.ext,
- org.jboss.tools.jst.web;bundle-version="2.0.0"
+ org.jboss.tools.jst.web;bundle-version="2.0.0",
+ org.jboss.tools.jst.web.kb;bundle-version="1.0.0",
+ org.eclipse.wst.css.core;bundle-version="1.1.300",
+ org.jboss.tools.common.el.core;bundle-version="2.0.0"
Export-Package: org.jboss.tools.jsf.text.ext.richfaces,
org.jboss.tools.jsf.text.ext.richfaces.hyperlink
Bundle-Version: 2.0.0
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-11-16
14:04:39 UTC (rev 18695)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2009-11-16
14:14:23 UTC (rev 18696)
@@ -314,6 +314,19 @@
</contentType>
</hyperlinkPartitioner>
+ <hyperlinkPartitioner
+
id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlinkPartitioner"
+
class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlinkPartitioner">
+ <contentType id="org.eclipse.jst.jsp.core.jspsource">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ </partitionType>
+ </contentType>
+ <contentType id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ATTRIBUTE_VALUE">
+ </partitionType>
+ </contentType>
+ </hyperlinkPartitioner>
+
</extension>
<extension
@@ -342,6 +355,17 @@
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_RICHFACES_BUNDLE" />
</contenttypeidentifier>
</hyperlink>
+
+ <hyperlink
+ class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlink"
+ id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesCSSClassHyperlink">
+ <contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS"
/>
+ </contenttypeidentifier>
+ <contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
+ <partitiontype id="org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS"
/>
+ </contenttypeidentifier>
+ </hyperlink>
</extension>
<extension point="org.jboss.tools.jst.web.kb.KbIncludeContext">
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -0,0 +1,90 @@
+package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
+import org.jboss.tools.jst.text.ext.hyperlink.CSSClassHyperlink;
+import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
+import org.w3c.dom.css.CSSRule;
+import org.w3c.dom.css.CSSRuleList;
+
+public class RichfacesCSSClassHyperlink extends CSSClassHyperlink {
+
+ @Override
+ protected void doHyperlink(IRegion region) {
+ ICSSContainerSupport cssContainerSupport = null;
+ IPageContext context = PageContextFactory.createPageContext(getFile(),
region.getOffset(), getContentType(getDocument()));
+ if (!(context instanceof ICSSContainerSupport)) {
+ openFileFailed();
+ return;
+ }
+ cssContainerSupport = (ICSSContainerSupport)context;
+ List<CSSStyleSheetDescriptor> descrs =
cssContainerSupport.getCSSStyleSheetDescriptors();
+
+ for (int i = (descrs == null) ? -1 : descrs.size() - 1; descrs != null && i
>= 0; i--) {
+ CSSStyleSheetDescriptor descr = descrs.get(i);
+ CSSRuleList rules = descr.sheet.getCssRules();
+ for (int r = 0; rules != null && r < rules.getLength(); r++) {
+ if (isRuleMatch(rules.item(r), getStyleName(region))) {
+ CSSRule rule = rules.item(r);
+ System.out.println();
+ showRegion(
+ PageContextFactory.getFileFromProject(descr.source, getFile()),
+ new Region(((IndexedRegion)rule).getStartOffset(),
((IndexedRegion)rule).getLength()));
+ return;
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ String styleName = getStyleName(fLastRegion);
+ if (styleName == null)
+ return MessageFormat.format(Messages.OpenA, Messages.CSSStyle);
+
+ return MessageFormat.format(Messages.OpenCSSStyle, styleName);
+ }
+
+
+ /**
+ * Returns the content type of document
+ *
+ * @param document -
+ * assumes document is not null
+ * @return String content type of given document
+ */
+ @SuppressWarnings("restriction")
+ private String getContentType(IDocument document) {
+ String type = null;
+
+ IModelManager mgr = StructuredModelManager.getModelManager();
+ IStructuredModel model = null;
+ try {
+ model = mgr.getExistingModelForRead(document);
+ if (model != null) {
+ type = model.getContentTypeIdentifier();
+ }
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return type;
+ }
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -0,0 +1,24 @@
+package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
+
+import org.eclipse.jface.text.IDocument;
+import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import org.jboss.tools.jst.text.ext.hyperlink.CSSClassHyperlinkPartitioner;
+
+public class RichfacesCSSClassHyperlinkPartitioner extends CSSClassHyperlinkPartitioner
{
+ public static final String RICHFACES_CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.RICHFACES_CSS_CLASS"; //$NON-NLS-1$
+ private static final String RICHFACES_CSS_CLASS_TOKEN = "/styleClass/";
//$NON-NLS-1$
+
+ @Override
+ public boolean recognize(IDocument document, IHyperlinkRegion region) {
+ if (region.getAxis() != null
+ && region.getAxis().endsWith(RICHFACES_CSS_CLASS_TOKEN))
+ return true;
+ return false;
+ }
+
+ @Override
+ protected String getPartitionType(String axis) {
+ return RICHFACES_CSS_CLASS_PARTITION;
+ }
+
+}
Property changes on:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlinkPartitioner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -227,28 +227,31 @@
* @param styleName
* @return
*/
- private boolean isRuleMatch(CSSRule cssRule, String styleName) {
+ protected boolean isRuleMatch(CSSRule cssRule, String styleName) {
// get selector text
String selectorText = ((ICSSStyleRule) cssRule).getSelectorText();
if (selectorText != null) {
-
- // split selector text by whitespace
- String[] styles = selectorText.trim().split(" "); //$NON-NLS-1$
- int searchIndex = Arrays.binarySearch(styles, styleName,
- new Comparator<String>() {
-
- public int compare(String o1, String o2) {
- Matcher matcher = Pattern.compile(
- COMPARE_CLASS_REGEX_PREFIX + o2)
- .matcher(o1);
- return matcher.matches() ? 0 : 1;
- }
-
- });
- if (searchIndex >= 0)
- return true;
+ String styles[] = selectorText.trim().split(","); //$NON-NLS-1$
+ for (String styleText : styles) {
+ String[] styleWords = styleText.trim().split(" "); //$NON-NLS-1$
+ if (styleWords != null) {
+ int searchIndex = Arrays.binarySearch(styleWords, styleName,
+ new Comparator<String>() {
+
+ public int compare(String o1, String o2) {
+ Matcher matcher = Pattern.compile(
+ COMPARE_CLASS_REGEX_PREFIX + o2)
+ .matcher(o1);
+ return matcher.matches() ? 0 : 1;
+ }
+
+ });
+ if (searchIndex >= 0)
+ return true;
+ }
+ }
}
return false;
}
@@ -296,7 +299,7 @@
*
* @param styleRegion
*/
- private void showRegion(RegionHolder styleRegion) {
+ protected void showRegion(RegionHolder styleRegion) {
IWorkbenchPage workbenchPage = ExtensionsPlugin.getDefault()
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
@@ -318,10 +321,35 @@
/**
*
+ * @param styleRegion
+ */
+ protected void showRegion(IFile file, IRegion region) {
+
+ IWorkbenchPage workbenchPage = ExtensionsPlugin.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart part = null;
+ if (file != null) {
+ try {
+ part = IDE.openEditor(workbenchPage, file, true);
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ if (part == null) {
+ openFileFailed();
+ return;
+ }
+ StructuredSelectionHelper.setSelectionAndReveal(part,
+ region);
+ }
+
+
+ /**
+ *
* @param region
* @return
*/
- private String getStyleName(IRegion region) {
+ protected String getStyleName(IRegion region) {
try {
return getDocument().get(region.getOffset(), region.getLength());
} catch (BadLocationException e) {
@@ -329,7 +357,7 @@
}
}
- IRegion fLastRegion = null;
+ protected IRegion fLastRegion = null;
/**
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
Modified:
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlinkPartitioner.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -31,7 +31,7 @@
public static final String CSS_CLASS_PARTITION =
"org.jboss.tools.common.text.ext.CSS_CLASS"; //$NON-NLS-1$
- private static final String CSS_CLASS_TOKEN = "class/"; //$NON-NLS-1$
+ private static final String CSS_CLASS_TOKEN = "/class/"; //$NON-NLS-1$
private static final String EXCLUSION_TOKEN = "jsp:usebean/class/";
//$NON-NLS-1$
@@ -71,7 +71,7 @@
}
}
- private String getPartitionType(String axis) {
+ protected String getPartitionType(String axis) {
return CSS_CLASS_PARTITION;
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/ICSSContainerSupport.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -12,6 +12,8 @@
import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.w3c.dom.css.CSSStyleSheet;
/**
@@ -26,14 +28,17 @@
/**
* Adds the CSS StyleSheet object found within the page
*
- * @param includedContext
+ * @param cssStyleSheet
+ * @param source
*/
- void addCSSStyleSheet(CSSStyleSheet cssStyleSheet);
+ void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheet);
+ IFile getResource();
+
/**
* Returns the list of all the collected CSS StyleSheet objects
*
* @return
*/
- List<CSSStyleSheet> getCSSStyleSheets();
+ List<CSSStyleSheetDescriptor> getCSSStyleSheetDescriptors();
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -85,6 +85,8 @@
public static String JSP_PAGE_CONTEXT_TYPE = "JSP_PAGE_CONTEXT_TYPE";
public static String FACELETS_PAGE_CONTEXT_TYPE =
"FACELETS_PAGE_CONTEXT_TYPE";
+
+
/**
* Creates a page context for the specified context type
* @
@@ -150,7 +152,7 @@
setFaceletsNameSpaces(context, offset);
context.setLibraries(getTagLibraries(context, offset));
context.setResourceBundles(getResourceBundles(context));
-
+
collectIncludedAdditionalInfo(context);
} finally {
releaseConnectedDocument(input);
@@ -235,25 +237,33 @@
private static void createCSSStyleSheetFromAttribute(IDOMElement node,
String attribute, ICSSContainerSupport context) {
- CSSStyleSheet sheet = getSheetForTagAttribute(node, attribute);
- if (sheet != null)
- context.addCSSStyleSheet(sheet);
+ CSSStyleSheetDescriptor descr = getSheetForTagAttribute(node, attribute);
+ if (descr != null)
+ context.addCSSStyleSheetDescriptor(descr);
}
private static void createCSSStyleSheetFromElement(IDOMElement node,
ICSSContainerSupport context) {
CSSStyleSheet sheet = getSheetForTag(node);
if (sheet != null)
- context.addCSSStyleSheet(sheet);
+ context.addCSSStyleSheetDescriptor(new
CSSStyleSheetDescriptor(context.getResource().getFullPath().toString(), sheet));
}
-
+ public static class CSSStyleSheetDescriptor {
+ public CSSStyleSheet sheet;
+ public String source;
+
+ CSSStyleSheetDescriptor (String source, CSSStyleSheet sheet) {
+ this.source = source;
+ this.sheet = sheet;
+ }
+ }
/**
*
* @param stylesContainer
* @return
*/
- private static CSSStyleSheet getSheetForTagAttribute(final Node stylesContainer, String
attribute) {
+ private static CSSStyleSheetDescriptor getSheetForTagAttribute(final Node
stylesContainer, String attribute) {
INodeNotifier notifier = (INodeNotifier) stylesContainer;
@@ -270,13 +280,14 @@
}
CSSStyleSheet sheet = null;
+ String source = null;
if (adapter != null) {
sheet = (CSSStyleSheet) adapter.getSheet();
-
+ source = ((ExtendedLinkElementAdapter)adapter).getSource();
}
- return sheet;
+ return sheet == null || source == null ? null : new CSSStyleSheetDescriptor(source,
sheet);
}
/**
@@ -913,6 +924,7 @@
private Element element;
private String hrefAttrName;
+ private String source = null;
public ExtendedLinkElementAdapter(Element element, String hrefAttrName) {
this.element = element;
@@ -924,8 +936,15 @@
return element;
}
+ public String getSource() {
+ return source;
+ }
+
@Override
protected boolean isValidAttribute() {
+ if (super.isValidAttribute())
+ return true;
+
String href = getElement().getAttribute(hrefAttrName);
if (href == null || href.length() == 0)
return false;
@@ -936,30 +955,34 @@
*/
public ICSSModel getModel() {
// Fix for JBIDE-5079 >>>
- ICSSModel model = null;
if (super.isValidAttribute()) {
- model = super.getModel();
+ source = getSourceFromAttribute("href");
+ } else if (isValidAttribute()) {
+ source = getSourceFromAttribute(hrefAttrName);
+ } else {
+ return null;
}
- // Fix for JBIDE-5079 <<<
- if (model == null) {
- model = retrieveModel();
- setModel(model);
- }
+
+ ICSSModel model = retrieveModel();
+ setModel(model);
return model;
}
+ private String getSourceFromAttribute(String hrefAttributeName) {
+ String hrefExtracted = findAndReplaceElVariable(element
+ .getAttribute(hrefAttrName));
+
+ return hrefExtracted;
+ }
+
/**
*/
private ICSSModel retrieveModel() {
- if (!isValidAttribute()) {
+ if (!isValidAttribute() || source == null) {
return null;
}
// null,attr check is done in isValidAttribute()
- Element element = getElement();
- String href = findAndReplaceElVariable(element
- .getAttribute(hrefAttrName));
-
IDOMModel baseModel = ((IDOMNode) element).getModel();
if (baseModel == null)
return null;
@@ -975,7 +998,7 @@
URLModelProvider provider = new URLModelProvider();
try {
IStructuredModel newModel = provider.getModelForRead(baseModel,
- href);
+ source);
if (newModel == null)
return null;
if (!(newModel instanceof ICSSModel)) {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/JspContextImpl.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -16,6 +16,7 @@
import org.jboss.tools.jst.web.kb.ICSSContainerSupport;
import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.jboss.tools.jst.web.kb.internal.taglib.NameSpace;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.css.CSSStyleSheet;
@@ -26,9 +27,8 @@
*/
public class JspContextImpl extends XmlContextImpl implements ICSSContainerSupport {
protected List<IPageContext> fIncludedContexts = null;
- protected List<CSSStyleSheet> fCSSStyleSheets = null;
+ protected List<CSSStyleSheetDescriptor> fCSSStyleSheetDescriptors = null;
-
@Override
public void addIncludedContext(IPageContext includedContext) {
if (fIncludedContexts == null) {
@@ -56,19 +56,19 @@
return superNameSpaces;
}
- public void addCSSStyleSheet(CSSStyleSheet cssStyleSheet) {
- if (fCSSStyleSheets == null) {
- fCSSStyleSheets = new ArrayList<CSSStyleSheet>();
+ public void addCSSStyleSheetDescriptor(CSSStyleSheetDescriptor cssStyleSheetDescriptor)
{
+ if (fCSSStyleSheetDescriptors == null) {
+ fCSSStyleSheetDescriptors = new ArrayList<CSSStyleSheetDescriptor>();
}
- fCSSStyleSheets.add(cssStyleSheet);
+ fCSSStyleSheetDescriptors.add(cssStyleSheetDescriptor);
}
- public List<CSSStyleSheet> getCSSStyleSheets() {
- List<CSSStyleSheet> sheets = new ArrayList<CSSStyleSheet>();
+ public List<CSSStyleSheetDescriptor> getCSSStyleSheetDescriptors() {
+ List<CSSStyleSheetDescriptor> descrs = new
ArrayList<CSSStyleSheetDescriptor>();
- if (fCSSStyleSheets != null) {
- for (CSSStyleSheet sheet : fCSSStyleSheets) {
- sheets.add(sheet);
+ if (fCSSStyleSheetDescriptors != null) {
+ for (CSSStyleSheetDescriptor descr : fCSSStyleSheetDescriptors) {
+ descrs.add(descr);
}
}
@@ -76,16 +76,14 @@
if (includedContexts != null) {
for (IPageContext includedContext : includedContexts) {
if (includedContext instanceof ICSSContainerSupport) {
- List<CSSStyleSheet> includedSheets =
((ICSSContainerSupport)includedContext).getCSSStyleSheets();
- if (includedSheets != null) {
- sheets.addAll(includedSheets);
+ List<CSSStyleSheetDescriptor> includedSheetDescriptors =
((ICSSContainerSupport)includedContext).getCSSStyleSheetDescriptors();
+ if (includedSheetDescriptors != null) {
+ descrs.addAll(includedSheetDescriptors);
}
}
}
}
- return sheets;
-
- }
-
+ return descrs;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-16
14:04:39 UTC (rev 18695)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/CSSClassProposalType.java 2009-11-16
14:14:23 UTC (rev 18696)
@@ -23,9 +23,9 @@
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.WebKbPlugin;
+import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
import org.w3c.dom.css.CSSRule;
import org.w3c.dom.css.CSSRuleList;
-import org.w3c.dom.css.CSSStyleSheet;
/**
* The CSS Class proposal type. Is used to collect and return the proposals on
@@ -49,17 +49,16 @@
if (context instanceof ICSSContainerSupport) {
ICSSContainerSupport cssSource = (ICSSContainerSupport)context;
- List<CSSStyleSheet> sheets = cssSource.getCSSStyleSheets();
- if (sheets != null) {
- for (CSSStyleSheet sheet : sheets) {
- CSSRuleList rules = sheet.getCssRules();
+ List<CSSStyleSheetDescriptor> descrs = cssSource.getCSSStyleSheetDescriptors();
+ if (descrs != null) {
+ for (CSSStyleSheetDescriptor descr : descrs) {
+ CSSRuleList rules = descr.sheet.getCssRules();
for (int i = 0; rules != null && i < rules.getLength(); i++) {
CSSRule rule = rules.item(i);
idList.addAll(getNamesFromCSSRule(rule));
}
}
}
-
}
}
@@ -70,7 +69,7 @@
* @param styleName
* @return
*/
- private Set<String> getNamesFromCSSRule(CSSRule cssRule) {
+ public static Set<String> getNamesFromCSSRule(CSSRule cssRule) {
Set<String> styleNames = new
TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
// get selector text