1 package com.quantum.actions;
3 import com.quantum.ImageStore;
4 import com.quantum.Messages;
5 import com.quantum.model.Entity;
6 import com.quantum.view.bookmark.EntityNode;
7 import com.quantum.view.tableview.TableView;
9 import org.eclipse.jface.viewers.IStructuredSelection;
10 import org.eclipse.ui.IViewPart;
11 import org.eclipse.ui.actions.SelectionListenerAction;
15 * Implements action for "View Table"
17 public class ViewTableAction extends SelectionListenerAction {
18 private Entity entity;
20 public ViewTableAction(IViewPart view) {
21 super(Messages.getString(ViewTableAction.class, "text"));
23 ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE));
27 TableView.getInstance().loadTable(this.entity);
28 // TODO: reinstate this
29 // } else if (view instanceof SubsetView){
30 // SubsetView subsetView = (SubsetView) view;
31 // node = (TreeNode) subsetView.getCurrent();
32 // if (!(node instanceof ObjectNode)) return;
33 // ObjectNode objectNode = (ObjectNode) node;
35 // String query = objectNode.getQuery();
37 // SQLResults results = ViewHelper.tryGetResults(view, objectNode.getConnection(), query);
38 // if (results != null && ! results.isError())
39 // TableView.getInstance().loadQuery(bookmark.getBookmark(), results);
43 public boolean updateSelection(IStructuredSelection selection) {
44 boolean enabled = super.updateSelection(selection);
45 enabled &= (selection.size() == 1);
48 Object object = selection.getFirstElement();
49 if (object != null && object instanceof EntityNode) {
50 EntityNode entityNode = (EntityNode) object;
51 this.entity = entityNode.getEntity();
52 enabled &= (entityNode.isTable() || entityNode.isView());