// $Id$
/**
* Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
+ * European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
- *
+ *
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import org.eclipse.ui.swt.IFocusService;
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
private Text text_search;
private String secondaryId;
- private final String defaultText = "Use \"*\" for wildcard searching";
+ private final String defaultText = Messages.SearchBar_0;
final private ConfigurationSelectionListener configurationListener = new ConfigurationSelectionListener();
* Handles focus changes for the search textfield.
*/
private void registerAtFocusService() {
- IFocusService focusService =
+ IFocusService focusService =
(IFocusService) PlatformUI.getWorkbench().getService(IFocusService.class);
if (focusService != null) {
focusService.addFocusTracker(text_search, "navigation.textControlId");
final ToolBar toolBar = new ToolBar(composite, SWT.NULL);
ToolItem toolItem = new ToolItem(toolBar, SWT.DROP_DOWN | SWT.BORDER);
- toolItem.setText("Search");
+ toolItem.setText(Messages.SearchBar_1);
DropdownSelectionListener dropdownListener = new DropdownSelectionListener(
toolItem);
private void addTextListeners() {
text_search.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
+ @Override
+ public void focusGained(FocusEvent e) {
text_search.setForeground(NavigationUtil.getColor(Resources.SEARCH_VIEW_FOCUS));
if (defaultText.equals(text_search.getText())) {
text_search.setText("");
}
}
- public void focusLost(FocusEvent e) {
+ @Override
+ public void focusLost(FocusEvent e) {
if (text_search.getText() == "") {
text_search.setForeground(NavigationUtil.getColor(Resources.SEARCH_VIEW_FOREGROUND));
text_search.setText(defaultText);
if(searchString == null){
return;
}
-
- if("*".equals(searchString.trim())){
- NavigationUtil.warningDialog("Could not execute search", this, "Please type at least one character when using the \"*\" wildcard.");
+
+ if(!searchString.trim().matches(".*\\p{L}+.*")){
+ MessagingUtils.warningDialog(Messages.SearchBar_2, this, Messages.SearchBar_3);
return;
}
-
-
+
+
IFindTaxaAndNamesConfigurator configurator = configurationListener.getConfigurator();
configurator.setTitleSearchString(searchString);
openSearchResultsView(configurator);
-
+
}
-
+
private String getSearchString(){
String searchString = text_search.getText().trim();
- if (searchString.equals(defaultText) || searchString.length() == 0)
- return null;
+ if (searchString.equals(defaultText) || searchString.length() == 0) {
+ return null;
+ }
return searchString;
}
-
+
/**
* Opens a new instance of the search result view to display the result to the user.
- *
+ *
* @param searchResult
*/
private void openSearchResultsView(IFindTaxaAndNamesConfigurator configurator) {
boolean openResultInSeparateWindows = PreferencesUtil.getPreferenceStore().getBoolean((IPreferenceKeys.SEARCH_OPEN_RESULTS_IN_SEPARATE_WINDOWS));
if(openResultInSeparateWindows){
- //increment change secondary id so it is unique
+ //increment change secondary id so it is unique
secondaryId += "1";
}
IWorkbenchPage.VIEW_ACTIVATE);
((SearchResultView) resultsView).performSearch(configurator);
} catch (PartInitException e) {
- NavigationUtil.error(this.getClass(), "Error opening search result.", e);
+ MessagingUtils.error(this.getClass(), Messages.SearchBar_4, e);
}
}
/**
* Handles drop down menu selection. Available items are defined in the enumeration SearchOption.
- *
+ *
* @author n.hoffmann
* @created Feb 2, 2010
* @version 1.0
/**
* Handles search configuration selection.
- *
+ *
* @author n.hoffmann
* @created Feb 2, 2010
* @version 1.0
class ConfigurationSelectionListener extends SelectionAdapter {
private IFindTaxaAndNamesConfigurator configurator = PreferencesUtil.getSearchConfigurator();
-
+
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
- NavigationUtil.info("configuration menu clicked");
SearchOption option = (SearchOption) e.widget.getData();
switch (option){
break;
case COMMON_NAME:
configurator.setDoTaxaByCommonNames(getConfigurator().isDoTaxaByCommonNames() ? false : true);
- break;
+ break;
}
-
+
saveConfigurator();
}
/**
* Available search options.
- *
+ *
* @author n.hoffmann
* @created Feb 2, 2010
* @version 1.0
*/
enum SearchOption {
- TAXON("Taxa"),
- SYNONYM("Synonyms"),
- NAME("Names (without taxa)"),
- COMMON_NAME("Common Names");
+ TAXON(Messages.SearchBar_6),
+ SYNONYM(Messages.SearchBar_7),
+ NAME(Messages.SearchBar_8),
+ COMMON_NAME(Messages.SearchBar_9);
private final String label;