1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.connection; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 26 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 27 import org.eclipse.jface.viewers.LabelProvider; 28 import org.eclipse.swt.graphics.Image; 29 30 31 38 public class ConnectionLabelProvider extends LabelProvider 39 { 40 41 47 public String getText( Object obj ) 48 { 49 if ( obj instanceof IConnection ) 50 { 51 IConnection conn = ( IConnection ) obj; 52 if ( conn.getEncryptionMethod() == IConnection.ENCYRPTION_LDAPS ) 53 { 54 return conn.getName() + " (LDAPS)"; 55 } 56 else if ( conn.getEncryptionMethod() == IConnection.ENCYRPTION_STARTTLS ) 57 { 58 return conn.getName() + " (StartTLS)"; 59 } 60 else 61 { 62 return conn.getName(); 63 } 64 } 65 else if ( obj != null ) 66 { 67 return obj.toString(); 68 } 69 else 70 { 71 return ""; 72 } 73 } 74 75 76 81 public Image getImage( Object obj ) 82 { 83 if ( obj instanceof IConnection ) 84 { 85 IConnection conn = ( IConnection ) obj; 86 return conn.isOpened() ? BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_CONNECTION_CONNECTED ) 87 : BrowserCommonActivator.getDefault().getImage( BrowserCommonConstants.IMG_CONNECTION_DISCONNECTED ); 88 } 89 else 90 { 91 return null; 92 } 93 } 94 95 } | Popular Tags |