Changeset 3214 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPritority.java
- Timestamp:
- 02.05.2010 18:12:34 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPritority.java
r3083 r3214 2 2 package org.openstreetmap.josm.gui.tagging.ac; 3 3 4 public enum AutoCompletionItemPritority implements Comparable<AutoCompletionItemPritority> { 5 6 /** Indicates that a value is in the current selection. */ 7 IS_IN_SELECTION, 4 /** 5 * Describes the priority of an item in an autocompletion list. 6 * The selected flag is currently only used in plugins. 7 * 8 * Instances of this class are not modifiable. 9 */ 10 public class AutoCompletionItemPritority implements Comparable<AutoCompletionItemPritority> { 8 11 9 12 /** … … 12 15 * usually not used by the user. 13 16 */ 14 IS_IN_STANDARD_AND_IN_DATASET, 17 public static AutoCompletionItemPritority IS_IN_STANDARD_AND_IN_DATASET = new AutoCompletionItemPritority(true, true, false); 18 19 /** 20 * Indicates that this is an arbitrary value from the data set, i.e. 21 * the value of a tag name=*. 22 */ 23 public static AutoCompletionItemPritority IS_IN_DATASET = new AutoCompletionItemPritority(true, false, false); 15 24 16 25 /** … … 18 27 * or a standard value for a given tag name (from the presets). 19 28 */ 20 IS_IN_STANDARD, 29 public static AutoCompletionItemPritority IS_IN_STANDARD = new AutoCompletionItemPritority(false, true, false); 30 31 /** 32 * Indicates that this is a value from a selected object. 33 */ 34 public static AutoCompletionItemPritority IS_IN_SELECTION = new AutoCompletionItemPritority(false, false, true); 35 36 /** Unknown priority. This is the lowest priority. */ 37 public static AutoCompletionItemPritority UNKNOWN = new AutoCompletionItemPritority(false, false, false); 38 39 private final boolean inDataSet; 40 private final boolean inStandard; 41 private final boolean selected; 42 43 public AutoCompletionItemPritority(boolean inDataSet, boolean inStandard, boolean selected) { 44 this.inDataSet = inDataSet; 45 this.inStandard = inStandard; 46 this.selected = selected; 47 } 48 49 public boolean isInDataSet() { 50 return inDataSet; 51 } 52 53 public boolean isInStandard() { 54 return inStandard; 55 } 56 57 public boolean isSelected() { 58 return selected; 59 } 21 60 22 61 /** 23 * I ndicates that this is an arbitrary value from the data set, i.e.24 * the value of a tag name=*.62 * Imposes an ordering on the priorities. 63 * Currently, being in the current DataSet is worth more than being in the Presets. 25 64 */ 26 IS_IN_DATASET, 65 public int compareTo(AutoCompletionItemPritority other) { 66 int sel = new Boolean(selected).compareTo(other.selected); 67 if (sel != 0) return sel; 27 68 28 /** Unknown priority. This is the lowest priority. */ 29 UNKNOWN 69 int ds = new Boolean(inDataSet).compareTo(other.inDataSet); 70 if (ds != 0) return ds; 71 72 int std = new Boolean(inStandard).compareTo(other.inStandard); 73 if (std != 0) return std; 74 75 return 0; 76 } 77 78 /** 79 * Merges two priorities. 80 * The resulting priority is always >= the original ones. 81 */ 82 public AutoCompletionItemPritority mergeWith(AutoCompletionItemPritority other) { 83 return new AutoCompletionItemPritority( 84 inDataSet || other.inDataSet, 85 inStandard || other.inStandard, 86 selected || other.selected); 87 } 88 89 @Override public String toString() { 90 return String.format("<Priority; inDataSet: %b, inStandard: %b, selected: %b>", inDataSet, inStandard, selected); 91 } 30 92 }
Note: See TracChangeset
for help on using the changeset viewer.
