Changes for variablemodificatin
[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 com.quantum.ImageStore;
8 import com.quantum.Messages;
9 import com.quantum.adapters.DatabaseAdapter;
10 import com.quantum.model.Bookmark;
11 import com.quantum.sql.SQLResults;
12 import com.quantum.view.ViewHelper;
13 import com.quantum.view.bookmark.EntityNode;
14 import com.quantum.view.tableview.TableView;
15
16 import org.eclipse.ui.IViewPart;
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(ImageStore.getImageDescriptor(ImageStore.GRID));
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 }