Changeset 6742 in josm for trunk/src/org
- Timestamp:
- 2014-01-19T20:59:05+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r6586 r6742 56 56 57 57 public static final int DEFAULT_SEARCH_HISTORY_SIZE = 15; 58 /** Maximum number of characters before the search expression is shortened for display purposes. */ 59 public static final int MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY = 100; 58 60 59 61 private static final String SEARCH_EXPRESSION = "searchExpression"; … … 321 323 new ToolbarPreferences.ActionDefinition(Main.main.menu.search); 322 324 aDef.getParameters().put(SEARCH_EXPRESSION, initialValues); 323 aDef.setName( initialValues.text); // Display search expression as tooltip instead of generic one325 aDef.setName(Utils.shortenString(initialValues.text, MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY)); // Display search expression as tooltip instead of generic one 324 326 // parametrized action definition is now composed 325 327 ActionParser actionParser = new ToolbarPreferences.ActionParser(null); … … 588 590 if (foundMatches == 0) { 589 591 String msg = null; 592 final String text = Utils.shortenString(s.text, MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY); 590 593 if (s.mode == SearchMode.replace) { 591 msg = tr("No match found for ''{0}''", s.text);594 msg = tr("No match found for ''{0}''", text); 592 595 } else if (s.mode == SearchMode.add) { 593 msg = tr("Nothing added to selection by searching for ''{0}''", s.text);596 msg = tr("Nothing added to selection by searching for ''{0}''", text); 594 597 } else if (s.mode == SearchMode.remove) { 595 msg = tr("Nothing removed from selection by searching for ''{0}''", s.text);598 msg = tr("Nothing removed from selection by searching for ''{0}''", text); 596 599 } else if (s.mode == SearchMode.in_selection) { 597 msg = tr("Nothing found in selection by searching for ''{0}''", s.text);600 msg = tr("Nothing found in selection by searching for ''{0}''", text); 598 601 } 599 602 Main.map.statusLine.setHelpText(msg); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r6380 r6742 38 38 import org.openstreetmap.josm.actions.relation.EditRelationAction; 39 39 import org.openstreetmap.josm.actions.relation.SelectInRelationListAction; 40 import org.openstreetmap.josm.actions.search.SearchAction; 40 41 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 41 42 import org.openstreetmap.josm.data.SelectionChangedListener; … … 74 75 import org.openstreetmap.josm.tools.Shortcut; 75 76 import org.openstreetmap.josm.tools.SubclassFilteredCollection; 77 import org.openstreetmap.josm.tools.Utils; 76 78 77 79 /** … … 275 277 putValue(NAME, tr("Search")); 276 278 putValue(SHORT_DESCRIPTION, tr("Search for objects")); 277 putValue(SMALL_ICON, ImageProvider.get("dialogs","se lect"));279 putValue(SMALL_ICON, ImageProvider.get("dialogs","search")); 278 280 updateEnabledState(); 279 281 } … … 657 659 658 660 public SearchMenuItem(SearchSetting s) { 659 super( s.toString());661 super(Utils.shortenString(s.toString(), org.openstreetmap.josm.actions.search.SearchAction.MAX_LENGTH_SEARCH_EXPRESSION_DISPLAY)); 660 662 this.s = s; 661 663 addActionListener(this); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r6707 r6742 806 806 selection = null; 807 807 } 808 if (positionString.length() > 20) { 809 positionString = positionString.substring(0, 17) + "..."; 810 } 811 return positionString; 808 return Utils.shortenString(positionString, 20); 812 809 } 813 810 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6740 r6742 947 947 return biggerCopy; 948 948 } 949 950 /** 951 * If the string {@code s} is longer than {@code maxLength}, the string is cut and "..." is appended. 952 */ 953 public static String shortenString(String s, int maxLength) { 954 if (s != null && s.length() > maxLength) { 955 return s.substring(0, maxLength - 3) + "..."; 956 } else { 957 return s; 958 } 959 } 949 960 }
Note:
See TracChangeset
for help on using the changeset viewer.