Author: scabanovich
Date: 2008-04-10 12:35:24 -0400 (Thu, 10 Apr 2008)
New Revision: 7492
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLinkHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java
Log:
JBIDE-893
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -42,9 +43,10 @@
}
private String getAction(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
@@ -52,8 +54,8 @@
private String getModule(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -63,7 +65,7 @@
Attr bundleAttr = (Attr)node.getAttributes().getNamedItem("module");
if(bundleAttr == null) return "";
return Utils.getTrimmedValue(getDocument(), bundleAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -36,9 +37,10 @@
}
private String getAction(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -13,6 +13,7 @@
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.w3c.dom.Attr;
@@ -53,30 +54,26 @@
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
protected void doHyperlink(IRegion region) {
+ if(region == null) return;
- try {
- String forID = getForId(region);
- String prefix = getPrefix(region);
+ String forID = getForId(region);
+ String prefix = getPrefix(region);
- IRegion elementByID = findElementByIDBackward(forID, region.getOffset(), prefix);
- if (elementByID != null) {
- StructuredSelectionHelper.setSelectionAndRevealInActiveEditor(elementByID);
- return;
- }
- StrutsFormBeanHyperlink openOn = new StrutsFormBeanHyperlink();
- openOn.setTextViewer(getTextViewer());
- openOn.setOffset(getOffset());
- openOn.doHyperlink(region);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- openFileFailed();
+ IRegion elementByID = findElementByIDBackward(forID, region.getOffset(), prefix);
+ if (elementByID != null) {
+ StructuredSelectionHelper.setSelectionAndRevealInActiveEditor(elementByID);
+ return;
}
+ StrutsFormBeanHyperlink openOn = new StrutsFormBeanHyperlink();
+ openOn.setTextViewer(getTextViewer());
+ openOn.setOffset(getOffset());
+ openOn.doHyperlink(region);
}
private IRegion findElementByIDBackward (String id, int endOffset, String prefix) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -117,9 +114,6 @@
return "IRegion [" + getOffset() +", " + getLength()+
"]";
}
};
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -127,8 +121,8 @@
private Element findElementByIDBackward(NodeList list, String id, int endOffset, String
prefix) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -138,34 +132,27 @@
for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
if(!(list.item(i) instanceof Element)) continue;
- try {
- Element element = (Element)list.item(i);
- int start = Utils.getValueStart(element);
- if (start < 0 || start >= endOffset) continue;
+ Element element = (Element)list.item(i);
+ int start = Utils.getValueStart(element);
+ if (start < 0 || start >= endOffset) continue;
- String elementExtracted =
JSPRootHyperlinkPartitioner.extractName(element.getNodeName(), trackersMap, tm);
- if (isInList(elementExtracted, trackersMap, tm, prefix)) {
+ String elementExtracted =
JSPRootHyperlinkPartitioner.extractName(element.getNodeName(), trackersMap, tm);
+ if (isInList(elementExtracted, trackersMap, tm, prefix)) {
- Attr idAttr = element.getAttributeNode("id");
- if (idAttr != null) {
- String val = Utils.trimQuotes(idAttr.getNodeValue());
- if (id.equals(val)) {
- return element;
- }
+ Attr idAttr = element.getAttributeNode("id");
+ if (idAttr != null) {
+ String val = Utils.trimQuotes(idAttr.getNodeValue());
+ if (id.equals(val)) {
+ return element;
}
}
+ }
- if (element.hasChildNodes()) {
- Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
prefix);
- if (child != null) return child;
- }
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- // Probably not an IDOMElement
+ if (element.hasChildNodes()) {
+ Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
prefix);
+ if (child != null) return child;
}
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
} finally {
smw.dispose();
}
@@ -191,7 +178,7 @@
String getForId(IRegion region) {
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -268,7 +255,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
@@ -291,9 +278,6 @@
Node node = n;
if (node.getNodeName().indexOf(":") == -1) return null;
return node.getNodeName().substring(0, node.getNodeName().indexOf(":"));
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -39,9 +40,10 @@
}
private String getBundle(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -36,7 +37,7 @@
Properties p = new Properties();
String value = getKey(region);
- value = (value == null? "" : value);
+ value = (value == null) ? "" : value;
p.setProperty(WebPromptingProvider.KEY, value);
p.setProperty("prefix", value);
@@ -48,9 +49,10 @@
}
private String getBundle(IRegion region) {
+ if(region == null) return "";
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -59,7 +61,7 @@
Attr bundleAttr = (Attr)node.getAttributes().getNamedItem("bundle");
if(bundleAttr == null) return "";
return Utils.getTrimmedValue(getDocument(), bundleAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
} finally {
@@ -68,11 +70,12 @@
}
private String getKey(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
+ return "";
}
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -41,9 +42,10 @@
}
private String getBundle(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
- return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -47,9 +48,10 @@
}
private String getBundle(IRegion region) {
+ if(region == null) return "";
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -58,7 +60,7 @@
Attr bundleAttr = (Attr)node.getAttributes().getNamedItem("bundle");
if(bundleAttr == null) return "";
return Utils.getTrimmedValue(getDocument(), bundleAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
} finally {
@@ -67,11 +69,12 @@
}
private String getKey(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
+ return "";
}
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -43,9 +44,10 @@
}
private String getAttributeValue(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -45,9 +46,10 @@
}
private String getName(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -55,8 +57,8 @@
private String getFormType(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -67,7 +69,7 @@
if (typeAttr == null) return null;
String type = Utils.getTrimmedValue(getDocument(), typeAttr);
return type;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -51,9 +52,10 @@
}
private String getAttributeValue(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -61,8 +63,8 @@
private String getPath(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -120,7 +122,7 @@
return null;
return parentNode.getNodeName() + "/" + nameOrType;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -38,9 +39,10 @@
}
private String getPage(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -44,9 +45,10 @@
}
private String getAttributeValue(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -105,7 +107,7 @@
if (propStart > offset || propStart + propLength < offset) return null;
IRegion region = new HyperlinkRegion(propStart, propLength);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -46,8 +48,8 @@
*/
protected boolean recognizeNature(IDocument document) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
IFile documentFile = smw.getFile();
IProject project = documentFile.getProject();
for (int i = 0; i < STRUTS_PROJECT_NATURES.length; i++) {
@@ -55,7 +57,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -75,7 +77,6 @@
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
public boolean recognize(IDocument document, IHyperlinkRegion region) {
-
if (!super.recognize(document, region))
return false;
@@ -83,8 +84,8 @@
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -102,19 +103,17 @@
return false;
return true;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return false;
} finally {
smw.dispose();
}
}
private String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(node == null || document == null || attrName == null) return "";
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -18,7 +18,6 @@
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.common.text.ext.hyperlink.ClassMethodHyperlink;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
public class StrutsConfigSetPropertyHyperlink extends ClassMethodHyperlink {
private static final String CLASSNAME_ATTRNAME = "className";
@@ -31,9 +30,10 @@
}
protected String getClassName(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -45,9 +45,6 @@
Node parentNode = node.getParentNode();
return getAttributeValue(parentNode, CLASSNAME_ATTRNAME);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -41,8 +43,8 @@
*/
protected boolean recognizeNature(IDocument document) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
IFile documentFile = smw.getFile();
IProject project = documentFile.getProject();
for (int i = 0; i < STRUTS_PROJECT_NATURES.length; i++) {
@@ -50,7 +52,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -65,7 +67,8 @@
* @see
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkPartitionRecognizer#recognize(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
public boolean recognize(IDocument document, IHyperlinkRegion region) {
-
+ if(document == null || region == null) return false;
+
if (!super.recognize(document, region))
return false;
@@ -73,8 +76,8 @@
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
@@ -88,19 +91,17 @@
String classNameValue = getAttributeValue(document, parent, CLASS_NAME_ATTR);
return (classNameValue != null && classNameValue.length() > 0 &&
propertyValue != null && propertyValue.length() > 0);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return false;
} finally {
smw.dispose();
}
}
private String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(node == null || document == null || attrName == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -24,10 +25,11 @@
* @author Jeremy
*/
public class StrutsContextParamLinkHyperlink extends StrutsLinkHyperlink {
+
protected IRegion getRegion (int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -77,7 +79,7 @@
if (propStart > offset || propStart + propLength < offset) return null;
IRegion region = new HyperlinkRegion(propStart, propLength);
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
@@ -48,8 +49,8 @@
private boolean checkTypeIsEmpty(IDocument document, IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -59,7 +60,7 @@
if (typeAttr == null) return true;
String typeValue = Utils.getTrimmedValue(document, typeAttr);
return (typeValue == null || typeValue.length() == 0);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -38,9 +39,10 @@
}
private String getFormBean(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -44,9 +45,10 @@
}
private String getKey(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -38,9 +39,10 @@
}
private String getForward(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.jboss.tools.struts.StrutsProject;
@@ -38,8 +39,8 @@
*/
protected boolean recognizeNature(IDocument document) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if(xmlDocument == null) return false;
IFile documentFile = smw.getFile();
@@ -50,7 +51,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -14,6 +14,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
@@ -42,13 +43,13 @@
IFile file = getFile();
XModel xModel = getXModel(file);
if (xModel == null) return;
- try {
+ {
WebPromptingProvider provider = WebPromptingProvider.getInstance();
Properties p = getRequestProperties(region);
p.put(WebPromptingProvider.FILE, file);
- List list = provider.getList(xModel, WebPromptingProvider.STRUTS_OPEN_TAG_LIBRARY,
p.getProperty("prefix"), p);
+ List<Object> list = provider.getList(xModel,
WebPromptingProvider.STRUTS_OPEN_TAG_LIBRARY, p.getProperty("prefix"), p);
if (list != null && list.size() >= 1) {
openFileInEditor((String)list.get(0));
return;
@@ -57,9 +58,6 @@
if ( error != null && error.length() > 0) {
openFileFailed();
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- openFileFailed();
}
}
@@ -84,9 +82,10 @@
}
private String getURI(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -105,18 +104,16 @@
if(!tmw.exists()) return null;
return tmw.getUri(nodePrefix);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
}
private String getTagName(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -128,9 +125,6 @@
String tagName = node.getNodeName();
if (tagName.indexOf(':') == -1) return null;
return tagName.substring(tagName.indexOf(':') + 1);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -140,18 +134,14 @@
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
*/
protected IRegion doGetHyperlinkRegion(int offset) {
- try {
- return getRegion(offset);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
+ return getRegion(offset);
}
private String getTagAttributeName(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -220,7 +210,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
@@ -229,10 +219,11 @@
}
protected String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(document == null || node == null || attrName == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -42,9 +44,10 @@
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -60,9 +63,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -82,7 +82,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -92,8 +92,8 @@
protected IRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -156,7 +156,7 @@
}
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -14,6 +14,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
@@ -44,13 +45,12 @@
XModel xModel = getXModel(documentFile);
if (xModel == null) return;
- try {
WebPromptingProvider provider = WebPromptingProvider.getInstance();
Properties p = getRequestProperties(region);
p.put(WebPromptingProvider.FILE, documentFile);
- List list = provider.getList(xModel, WebPromptingProvider.STRUTS_OPEN_TAG_LIBRARY,
p.getProperty("prefix"), p);
+ List<Object> list = provider.getList(xModel,
WebPromptingProvider.STRUTS_OPEN_TAG_LIBRARY, p.getProperty("prefix"), p);
if (list != null && list.size() >= 1) {
openFileInEditor((String)list.get(0));
return;
@@ -59,10 +59,6 @@
if ( error != null && error.length() > 0) {
openFileFailed();
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- openFileFailed();
- }
}
@@ -82,9 +78,10 @@
}
private String getURI(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -105,18 +102,16 @@
if (!tmw.exists()) return null;
return tmw.getUri(nodePrefix);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
}
private String getTagName(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -128,9 +123,6 @@
if (tagName.indexOf(':') == -1) return null;
return tagName.substring(tagName.indexOf(':') + 1);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -140,18 +132,13 @@
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
*/
protected IRegion doGetHyperlinkRegion(int offset) {
- try {
- return getRegion(offset);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
+ return getRegion(offset);
}
protected IRegion getRegion (int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -192,19 +179,17 @@
};
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
}
protected String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(document == null || node == null || attrName == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
@@ -40,9 +41,10 @@
* @see
com.ibm.sse.editor.hyperlink.AbstractHyperlinkPartitioner#parse(org.eclipse.jface.text.IDocument,
com.ibm.sse.editor.extensions.hyperlink.IHyperlinkRegion)
*/
protected IHyperlinkRegion parse(IDocument document, IHyperlinkRegion superRegion) {
+ if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -60,9 +62,6 @@
IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -73,8 +72,8 @@
*/
public boolean recognize(IDocument document, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
IFile documentFile = smw.getFile();
IProject project = documentFile.getProject();
@@ -83,7 +82,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -93,8 +92,8 @@
protected IRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -135,9 +134,6 @@
};
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLinkHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLinkHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLinkHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -21,15 +21,11 @@
public class StrutsLinkHyperlink extends LinkHyperlink {
protected IFile getFileFromProject(String fileName) {
+ if(fileName == null || fileName.length() == 0) return null;
IFile documentFile = getFile();
-
- try {
- IProject project = documentFile.getProject();
- return super.getFileFromProject(updateFilenameForModel(fileName, project));
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
+ if(documentFile == null) return null;
+ IProject project = documentFile.getProject();
+ return super.getFileFromProject(updateFilenameForModel(fileName, project));
}
}
\ No newline at end of file
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -16,6 +16,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.w3c.dom.Attr;
@@ -55,6 +56,7 @@
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
*/
protected void doHyperlink(IRegion region) {
+ if(region == null) return;
IFile documentFile = getFile();
XModel xModel = getXModel(documentFile);
if (xModel == null) {
@@ -63,8 +65,8 @@
}
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
String forID = getForId(region);
String prefix = getPrefix(region);
@@ -95,7 +97,7 @@
p.setProperty(WebPromptingProvider.PROPERTY, getFormBeanProperty(region));
p.put(WebPromptingProvider.FILE, documentFile);
- List list = provider.getList(xModel, WebPromptingProvider.STRUTS_OPEN_FORM_BEAN,
getFormBeanName(region, n), p);
+ List<Object> list = provider.getList(xModel,
WebPromptingProvider.STRUTS_OPEN_FORM_BEAN, getFormBeanName(region, n), p);
if (list != null && list.size() >= 1) {
openFileInEditor((String)list.get(0));
return;
@@ -104,9 +106,6 @@
if ( error != null && error.length() > 0) {
openFileFailed();
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- openFileFailed();
} finally {
smw.dispose();
}
@@ -114,19 +113,21 @@
}
private String getFormBeanName(IRegion region, Node node) {
+ if(region == null || node == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem("name");
return Utils.getTrimmedValue(getDocument(), attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
}
private String getFormBeanProperty(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
@@ -134,8 +135,8 @@
private IRegion findElementByIDBackward (String id, int endOffset, String prefix) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -176,9 +177,6 @@
return "IRegion [" + getOffset() +", " + getLength()+
"]";
}
};
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
@@ -186,55 +184,41 @@
private Element findElementByIDBackward(NodeList list, String id, int endOffset, String
prefix) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Map trackersMap = JSPRootHyperlinkPartitioner.getTrackersMap(getDocument(),
endOffset);
XModel xModel = null;
TaglibMapping tm = null;
- try {
- if(xModel != null) {
- tm = WebProject.getInstance(xModel).getTaglibMapping();
- } else {
- tm = null;
- }
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- tm = null; // For sure
+ if(xModel != null) {
+ tm = WebProject.getInstance(xModel).getTaglibMapping();
}
for (int i = list.getLength() - 1; list != null && i >= 0; i--) {
if(!(list.item(i) instanceof Element)) continue;
- try {
- Element element = (Element)list.item(i);
- int start = Utils.getValueStart(element);
- if (start < 0 || start >= endOffset) continue;
+ Element element = (Element)list.item(i);
+ int start = Utils.getValueStart(element);
+ if (start < 0 || start >= endOffset) continue;
- String elementExtracted =
JSPRootHyperlinkPartitioner.extractName(element.getNodeName(), trackersMap, tm);
- if (isInList(elementExtracted, trackersMap, tm, prefix)) {
-
- Attr idAttr = (Attr)element.getAttributeNode("id");
- if (idAttr != null) {
- String val = Utils.trimQuotes(idAttr.getNodeValue());
- if (id.equals(val)) {
- return element;
- }
+ String elementExtracted =
JSPRootHyperlinkPartitioner.extractName(element.getNodeName(), trackersMap, tm);
+ if (isInList(elementExtracted, trackersMap, tm, prefix)) {
+
+ Attr idAttr = (Attr)element.getAttributeNode("id");
+ if (idAttr != null) {
+ String val = Utils.trimQuotes(idAttr.getNodeValue());
+ if (id.equals(val)) {
+ return element;
}
}
+ }
- if (element.hasChildNodes()) {
- Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
prefix);
- if (child != null) return child;
- }
- } catch (Exception x) {
- // Probably not an IDOMElement
- StrutsExtensionsPlugin.getPluginLog().logError(x);
+ if (element.hasChildNodes()) {
+ Element child = findElementByIDBackward(element.getChildNodes(), id, endOffset,
prefix);
+ if (child != null) return child;
}
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
} finally {
smw.dispose();
}
@@ -258,9 +242,10 @@
}
String getForId(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -276,8 +261,8 @@
private IRegion getRegion(int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -337,7 +322,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
@@ -346,9 +331,10 @@
}
private String getPrefix(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -360,9 +346,6 @@
Node node = n;
if (node.getNodeName().indexOf(":") == -1) return null;
return node.getNodeName().substring(0, node.getNodeName().indexOf(":"));
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -38,9 +39,10 @@
}
private String getPage(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -11,6 +11,8 @@
package org.jboss.tools.struts.text.ext.hyperlink;
import java.util.Properties;
+
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
@@ -35,9 +37,10 @@
}
private String getProperty(IRegion region) {
+ if(region == null || getDocument() == null) return "";
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -47,18 +48,20 @@
}
private String getProperty(IRegion region) {
- try {
+ if(region == null || getDocument() == null) return "";
+ try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return "";
}
}
private String getFormType(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -86,7 +89,7 @@
Attr typeAttr = (Attr)formNode.getAttributes().getNamedItem("type");
if (typeAttr == null) return null;
return Utils.getTrimmedValue(getDocument(), typeAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
@@ -95,9 +98,10 @@
}
private String getFormAction (IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -125,7 +129,7 @@
Attr actionAttr = (Attr)formNode.getAttributes().getNamedItem("action");
if (actionAttr == null) return null;
return Utils.getTrimmedValue(getDocument(), actionAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -38,8 +39,8 @@
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -54,8 +55,6 @@
if (uri != null) {
p.setProperty("prefix", uri);
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
} finally {
smw.dispose();
}
@@ -64,10 +63,11 @@
}
private String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(document == null || node == null || attrName == null)return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(getDocument(), attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -75,8 +75,8 @@
protected IRegion getRegion(final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -85,7 +85,7 @@
if (n == null || !(n instanceof Attr || n instanceof Node)) return null;
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if ((n == null) || !(n instanceof Node)) return null;
+ if ((n == null) || !(n instanceof IDOMNode)) return null;
IDOMNode node = (IDOMNode)n;
@@ -114,9 +114,6 @@
}
};
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -51,8 +52,8 @@
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
@@ -60,9 +61,6 @@
if (!(n instanceof Attr || n instanceof Node) ) return false;
return true;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return false;
} finally {
smw.dispose();
}
@@ -82,7 +80,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -92,8 +90,8 @@
public IRegion getRegion(IDocument document, final int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -101,7 +99,7 @@
if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if ((n == null) || !(n instanceof Node)) return null;
+ if ((n == null) || !(n instanceof IDOMNode)) return null;
IDOMNode node = (IDOMNode)n;
@@ -129,9 +127,6 @@
}
};
return region;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -41,9 +42,10 @@
}
private String getBundle(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -50,9 +51,10 @@
}
private String getKey(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -60,8 +62,8 @@
private String getBundle(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -69,7 +71,7 @@
Node node = ((Attr)n).getOwnerElement();
Attr bundleAttr = (Attr)node.getAttributes().getNamedItem("bundle");
return Utils.getTrimmedValue(getDocument(), bundleAttr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -47,8 +48,8 @@
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
@@ -61,9 +62,6 @@
return false;
return true;
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return false;
} finally {
smw.dispose();
}
@@ -71,10 +69,11 @@
}
protected String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(document == null || node == null || attrName == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.util.Utils;
@@ -28,9 +29,10 @@
protected String getMethodName(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -62,9 +63,10 @@
private String getMethodName(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -76,8 +78,8 @@
private String getAttributeValue(IRegion region, String attrName) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -85,7 +87,7 @@
Node node = ((Attr)n).getOwnerElement();
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(getDocument(), attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -48,23 +49,23 @@
}
return p;
- }
+ }
-
-
private String getProperty(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
}
private String getFormName(IRegion region) {
+ if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
@@ -74,9 +75,6 @@
Node parentNode = node.getParentNode();
return getAttributeValue(getDocument(), parentNode, NAME_ATTRNAME);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
} finally {
smw.dispose();
}
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -43,9 +44,10 @@
}
private String getAttributeValue(IRegion region) {
+ if(region == null || getDocument() == null) return null;
try {
return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}
@@ -53,8 +55,8 @@
public IRegion getRegion (int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -117,7 +119,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -46,8 +48,8 @@
*/
protected boolean recognizeNature(IDocument document) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
IFile documentFile = smw.getFile();
IProject project = documentFile.getProject();
@@ -56,7 +58,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
@@ -118,7 +120,6 @@
if (paramNameNode == null) return false;
String paramNameValue = null;
- try {
NodeList list = paramNameNode.getChildNodes();
for (int i = 0; list != null && i < list.getLength(); i++) {
if (list.item(i) instanceof Text) {
@@ -133,9 +134,6 @@
}
}
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- }
if (paramNameValue == null) return false;
boolean paramNameValueIsCorrect = false;
for (int i = 0; i < VALID_INIT_PARAM_NAMES.length; i++) {
@@ -160,8 +158,8 @@
if (servletClassNode == null) return false;
String servletClassValue = null;
- try {
- NodeList list = servletClassNode.getChildNodes();
+
+ list = servletClassNode.getChildNodes();
for (int i = 0; list != null && i < list.getLength(); i++) {
if (list.item(i) instanceof Text) {
Text text = (Text)list.item(i);
@@ -175,9 +173,7 @@
}
}
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- }
+
if (servletClassValue == null) return false;
boolean servletClassValueIsCorrect = false;
@@ -188,7 +184,7 @@
}
return (paramNameValueIsCorrect && servletClassValueIsCorrect);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.jboss.tools.struts.StrutsProject;
@@ -41,8 +42,8 @@
*/
public boolean recognize(IDocument document, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(document);
try {
- smw.init(document);
IFile documentFile = smw.getFile();
IProject project = documentFile.getProject();
@@ -51,7 +52,7 @@
return true;
}
return false;
- } catch (Exception x) {
+ } catch (CoreException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return false;
} finally {
Modified:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java 2008-04-10
16:33:44 UTC (rev 7491)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java 2008-04-10
16:35:24 UTC (rev 7492)
@@ -14,6 +14,7 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.w3c.dom.Attr;
@@ -40,13 +41,13 @@
IFile documentFile = getFile();
XModel xModel = getXModel(documentFile);
if (xModel == null) return;
- try {
+
WebPromptingProvider provider = WebPromptingProvider.getInstance();
Properties p = getRequestProperties(region);
p.put(WebPromptingProvider.FILE, documentFile);
- List list = provider.getList(xModel, getRequestMethod(),
p.getProperty("prefix"), p);
+ List<Object> list = provider.getList(xModel, getRequestMethod(),
p.getProperty("prefix"), p);
if (list != null && list.size() >= 1) {
openFileInEditor((String)list.get(0));
return;
@@ -55,10 +56,6 @@
if ( error != null && error.length() > 0) {
openFileFailed();
}
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- openFileFailed();
- }
}
protected abstract String getRequestMethod();
@@ -69,18 +66,13 @@
* @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
*/
protected IRegion doGetHyperlinkRegion(int offset) {
- try {
- return getRegion(offset);
- } catch (Exception x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
+ return getRegion(offset);
}
protected IRegion getRegion (int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
+ smw.init(getDocument());
try {
- smw.init(getDocument());
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
@@ -140,7 +132,7 @@
};
return region;
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
} finally {
@@ -149,10 +141,11 @@
}
protected String getAttributeValue (IDocument document, Node node, String attrName) {
+ if(document == null || node == null || attrName == null) return null;
try {
Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
return Utils.getTrimmedValue(document, attr);
- } catch (Exception x) {
+ } catch (BadLocationException x) {
StrutsExtensionsPlugin.getPluginLog().logError(x);
return null;
}