1 20 21 package org.apache.directory.ldapstudio.browser.common.actions; 22 23 24 import org.apache.directory.ldapstudio.browser.common.BrowserCommonActivator; 25 import org.apache.directory.ldapstudio.browser.common.BrowserCommonConstants; 26 import org.apache.directory.ldapstudio.browser.core.model.schema.SchemaUtils; 27 import org.eclipse.jface.resource.ImageDescriptor; 28 29 30 36 public class NewValueAction extends BrowserAction 37 { 38 41 public NewValueAction() 42 { 43 super(); 44 } 45 46 47 50 public void dispose() 51 { 52 super.dispose(); 53 } 54 55 56 59 public void run() 60 { 61 if ( getSelectedValues().length == 1 ) 62 { 63 getSelectedValues()[0].getAttribute().addEmptyValue(); 64 } 65 else if ( getSelectedAttributes().length == 1 ) 66 { 67 getSelectedAttributes()[0].addEmptyValue(); 68 } 69 else if ( getSelectedAttributeHierarchies().length == 1 ) 70 { 71 getSelectedAttributeHierarchies()[0].getAttribute().addEmptyValue(); 72 } 73 74 if ( getSelectedSearchResults().length > 0 ) 75 { 76 77 } 78 } 79 80 81 84 public String getText() 85 { 86 return "New Value"; 87 } 88 89 90 93 public ImageDescriptor getImageDescriptor() 94 { 95 return BrowserCommonActivator.getDefault().getImageDescriptor( BrowserCommonConstants.IMG_VALUE_ADD ); 96 } 97 98 99 102 public String getCommandId() 103 { 104 return "org.apache.directory.ldapstudio.browser.action.addValue"; 105 } 106 107 108 111 public boolean isEnabled() 112 { 113 124 return ( getSelectedSearchResults().length == 0 && getSelectedAttributes().length == 0 125 && getSelectedValues().length == 1 && SchemaUtils.isModifyable( getSelectedValues()[0].getAttribute() 126 .getAttributeTypeDescription() ) ) 127 128 || ( getSelectedSearchResults().length == 0 && getSelectedValues().length == 0 129 && getSelectedAttributes().length == 1 && SchemaUtils.isModifyable( getSelectedAttributes()[0] 130 .getAttributeTypeDescription() ) ) 131 132 || ( getSelectedSearchResults().length == 1 && getSelectedValues().length == 0 133 && getSelectedAttributes().length == 0 && getSelectedAttributeHierarchies().length == 1 && SchemaUtils 134 .isModifyable( getSelectedAttributeHierarchies()[0].getAttribute().getAttributeTypeDescription() ) ); 135 } 136 } 137 | Popular Tags |