Author: vrubezhny
Date: 2009-05-04 11:12:37 -0400 (Mon, 04 May 2009)
New Revision: 15008
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/Messages.properties
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlink.java
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java
Log:
JBIDE-4068 Add option (Open On) to open the correspondent Seam component when we have a
@In annotation in a field and click on the field name.
Minor changes on the resource name showing
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/Messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/Messages.properties 2009-05-04
14:40:33 UTC (rev 15007)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/Messages.properties 2009-05-04
15:12:37 UTC (rev 15008)
@@ -1,5 +1,5 @@
OpenSeamDeclarationAs=Open Declaration of {1} for ''{0}'' {2}
-InResource=in ''{0}''
+InResource=in {0}
SeamComponent=Seam Component
SeamRole=@Role/@Roles
SeamFactory=Seam Factory
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlink.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlink.java 2009-05-04
14:40:33 UTC (rev 15007)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlink.java 2009-05-04
15:12:37 UTC (rev 15008)
@@ -39,7 +39,7 @@
public class SeamComponentHyperlink implements IHyperlink {
private IRegion fRegion;
- private ISeamContextVariable fVariable;
+ private String fResourceName;
private IJavaElement fElement;
private IOpenableElement fOpenable;
private String fLabel;
@@ -48,14 +48,13 @@
/**
* Creates a new Seam Component hyperlink.
*/
- SeamComponentHyperlink(IRegion region, ISeamContextVariable variable, IJavaElement
element, String name) {
+ SeamComponentHyperlink(IRegion region, String resourceName, IJavaElement element, String
name) {
Assert.isNotNull(region);
- Assert.isNotNull(variable);
Assert.isNotNull(element);
Assert.isNotNull(name);
fRegion = region;
- fVariable = variable;
+ fResourceName = resourceName;
fElement = element;
fOpenable = null;
fLabel = SeamExtMessages.SeamFactory;
@@ -65,14 +64,13 @@
/**
* Creates a new Seam Component hyperlink.
*/
- SeamComponentHyperlink(IRegion region, ISeamContextVariable variable, ISeamComponent
element, String name) {
+ SeamComponentHyperlink(IRegion region, String resourceName, ISeamComponent element,
String name) {
Assert.isNotNull(region);
- Assert.isNotNull(variable);
Assert.isNotNull(element);
Assert.isNotNull(name);
fRegion = region;
- fVariable = variable;
+ fResourceName = resourceName;
fElement = null;
fLabel = SeamExtMessages.SeamComponent;
fName = name;
@@ -95,14 +93,13 @@
/**
* Creates a new Seam Component hyperlink.
*/
- SeamComponentHyperlink(IRegion region, ISeamContextVariable variable, IBijectedAttribute
element, String name) {
+ SeamComponentHyperlink(IRegion region, String resourceName, IBijectedAttribute element,
String name) {
Assert.isNotNull(region);
- Assert.isNotNull(variable);
Assert.isNotNull(element);
Assert.isNotNull(name);
fRegion = region;
- fVariable = variable;
+ fResourceName = resourceName;
fElement = element.getSourceMember();
fLabel = SeamExtMessages.SeamBijected;
fName = name;
@@ -112,15 +109,14 @@
/**
* Creates a new Seam Component hyperlink.
*/
- SeamComponentHyperlink(IRegion region, ISeamContextVariable variable, IRole element,
String name) {
+ SeamComponentHyperlink(IRegion region, String resourceName, IRole element, String name)
{
Assert.isNotNull(region);
- Assert.isNotNull(variable);
Assert.isNotNull(element);
Assert.isTrue(element instanceof IOpenableElement);
Assert.isNotNull(name);
fRegion = region;
- fVariable = variable;
+ fResourceName = resourceName;
fElement = null;
fOpenable = (IOpenableElement)element;
fLabel = SeamExtMessages.SeamRole;
@@ -176,12 +172,8 @@
*/
public String getHyperlinkText() {
String formattedIn = "";
- if (fVariable.getResource() != null) {
- String resourceName = fVariable.getResource().getName();
-
- if (resourceName != null && resourceName.trim().length() > 0) {
- formattedIn = MessageFormat.format(SeamExtMessages.InResource, resourceName);
- }
+ if (fResourceName != null && fResourceName.trim().length() > 0) {
+ formattedIn = MessageFormat.format(SeamExtMessages.InResource, fResourceName);
}
return MessageFormat.format(SeamExtMessages.OpenSeamDeclarationAs, fName, fLabel,
formattedIn);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java 2009-05-04
14:40:33 UTC (rev 15007)
+++
trunk/seam/plugins/org.jboss.tools.seam.text.ext/src/org/jboss/tools/seam/text/ext/hyperlink/SeamComponentHyperlinkDetector.java 2009-05-04
15:12:37 UTC (rev 15008)
@@ -41,6 +41,7 @@
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamContextShortVariable;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ISeamMessages;
@@ -170,18 +171,38 @@
}
if (javaElements != null) {
for (IJavaElement javaElement : javaElements) {
- hyperlinks.add(new SeamComponentHyperlink(wordRegion, var, javaElement,
nameToSearch));
+ String resourceName = null;
+ if (javaElement.getResource() != null) {
+ resourceName=javaElement.getResource().getName();
+ }
+ hyperlinks.add(new SeamComponentHyperlink(wordRegion, resourceName,
javaElement, nameToSearch));
}
}
} else if (var instanceof ISeamComponent) {
- var.getResource().getName();
- hyperlinks.add(new SeamComponentHyperlink(wordRegion, var, (ISeamComponent)var,
nameToSearch));
+ String resourceName = null;
+ ISeamComponent comp = (ISeamComponent)var;
+ Set<ISeamComponentDeclaration> decls = comp.getAllDeclarations();
+ for (ISeamComponentDeclaration decl : decls) {
+ if (decl.getResource() != null) {
+ resourceName = decl.getResource().getName();
+ break;
+ }
+ }
+ hyperlinks.add(new SeamComponentHyperlink(wordRegion, resourceName,
(ISeamComponent)var, nameToSearch));
} else if (var instanceof IRole) {
- hyperlinks.add(new SeamComponentHyperlink(wordRegion, var, (IRole)var,
nameToSearch));
+ String resourceName = null;
+ if (var.getResource() != null) {
+ resourceName = var.getResource().getName();
+ }
+ hyperlinks.add(new SeamComponentHyperlink(wordRegion, resourceName, (IRole)var,
nameToSearch));
} else if (var instanceof IBijectedAttribute) {
+ String resourceName = null;
+ if (var.getResource() != null) {
+ resourceName = var.getResource().getName();
+ }
IBijectedAttribute attr = (IBijectedAttribute)var;
if (attr.getSourceMember() != null) {
- hyperlinks.add(new SeamComponentHyperlink(wordRegion, var,
(IBijectedAttribute)var, nameToSearch));
+ hyperlinks.add(new SeamComponentHyperlink(wordRegion, resourceName,
(IBijectedAttribute)var, nameToSearch));
}
}
}