1 package com.quantum.view.bookmark;
3 import java.sql.SQLException;
5 import com.quantum.model.NotConnectedException;
6 import com.quantum.ui.dialog.ExceptionDisplayDialog;
8 import org.eclipse.jface.viewers.ITreeContentProvider;
9 import org.eclipse.jface.viewers.Viewer;
10 import org.eclipse.swt.widgets.Shell;
11 import org.eclipse.ui.IViewPart;
13 public class BookmarkContentProvider implements ITreeContentProvider {
15 private final IViewPart view;
17 public BookmarkContentProvider(IViewPart view) {
22 public Object[] getChildren(Object element) {
23 if (element instanceof TreeNode) {
24 TreeNode node = (TreeNode) element;
26 return node.getChildren();
27 } catch (NotConnectedException e) {
28 ExceptionDisplayDialog.openError(getShell(), null, null, e);
29 } catch (SQLException e) {
30 ExceptionDisplayDialog.openError(getShell(), null, null, e);
33 return BookmarkListNode.EMPTY_ARRAY;
38 private Shell getShell() {
39 return this.view.getSite().getShell();
42 public Object[] getElements(Object inputElement) {
43 return getChildren(inputElement);
46 public Object getParent(Object element) {
47 if (element instanceof TreeNode) {
48 TreeNode node = (TreeNode) element;
49 return node.getParent();
54 public boolean hasChildren(Object element) {
55 if (element instanceof TreeNode) {
56 TreeNode node = (TreeNode) element;
57 return node.hasChildren();
62 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
65 public void dispose() {