package com.quantum.actions; import com.quantum.ImageStore; import com.quantum.Messages; import com.quantum.model.Entity; import com.quantum.view.bookmark.EntityNode; import com.quantum.view.tableview.TableView; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IViewPart; import org.eclipse.ui.actions.SelectionListenerAction; /** * @author root * Implements action for "View Table" */ public class ViewTableAction extends SelectionListenerAction { private Entity entity; public ViewTableAction(IViewPart view) { super(Messages.getString(ViewTableAction.class, "text")); setImageDescriptor( ImageStore.getImageDescriptor(ImageStore.OPEN_TABLE)); } public void run() { TableView.getInstance().loadTable(this.entity); // TODO: reinstate this // } else if (view instanceof SubsetView){ // SubsetView subsetView = (SubsetView) view; // node = (TreeNode) subsetView.getCurrent(); // if (!(node instanceof ObjectNode)) return; // ObjectNode objectNode = (ObjectNode) node; // // String query = objectNode.getQuery(); // // SQLResults results = ViewHelper.tryGetResults(view, objectNode.getConnection(), query); // if (results != null && ! results.isError()) // TableView.getInstance().loadQuery(bookmark.getBookmark(), results); // } public boolean updateSelection(IStructuredSelection selection) { boolean enabled = super.updateSelection(selection); enabled &= (selection.size() == 1); if (enabled) { Object object = selection.getFirstElement(); if (object != null && object instanceof EntityNode) { EntityNode entityNode = (EntityNode) object; this.entity = entityNode.getEntity(); enabled &= (entityNode.isTable() || entityNode.isView()); } } return enabled; } }