From 853dcb0b0411af863254de2ade4d9d54b1c4446b Mon Sep 17 00:00:00 2001 From: Patrick Plitzner Date: Thu, 1 Sep 2016 11:31:47 +0200 Subject: [PATCH 1/1] i18n for SearchManager --- .../OSGI-INF/l10n/messages.properties | 3 ++ .../OSGI-INF/l10n/messages_de.properties | 3 ++ .../java/eu/etaxonomy/taxeditor/Messages.java | 2 + .../taxeditor/store/SearchManager.java | 42 +++++++++---------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties index 443cbe54a..08c5bc41e 100644 --- a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties +++ b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties @@ -108,3 +108,6 @@ PasswordWizardPage_OLD_PASSWORD=Old Password PasswordWizardPage_PASSWORD_MIN_CHARACTER=Password has to have at least %s characters PasswordWizardPage_PASSWORDS_DO_NOT_MATCH=The passwords do not match PasswordWizardPage_REPEAT_PASSWORD=Repeat Password + +SearchManager_LARGE_RESULT_EXPECTED=Large result expected +SearchManager_LONG_SEARCH_WARNING=The current search will return %s objects. This will take a long time and/or might render the editor unusable. Please consider refining your search.\nSearch anyway? diff --git a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties index c165b4a63..7b1f5431d 100644 --- a/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties +++ b/eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties @@ -108,3 +108,6 @@ PasswordWizardPage_OLD_PASSWORD=Altes Kennwort PasswordWizardPage_PASSWORD_MIN_CHARACTER=Kennwort muss mindesten %s Zeichen enthalten PasswordWizardPage_PASSWORDS_DO_NOT_MATCH=Die Kennwörter stimmen nicht überein PasswordWizardPage_REPEAT_PASSWORD=Kennwort wiederholen + +SearchManager_LARGE_RESULT_EXPECTED=Große Anzahl an Suchergebnissen +SearchManager_LONG_SEARCH_WARNING=Die aktuelle Suche wird %s Objekte laden. Dies kann einige Zeit dauern und den Editor währenddessen unbedienbar machen. Bitte erstellen sie eine detailliertere Suche.\nTrotzdem suchen? diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java index 716a64c0d..8d33a5431 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java @@ -122,6 +122,8 @@ public class Messages extends NLS { public static String RemotingLoginDialog_JOB_SERVER_LAUNCH; public static String RemotingLoginDialog_STARTING_MGD_SERVER; public static String RemotingLoginDialog_TASK_LAUNCHING_SERVER; + public static String SearchManager_LARGE_RESULT_EXPECTED; + public static String SearchManager_LONG_SEARCH_WARNING; static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java index bfa1e5528..91b014748 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java @@ -44,6 +44,7 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; import eu.etaxonomy.cdm.model.reference.Reference; import eu.etaxonomy.cdm.model.taxon.TaxonBase; import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; +import eu.etaxonomy.taxeditor.Messages; import eu.etaxonomy.taxeditor.preference.IPreferenceKeys; import eu.etaxonomy.taxeditor.preference.PreferencesUtil; @@ -56,16 +57,16 @@ public class SearchManager { public static final List NO_RESULTS = Arrays.asList(new Object[]{}); - public static final String WILDCARD = "*"; + public static final String WILDCARD = "*"; //$NON-NLS-1$ public static int NO_COUNT = -1; - + // TODO make this configurable via preferences private static final int MAX_RESULTS_BEFORE_WARNING = 500; public List findNames(IIdentifiableEntityServiceConfigurator configurator, ConversationHolder conversation){ - + if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){ List records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords(); addUuidSearchResults(records, configurator, INameService.class); @@ -166,25 +167,25 @@ public class SearchManager { public List findOccurrences(IIdentifiableEntityServiceConfigurator configurator, boolean showFieldUnits){ List records = new ArrayList(); final List BASE_OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] { - "collection", - "descriptions", - "identifiers", - "derivationEvents.originals", - "derivedFrom.originals", - "gatheringEvent.country.representations", - "gatheringEvent.collector", - "gatheringEvent.locality", - "descriptions.descriptionElements", - "kindOfUnit", - "amplificationResults", - "sequences.singleReadAlignments", - "mediaSpecimen" + "collection", //$NON-NLS-1$ + "descriptions", //$NON-NLS-1$ + "identifiers", //$NON-NLS-1$ + "derivationEvents.originals", //$NON-NLS-1$ + "derivedFrom.originals", //$NON-NLS-1$ + "gatheringEvent.country.representations", //$NON-NLS-1$ + "gatheringEvent.collector", //$NON-NLS-1$ + "gatheringEvent.locality", //$NON-NLS-1$ + "descriptions.descriptionElements", //$NON-NLS-1$ + "kindOfUnit", //$NON-NLS-1$ + "amplificationResults", //$NON-NLS-1$ + "sequences.singleReadAlignments", //$NON-NLS-1$ + "mediaSpecimen" //$NON-NLS-1$ }); List occurrencePropertyPaths = new ArrayList(); occurrencePropertyPaths.addAll(BASE_OCCURRENCE_INIT_STRATEGY); for(String propertyPath:BASE_OCCURRENCE_INIT_STRATEGY) { - occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath); + occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath); //$NON-NLS-1$ } configurator.setPropertyPaths(occurrencePropertyPaths); @@ -219,16 +220,15 @@ public class SearchManager { private boolean checkLargeResult(int count, int maxBeforWarning) { if(count > maxBeforWarning){ - return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Large result expected", - String.format("The current search will return %s objects. This will " + - "take a long time and/or might render the editor unusable. Please consider refining your search.", count)); + return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.SearchManager_LARGE_RESULT_EXPECTED, + String.format(Messages.SearchManager_LONG_SEARCH_WARNING, count)); }else{ return true; } } private String sqlizeTitleSearchString(IIdentifiableEntityServiceConfigurator configurator){ - return configurator.getTitleSearchString().replace(WILDCARD, "%"); + return configurator.getTitleSearchString().replace(WILDCARD, "%"); //$NON-NLS-1$ } public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) { -- 2.34.1