1 20 21 package org.apache.directory.ldapstudio.browser.ui.search; 22 23 24 import org.apache.directory.ldapstudio.browser.common.actions.SelectionUtils; 25 import org.apache.directory.ldapstudio.browser.common.widgets.BaseWidgetUtils; 26 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyEvent; 27 import org.apache.directory.ldapstudio.browser.common.widgets.WidgetModifyListener; 28 import org.apache.directory.ldapstudio.browser.common.widgets.search.SearchPageWrapper; 29 import org.apache.directory.ldapstudio.browser.core.model.ISearch; 30 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin; 31 import org.eclipse.jface.dialogs.DialogPage; 32 import org.eclipse.jface.dialogs.IDialogConstants; 33 import org.eclipse.jface.resource.ImageDescriptor; 34 import org.eclipse.search.ui.ISearchPage; 35 import org.eclipse.search.ui.ISearchPageContainer; 36 import org.eclipse.swt.layout.GridData; 37 import org.eclipse.swt.layout.GridLayout; 38 import org.eclipse.swt.widgets.Composite; 39 import org.eclipse.ui.PlatformUI; 40 41 42 49 public class SearchPage extends DialogPage implements ISearchPage, WidgetModifyListener 50 { 51 52 53 private ISearchPageContainer container; 54 55 56 private ISearch search; 57 58 59 private SearchPageWrapper spw; 60 61 62 67 public static String getId() 68 { 69 return SearchPage.class.getName(); 70 } 71 72 73 76 public void dispose() 77 { 78 spw.removeWidgetModifyListener( this ); 79 super.dispose(); 80 } 81 82 83 86 public SearchPage() 87 { 88 } 89 90 91 96 public SearchPage( String title ) 97 { 98 super( title ); 99 } 100 101 102 108 public SearchPage( String title, ImageDescriptor image ) 109 { 110 super( title, image ); 111 } 112 113 114 117 public boolean performAction() 118 { 119 spw.saveToSearch( search ); 120 if ( search.getConnection() != null ) 121 { 122 search.getConnection().getSearchManager().addSearch( search ); 123 return spw.performSearch( search ); 124 } 125 126 return false; 127 } 128 129 130 133 public void setContainer( ISearchPageContainer container ) 134 { 135 this.container = container; 136 } 137 138 139 142 public void createControl( Composite parent ) 143 { 144 search = SelectionUtils.getExampleSearch( container.getSelection() ); 146 147 GridLayout gl = new GridLayout(); 149 parent.setLayout( gl ); 150 GridData gd = new GridData( GridData.FILL_BOTH ); 151 gd.widthHint = convertHorizontalDLUsToPixels( IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH ); 152 parent.setLayoutData( gd ); 155 156 Composite composite = BaseWidgetUtils.createColumnContainer( parent, 3, 1 ); 157 spw = new SearchPageWrapper( SearchPageWrapper.NONE ); 158 spw.createContents( composite ); 159 spw.loadFromSearch( search ); 160 spw.addWidgetModifyListener( this ); 161 162 PlatformUI.getWorkbench().getHelpSystem().setHelp( composite, 163 BrowserUIPlugin.PLUGIN_ID + "." + "tools_search_dialog" ); 164 PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, 165 BrowserUIPlugin.PLUGIN_ID + "." + "tools_search_dialog" ); 166 167 super.setControl( parent ); 168 } 169 170 171 174 public void setVisible( boolean visible ) 175 { 176 container.setPerformActionEnabled( spw.isValid() ); 177 super.setVisible( visible ); 178 } 179 180 181 184 public void widgetModified( WidgetModifyEvent event ) 185 { 186 container.setPerformActionEnabled( spw.isValid() ); 187 } 188 189 } 190 | Popular Tags |