KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > console > actions > DeleteConfigurationAction


1 /*
2  * Created on 2004-11-01 by max
3  *
4  */

5 package org.hibernate.eclipse.console.actions;
6
7 import java.util.Iterator JavaDoc;
8 import java.util.List JavaDoc;
9
10 import org.eclipse.jface.viewers.IStructuredSelection;
11 import org.eclipse.ui.actions.SelectionListenerAction;
12 import org.hibernate.console.KnownConfigurations;
13 import org.hibernate.console.node.BaseNode;
14
15 /**
16  * @author max
17  *
18  */

19 public class DeleteConfigurationAction extends SelectionListenerAction {
20     
21     public DeleteConfigurationAction() {
22         super("Delete");
23         setEnabled(false);
24     }
25
26     public void run() {
27         List JavaDoc selectedNonResources = getSelectedNonResources();
28         
29         Iterator JavaDoc iter = selectedNonResources.iterator();
30         while (iter.hasNext()) {
31             BaseNode element = (BaseNode) iter.next();
32             KnownConfigurations.getInstance().removeConfiguration(element.getConsoleConfiguration());
33         }
34     }
35     
36     protected boolean updateSelection(IStructuredSelection selection) {
37         if(!selection.isEmpty()) {
38             Iterator JavaDoc iter = getSelectedNonResources().iterator();
39             while (iter.hasNext()) {
40                 Object JavaDoc element = iter.next();
41                 if(element instanceof BaseNode) {
42                     return true;
43                 }
44             }
45         }
46         return false;
47     }
48 }
49
Popular Tags