1 20 21 package org.apache.directory.ldapstudio.valueeditors.image; 22 23 24 import org.apache.directory.ldapstudio.browser.common.dialogs.TextDialog; 25 import org.apache.directory.ldapstudio.browser.core.model.IValue; 26 import org.apache.directory.ldapstudio.valueeditors.AbstractDialogBinaryValueEditor; 27 import org.eclipse.swt.SWT; 28 import org.eclipse.swt.widgets.Shell; 29 30 31 38 public class ImageValueEditor extends AbstractDialogBinaryValueEditor 39 { 40 41 46 protected boolean openDialog( Shell shell ) 47 { 48 Object value = getValue(); 49 50 if ( value != null && value instanceof byte[] ) 51 { 52 byte[] currentImageData = ( byte[] ) value; 53 54 ImageDialog dialog = new ImageDialog( shell, currentImageData, SWT.IMAGE_JPEG ); 55 if ( dialog.open() == TextDialog.OK && dialog.getNewImageRawData() != null ) 56 { 57 setValue( dialog.getNewImageRawData() ); 58 return true; 59 } 60 } 61 return false; 62 } 63 64 65 71 public String getDisplayValue( IValue value ) 72 { 73 if ( showRawValues() ) 74 { 75 return getPrintableString( value ); 76 } 77 else 78 { 79 if ( value == null ) 80 { 81 return "NULL"; 82 } 83 else if ( value.isBinary() ) 84 { 85 byte[] data = value.getBinaryValue(); 86 String text = ImageDialog.getImageInfo( data ); 87 return text; 88 } 89 else 90 { 91 return "Invalid Image Data"; 92 } 93 } 94 } 95 96 } 97 | Popular Tags |