package com.quantum.view.bookmark;
+import java.sql.SQLException;
+
+import com.quantum.model.NotConnectedException;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IViewPart;
public class BookmarkContentProvider implements ITreeContentProvider {
+
+ private final IViewPart view;
+
+ public BookmarkContentProvider(IViewPart view) {
+ this.view = view;
+ }
+
public Object[] getChildren(Object element) {
if (element instanceof TreeNode) {
TreeNode node = (TreeNode) element;
- return node.getChildren();
+ try {
+ return node.getChildren();
+ } catch (NotConnectedException e) {
+ ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ } catch (SQLException e) {
+ ExceptionDisplayDialog.openError(getShell(), null, null, e);
+ }
}
return BookmarkListNode.EMPTY_ARRAY;
}
+ /**
+ * @return
+ */
+ private Shell getShell() {
+ return this.view.getSite().getShell();
+ }
+
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}