latest quantum sources 2.3.2
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / RefreshBookmarkAction.java
1 package com.quantum.actions;
2
3 import java.sql.SQLException;
4 import java.util.Iterator;
5 import java.util.List;
6
7 import com.quantum.Messages;
8 import com.quantum.QuantumPlugin;
9 import com.quantum.model.NotConnectedException;
10 import com.quantum.ui.dialog.ExceptionDisplayDialog;
11 import com.quantum.view.bookmark.TreeNode;
12
13 import org.eclipse.ui.IViewPart;
14 import org.eclipse.ui.actions.SelectionListenerAction;
15
16 /**
17  * @author root
18  */
19 public class RefreshBookmarkAction extends SelectionListenerAction {
20     private IViewPart view;
21         public RefreshBookmarkAction(IViewPart view) {
22         super(Messages.getString(RefreshBookmarkAction.class.getName() + ".text"));
23                 this.view = view;
24         setImageDescriptor(QuantumPlugin.getImageDescriptor("refresh.gif"));
25         }
26
27         public void run() {
28                 List list = getSelectedNonResources();
29         for (Iterator i = list.iterator(); i.hasNext(); ) {
30             Object object = i.next();
31             if (object != null && object instanceof TreeNode) {
32                 try {
33                         ((TreeNode) object).reload();
34                 } catch (NotConnectedException e) {
35                         handleException(e);
36                 } catch (SQLException e) {
37                         handleException(e);
38                 }
39             }
40         }
41         }
42
43         /**
44          * @param e
45          */
46         private void handleException(Throwable t) {
47                 ExceptionDisplayDialog.openError(
48                                 this.view.getSite().getShell(), null, null, t);
49         }
50 }