Added new Option "Wrap PHPdocs and comments at print margin"
[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.Messages;
10 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
11 import net.sourceforge.phpdt.sql.view.BookmarkView;
12 import net.sourceforge.phpdt.sql.view.TableView;
13 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
14 import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
15 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
16 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
17
18 public class ViewTableDetailsAction extends Action implements IViewActionDelegate {
19         BookmarkView view;
20         
21         public void init(IViewPart view) {
22                 this.view = (BookmarkView) view;
23         }
24
25         public void run(IAction action) {
26                 run();
27         }
28         public void run() {
29                 TreeNode node = (TreeNode) view.getCurrent();
30                 StringBuffer query = new StringBuffer();
31                 query.append(Messages.getString("MetaDataKey")+Messages.getString("MetaDataKeySeparator")); //$NON-NLS-1$ //$NON-NLS-2$
32                 if (node instanceof TableNode) {
33                         query.append(((TableNode) node).getName());
34                 } else if (node instanceof ViewNode) {
35                         query.append(((ViewNode) node).getName());
36                 }
37                 MultiSQLServer server = MultiSQLServer.getInstance();
38                 BookmarkNode current = view.getCurrentBookmark();
39
40                 TableView.getInstance().loadQuery(current, server.execute(current.getConnection(), query.toString()));
41         }
42         public void selectionChanged(IAction action, ISelection selection) {
43         }
44
45 }