1 package com.quantum.actions;
3 import com.quantum.Messages;
4 import com.quantum.view.SQLQueryView;
5 import com.quantum.view.bookmark.QueryNode;
7 import org.eclipse.jface.viewers.IStructuredSelection;
8 import org.eclipse.ui.IViewPart;
9 import org.eclipse.ui.actions.SelectionListenerAction;
14 public class OpenQueryAction extends SelectionListenerAction {
19 public OpenQueryAction(IViewPart viewPart) {
20 super(Messages.getString(OpenQueryAction.class.getName() + ".text"));
23 protected boolean updateSelection(IStructuredSelection selection) {
24 boolean enabled = super.updateSelection(selection);
25 enabled &= (selection.size() == 1 &&
26 selection.getFirstElement() instanceof QueryNode);
30 SQLQueryView queryView = SQLQueryView.getInstance();
31 if (queryView != null) {
32 queryView.setQuery(getQuery());
35 private String getQuery() {
37 QueryNode node = (QueryNode) getSelectedNonResources().get(0);
38 String query = node.getQuery();
39 return query == null || query.trim().endsWith(";") ? query : (query + ";");