1 20 21 package org.apache.directory.ldapstudio.browser.common.actions; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 26 import org.eclipse.jface.resource.ImageDescriptor; 27 28 29 35 public class CloseConnectionAction extends BrowserAction 36 { 37 40 public void run() 41 { 42 for ( int i = 0; i < getSelectedConnections().length; i++ ) 43 { 44 if ( getSelectedConnections()[i].canClose() ) 45 { 46 getSelectedConnections()[i].close(); 47 } 48 } 49 } 50 51 52 55 public String getText() 56 { 57 return getSelectedConnections().length > 1 ? "Close Connections" : "Close Connection"; 58 } 59 60 61 64 public ImageDescriptor getImageDescriptor() 65 { 66 return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_CONNECTION_DISCONNECT ); 67 } 68 69 70 73 public String getCommandId() 74 { 75 return null; 76 } 77 78 79 public boolean isEnabled() 80 { 81 boolean canClose = false; 82 for ( int i = 0; i < getSelectedConnections().length; i++ ) 83 { 84 if ( getSelectedConnections()[i].canClose() ) 85 { 86 canClose = true; 87 break; 88 } 89 } 90 return getSelectedConnections().length > 0 && canClose; 91 } 92 } 93 | Popular Tags |