Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-04-26 07:45:01 -0400
committerMilos Kleint2011-04-26 07:45:01 -0400
commit15c1cbc2d9a09eb9dbbdc3a5c5c31b95fbeb52f0 (patch)
tree5498c4d1875685579e0a041e6a191f26bedc1de7
parent494faeb5bef12457c9de3106d100252a5d844a60 (diff)
downloadm2e-core-15c1cbc2d9a09eb9dbbdc3a5c5c31b95fbeb52f0.tar.gz
m2e-core-15c1cbc2d9a09eb9dbbdc3a5c5c31b95fbeb52f0.tar.xz
m2e-core-15c1cbc2d9a09eb9dbbdc3a5c5c31b95fbeb52f0.zip
343817 no link in hover when definition not found. hint about import scoped deps added, also fixed spacing in the message construction
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomHyperlinkDetector.java8
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java2
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java13
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties4
4 files changed, 20 insertions, 7 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomHyperlinkDetector.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomHyperlinkDetector.java
index e701518d..1996de4d 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomHyperlinkDetector.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomHyperlinkDetector.java
@@ -409,6 +409,12 @@ public class PomHyperlinkDetector implements IHyperlinkDetector {
return region.project != null && region.project.getModel().getProperties().containsKey(region.property);
}
+ //only create the hyperlink when the origin location for jumping is present.
+ //in some cases (managed version comes from imported dependencies) we don't have the location and have nowhere to jump)
+ public static boolean canCreateHyperLink(final ManagedArtifactRegion region) {
+ return region.project != null && PomHyperlinkDetector.findLocationForManagedArtifact(region, region.project) != null;
+ }
+
static IHyperlink[] openExternalMarkerDefinition(ISourceViewer sourceViewer, int offset) {
List<IHyperlink> toRet = new ArrayList<IHyperlink>();
@@ -778,7 +784,7 @@ public class PomHyperlinkDetector implements IHyperlinkDetector {
public int getOffset() {
return offset;
}
- }
+ }
public static class MarkerRegion implements IRegion {
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
index e659e623..65cecdf5 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
@@ -90,9 +90,11 @@ public class PomTextHover implements ITextHover, ITextHoverExtension, ITextHover
// check!
InputSource source = openLocation.getSource();
if (source != null) {
+ ret.append(" "); // a space after the version value
ret.append(NLS.bind(Messages.PomTextHover_managed_location, source.getModelId()));
}
} else {
+ ret.append(" "); // a space after the version value
ret.append(Messages.PomTextHover_managed_location_missing);
}
return ret;
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
index 76c622f6..5b77dcf1 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/MarkerHoverControl.java
@@ -201,9 +201,13 @@ public class MarkerHoverControl extends AbstractInformationControl implements II
createResolutionsControl(composite, mark, resolutions);
}
}
- if (reg instanceof ManagedArtifactRegion) {
- final ManagedArtifactRegion man = (ManagedArtifactRegion)reg;
- Link link = createHyperlink(createTooltipComposite(composite, PomTextHover.getLabelForRegion(man)));
+ if(reg instanceof ManagedArtifactRegion) {
+ final ManagedArtifactRegion man = (ManagedArtifactRegion) reg;
+ Composite comp = createTooltipComposite(composite, PomTextHover.getLabelForRegion(man));
+ //only create the hyperlink when the origin location for jumping is present.
+ //in some cases (managed version comes from imported dependencies) we don't have the location and have nowhere to jump)
+ if (PomHyperlinkDetector.canCreateHyperLink(man)) {
+ Link link = createHyperlink(comp);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -211,8 +215,9 @@ public class MarkerHoverControl extends AbstractInformationControl implements II
PomHyperlinkDetector.createHyperlink(man).open();
}
});
-
}
+
+ }
if (reg instanceof ExpressionRegion) {
final ExpressionRegion expr = (ExpressionRegion)reg;
Composite tooltipComposite = createTooltipComposite(composite, PomTextHover.getLabelForRegion(expr));
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
index 4c9a56bf..88a30ae0 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/messages.properties
@@ -70,8 +70,8 @@ PomTextHover_eval1=This expression evaluates to
PomTextHover_eval2=The property is defined in {0}
PomTextHover_jump_to=<a>Jump to location</a>
PomTextHover_managed_location=The artifact is managed in {0}
-PomTextHover_managed_location_missing=The managed artifact's location could not be determined.
+PomTextHover_managed_location_missing=The managed definition location could not be determined, probably defined by "import" scoped dependencies.
PomTextHover_managed_version=The managed version is
-PomTextHover_managed_version_missing=The managed version could not be determined
+PomTextHover_managed_version_missing=The managed version could not be determined.
PomTextHover_more_quickfixes={0} quick fixes available:
PomTextHover_one_quickfix=\ 1 quick fix available:

Back to the top