file_size_slider.addModifyListener(new ExSliderModifyListener() {
public void downValueChanged(double downValue) {
updated_file_size = true;
DecimalFormat formatter = new DecimalFormat("0.00");
downValue = Math.round(downValue);
double u = 1024 / 100D;
min_file_size.setText(formatter.format(u * downValue));
}
public void upValueChanged(double upValue) {
updated_file_size = true;
DecimalFormat formatter = new DecimalFormat("0.00");
upValue = Math.round(upValue);
double u = 1024 / 100D;
max_file_size.setText(formatter.format(u * upValue));
}
});
Composite options_composite = new Composite(shell,SWT.NONE);
layout_data = new GridData();
layout_data.grabExcessHorizontalSpace = true;
layout_data.horizontalAlignment = GridData.FILL;
options_composite.setLayoutData(layout_data);
options_composite.setLayout(new GridLayout(4,false));
label = new Label(options_composite,SWT.NONE);
label.setText("File type : ");
layout_data = new GridData();
layout_data.horizontalAlignment = SWT.RIGHT;
label.setLayoutData(layout_data);
file_type = new Combo(options_composite,SWT.READ_ONLY);
// must be same order as filetypes
file_type.add(_._("advancedsearchwindow.file_type.any"));
file_type.add(_._("advancedsearchwindow.file_type.archive"));
file_type.add(_._("advancedsearchwindow.file_type.audio"));
file_type.add(_._("advancedsearchwindow.file_type.cd_image"));
file_type.add(_._("advancedsearchwindow.file_type.document"));
file_type.add(_._("advancedsearchwindow.file_type.pictures"));
file_type.add(_._("advancedsearchwindow.file_type.program"));
file_type.add(_._("advancedsearchwindow.file_type.video"));
file_type.select(0);
file_type.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
layout_data = new GridData();
file_type.setLayoutData(layout_data);
label = new Label(options_composite,SWT.NONE);
label.setText(_._("advancedsearchwindow.label.extension") + " : ");
layout_data = new GridData();
layout_data.horizontalAlignment = SWT.RIGHT;
label.setLayoutData(layout_data);
file_extension = new Text(options_composite,SWT.BORDER);
label = new Label(options_composite,SWT.NONE);
label.setText(_._("advancedsearchwindow.label.availability") + " : ");
layout_data = new GridData();
layout_data.horizontalAlignment = SWT.RIGHT;
label.setLayoutData(layout_data);
av_spinner = new Spinner(options_composite,SWT.BORDER);
av_spinner.setMaximum(1000);
label = new Label(options_composite,SWT.NONE);
label.setText(_._("advancedsearchwindow.label.complete_sources") + " : ");
layout_data = new GridData();
layout_data.horizontalAlignment = SWT.RIGHT;
label.setLayoutData(layout_data);
cmp_src_spinner = new Spinner(options_composite,SWT.BORDER);
cmp_src_spinner.setMaximum(1000);
Composite button_composite = new Composite(shell,SWT.BORDER);
layout_data = new GridData();
layout_data.verticalAlignment = GridData.END;
layout_data.horizontalAlignment = GridData.FILL;
layout_data.grabExcessHorizontalSpace = true;
layout_data.grabExcessVerticalSpace=true;
button_composite.setLayoutData(layout_data);
layout = new GridLayout(3,false);
button_composite.setLayout(layout);
Button button_clear = new Button(button_composite,SWT.NONE);
button_clear.setText(_._("advancedsearchwindow.button.clear"));
button_clear.setImage(SWTImageRepository.getImage("remove_all.png"));
button_clear.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
min_file_size.setText("0.0");
min_file_size_units.select(0);
max_file_size.setText("1024.00");
max_file_size_units.select(0);
file_extension.setText("");
file_type.select(0);
av_spinner.setSelection(0);
cmp_src_spinner.setSelection(0);
updated_file_size = false;
}
});
Button button_ok = new Button(button_composite,SWT.NONE);
button_ok.setText(_._("advancedsearchwindow.button.ok"));
button_ok.setImage(skin.getButtonImage(Skin.OK_BUTTON_IMAGE));
layout_data = new GridData();
layout_data.grabExcessHorizontalSpace=true;
layout_data.horizontalAlignment = SWT.RIGHT;
button_ok.setLayoutData(layout_data);
button_ok.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
long min_unit = (Long)min_file_size_units.getData(min_file_size_units.getText());
long max_unit = (Long)max_file_size_units.getData(max_file_size_units.getText());
double min = formatSize(file_size_slider.getDownValue(), min_unit);
double max = formatSize(file_size_slider.getUpValue(), max_unit);
if (updated_file_size)
save((long)min, (long)max, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
else
save((long)0, (long)0, file_types[file_type.getSelectionIndex()],file_extension.getText(), av_spinner.getSelection(), cmp_src_spinner.getSelection());
shell.close();
}
});
Button button_cancel = new Button(button_composite,SWT.NONE);
button_cancel.setText(_._("advancedsearchwindow.button.cancel"));
button_cancel.setImage(skin.getButtonImage(Skin.CANCEL_BUTTON_IMAGE));
button_cancel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
shell.close();
}
});
Utils.centreWindow(shell);
shell.open();
// initialization
DecimalFormat formatter = new DecimalFormat("0.00");
min_file_size.setText(formatter.format(min));
max_file_size.setText(formatter.format(max));
min_file_size_units.select(initial_min_size_units);
max_file_size_units.select(initial_max_size_units);
file_extension.setText(initial_extension);