show HTML files as local resources (no 'http://' url prefix)
[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
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;
12
13 public class BookmarkContentProvider implements ITreeContentProvider {
14         
15         private final IViewPart view;
16
17         public BookmarkContentProvider(IViewPart view) {
18                 this.view = view;
19         }
20         
21     
22         public Object[] getChildren(Object element) {
23                 if (element instanceof TreeNode) {
24                         TreeNode node = (TreeNode) element;
25                         try {
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);
31                         }
32                 }
33                 return BookmarkListNode.EMPTY_ARRAY;
34         }
35         /**
36          * @return
37          */
38         private Shell getShell() {
39                 return this.view.getSite().getShell();
40         }
41
42         public Object[] getElements(Object inputElement) {
43                 return getChildren(inputElement);
44         }
45
46         public Object getParent(Object element) {
47                 if (element instanceof TreeNode) {
48                         TreeNode node = (TreeNode) element;
49                         return node.getParent();
50                 }
51                 return null;
52         }
53
54         public boolean hasChildren(Object element) {
55                 if (element instanceof TreeNode) {
56                         TreeNode node = (TreeNode) element;
57                         return node.hasChildren();
58                 }
59                 return false;
60         }
61
62         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
63         }
64         
65         public void dispose() {
66         }
67 }