import java.sql.Connection;
import java.util.List;
+import com.quantum.adapters.DatabaseAdapter;
import com.quantum.model.Bookmark;
+import com.quantum.sql.SQLResultSetCollection;
+import com.quantum.sql.SQLResultSetResults;
+import com.quantum.sql.SQLResults;
import com.quantum.util.connection.ConnectionUtil;
+import com.quantum.view.ViewHelper;
import com.quantum.view.bookmark.EntityNode;
import com.quantum.view.bookmark.TreeNode;
protected BaseSequenceAction(String text, IViewPart view) {
super(text);
-
+ this.view = view;
}
protected Bookmark getBookmark() {
&& (selection.getFirstElement() instanceof EntityNode)
&& ((EntityNode) selection.getFirstElement()).isSequence();
}
+
+ public void run() {
+ EntityNode sequence = getEntityNode();
+ String name = null;
+ if (sequence.isSequence()) {
+ Bookmark bookmark = sequence.getBookmark();
+ DatabaseAdapter adapter = bookmark.getAdapter();
+ if (adapter == null) return;
+ name = sequence.getName();
+ String query = getQuery(sequence, name, adapter);
+
+ SQLResults results = ViewHelper.tryGetResults(view, bookmark, getConnection(), query);
+ if (results != null && results.isResultSet())
+ SQLResultSetCollection.getInstance().addSQLResultSet((SQLResultSetResults) results);
+ }
+ }
+
+ /**
+ * @param sequence
+ * @param name
+ * @param adapter
+ * @return
+ */
+ protected abstract String getQuery(EntityNode sequence, String name, DatabaseAdapter adapter);
}