improved PHP Scanner
[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 org.eclipse.jface.action.Action;
4 import org.eclipse.jface.action.IAction;
5 import org.eclipse.jface.viewers.ISelection;
6 import org.eclipse.ui.IViewActionDelegate;
7 import org.eclipse.ui.IViewPart;
8
9 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
10 import net.sourceforge.phpdt.sql.view.BookmarkView;
11 import net.sourceforge.phpdt.sql.view.TableView;
12 import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
13 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
14 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
15
16 public class ViewTableDetailsAction extends Action implements IViewActionDelegate {
17         BookmarkView view;
18         
19         public void init(IViewPart view) {
20                 this.view = (BookmarkView) view;
21         }
22
23         public void run(IAction action) {
24                 run();
25         }
26         public void run() {
27                 TreeNode node = (TreeNode) view.getCurrent();
28                 StringBuffer query = new StringBuffer();
29                 query.append("METADATA:");
30                 if (node instanceof TableNode) {
31                         query.append(((TableNode) node).getName());
32                 } else if (node instanceof ViewNode) {
33                         query.append(((ViewNode) node).getName());
34                 }
35                 MultiSQLServer server = MultiSQLServer.getInstance();
36                 TableView.getInstance().loadQuery(server.execute(query.toString()));
37         }
38         public void selectionChanged(IAction action, ISelection selection) {
39         }
40
41 }