KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > editors > searchresult > OpenBestEditorAction


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.browser.ui.editors.searchresult;
22
23
24 import org.apache.directory.ldapstudio.valueeditors.IValueEditor;
25 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager;
26 import org.eclipse.jface.viewers.TableViewer;
27
28
29 public class OpenBestEditorAction extends AbstractOpenEditorAction
30 {
31
32     private IValueEditor valueEditor;
33
34
35     public OpenBestEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
36         SearchResultEditorActionGroup actionGroup, ValueEditorManager valueEditorManager )
37     {
38         super( viewer, cursor, actionGroup, valueEditorManager );
39     }
40
41
42     public IValueEditor getBestValueEditor()
43     {
44         return this.valueEditor;
45     }
46
47
48     protected void updateEnabledState()
49     {
50
51         if ( viewer.getCellModifier().canModify( this.selectedSearchResult, this.selectedProperty ) )
52         {
53
54             if ( this.selectedAttributeHierarchie == null )
55             {
56                 this.valueEditor = this.valueEditorManager.getCurrentValueEditor( this.selectedSearchResult
57                     .getEntry(), this.selectedProperty );
58             }
59             else
60             {
61                 this.valueEditor = this.valueEditorManager
62                     .getCurrentValueEditor( this.selectedAttributeHierarchie );
63             }
64
65             super.cellEditor = this.valueEditor.getCellEditor();
66             this.setEnabled( true );
67             this.setText( "" + this.valueEditor.getValueEditorName() );
68             this.setToolTipText( "" + this.valueEditor.getValueEditorName() );
69             this.setImageDescriptor( this.valueEditor.getValueEditorImageDescriptor() );
70
71         }
72         else
73         {
74             this.setEnabled( false );
75             this.cellEditor = null;
76             this.setText( "Best Editor" );
77             this.setToolTipText( "Best Editor" );
78             this.setImageDescriptor( null );
79         }
80     }
81
82 }
83
Popular Tags