1 package com.quantum.actions;
3 import java.sql.Connection;
6 import com.quantum.model.Bookmark;
7 import com.quantum.util.connection.ConnectionUtil;
8 import com.quantum.view.bookmark.EntityNode;
9 import com.quantum.view.bookmark.TreeNode;
11 import org.eclipse.jface.viewers.IStructuredSelection;
12 import org.eclipse.swt.widgets.Shell;
13 import org.eclipse.ui.IViewPart;
14 import org.eclipse.ui.actions.SelectionListenerAction;
19 public abstract class BaseSequenceAction extends SelectionListenerAction {
21 protected IViewPart view;
22 private ConnectionUtil connectionUtil = new ConnectionUtil();
24 protected BaseSequenceAction(String text, IViewPart view) {
29 protected Bookmark getBookmark() {
30 TreeNode node = getEntityNode();
31 return node.getBookmark();
34 protected Connection getConnection() {
35 return connectionUtil.getConnection(getBookmark(), getShell());
38 protected EntityNode getEntityNode() {
39 List list = getSelectedNonResources();
40 return (EntityNode) list.get(0);
43 protected Shell getShell() {
44 return this.view.getViewSite().getShell();
47 protected boolean updateSelection(IStructuredSelection selection) {
48 boolean enabled = super.updateSelection(selection);
49 return enabled && selection.size() == 1
50 && (selection.getFirstElement() instanceof EntityNode)
51 && ((EntityNode) selection.getFirstElement()).isSequence();