Open preview on editor open
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / ViewTableDetailsAction.java
1 package net.sourceforge.phpdt.sql.actions;
2
3 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
4 import net.sourceforge.phpdt.sql.view.BookmarkView;
5 import net.sourceforge.phpdt.sql.view.TableView;
6 import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
7 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
8 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
9
10 import org.eclipse.jface.action.Action;
11 import org.eclipse.jface.action.IAction;
12 import org.eclipse.jface.viewers.ISelection;
13 import org.eclipse.ui.IViewActionDelegate;
14 import org.eclipse.ui.IViewPart;
15 import org.eclipse.ui.IWorkbenchPage;
16 import org.eclipse.ui.PartInitException;
17 import org.eclipse.ui.PlatformUI;
18
19 public class ViewTableDetailsAction extends Action implements IViewActionDelegate {
20         BookmarkView view;
21         
22         public void init(IViewPart view) {
23                 this.view = (BookmarkView) view;
24         }
25
26         public void run(IAction action) {
27                 run();
28         }
29         public void run() {
30                 TreeNode node = (TreeNode) view.getCurrent();
31                 StringBuffer query = new StringBuffer();
32                 query.append("METADATA:");
33                 if (node instanceof TableNode) {
34                         query.append(((TableNode) node).getName());
35                 } else if (node instanceof ViewNode) {
36                         query.append(((ViewNode) node).getName());
37                 }
38     try {
39       IWorkbenchPage page =
40         PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
41       page.showView(TableView.TABLEVIEW_ID);
42     } catch (PartInitException e) {
43     }
44                 MultiSQLServer server = MultiSQLServer.getInstance();
45                 TableView.getInstance().loadQuery(server.execute(query.toString()));
46         }
47         public void selectionChanged(IAction action, ISelection selection) {
48         }
49
50 }