1 20 21 package org.apache.directory.ldapstudio.browser.core.jobs; 22 23 24 import org.apache.directory.ldapstudio.browser.core.BrowserCoreMessages; 25 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry; 26 import org.apache.directory.ldapstudio.browser.core.events.ValueModifiedEvent; 27 import org.apache.directory.ldapstudio.browser.core.internal.model.Value; 28 import org.apache.directory.ldapstudio.browser.core.model.IAttribute; 29 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 30 import org.apache.directory.ldapstudio.browser.core.model.IValue; 31 import org.apache.directory.ldapstudio.browser.core.model.ModelModificationException; 32 33 34 public class ModifyValueJob extends AbstractModificationJob 35 { 36 37 private IAttribute attribute; 38 39 private IValue oldValue; 40 41 private Object newRawValue; 42 43 private ValueModifiedEvent event; 44 45 46 public ModifyValueJob( IAttribute attribute, IValue oldValue, Object newRawValue ) 47 { 48 this.attribute = attribute; 49 this.oldValue = oldValue; 50 this.newRawValue = newRawValue; 51 setName( BrowserCoreMessages.jobs__modify_value_name ); 52 } 53 54 55 protected void executeAsyncModificationJob( ExtendedProgressMonitor monitor ) throws ModelModificationException 56 { 57 58 monitor.beginTask( BrowserCoreMessages.jobs__modify_value_task, 2 ); 59 monitor.reportProgress( " " ); monitor.worked( 1 ); 61 62 IValue newValue = new Value( attribute, newRawValue ); 63 attribute.modifyValue( oldValue, newValue ); 64 attribute.getEntry().getConnection().modify( oldValue, newValue, monitor ); 65 66 this.event = new ValueModifiedEvent( attribute.getEntry().getConnection(), attribute.getEntry(), attribute, 67 oldValue, newValue ); 68 } 69 70 71 protected IEntry getModifiedEntry() 72 { 73 return attribute.getEntry(); 74 } 75 76 77 protected String [] getAffectedAttributeNames() 78 { 79 return new String [] 80 { this.attribute.getDescription() }; 81 } 82 83 84 protected void runNotification() 85 { 86 if ( this.event != null ) 87 { 88 EventRegistry.fireEntryUpdated( this.event, this ); 89 } 90 } 91 92 93 protected String getErrorMessage() 94 { 95 return BrowserCoreMessages.jobs__modify_value_error; 96 } 97 98 } 99 | Popular Tags |