latest quantum sources 2.3.2
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / RefreshBookmarkAction.java
index 525503f..c28df56 100644 (file)
@@ -1,12 +1,13 @@
 package com.quantum.actions;
 
+import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.List;
 
 import com.quantum.Messages;
 import com.quantum.QuantumPlugin;
-import com.quantum.sql.SQLHelper;
-import com.quantum.view.bookmark.BookmarkView;
+import com.quantum.model.NotConnectedException;
+import com.quantum.ui.dialog.ExceptionDisplayDialog;
 import com.quantum.view.bookmark.TreeNode;
 
 import org.eclipse.ui.IViewPart;
@@ -16,12 +17,10 @@ import org.eclipse.ui.actions.SelectionListenerAction;
  * @author root
  */
 public class RefreshBookmarkAction extends SelectionListenerAction {
-       SQLHelper helper = new SQLHelper();
-
-    BookmarkView view;
+    private IViewPart view;
        public RefreshBookmarkAction(IViewPart view) {
         super(Messages.getString(RefreshBookmarkAction.class.getName() + ".text"));
-               this.view = (BookmarkView) view;
+               this.view = view;
         setImageDescriptor(QuantumPlugin.getImageDescriptor("refresh.gif"));
        }
 
@@ -30,8 +29,22 @@ public class RefreshBookmarkAction extends SelectionListenerAction {
         for (Iterator i = list.iterator(); i.hasNext(); ) {
             Object object = i.next();
             if (object != null && object instanceof TreeNode) {
-                ((TreeNode) object).reload();
+               try {
+                       ((TreeNode) object).reload();
+               } catch (NotConnectedException e) {
+                       handleException(e);
+               } catch (SQLException e) {
+                       handleException(e);
+               }
             }
         }
        }
+
+       /**
+        * @param e
+        */
+       private void handleException(Throwable t) {
+               ExceptionDisplayDialog.openError(
+                               this.view.getSite().getShell(), null, null, t);
+       }
 }