misc
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / actions / PrevSequenceAction.java
1 /*
2  * Created on 22-jul-2003
3  *
4  */
5 package com.quantum.actions;
6
7 import org.eclipse.ui.IViewPart;
8
9 import com.quantum.Messages;
10 import com.quantum.QuantumPlugin;
11 import com.quantum.adapters.DatabaseAdapter;
12 import com.quantum.model.Bookmark;
13 import com.quantum.sql.SQLResults;
14 import com.quantum.view.ViewHelper;
15 import com.quantum.view.bookmark.EntityNode;
16 import com.quantum.view.tableview.TableView;
17
18 public class PrevSequenceAction extends BaseSequenceAction {
19         /**
20      * @param text
21      * @param view
22      */
23     public PrevSequenceAction(IViewPart view) {
24         super(Messages.getString(PrevSequenceAction.class.getName() + ".text"), view);
25         setImageDescriptor(QuantumPlugin.getImageDescriptor("grid.gif"));
26     }
27
28     public void run() {
29                 EntityNode sequence = getEntityNode();
30                 if (sequence.isSequence()) {
31                         Bookmark bookmark = sequence.getBookmark();
32                         DatabaseAdapter adapter = bookmark.getAdapter();
33                         if (adapter == null) return;
34                         String name = sequence.getName();
35                         String query = adapter.getPrevValue(name, sequence.getEntity().getSchema());
36                         SQLResults results = ViewHelper.tryGetResults(view, getConnection(), query);
37                         if (results != null && ! results.isError()) 
38                                 TableView.getInstance().loadQuery(bookmark, results);
39                 }
40         }
41 }