1 20 21 package org.apache.directory.ldapstudio.browser.common.widgets.entryeditor; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 25 import org.apache.directory.ldapstudio.browser.common.actions.BrowserAction; 26 import org.apache.directory.ldapstudio.browser.common.actions.RenameAction; 27 import org.apache.directory.ldapstudio.browser.common.actions.proxy.EntryEditorActionProxy; 28 import org.eclipse.jface.resource.ImageDescriptor; 29 import org.eclipse.jface.viewers.TreeViewer; 30 31 32 41 public class OpenDefaultEditorAction extends BrowserAction 42 { 43 44 45 private EntryEditorActionProxy bestValueEditorProxy; 46 47 48 private EntryEditorActionProxy renameProxy; 49 50 51 58 public OpenDefaultEditorAction( TreeViewer viewer, EntryEditorActionProxy bestValueEditorProxy, boolean enableRenameAction ) 59 { 60 this.bestValueEditorProxy = bestValueEditorProxy; 61 this.renameProxy = enableRenameAction ? new EntryEditorActionProxy( viewer, new RenameAction() ) : null; 62 } 63 64 65 68 public void dispose() 69 { 70 bestValueEditorProxy = null; 71 renameProxy = null; 72 73 super.dispose(); 74 } 75 76 77 80 @Override 81 public String getCommandId() 82 { 83 return BrowserCommonConstants.ACTION_ID_EDIT_VALUE; 84 } 85 86 87 90 @Override 91 public ImageDescriptor getImageDescriptor() 92 { 93 if ( bestValueEditorProxy != null ) 94 { 95 return bestValueEditorProxy.getImageDescriptor(); 96 } 97 else if ( renameProxy != null ) 98 { 99 return renameProxy.getImageDescriptor(); 100 } 101 else 102 { 103 return null; 104 } 105 } 106 107 108 111 @Override 112 public String getText() 113 { 114 return "Edit Value"; 115 } 116 117 118 121 @Override 122 public boolean isEnabled() 123 { 124 142 if ( bestValueEditorProxy != null && renameProxy != null ) 143 { 144 return bestValueEditorProxy.isEnabled() || renameProxy.isEnabled(); 145 } 146 else if ( renameProxy != null ) 147 { 148 return renameProxy.isEnabled(); 149 } 150 else if ( bestValueEditorProxy != null ) 151 { 152 return bestValueEditorProxy.isEnabled(); 153 } 154 else 155 { 156 return false; 157 } 158 } 159 160 161 164 @Override 165 public void run() 166 { 167 if ( bestValueEditorProxy != null && bestValueEditorProxy.isEnabled() ) 168 { 169 bestValueEditorProxy.run(); 170 } 171 else if ( renameProxy != null && renameProxy.isEnabled() ) 172 { 173 renameProxy.run(); 174 } 175 176 } 177 178 } 179 | Popular Tags |