1 20 21 package org.apache.directory.ldapstudio.ldifeditor.editor; 22 23 24 import org.apache.directory.ldapstudio.ldifeditor.LdifEditorActivator; 25 import org.eclipse.ui.IActionBars; 26 import org.eclipse.ui.IEditorPart; 27 import org.eclipse.ui.IWorkbenchPage; 28 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor; 29 import org.eclipse.ui.texteditor.ITextEditor; 30 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; 31 import org.eclipse.ui.texteditor.RetargetTextEditorAction; 32 33 34 40 public class LdifEditorContributor extends BasicTextEditorActionContributor 41 { 42 43 private static final String CONTENTASSIST_ACTION = "org.apache.directory.ldapstudio.browser.ContentAssist"; 44 45 private RetargetTextEditorAction contentAssist; 46 47 48 51 public LdifEditorContributor() 52 { 53 super(); 54 55 contentAssist = new RetargetTextEditorAction( LdifEditorActivator.getDefault().getResourceBundle(), 56 "ContentAssistProposal." ); 57 contentAssist.setActionDefinitionId( ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS ); 58 } 59 60 61 64 public void setActiveEditor( IEditorPart part ) 65 { 66 super.setActiveEditor( part ); 67 ITextEditor editor = ( part instanceof ITextEditor ) ? ( ITextEditor ) part : null; 68 contentAssist.setAction( getAction( editor, CONTENTASSIST_ACTION ) ); 69 } 70 71 72 75 public void init( IActionBars bars, IWorkbenchPage page ) 76 { 77 super.init( bars, page ); 78 bars.setGlobalActionHandler( CONTENTASSIST_ACTION, contentAssist ); 79 } 80 81 82 85 public void dispose() 86 { 87 setActiveEditor( null ); 88 super.dispose(); 89 } 90 } 91 | Popular Tags |