Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / actions / NextSequenceAction.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.adapters.AdapterFactory;
10 import net.sourceforge.phpdt.sql.adapters.DatabaseAdapter;
11 import net.sourceforge.phpdt.sql.sql.MultiSQLServer;
12 import net.sourceforge.phpdt.sql.sql.SQLResults;
13 import net.sourceforge.phpdt.sql.view.BookmarkView;
14 import net.sourceforge.phpdt.sql.view.TableView;
15 import net.sourceforge.phpdt.sql.view.bookmark.BookmarkNode;
16 import net.sourceforge.phpdt.sql.view.bookmark.SequenceNode;
17 import net.sourceforge.phpdt.sql.view.bookmark.TreeNode;
18
19 public class NextSequenceAction 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
30         public void run() {
31                 TreeNode node = (TreeNode) view.getCurrent();
32                 String name = null;
33                 if (node instanceof SequenceNode) {
34                         SequenceNode sequence = (SequenceNode) node;
35                         BookmarkNode parent = (BookmarkNode) sequence.getParent();
36                         DatabaseAdapter adapter = AdapterFactory.getInstance().getAdapter(parent.getType());
37                         if (adapter == null) return;
38                         name = sequence.getName();
39                         String query = adapter.getNextValue(name);
40                         MultiSQLServer server = MultiSQLServer.getInstance();
41                         SQLResults results = server.execute(parent.getConnection(), query);
42                         TableView.getInstance().loadQuery(parent, results);
43                 }
44         }
45
46         public void selectionChanged(IAction action, ISelection selection) {
47         }
48
49 }