1 20 21 package org.apache.directory.ldapstudio.ldifeditor.editor.text; 22 23 24 import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile; 25 import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifPart; 26 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer; 27 import org.apache.directory.ldapstudio.browser.core.model.ldif.lines.LdifValueLineBase; 28 import org.apache.directory.ldapstudio.ldifeditor.editor.ILdifEditor; 29 30 import org.eclipse.jface.text.IRegion; 31 import org.eclipse.jface.text.ITextHover; 32 import org.eclipse.jface.text.ITextViewer; 33 import org.eclipse.jface.text.Region; 34 35 36 public class LdifTextHover implements ITextHover 37 { 38 39 private ILdifEditor editor; 40 41 42 public LdifTextHover( ILdifEditor editor ) 43 { 44 this.editor = editor; 45 } 46 47 48 public String getHoverInfo( ITextViewer textViewer, IRegion hoverRegion ) 49 { 50 51 if ( this.editor != null ) 52 { 53 54 LdifContainer container = LdifFile.getContainer( this.editor.getLdifModel(), hoverRegion.getOffset() ); 55 if ( container != null ) 56 { 57 LdifPart part = LdifFile.getContainerContent( container, hoverRegion.getOffset() ); 58 if ( part != null ) 59 { 60 if ( part instanceof LdifValueLineBase ) 61 { 62 LdifValueLineBase line = ( LdifValueLineBase ) part; 63 if ( line.isValueTypeBase64() ) 64 { 65 return line.getValueAsString(); 66 } 67 } 68 } 69 } 70 } 71 72 return null; 73 } 74 75 76 public IRegion getHoverRegion( ITextViewer textViewer, int offset ) 77 { 78 79 if ( this.editor != null ) 80 { 81 return new Region( offset, 0 ); 82 } 83 84 return null; 85 } 86 87 } 88 | Popular Tags |