1 20 21 package org.apache.directory.ldapstudio.ldifeditor.editor.actions; 22 23 24 import org.apache.directory.ldapstudio.ldifeditor.editor.LdifEditor; 25 import org.eclipse.jface.text.IDocument; 26 import org.eclipse.jface.text.source.ISourceViewer; 27 28 29 public class FormatLdifDocumentAction extends AbstractLdifAction 30 { 31 32 public FormatLdifDocumentAction( LdifEditor editor ) 33 { 34 super( "Format Document", editor ); 35 } 36 37 38 protected void doRun() 39 { 40 IDocument document = editor.getDocumentProvider().getDocument( editor.getEditorInput() ); 41 ISourceViewer sourceViewer = ( ISourceViewer ) editor.getAdapter( ISourceViewer.class ); 42 int topIndex = sourceViewer.getTopIndex(); 43 document.set( super.getLdifModel().toFormattedString() ); 44 sourceViewer.setTopIndex( topIndex ); 45 } 46 47 48 public void update() 49 { 50 } 51 52 } 53 | Popular Tags |