1 20 21 package org.apache.directory.ldapstudio.browser.ui.actions; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.DN; 25 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult; 26 import org.apache.directory.ldapstudio.browser.core.model.IValue; 27 import org.apache.directory.ldapstudio.browser.core.model.NameException; 28 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants; 29 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; 30 31 import org.eclipse.jface.resource.ImageDescriptor; 32 33 34 44 public class LocateDnInDitAction extends LocateInDitAction 45 { 46 49 public LocateDnInDitAction() 50 { 51 } 52 53 54 57 public String getText() 58 { 59 return "Locate DN in DIT"; 60 } 61 62 63 66 public ImageDescriptor getImageDescriptor() 67 { 68 return BrowserUIPlugin.getDefault().getImageDescriptor( BrowserUIConstants.IMG_LOCATE_DN_IN_DIT ); 69 } 70 71 72 76 protected ConnectionAndDn getConnectionAndDn() 77 { 78 79 if ( getSelectedAttributeHierarchies().length == 1 80 && getSelectedAttributeHierarchies()[0].getAttribute().getValueSize() == 1 81 && getSelectedSearchResults().length == 1 ) 82 { 83 try 84 { 85 IValue value = getSelectedAttributeHierarchies()[0].getAttribute().getValues()[0]; 86 if ( value.isString() && new DN( value.getStringValue() ) != null ) 87 { 88 return new ConnectionAndDn( value.getAttribute().getEntry().getConnection(), new DN( value 89 .getStringValue() ) ); 90 } 91 } 92 catch ( NameException e ) 93 { 94 } 96 } 97 98 if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 ) 99 { 100 try 101 { 102 IValue value = getSelectedValues()[0]; 103 if ( value.isString() && new DN( value.getStringValue() ) != null ) 104 { 105 return new ConnectionAndDn( value.getAttribute().getEntry().getConnection(), new DN( value 106 .getStringValue() ) ); 107 } 108 } 109 catch ( NameException e ) 110 { 111 } 113 } 114 115 if ( getSelectedSearchResults().length == 1 && getSelectedAttributeHierarchies().length == 0 ) 116 { 117 ISearchResult result = getSelectedSearchResults()[0]; 118 return new ConnectionAndDn( result.getEntry().getConnection(), result.getEntry().getDn() ); 119 } 120 121 return null; 122 } 123 } 124 | Popular Tags |