Modified: 1216132 - Error when debugging eval()'d code
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / BookmarkContentProvider.java
1 package com.quantum.view.bookmark;
2
3 import java.sql.SQLException;
4
5 import com.quantum.model.NotConnectedException;
6 import com.quantum.ui.dialog.ExceptionDisplayDialog;
7 import com.quantum.ui.dialog.SQLExceptionDialog;
8
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;
13
14 public class BookmarkContentProvider implements ITreeContentProvider {
15         
16         private final IViewPart view;
17
18         public BookmarkContentProvider(IViewPart view) {
19                 this.view = view;
20         }
21         
22     
23         public Object[] getChildren(Object element) {
24                 if (element != null && element instanceof TreeNode) {
25                         TreeNode node = (TreeNode) element;
26                         try {
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);
32                         }
33                 }
34                 return BookmarkListNode.EMPTY_ARRAY;
35         }
36         /**
37          * @return
38          */
39         private Shell getShell() {
40                 return this.view.getSite().getShell();
41         }
42
43         public Object[] getElements(Object inputElement) {
44                 return getChildren(inputElement);
45         }
46
47         public Object getParent(Object element) {
48                 if (element instanceof TreeNode) {
49                         TreeNode node = (TreeNode) element;
50                         return node.getParent();
51                 }
52                 return null;
53         }
54
55         public boolean hasChildren(Object element) {
56                 if (element instanceof TreeNode) {
57                         TreeNode node = (TreeNode) element;
58                         return node.hasChildren();
59                 }
60                 return false;
61         }
62
63         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
64         }
65         
66         public void dispose() {
67         }
68 }