KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > ldifeditor > editor > LdifEditorContributor


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

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 /**
35  * This class manages the installation and removal of global actions for the LDIF Editor.
36  *
37  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
38  * @version $Rev$, $Date$
39  */

40 public class LdifEditorContributor extends BasicTextEditorActionContributor
41 {
42
43     private static final String JavaDoc CONTENTASSIST_ACTION = "org.apache.directory.ldapstudio.browser.ContentAssist";
44
45     private RetargetTextEditorAction contentAssist;
46
47
48     /**
49      * Creates a new instance of LdifEditorContributor.
50      */

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     /**
62      * {@inheritDoc}
63      */

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     /**
73      * {@inheritDoc}
74      */

75     public void init( IActionBars bars, IWorkbenchPage page )
76     {
77         super.init( bars, page );
78         bars.setGlobalActionHandler( CONTENTASSIST_ACTION, contentAssist );
79     }
80
81
82     /**
83      * {@inheritDoc}
84      */

85     public void dispose()
86     {
87         setActiveEditor( null );
88         super.dispose();
89     }
90 }
91
Popular Tags