Author: vrubezhny
Date: 2009-11-26 12:59:36 -0500 (Thu, 26 Nov 2009)
New Revision: 18867
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java
Log:
JBIDE-5149: Make OpenOn work for styleClass="|"
The CSS-file search and an start position calculation are fixed
Modified:
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 2009-11-26
17:59:32 UTC (rev 18866)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesCSSClassHyperlink.java 2009-11-26
17:59:36 UTC (rev 18867)
@@ -12,26 +12,15 @@
package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
import java.text.MessageFormat;
-import java.util.List;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.jboss.tools.common.el.core.resolver.ELContext;
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.PageContextFactory;
-import org.jboss.tools.jst.web.kb.PageContextFactory.CSSStyleSheetDescriptor;
-import org.w3c.dom.css.CSSRule;
-import org.w3c.dom.css.CSSRuleList;
/**
*
* @author Victor Rubezhny
*
*/
-@SuppressWarnings("restriction")
public class RichfacesCSSClassHyperlink extends CSSClassHyperlink {
/*
* (non-Javadoc)
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-26
17:59:32 UTC (rev 18866)
+++
trunk/jst/plugins/org.jboss.tools.jst.text.ext/src/org/jboss/tools/jst/text/ext/hyperlink/CSSClassHyperlink.java 2009-11-26
17:59:36 UTC (rev 18867)
@@ -18,6 +18,7 @@
import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -75,17 +76,48 @@
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;
+ IFile file = findFileForCSSStyleSheet(descr.source);
+ if (file != null) {
+ int startOffset = 0;
+ if (descr.sheet.getOwnerNode() != null) {
+ Node node = descr.sheet.getOwnerNode().getFirstChild();
+ if (node instanceof IndexedRegion) {
+ startOffset = ((IndexedRegion)node).getStartOffset();
+ }
+ }
+ showRegion(
+ file,
+ new Region(startOffset + ((IndexedRegion)rule).getStartOffset(),
((IndexedRegion)rule).getLength()));
+ return;
+ }
}
}
}
openFileFailed();
}
+ /*
+ * Finds a file representing the specified stylesheet
+ *
+ * Three kinds of filePath values are tested:
+ * - workspace related full path (Comes for a stylesheet defined in STYLE tag. Actually
it is a path to the page where the STYLE tag is used)
+ * - full file path to the CSS-file within the project
+ * - relative file path
+ *
+ * @param filePath
+ * @return
+ */
+ private IFile findFileForCSSStyleSheet(String filePath) {
+ // First try to find a file by WS-related path (because it's the most longest
path)
+ IFile file = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(
+ ResourcesPlugin.getWorkspace().getRoot().
+ getLocation().append(filePath));
+
+ return file != null ? file : PageContextFactory.getFileFromProject(filePath,
getFile());
+
+ }
+
/**
*
* @param cssRule
Show replies by date