1 20 package org.apache.directory.ldapstudio.aciitemeditor; 21 22 23 import org.apache.directory.ldapstudio.aciitemeditor.dialogs.ACIItemDialog; 24 import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy; 25 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 26 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 27 import org.apache.directory.ldapstudio.browser.core.model.IValue; 28 import org.apache.directory.ldapstudio.valueeditors.AbstractDialogStringValueEditor; 29 import org.eclipse.swt.widgets.Shell; 30 31 32 38 public class ACIItemValueEditor extends AbstractDialogStringValueEditor 39 { 40 41 44 public ACIItemValueEditor() 45 { 46 super(); 47 } 48 49 50 57 public boolean openDialog( Shell shell ) 58 { 59 Object value = getValue(); 60 if ( value != null && value instanceof ACIItemValueWithContext ) 61 { 62 ACIItemValueWithContext context = (ACIItemValueWithContext)value; 63 64 ACIItemDialog dialog = new ACIItemDialog( shell, context ); 65 if ( dialog.open() == ACIItemDialog.OK && !"".equals( dialog.getACIItemValue() ) ) { 67 setValue( dialog.getACIItemValue() ); 68 return true; 69 } 70 } 71 return false; 72 } 73 74 75 88 public Object getRawValue( AttributeHierarchy attributeHierarchy ) 89 { 90 if ( attributeHierarchy == null ) 91 { 92 return null; 93 } 94 else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 0 ) 95 { 96 IEntry entry = attributeHierarchy.getAttribute().getEntry(); 97 IConnection connection = entry.getConnection(); 98 return new ACIItemValueWithContext( connection, entry, "" ); } 100 else if ( attributeHierarchy.size() == 1 && attributeHierarchy.getAttribute().getValueSize() == 1 ) 101 { 102 IEntry entry = attributeHierarchy.getAttribute().getEntry(); 103 IConnection connection = entry.getConnection(); 104 String value = getDisplayValue( attributeHierarchy ); 105 return new ACIItemValueWithContext( connection, entry, value ); 106 } 107 else 108 { 109 return null; 110 } 111 } 112 113 114 122 public Object getRawValue( IValue value ) 123 { 124 Object o = super.getRawValue( value ); 125 if ( o != null && o instanceof String ) 126 { 127 IEntry entry = value.getAttribute().getEntry(); 128 IConnection connection = entry.getConnection(); 129 String v = (String ) o; 130 return new ACIItemValueWithContext( connection, entry, v ); 131 } 132 133 return null; 134 } 135 136 137 146 public Object getRawValue( IConnection connection, Object value ) 147 { 148 Object o = super.getRawValue( connection, value ); 149 if ( o != null && o instanceof String ) 150 { 151 String v = (String ) o; 152 return new ACIItemValueWithContext( connection, null, v ); 153 } 154 155 return null; 156 } 157 158 180 } 181 | Popular Tags |