1 20 21 package org.apache.directory.ldapstudio.browser.ui.dialogs.properties; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 25 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent; 26 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener; 27 import org.apache.directory.ldapstudio.browser.common.widgets.search.SearchPageWrapper; 28 import org.apache.directory.ldapstudio.browser.core.events.EventRegistry; 29 import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent; 30 import org.apache.directory.ldapstudio.browser.core.internal.model.Search; 31 import org.apache.directory.ldapstudio.browser.core.model.ISearch; 32 import org.apache.directory.ldapstudio.browser.core.utils.Utils; 33 34 import org.eclipse.swt.widgets.Composite; 35 import org.eclipse.swt.widgets.Control; 36 import org.eclipse.ui.IWorkbenchPropertyPage; 37 import org.eclipse.ui.dialogs.PropertyPage; 38 39 40 public class SearchPropertyPage extends PropertyPage implements IWorkbenchPropertyPage, WidgetModifyListener 41 { 42 43 private ISearch search; 44 45 private SearchPageWrapper spw; 46 47 48 public SearchPropertyPage() 49 { 50 super(); 51 super.noDefaultAndApplyButton(); 52 } 53 54 55 public void dispose() 56 { 57 this.spw.removeWidgetModifyListener( this ); 58 super.dispose(); 59 } 60 61 62 protected Control createContents( Composite parent ) 63 { 64 65 ISearch search = ( ISearch ) getElement(); 67 if ( search != null ) 68 { 69 this.search = search; 70 } 71 else 72 { 73 this.search = new Search(); 74 } 75 76 super.setMessage( "Search " + Utils.shorten( search.getName(), 30 ) ); 77 78 Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); 79 80 this.spw = new SearchPageWrapper( SearchPageWrapper.CONNECTION_READONLY ); 81 this.spw.createContents( composite ); 82 this.spw.loadFromSearch( this.search ); 83 this.spw.addWidgetModifyListener( this ); 84 85 return composite; 86 } 87 88 89 public boolean performOk() 90 { 91 boolean modified = this.spw.saveToSearch( this.search ); 92 if ( modified && this.search.getConnection() != null && this.search.getConnection().isOpened() ) 93 { 94 EventRegistry.fireSearchUpdated( new SearchUpdateEvent( this.search, 96 SearchUpdateEvent.EventDetail.SEARCH_PARAMETER_UPDATED ), this ); 97 98 return this.spw.performSearch( this.search ); 99 } 100 101 return true; 102 } 103 104 105 public void widgetModified( WidgetModifyEvent event ) 106 { 107 setValid( this.spw.isValid() ); 108 } 109 110 } 111 | Popular Tags |