1 package com.quantum.view.bookmark;
3 import java.sql.SQLException;
5 import com.quantum.model.NotConnectedException;
6 import com.quantum.ui.dialog.ExceptionDisplayDialog;
7 import com.quantum.ui.dialog.SQLExceptionDialog;
9 import org.eclipse.jface.viewers.ITreeContentProvider;
10 import org.eclipse.jface.viewers.Viewer;
11 import org.eclipse.swt.widgets.Shell;
12 import org.eclipse.ui.IViewPart;
14 public class BookmarkContentProvider implements ITreeContentProvider {
16 private final IViewPart view;
18 public BookmarkContentProvider(IViewPart view) {
23 public Object[] getChildren(Object element) {
24 if (element != null && element instanceof TreeNode) {
25 TreeNode node = (TreeNode) element;
27 return node.getChildren();
28 } catch (NotConnectedException e) {
29 ExceptionDisplayDialog.openError(getShell(), null, null, e);
30 } catch (SQLException e) {
31 SQLExceptionDialog.openException(getShell(), node.getBookmark(), e);
34 return BookmarkListNode.EMPTY_ARRAY;
39 private Shell getShell() {
40 return this.view.getSite().getShell();
43 public Object[] getElements(Object inputElement) {
44 return getChildren(inputElement);
47 public Object getParent(Object element) {
48 if (element instanceof TreeNode) {
49 TreeNode node = (TreeNode) element;
50 return node.getParent();
55 public boolean hasChildren(Object element) {
56 if (element instanceof TreeNode) {
57 TreeNode node = (TreeNode) element;
58 return node.hasChildren();
63 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
66 public void dispose() {