1 20 21 package org.apache.directory.ldapstudio.aciitemeditor.valueeditors; 22 23 24 import org.apache.directory.ldapstudio.browser.common.dialogs.FilterWidgetDialog; 25 import org.apache.directory.ldapstudio.browser.common.dialogs.TextDialog; 26 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 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 FilterValueEditor extends AbstractDialogStringValueEditor 39 { 40 41 private static final String EMPTY = ""; 43 44 49 public boolean openDialog( Shell shell ) 50 { 51 Object value = getValue(); 52 if ( value != null && value instanceof FilterValueEditorRawValueWrapper ) 53 { 54 FilterValueEditorRawValueWrapper wrapper = ( FilterValueEditorRawValueWrapper ) value; 55 FilterWidgetDialog dialog = new FilterWidgetDialog( shell, Messages 56 .getString( "FilterValueEditor.dialog.title" ), wrapper.filter, wrapper.connection ); 58 if ( dialog.open() == TextDialog.OK && !EMPTY.equals( dialog.getFilter() ) ) 59 { 60 setValue( dialog.getFilter() ); 61 return true; 62 } 63 } 64 return false; 65 } 66 67 68 73 public Object getRawValue( IValue value ) 74 { 75 return value != null ? getRawValue( value.getAttribute().getEntry().getConnection(), value.getStringValue() ) 76 : null; 77 } 78 79 80 85 public Object getRawValue( IConnection connection, Object value ) 86 { 87 if ( connection == null || value == null || !( value instanceof String ) ) 88 { 89 return null; 90 } 91 92 String filterValue = ( String ) value; 93 FilterValueEditorRawValueWrapper wrapper = new FilterValueEditorRawValueWrapper( connection, filterValue ); 94 return wrapper; 95 } 96 97 104 private class FilterValueEditorRawValueWrapper 105 { 106 110 private IConnection connection; 111 112 113 private String filter; 114 115 116 122 private FilterValueEditorRawValueWrapper( IConnection connection, String filter ) 123 { 124 this.connection = connection; 125 this.filter = filter; 126 } 127 } 128 } 129 | Popular Tags |