Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2008-05-05 21:21:02 +0000
committerChris Goldthorpe2008-05-05 21:21:02 +0000
commitfe65d02bf11dcde0197ba2a294b881694f7f0627 (patch)
tree47f898bf2b3c309482d54728e850359c3485d8c0 /org.eclipse.ui.cheatsheets
parentf25bc56367423ece6ac455837fc4f2c5ff1b1fb6 (diff)
downloadeclipse.platform.ua-fe65d02bf11dcde0197ba2a294b881694f7f0627.tar.gz
eclipse.platform.ua-fe65d02bf11dcde0197ba2a294b881694f7f0627.tar.xz
eclipse.platform.ua-fe65d02bf11dcde0197ba2a294b881694f7f0627.zip
Bug 229895 – [CheatSheet] NPE when opening a cheatsheet whose content file does not existv20080505
Diffstat (limited to 'org.eclipse.ui.cheatsheets')
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java14
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java5
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java9
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java13
-rw-r--r--org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java4
5 files changed, 38 insertions, 7 deletions
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java
index 78de00d4e..b1c440969 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/CheatsheetTaskEditor.java
@@ -63,10 +63,13 @@ public class CheatsheetTaskEditor extends TaskEditor {
if (id == null) {
id = task.getId();
}
- viewer.setInput(id, task.getName(), url, stateManager, false);
+ if (url != null) {
+ viewer.setInput(id, task.getName(), url, stateManager, false);
+ } else {
+ errorBadUrl(path);
+ }
} catch (MalformedURLException e) {
- String message = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {path}));
- viewer.showError(message);
+ errorBadUrl(path);
}
} else if (id != null){
viewer.setInput(id, stateManager);
@@ -78,6 +81,11 @@ public class CheatsheetTaskEditor extends TaskEditor {
}
viewer.addListener(new TaskListener());
}
+
+ private void errorBadUrl(String path) {
+ String message = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {path}));
+ viewer.showError(message);
+ }
/*
* Listener for the cheatsheet used by this class
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java
index 350e91b10..072d2303b 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/CheatSheetParser.java
@@ -866,7 +866,7 @@ public class CheatSheetParser implements IStatusContainer {
}
public ICheatSheet parse(URL url, String pluginId, int cheatSheetKind) {
- return parse(new ParserInput(url, pluginId), cheatSheetKind);
+ return parse(new ParserInput(url, pluginId, null), cheatSheetKind);
}
public ICheatSheet parse(ParserInput input, int cheatSheetKind) {
@@ -876,6 +876,9 @@ public class CheatSheetParser implements IStatusContainer {
if(input == null) {
return null;
}
+ if (input.getErrorMessage() != null) {
+ addStatus(IStatus.ERROR, input.getErrorMessage(), null);
+ }
InputStream is = null;
InputSource inputSource = null;
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java
index 41f12e279..89c1b122d 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/data/ParserInput.java
@@ -23,6 +23,7 @@ public class ParserInput {
private URL url;
private String xml;
private String pluginId;
+ private String errorMessage;
public ParserInput() {
url = null;
@@ -32,6 +33,7 @@ public class ParserInput {
public ParserInput(String xml, String basePath) {
this.xml = xml;
this.url = null;
+ this.errorMessage = null;
if (basePath != null) {
try {
this.url = new URL(basePath);
@@ -41,9 +43,10 @@ public class ParserInput {
}
}
- public ParserInput(URL url, String pluginId) {
+ public ParserInput(URL url, String pluginId, String errorMessage) {
this.url = url;
this.xml = null;
+ this.errorMessage = errorMessage;
this.pluginId = pluginId;
}
@@ -58,5 +61,9 @@ public class ParserInput {
public String getPluginId() {
return pluginId;
}
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
}
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java
index db8b42cf3..e615e4314 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/CheatSheetViewer.java
@@ -135,6 +135,9 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor {
}
public void advanceIntroItem() {
+ if (getViewItemAtIndex(0) == null) {
+ return; // Cheat Sheet has no items or was not opened correctly
+ }
resetItemState();
/* LP-item event */
// fireManagerItemEvent(ICheatSheetItemEvent.ITEM_DEACTIVATED, introItem);
@@ -1146,6 +1149,7 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor {
String contentXml = element.getContentXml();
URL contentURL = null;
restorePath = element.getRestorePath();
+ String errorMessage = null;
if (contentXml != null) {
parserInput = new ParserInput(contentXml, element.getHref());
@@ -1163,6 +1167,9 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor {
}
if (bundle != null) {
contentURL = FileLocator.find(bundle, new Path(element.getContentFile()), null);
+ if (contentURL == null && element.getContentFile() != null) {
+ errorMessage = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {element.getContentFile()}));
+ }
}
if (contentURL == null) {
@@ -1170,8 +1177,12 @@ public class CheatSheetViewer implements ICheatSheetViewer, IMenuContributor {
contentURL = new URL(element.getHref());
} catch (MalformedURLException mue) {
}
+ if (contentURL == null && element.getHref() != null) {
+ errorMessage = NLS.bind(Messages.ERROR_OPENING_FILE_IN_PARSER, (new Object[] {element.getHref()}));
+ }
}
- parserInput = new ParserInput(contentURL, bundle != null ? bundle.getSymbolicName() : null);
+ String pluginId = bundle != null ? bundle.getSymbolicName() : null;
+ parserInput = new ParserInput(contentURL, pluginId, errorMessage);
}
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java
index 50cb839a8..4d691c918 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/views/ErrorPage.java
@@ -106,7 +106,9 @@ public class ErrorPage extends Page {
Label imageLabel = toolkit.createLabel(form.getBody(), ""); //$NON-NLS-1$
imageLabel.setImage(getImage(nextStatus.getSeverity()));
Label messageLabel = toolkit.createLabel(form.getBody(), nextStatus.getMessage(), SWT.WRAP);
- messageLabel.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB);
+ layoutData.indent = 10;
+ messageLabel.setLayoutData(layoutData);
}
}

Back to the top