X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java new file mode 100644 index 0000000..6da4e9f --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/actions/ViewTableAction.java @@ -0,0 +1,59 @@ +package com.quantum.actions; + +import com.quantum.Messages; +import com.quantum.QuantumPlugin; +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 IViewPart view; + private Entity entity; + + public ViewTableAction(IViewPart view) { + super(Messages.getString(ViewTableAction.class.getName() + ".text")); + this.view = view; + setImageDescriptor( + QuantumPlugin.getImageDescriptor("table.gif")); //$NON-NLS-1$ + } + + 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; + } +}