shortened display text of variable proposal in content assist
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / tableview / CloseResultSetAction.java
1 package com.quantum.view.tableview;
2
3
4 import java.util.Iterator;
5
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;
11
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;
16
17 /**
18  * @author root
19  * @author BC Holmes
20  */
21 public class CloseResultSetAction extends SelectionListenerAction {
22         
23         private final ISelectionProvider selectionProvider;
24         
25         /**
26          * @param text
27          */
28         public CloseResultSetAction(IViewPart view, ISelectionProvider selectionProvider) {
29                 super("");
30                 this.selectionProvider = selectionProvider;
31                 this.selectionProvider.addSelectionChangedListener(this);
32                 setEnabled(!this.selectionProvider.getSelection().isEmpty());
33                 
34                 setImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLOSE));
35                 if (VersioningHelper.isEclipse30()) {
36                         setDisabledImageDescriptor(ImageStore.getImageDescriptor(ImageStore.CLOSE_DISABLED));
37                 }
38                 setToolTipText(Messages.getString(getClass(), "text"));
39         }
40
41         public void run() {
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());
47                         }
48                 }
49         }
50
51         public boolean updateSelection(IStructuredSelection selection) {
52         return !selection.isEmpty();
53         }
54 }