};
_core.getSearchManager().addSeachResultListener(listener);
setLayout(new GridLayout(1,true));
Composite search_bar_composite = new Composite(this,SWT.NONE);
search_bar_composite.setLayout(new FillLayout());
search_bar_composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Group search_bar = new Group(search_bar_composite,SWT.NONE);
search_bar.setLayout(new GridLayout(1,true));
Composite basic_search_controls = new Composite(search_bar,SWT.NONE);
GridData layout_data = new GridData();
layout_data.grabExcessHorizontalSpace = true;
layout_data.horizontalAlignment = GridData.CENTER;
basic_search_controls.setLayoutData(layout_data);
layout = new GridLayout(6,false);
layout.marginHeight = 0;
layout.marginWidth = 0;
basic_search_controls.setLayout(layout);
Label label = new Label(basic_search_controls,SWT.NONE);
label.setText(_._("mainwindow.searchtab.label.search") + " : ");
search_query = new Text(basic_search_controls,SWT.SINGLE | SWT.BORDER);
layout_data = new GridData();
layout_data.widthHint = 300;
search_query.setLayoutData(layout_data);
Button search_button = new Button(basic_search_controls,SWT.PUSH);
search_button.setText(Localizer._("mainwindow.searchtab.button.search"));
search_button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
search();
}
});
searchType = new Combo (basic_search_controls, SWT.READ_ONLY);
searchType.add("Server");
searchType.add("Kad");
searchType.add("Both");
searchType.select(0);
Label adv_search = new Label(basic_search_controls,SWT.NONE);
adv_search.setText(_._("mainwindow.searchtab.label.advanced"));
Utils.formatAsLink(adv_search, new MouseAdapter() {
public void mouseUp(MouseEvent arg0) {
if (show_advanced_options) {
new AdvancedSearchWindow(minFileSize,maxFileSize,fileType,extension,availableSources,completedSources){
public void save(long minSize, long maxSize,
FileType fileType, String extension,
long availableSources, long completedSources) {
maxFileSize = maxSize;
minFileSize = minSize;
SearchTab.this.availableSources = availableSources;
SearchTab.this.completedSources = completedSources;
SearchTab.this.fileType = fileType;
SearchTab.this.extension = extension;
showAdvancedOptions();
}
};
}else {
new AdvancedSearchWindow(){
public void save(long minSize, long maxSize,
FileType fileType, String extension,
long availableSources, long completedSources) {
maxFileSize = maxSize;
minFileSize = minSize;
SearchTab.this.availableSources = availableSources;
SearchTab.this.completedSources = completedSources;
SearchTab.this.fileType = fileType;
SearchTab.this.extension = extension;
showAdvancedOptions();
}
};
}
}
});
search_query.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent arg0) {
if (arg0.keyCode == SWT.CR) {
search();
}
}
} );
clear_advanced_options = new Label(basic_search_controls,SWT.NONE);
clear_advanced_options.setText(_._("mainwindow.searchtab.label.clear"));
clear_advanced_options.setVisible(false);
Utils.formatAsLink(clear_advanced_options, new MouseAdapter() {
public void mouseUp(MouseEvent arg0) {
hideAdvancedOptions();
}
});
Composite advanced_options = new Composite(search_bar,SWT.NONE);
layout_data = new GridData();
layout_data.grabExcessHorizontalSpace = true;
layout_data.horizontalAlignment = GridData.FILL;
advanced_options.setLayoutData(layout_data);
advanced_options.setLayout(new GridLayout(1,false));
advanced_info_search_label = new Label(advanced_options,SWT.NONE);
layout_data = new GridData();
layout_data.horizontalAlignment = GridData.CENTER;
layout_data.grabExcessHorizontalSpace = true;
advanced_info_search_label.setLayoutData(layout_data);
advanced_info_search_label.setVisible(false);
search_query_tab_list = new CTabFolder(this, SWT.BORDER);
search_query_tab_list.setLayoutData(new GridData(GridData.FILL_BOTH));
search_query_tab_list.setLayout(new FillLayout());
search_query_tab_list.setSimple(false);
search_query_tab_list.setUnselectedImageVisible(true);
search_query_tab_list.setUnselectedCloseVisible(false);
}