remove name clash with JDT editor category
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / BookmarkContentProvider.java
index 2335110..680a382 100644 (file)
@@ -1,17 +1,45 @@
 package com.quantum.view.bookmark;
 
+import java.sql.SQLException;
+
+import com.quantum.model.NotConnectedException;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
+import com.quantum.ui.dialog.SQLExceptionDialog;
+
 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) {
+               if (element != null && 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) {
+                               SQLExceptionDialog.openException(getShell(), node.getBookmark(), e);
+                       }
                }
                return BookmarkListNode.EMPTY_ARRAY;
        }
+       /**
+        * @return
+        */
+       private Shell getShell() {
+               return this.view.getSite().getShell();
+       }
+
        public Object[] getElements(Object inputElement) {
                return getChildren(inputElement);
        }