Skip to content

Commit 6ccf4fc

Browse files
author
jantje
committed
avoiding problems when a package is not found
Instead of null pointer exception a warning is logged. Also a trim is added to the tools name; because...well you know...
1 parent c5014d8 commit 6ccf4fc

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

io.sloeber.core/src/io/sloeber/core/managers/Package.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public List<Tool> getTools() {
126126

127127
public Tool getTool(String toolName, String version) {
128128
for (Tool tool : this.tools) {
129-
if (tool.getName().equals(toolName) && tool.getVersion().equals(version)) {
129+
if (tool.getName().trim().equals(toolName) && tool.getVersion().equals(version)) {
130130
return tool;
131131
}
132132
}

io.sloeber.ui/src/io/sloeber/ui/actions/LinkCommandHandler.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@
55
import org.eclipse.core.commands.ExecutionException;
66
import org.eclipse.core.runtime.IStatus;
77
import org.eclipse.core.runtime.Status;
8+
import org.osgi.framework.FrameworkUtil;
89

910
import io.sloeber.ui.Activator;
1011
import io.sloeber.ui.Messages;
1112

1213
public class LinkCommandHandler extends AbstractHandler {
1314

14-
@Override
15-
public Object execute(ExecutionEvent event) throws ExecutionException {
16-
try {
17-
String url = event.getParameter("io.sloeber.core.link.parameter");//$NON-NLS-1$
18-
org.eclipse.swt.program.Program.launch(url);
19-
} catch (IllegalArgumentException e) {
20-
Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.json_browser_fail, e));
15+
@Override
16+
public Object execute(ExecutionEvent event) throws ExecutionException {
17+
try {
18+
org.osgi.framework.Version version = FrameworkUtil.getBundle(getClass()).getVersion();
19+
String url = event.getParameter("io.sloeber.core.link.parameter");//$NON-NLS-1$
20+
21+
url = url.replace("${MAJOR_VERSION}", String.valueOf(version.getMajor())); //$NON-NLS-1$
22+
url = url.replace("${MINOR_VERSION}", String.valueOf(version.getMinor())); //$NON-NLS-1$
23+
url = url.replace("${MICRO_VERSION}", String.valueOf(version.getMinor())); //$NON-NLS-1$
24+
url = url.replace("${QUALIFIER_VERSION}", String.valueOf(version.getMinor())); //$NON-NLS-1$
25+
org.eclipse.swt.program.Program.launch(url);
26+
} catch (IllegalArgumentException e) {
27+
Activator.log(new Status(IStatus.ERROR, Activator.getId(), Messages.json_browser_fail, e));
28+
}
29+
return null;
2130
}
22-
return null;
23-
}
2431

2532
}

0 commit comments

Comments
 (0)