1 5 package org.hibernate.eclipse.console.actions; 6 7 import java.util.Iterator ; 8 import java.util.List ; 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 19 public class DeleteConfigurationAction extends SelectionListenerAction { 20 21 public DeleteConfigurationAction() { 22 super("Delete"); 23 setEnabled(false); 24 } 25 26 public void run() { 27 List selectedNonResources = getSelectedNonResources(); 28 29 Iterator 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 iter = getSelectedNonResources().iterator(); 39 while (iter.hasNext()) { 40 Object element = iter.next(); 41 if(element instanceof BaseNode) { 42 return true; 43 } 44 } 45 } 46 return false; 47 } 48 } 49 | Popular Tags |