1 package com.quantum.actions;
3 import com.quantum.Messages;
4 import com.quantum.QuantumPlugin;
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 IViewPart view;
19 private Entity entity;
21 public ViewTableAction(IViewPart view) {
22 super(Messages.getString(ViewTableAction.class.getName() + ".text"));
25 QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$
29 TableView.getInstance().loadTable(this.entity);
30 // TODO: reinstate this
31 // } else if (view instanceof SubsetView){
32 // SubsetView subsetView = (SubsetView) view;
33 // node = (TreeNode) subsetView.getCurrent();
34 // if (!(node instanceof ObjectNode)) return;
35 // ObjectNode objectNode = (ObjectNode) node;
37 // String query = objectNode.getQuery();
39 // SQLResults results = ViewHelper.tryGetResults(view, objectNode.getConnection(), query);
40 // if (results != null && ! results.isError())
41 // TableView.getInstance().loadQuery(bookmark.getBookmark(), results);
45 public boolean updateSelection(IStructuredSelection selection) {
46 boolean enabled = super.updateSelection(selection);
47 enabled &= (selection.size() == 1);
50 Object object = selection.getFirstElement();
51 if (object != null && object instanceof EntityNode) {
52 EntityNode entityNode = (EntityNode) object;
53 this.entity = entityNode.getEntity();
54 enabled &= (entityNode.isTable() || entityNode.isView());