1 package com.quantum.view.tableview;
4 import java.util.Iterator;
6 import com.quantum.ImageStore;
7 import com.quantum.Messages;
8 import com.quantum.sql.SQLResultSetCollection;
9 import com.quantum.sql.SQLResultSetResults;
10 import com.quantum.util.versioning.VersioningHelper;
12 import org.eclipse.jface.viewers.ISelectionProvider;
13 import org.eclipse.jface.viewers.IStructuredSelection;
14 import org.eclipse.ui.IViewPart;
15 import org.eclipse.ui.actions.SelectionListenerAction;
21 public class CloseResultSetAction extends SelectionListenerAction {
23 private final ISelectionProvider selectionProvider;
28 public CloseResultSetAction(IViewPart view, ISelectionProvider selectionProvider) {
30 this.selectionProvider = selectionProvider;
31 this.selectionProvider.addSelectionChangedListener(this);
32 setEnabled(!this.selectionProvider.getSelection().isEmpty());
34 setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLOSE));
35 if (VersioningHelper.isEclipse30()) {
36 setDisabledImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLOSE_DISABLED));
38 setToolTipText(Messages.getString(getClass(), "text"));
42 IStructuredSelection selection =
43 (IStructuredSelection) this.selectionProvider.getSelection();
44 if (!selection.isEmpty()) {
45 for (Iterator i = selection.iterator(); i.hasNext(); ) {
46 SQLResultSetCollection.getInstance().removeSQLResultSet((SQLResultSetResults) i.next());
51 public boolean updateSelection(IStructuredSelection selection) {
52 return !selection.isEmpty();