KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Arrays JavaDoc;
25
26 import org.apache.directory.ldapstudio.valueeditors.IValueEditor;
27 import org.apache.directory.ldapstudio.valueeditors.ValueEditorManager;
28 import org.eclipse.jface.viewers.TableViewer;
29
30
31 public class OpenEditorAction extends AbstractOpenEditorAction
32 {
33
34     private IValueEditor valueEditor;
35
36
37     public OpenEditorAction( TableViewer viewer, SearchResultEditorCursor cursor,
38         SearchResultEditorActionGroup actionGroup, ValueEditorManager valueEditorManager,
39         IValueEditor valueEditor )
40     {
41         super( viewer, cursor, actionGroup, valueEditorManager );
42         super.cellEditor = valueEditor.getCellEditor();
43         this.valueEditor = valueEditor;
44         this.setText( "" + this.valueEditor.getValueEditorName() );
45         this.setToolTipText( "" + this.valueEditor.getValueEditorName() );
46         this.setImageDescriptor( this.valueEditor.getValueEditorImageDescriptor() );
47     }
48
49
50     public IValueEditor getValueEditor()
51     {
52         return this.valueEditor;
53     }
54
55
56     protected void updateEnabledState()
57     {
58
59         if ( viewer.getCellModifier().canModify( this.selectedSearchResult, this.selectedProperty ) )
60         {
61
62             IValueEditor[] alternativeVps;
63             if ( this.selectedAttributeHierarchie == null )
64             {
65                 this.setEnabled( false );
66             }
67             else
68             {
69                 alternativeVps = this.valueEditorManager
70                     .getAlternativeValueEditors( this.selectedAttributeHierarchie );
71                 this.setEnabled( Arrays.asList( alternativeVps ).contains( this.valueEditor )
72                     && this.valueEditor.getRawValue( this.selectedAttributeHierarchie ) != null );
73             }
74         }
75         else
76         {
77             this.setEnabled( false );
78         }
79     }
80
81
82     public void run()
83     {
84         this.valueEditorManager.setUserSelectedValueEditor( this.valueEditor );
85         super.run();
86     }
87
88 }
89
Popular Tags