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