Author: vrubezhny
Date: 2012-01-30 14:28:30 -0500 (Mon, 30 Jan 2012)
New Revision: 38297
Removed:
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java
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/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/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-10621
Redesign HyperlinkDetector so that partitioning and hyperlinks not do twice the same job.
Hyperlinks and Hyperlink Partitioners are redesigned due to exclude duplication work on
regions calculation.
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -81,11 +81,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String actionName = getAction(fLastRegion);
+ String actionName = getAction(getHyperlinkRegion());
if (actionName == null)
return MessageFormat.format(Messages.OpenAn, StrutsTextExtMessages.Action);
return MessageFormat.format(StrutsTextExtMessages.OpenAction, actionName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsActionMappingHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -54,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String actionName = getAction(fLastRegion);
+ String actionName = getAction(getHyperlinkRegion());
if (actionName == null)
return MessageFormat.format(Messages.OpenAn, StrutsTextExtMessages.ActionMapping);
return MessageFormat.format(StrutsTextExtMessages.OpenActionMapping, actionName);
}
-
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBeanNameHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,11 +19,11 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.StructuredSelectionHelper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.tld.TaglibMapping;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
@@ -32,7 +32,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -188,86 +187,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
-
- IRegion region = new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String getPrefix(IRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
@@ -294,11 +213,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forId = getForId(fLastRegion);
+ String forId = getForId(getHyperlinkRegion());
if (forId == null)
return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
return MessageFormat.format(Messages.BrowseForBeanId, forId);
}
-
}
\ No newline at end of file
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -23,8 +23,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,11 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
return MessageFormat.format(Messages.OpenBundle, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsBundleKeyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -86,12 +86,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
- String propertyName = getKey(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
+ String propertyName = getKey(getHyperlinkRegion());
if (baseName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.BundleProperty);
return MessageFormat.format(Messages.OpenBundleProperty, propertyName, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -23,8 +23,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -58,11 +56,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, Messages.Bundle);
return MessageFormat.format(Messages.OpenBundle, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigBundleKeyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -85,12 +85,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
- String propertyName = getKey(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
+ String propertyName = getKey(getHyperlinkRegion());
if (baseName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.BundleProperty);
return MessageFormat.format(Messages.OpenBundleProperty, propertyName, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormBeanHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigFormBeanHyperlink extends StrutsXModelBasedHyperlink {
@@ -61,11 +59,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formBeanName = getAttributeValue(fLastRegion);
+ String formBeanName = getAttributeValue(getHyperlinkRegion());
if (formBeanName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormBean);
return MessageFormat.format(StrutsTextExtMessages.OpenFormBean, formBeanName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigFormPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -85,7 +85,7 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formPropertyName = getName(fLastRegion);
+ String formPropertyName = getName(getHyperlinkRegion());
if (formPropertyName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormProperty);
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigForwardPathHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -138,11 +138,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String path = getPath(fLastRegion);
+ String path = getPath(getHyperlinkRegion());
if (path == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ForwardPath);
return MessageFormat.format(StrutsTextExtMessages.OpenForwardPath, path);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPageHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsConfigPageHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String page = getPage(fLastRegion);
+ String page = getPage(getHyperlinkRegion());
if (page == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Page);
return MessageFormat.format(StrutsTextExtMessages.OpenPage, page);
}
-
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,15 +15,10 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -54,80 +49,17 @@
return null;
}
}
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/'
&&
- sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-'
&&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_'
&&
- sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?'
&&
- sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=')
{
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/'
&&
- sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-'
&&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_'
&&
- sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?'
&&
- sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
- break;
- }
- bEnd++;
- }
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
- if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new HyperlinkRegion(propStart, propLength);
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getAttributeValue(fLastRegion);
+ String propertyName = getAttributeValue(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Setter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter,
propertyName);
}
-
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigPluginSetPropertyHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -73,13 +73,12 @@
private static final String VALID_CLASS_NAME_VALUE =
"org.apache.struts.validator.ValidatorPlugIn";
private static final String VALID_PROPERTY_VALUE = "pathnames";
-
/**
* @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))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
if (!recognizeNature(document))
@@ -90,7 +89,7 @@
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
Node node = ((Attr)n).getOwnerElement();
Node plugInNode = node.getParentNode();
@@ -120,5 +119,4 @@
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -62,11 +62,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getAttributeValue(fLastRegion, PROPERTY_ATTRNAME);
+ String propertyName = getAttributeValue(getHyperlinkRegion(), PROPERTY_ATTRNAME);
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.Setter);
return MessageFormat.format(Messages.OpenGetterOrSetterForProperty, Messages.Setter,
propertyName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsConfigSetPropertyHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -68,10 +68,10 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if(document == null || region == null) return false;
- if (!super.recognize(document, region))
+ if (!super.recognize(document, offset, region))
return false;
if (!recognizeNature(document))
@@ -83,7 +83,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
@@ -108,5 +108,4 @@
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsContextParamLinkHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,90 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
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;
-import org.w3c.dom.Text;
-import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-
/**
* @author Jeremy
*/
public class StrutsContextParamLinkHyperlink extends StrutsLinkHyperlink {
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Text)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '\\' && sb.charAt(bStart) != '/'
&&
- sb.charAt(bStart) != ':' && sb.charAt(bStart) != '-'
&&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '_'
&&
- sb.charAt(bStart) != '%' && sb.charAt(bStart) != '?'
&&
- sb.charAt(bStart) != '&' && sb.charAt(bStart) != '=')
{
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '\\' && sb.charAt(bEnd) != '/'
&&
- sb.charAt(bEnd) != ':' && sb.charAt(bEnd) != '-'
&&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '_'
&&
- sb.charAt(bEnd) != '%' && sb.charAt(bEnd) != '?'
&&
- sb.charAt(bEnd) != '&' && sb.charAt(bEnd) != '=') {
- break;
- }
- bEnd++;
- }
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
- if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new HyperlinkRegion(propStart, propLength);
- return region;
- } catch (BadLocationException 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/StrutsFormActionHyperlinkPartitioner.java
===================================================================
---
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormActionHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,27 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
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;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -39,21 +37,20 @@
/**
* @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))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
-
-
- return checkTypeIsEmpty(document, region);
+
+ return checkTypeIsEmpty(document, offset);
}
- private boolean checkTypeIsEmpty(IDocument document, IRegion region) {
+ private boolean checkTypeIsEmpty(IDocument document, int offset) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (n == null || !(n instanceof Attr)) return false;
Node node = ((Attr)n).getOwnerElement();
Attr typeAttr = (Attr)node.getAttributes().getNamedItem("type");
@@ -67,5 +64,4 @@
smw.dispose();
}
}
-
}
\ No newline at end of file
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormBeanHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsFormBeanHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,7 +54,7 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String formBeanName = getFormBean(fLastRegion);
+ String formBeanName = getFormBean(getHyperlinkRegion());
if (formBeanName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.FormBean);
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsFormValidationBundleKeyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,7 +15,6 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
-
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
@@ -26,8 +25,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsFormValidationBundleKeyHyperlink extends StrutsXModelBasedHyperlink {
@@ -63,11 +60,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getKey(fLastRegion);
+ String propertyName = getKey(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA,
StrutsTextExtMessages.ValidationBundleProperty);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationBundleProperty,
propertyName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsForwardHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsForwardHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,11 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forward = getForward(fLastRegion);
+ String forward = getForward(getHyperlinkRegion());
if (forward == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Forward);
return MessageFormat.format(StrutsTextExtMessages.OpenForward, forward);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPLinkHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -14,12 +14,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
-
-import org.jboss.tools.struts.StrutsProject;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPLinkHyperlinkPartitioner;
+import org.jboss.tools.struts.StrutsProject;
+import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Document;
public class StrutsJSPLinkHyperlinkPartitioner extends JSPLinkHyperlinkPartitioner {
@@ -65,8 +64,7 @@
/**
* @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) {
- return recognizeNature(document) ? super.recognize(document, region) : false;
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ return recognizeNature(document) ? super.recognize(document, offset, region) : false;
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -21,8 +21,8 @@
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
@@ -30,7 +30,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -63,7 +62,6 @@
}
}
-
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
@@ -132,15 +130,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
private String getTagAttributeName(IRegion region) {
if(region == null || getDocument() == null) return null;
try {
@@ -151,77 +140,6 @@
}
}
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- try {
- smw.init(getDocument());
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
-
- };
-
- return region;
- } catch (BadLocationException 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 {
@@ -239,12 +157,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
- String attrName = getTagAttributeName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
+ String attrName = getTagAttributeName(getHyperlinkRegion());
if (tagName == null || attrName == null)
return StrutsTextExtMessages.OpenTagLibraryForAnAttribute;
return MessageFormat.format(StrutsTextExtMessages.OpenTagLibraryForAttributeName,
attrName, tagName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagAttributeHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -42,7 +42,7 @@
/**
* @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) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -50,18 +50,14 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
- IRegion r = getRegion(document, superRegion.getOffset());
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = STRUTS_JSP_TAG_ATTRIBUTE_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -70,7 +66,7 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
try {
smw.init(document);
@@ -172,5 +168,4 @@
}
return superRegion.getAxis();
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -18,12 +18,11 @@
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;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
@@ -63,7 +62,6 @@
openFileFailed();
}
}
-
protected Properties getRequestProperties(IRegion region) {
Properties p = new Properties();
@@ -131,64 +129,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof IDOMElement)) return null;
-
- IDOMElement elem = (IDOMElement)n;
- String tagName = elem.getTagName();
- int start = elem.getStartOffset();
- final int nameStart = start + (elem.isEndTag() ? "</" :
"<").length();
- final int nameEnd = nameStart + tagName.length();
-
- if (nameStart > offset || nameEnd <= offset) return null;
-
- IRegion region = new IRegion () {
-
- public int getLength() {
- return nameEnd - nameStart;
- }
-
- public int getOffset() {
- return nameStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
- };
-
- return region;
- } finally {
- smw.dispose();
- }
- }
-
protected String getAttributeValue (IDocument document, Node node, String attrName) {
if(document == null || node == null || attrName == null) return null;
try {
@@ -206,11 +146,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String tagName = getTagName(fLastRegion);
+ String tagName = getTagName(getHyperlinkRegion());
if (tagName == null)
return StrutsTextExtMessages.OpenTagLibraryForATag;
return MessageFormat.format(StrutsTextExtMessages.OpenTagLibraryForTagName, tagName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsJSPTagNameHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,14 +15,15 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.struts.StrutsProject;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Document;
@@ -39,7 +40,7 @@
/**
* @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) {
+ protected IHyperlinkRegion parse(IDocument document, int offset, IHyperlinkRegion
superRegion) {
if(document == null || superRegion == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
@@ -47,20 +48,14 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
-// Node n =
- Utils.findNodeForOffset(xmlDocument, superRegion.getOffset());
-// if (!recognize(document, superRegion)) return null;
- IRegion r = getRegion(document, superRegion.getOffset());
+ IRegion r = getRegion(document, offset);
if (r == null) return null;
String axis = getAxis(document, superRegion);
String contentType = superRegion.getContentType();
String type = STRUTS_JSP_TAG_NAME_PARTITION;
- int length = r.getLength() - (superRegion.getOffset() - r.getOffset());
- int offset = superRegion.getOffset();
- IHyperlinkRegion region = new HyperlinkRegion(offset, length, axis, contentType,
type);
- return region;
+ return new HyperlinkRegion(r.getOffset(), r.getLength(), axis, contentType, type);
} finally {
smw.dispose();
}
@@ -69,7 +64,7 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -100,42 +95,17 @@
if (xmlDocument == null) return null;
Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
if (n == null || !(n instanceof IDOMElement)) return null;
IDOMElement elem = (IDOMElement)n;
String tagName = elem.getTagName();
int start = elem.getStartOffset();
+
final int nameStart = start + (elem.isEndTag() ? "</" :
"<").length();
final int nameEnd = nameStart + tagName.length();
-
if (nameStart > offset || nameEnd <= offset) return null;
- IRegion region = new IRegion () {
-
- public int getLength() {
- return nameEnd - nameStart;
- }
-
- public int getOffset() {
- return nameStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
- };
-
- return region;
+ return new Region(nameStart, nameEnd-nameStart);
} finally {
smw.dispose();
}
@@ -148,5 +118,4 @@
}
return superRegion.getAxis();
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsLogicPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,13 +19,14 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.jst.web.tld.TaglibMapping;
@@ -35,7 +36,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -159,28 +159,7 @@
final int offset = Utils.getValueStart(element);
final int length =
((IDOMElement)element).getStartStructuredDocumentRegion().getLength();
- return new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return length;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
- };
+ return new Region (offset, length);
} finally {
smw.dispose();
}
@@ -255,86 +234,6 @@
}
}
- IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- private IRegion getRegion(int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of path property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
-
- IRegion region = new IRegion () {
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
private String getPrefix(IRegion region) {
if(region == null) return null;
StructuredModelWrapper smw = new StructuredModelWrapper();
@@ -362,11 +261,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String forId = getForId(fLastRegion);
+ String forId = getForId(getHyperlinkRegion());
if (forId == null)
return MessageFormat.format(Messages.BrowseFor, Messages.BeanId);
return MessageFormat.format(Messages.BrowseForBeanId, forId);
}
-
}
\ No newline at end of file
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPageHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsPageHyperlink extends StrutsXModelBasedHyperlink {
@@ -56,12 +54,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String page = getPage(fLastRegion);
+ String page = getPage(getHyperlinkRegion());
if (page == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Page);
return MessageFormat.format(StrutsTextExtMessages.OpenPage, page);
}
-
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertiesFileHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -55,11 +55,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
if (propertyName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Property);
return MessageFormat.format(StrutsTextExtMessages.OpenProperty, propertyName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -145,13 +145,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
- String actionName = getFormAction(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
+ String actionName = getFormAction(getHyperlinkRegion());
if (propertyName == null || actionName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Property);
return MessageFormat.format(StrutsTextExtMessages.OpenPropertyForFormAction,
propertyName, actionName);
}
-
-
}
\ No newline at end of file
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -16,7 +16,6 @@
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;
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
@@ -84,64 +83,16 @@
}
}
- protected IRegion getRegion(final int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Node)) return null;
-
- if (n instanceof Attr) n = ((Attr)n).getOwnerElement();
- if ((n == null) || !(n instanceof IDOMNode)) return null;
-
- IDOMNode node = (IDOMNode)n;
-
- final int propStart = node.getStartOffset();
- final int propLength = node.getEndOffset() - propStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
-
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
- };
- return region;
- } finally {
- smw.dispose();
- }
-
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String uri = getTaglibUri(fLastRegion);
+ String uri = getTaglibUri(getHyperlinkRegion());
if (uri == null)
return MessageFormat.format(Messages.OpenA, Messages.TagLibrary);
return MessageFormat.format(Messages.OpenTagLibraryForUri, uri);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsTaglibDirectiveHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -15,11 +15,12 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
-import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import
org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.StrutsProject;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Attr;
@@ -46,7 +47,7 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if (!recognizeNature(document))
return false;
@@ -56,7 +57,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr || n instanceof Node) ) return false;
return true;
@@ -110,30 +111,9 @@
if (propStart > offset || propStart + propLength < offset) return null;
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
- };
- return region;
+ return new Region(propStart, propLength);
} 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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -24,8 +24,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsValidationBundleHyperlink extends StrutsXModelBasedHyperlink {
@@ -59,11 +57,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundle(fLastRegion);
+ String baseName = getBundle(getHyperlinkRegion());
if (baseName == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.ValidationBundle);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationBundle, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -87,12 +87,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getKey(fLastRegion);
- String baseName = getBundle(fLastRegion);
+ String propertyName = getKey(getHyperlinkRegion());
+ String baseName = getBundle(getHyperlinkRegion());
if (propertyName == null || baseName == null)
return MessageFormat.format(Messages.OpenA,
StrutsTextExtMessages.ValidationBundleProperty);
return
MessageFormat.format(StrutsTextExtMessages.OpenValidationBundlePropertyForBundle,
propertyName, baseName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationBundleKeyHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,26 +1,25 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
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;
-import org.w3c.dom.Node;
-
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
+import
org.jboss.tools.common.text.ext.hyperlink.xml.XMLTagAttributeValueHyperlinkPartitioner;
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.xml.XMLTagAttributeValueHyperlinkPartitioner;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -43,8 +42,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 (!super.recognize(document, region))
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
+ if (!super.recognize(document, offset, region))
return false;
StructuredModelWrapper smw = new StructuredModelWrapper();
@@ -53,7 +52,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Attr)) return false;
Node parentNode = ((Attr)n).getOwnerElement();
@@ -78,6 +77,4 @@
return null;
}
}
-
-
}
\ No newline at end of file
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -22,8 +22,6 @@
/**
* @author Jeremy
*
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
*/
public class StrutsValidationMethodHyperlink extends ClassMethodHyperlink {
private static final String CLASSNAME_ATTRNAME = "classname";
@@ -54,12 +52,10 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String methodName = getMethodName(fLastRegion);
+ String methodName = getMethodName(getHyperlinkRegion());
if (methodName == null)
return MessageFormat.format(Messages.OpenA, Messages.ValidationMethod);
return MessageFormat.format(Messages.OpenValidationMethod, methodName);
}
-
-
}
Deleted:
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationMethodHyperlink0.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.struts.text.ext.hyperlink;
-
-import java.text.MessageFormat;
-import java.util.Properties;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * @author Jeremy
- */
-public class StrutsValidationMethodHyperlink0 extends StrutsXModelBasedHyperlink {
- private static final String CLASSNAME_ATTRNAME = "classname";
-// private static final String METHODPARAMS_ATTRNAME = "methodParams";
-
- protected String getRequestMethod() {
- return WebPromptingProvider.STRUTS_OPEN_METHOD;
- }
-
- protected Properties getRequestProperties(IRegion region) {
- Properties p = new Properties();
-
- String value = getMethodName(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.NAME, value);
- p.setProperty("prefix", value);
- }
-
-
- value = getClassName(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.TYPE, value);
- }
-
- /* Isn't used yet!!!
- *
- value = getMethodParams(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.TYPE, value);
- }
- */
-
- return p;
- }
-
-
-
- private String getMethodName(IRegion region) {
- if(region == null || getDocument() == null) return null;
- try {
- return Utils.trimQuotes(getDocument().get(region.getOffset(), region.getLength()));
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- }
- }
-
- private String getClassName(IRegion region) {
- return getAttributeValue(region, CLASSNAME_ATTRNAME);
- }
-
- private String getAttributeValue(IRegion region, String attrName) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
- if (n == null || !(n instanceof Attr)) return null;
- Node node = ((Attr)n).getOwnerElement();
- Attr attr = (Attr)node.getAttributes().getNamedItem(attrName);
- return Utils.getTrimmedValue(getDocument(), attr);
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- String methodName = getMethodName(fLastRegion);
- if (methodName == null)
- return MessageFormat.format(Messages.OpenA, Messages.ValidationMethod);
-
- return MessageFormat.format(Messages.OpenValidationMethod, methodName);
- }
-
-}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationPropertyHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -88,12 +88,11 @@
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String propertyName = getProperty(fLastRegion);
- String formName = getFormName(fLastRegion);
+ String propertyName = getProperty(getHyperlinkRegion());
+ String formName = getFormName(getHyperlinkRegion());
if (propertyName == null || formName == null)
return MessageFormat.format(Messages.OpenA,
StrutsTextExtMessages.ValidationProperty);
return MessageFormat.format(StrutsTextExtMessages.OpenValidationProperty, propertyName,
formName);
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsValidationValidatorHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -16,14 +16,10 @@
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.jboss.tools.struts.text.ext.StrutsTextExtMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
/**
* @author Jeremy
@@ -55,92 +51,16 @@
}
}
- public IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr)) return null;
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if (start < 0 || start > offset) return null;
-
- String attrText = getDocument().get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart))) {
- bStart++;
- break;
- }
-
- if (bStart == 0) break;
- bStart--;
- }
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)))
- break;
- bEnd++;
- }
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
-
- };
-
- return region;
- } catch (BadLocationException x) {
- StrutsExtensionsPlugin.getPluginLog().logError(x);
- return null;
- } finally {
- smw.dispose();
- }
- }
-
/*
* (non-Javadoc)
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String validator = getAttributeValue(fLastRegion);
+ String validator = getAttributeValue(getHyperlinkRegion());
if (validator == null)
return MessageFormat.format(Messages.OpenA, StrutsTextExtMessages.Validator);
return MessageFormat.format(StrutsTextExtMessages.OpenValidator, validator);
}
-
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLContextParamLinkHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -81,7 +81,7 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
if (!recognizeNature(document))
return false;
@@ -92,7 +92,7 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return false;
- Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
+ Node n = Utils.findNodeForOffset(xmlDocument, offset);
if (!(n instanceof Text)) return false;
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXMLLinkHyperlinkPartitioner.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -27,7 +27,6 @@
public static final String STRUTS_XML_LINK_PARTITION =
"org.jboss.tools.common.text.ext.xml.STRUTS_XML_LINK";
private String[] STRUTS_PROJECT_NATURES = {StrutsProject.NATURE_ID };
-
/**
* @see
org.jboss.tools.common.text.ext.hyperlink.XMLLinkHyperlinkPartitioner#getPartitionType()
@@ -39,7 +38,7 @@
/**
* @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) {
+ public boolean recognize(IDocument document, int offset, IHyperlinkRegion region) {
StructuredModelWrapper smw = new StructuredModelWrapper();
smw.init(document);
try {
@@ -61,5 +60,4 @@
smw.dispose();
}
}
-
}
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 2012-01-30
19:25:59 UTC (rev 38296)
+++
trunk/struts/plugins/org.jboss.tools.struts.text.ext/src/org/jboss/tools/struts/text/ext/hyperlink/StrutsXModelBasedHyperlink.java 2012-01-30
19:28:30 UTC (rev 38297)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.struts.text.ext.hyperlink;
@@ -19,14 +19,11 @@
import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlink;
-import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
import org.jboss.tools.struts.text.ext.StrutsExtensionsPlugin;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Node;
-import org.w3c.dom.Text;
/**
* @author Jeremy
@@ -64,86 +61,6 @@
protected abstract Properties getRequestProperties(IRegion region);
- protected IRegion fLastRegion = null;
- /**
- * @see com.ibm.sse.editor.AbstractHyperlink#doGetHyperlinkRegion(int)
- */
- protected IRegion doGetHyperlinkRegion(int offset) {
- fLastRegion = getRegion(offset);
- return fLastRegion;
- }
-
- protected IRegion getRegion (int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
-
- if (start > offset || end < offset) return null;
-
- String text = getDocument().get(start, end - start);
- StringBuffer sb = new StringBuffer(text);
-
- //find start and end of class property
- int bStart = 0;
- int bEnd = text.length() - 1;
-
- while (bStart < bEnd && (Character.isWhitespace(sb.charAt(bStart))
- || sb.charAt(bStart) == '\"' || sb.charAt(bStart) ==
'\"')) {
- bStart++;
- }
- while (bEnd > bStart && (Character.isWhitespace(sb.charAt(bEnd))
- || sb.charAt(bEnd) == '\"' || sb.charAt(bEnd) == '\"')) {
- bEnd--;
- }
- bEnd++;
-
- final int propStart = bStart + start;
- final int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IRegion region = new IRegion () {
- public int getLength() {
- return propLength;
- }
-
- public int getOffset() {
- return propStart;
- }
-
- public boolean equals(Object arg) {
- if (!(arg instanceof IRegion)) return false;
- IRegion region = (IRegion)arg;
-
- if (getOffset() != region.getOffset()) return false;
- if (getLength() != region.getLength()) return false;
- return true;
- }
-
- public String toString() {
- return "IRegion [" + getOffset() +", " + getLength()+
"]";
- }
-
- };
-
- return region;
- } catch (BadLocationException 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 {
@@ -154,5 +71,4 @@
return null;
}
}
-
}