introduced IConstant.DEBUG flag
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / ViewTableAction.java
1 package net.sourceforge.phpdt.sql.actions;
2
3 import net.sourceforge.phpdt.sql.view.BookmarkView;
4 import net.sourceforge.phpdt.sql.view.TableView;
5 import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
6 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
7 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
8
9 import org.eclipse.jface.action.Action;
10 import org.eclipse.jface.action.IAction;
11 import org.eclipse.jface.viewers.ISelection;
12 import org.eclipse.ui.IViewActionDelegate;
13 import org.eclipse.ui.IViewPart;
14 import org.eclipse.ui.IWorkbenchPage;
15 import org.eclipse.ui.PartInitException;
16 import org.eclipse.ui.PlatformUI;
17
18 /**
19  * @author root
20  *
21  * To change this generated comment edit the template variable "typecomment":
22  * Window>Preferences>Java>Templates.
23  * To enable and disable the creation of type comments go to
24  * Window>Preferences>Java>Code Generation.
25  */
26 public class ViewTableAction extends Action implements IViewActionDelegate {
27   BookmarkView view;
28   /**
29    * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
30    */
31   public void init(IViewPart view) {
32     this.view = (BookmarkView) view;
33   }
34
35   /**
36    * @see org.eclipse.ui.IActionDelegate#run(IAction)
37    */
38   public void run(IAction action) {
39     run();
40   }
41
42   public void run() {
43     TreeNode node = (TreeNode) view.getCurrent();
44     String name = null;
45     if (node instanceof TableNode) {
46       name = ((TableNode) node).getName();
47     } else if (node instanceof ViewNode) {
48       name = ((ViewNode) node).getName();
49     }
50
51     try {
52       IWorkbenchPage page =
53         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
54       page.showView(TableView.TABLEVIEW_ID);
55     } catch (PartInitException e) {
56     }
57     TableView.getInstance().loadTable(name);
58   }
59
60   /**
61    * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
62    */
63   public void selectionChanged(IAction action, ISelection selection) {
64   }
65
66 }