1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.entryeditor; 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.resource.ImageDescriptor; 29 import org.eclipse.jface.viewers.TreeViewer; 30 31 32 38 public class OpenEditorAction extends AbstractOpenEditorAction 39 { 40 41 42 private IValueEditor valueEditor; 43 44 45 53 public OpenEditorAction( TreeViewer viewer, EntryEditorWidgetActionGroup actionGroup, 54 ValueEditorManager valueEditorManager, IValueEditor valueEditor ) 55 { 56 super( viewer, actionGroup, valueEditorManager ); 57 super.cellEditor = valueEditor.getCellEditor(); 58 this.valueEditor = valueEditor; 59 } 60 61 62 67 public IValueEditor getValueEditor() 68 { 69 return valueEditor; 70 } 71 72 73 76 public void run() 77 { 78 valueEditorManager.setUserSelectedValueEditor( valueEditor ); 80 81 super.run(); 82 } 83 84 85 88 public void dispose() 89 { 90 this.valueEditor = null; 91 super.dispose(); 92 } 93 94 95 98 @Override 99 public String getCommandId() 100 { 101 return null; 102 } 103 104 105 108 @Override 109 public ImageDescriptor getImageDescriptor() 110 { 111 return valueEditor.getValueEditorImageDescriptor(); 112 } 113 114 115 118 @Override 119 public String getText() 120 { 121 return valueEditor.getValueEditorName(); 122 } 123 124 125 128 @Override 129 public boolean isEnabled() 130 { 131 if ( getSelectedValues().length == 1 132 && getSelectedAttributes().length == 0 133 && viewer.getCellModifier().canModify( getSelectedValues()[0], 134 EntryEditorWidgetTableMetadata.VALUE_COLUMN_NAME ) ) 135 { 136 IValueEditor[] alternativeVps = valueEditorManager.getAlternativeValueEditors( getSelectedValues()[0] ); 137 return Arrays.asList( alternativeVps ).contains( valueEditor ) 138 && valueEditor.getRawValue( getSelectedValues()[0] ) != null; 139 } 140 else 141 { 142 return false; 143 } 144 } 145 146 } 147 | Popular Tags |