1 20 21 package org.apache.directory.ldapstudio.browser.ui.editors.searchresult; 22 23 24 import java.util.Arrays ; 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 |