Changeset 3317 in josm for trunk/src/org


Ignore:
Timestamp:
2010-06-08T15:42:33+02:00 (14 years ago)
Author:
stoecker
Message:

allow to search incomplete elements again

Location:
trunk/src/org/openstreetmap/josm
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r3252 r3317  
    477477        if (args.containsKey("selection")) {
    478478            for (String s : args.get("selection")) {
    479                 SearchAction.search(s, SearchAction.SearchMode.add, false, false);
     479                SearchAction.search(s, SearchAction.SearchMode.add);
    480480            }
    481481        }
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r3305 r3317  
    158158
    159159        JCheckBox caseSensitive = new JCheckBox(tr("case sensitive"), initialValues.caseSensitive);
     160        JCheckBox allElements = new JCheckBox(tr("all objects"), initialValues.allElements);
     161        allElements.setToolTipText(tr("Also include incomplete and deleted objects in search."));
    160162        JCheckBox regexSearch   = new JCheckBox(tr("regular expression"), initialValues.regexSearch);
    161163
     
    168170        left.add(in_selection, GBC.eop());
    169171        left.add(caseSensitive, GBC.eol());
     172        left.add(allElements, GBC.eol());
    170173        left.add(regexSearch, GBC.eol());
    171174
     
    231234        initialValues.mode = mode;
    232235        initialValues.caseSensitive = caseSensitive.isSelected();
     236        initialValues.allElements = allElements.isSelected();
    233237        initialValues.regexSearch = regexSearch.isSelected();
    234238        return initialValues;
     
    277281            }
    278282
    279             for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedCompletePrimitives()) {
     283            Collection<OsmPrimitive> all;
     284            if(s.allElements)
     285                all = Main.main.getCurrentDataSet().allPrimitives();
     286            else
     287                all = Main.main.getCurrentDataSet().allNonDeletedCompletePrimitives();
     288            for (OsmPrimitive osm : all) {
    280289                if (s.mode == SearchMode.replace) {
    281290                    if (matcher.match(osm)) {
     
    348357    }
    349358
    350     public static void search(String search, SearchMode mode, boolean caseSensitive, boolean regexSearch) {
    351         search(new SearchSetting(search, mode, caseSensitive, regexSearch));
     359    public static void search(String search, SearchMode mode) {
     360        search(new SearchSetting(search, mode, false, false, false));
    352361    }
    353362
     
    402411        public boolean caseSensitive;
    403412        public boolean regexSearch;
     413        public boolean allElements;
    404414
    405415        public SearchSetting() {
    406             this("", SearchMode.replace, false /* case insensitive */, false /* no regexp */);
    407         }
    408 
    409         public SearchSetting(String text, SearchMode mode, boolean caseSensitive, boolean regexSearch) {
     416            this("", SearchMode.replace, false /* case insensitive */,
     417            false /* no regexp */, false /* only useful primitives */);
     418        }
     419
     420        public SearchSetting(String text, SearchMode mode, boolean caseSensitive,
     421        boolean regexSearch, boolean allElements) {
    410422            this.caseSensitive = caseSensitive;
    411423            this.regexSearch = regexSearch;
     424            this.allElements = allElements;
    412425            this.mode = mode;
    413426            this.text = text;
     
    415428
    416429        public SearchSetting(SearchSetting original) {
    417             this(original.text, original.mode, original.caseSensitive, original.regexSearch);
     430            this(original.text, original.mode, original.caseSensitive,
     431            original.regexSearch, original.allElements);
    418432        }
    419433
     
    422436            String cs = caseSensitive ?
    423437                    /*case sensitive*/  trc("search", "CS") :
    424                         /*case insensitive*/  trc("search", "CI");
    425                     /*regex search*/
    426                     String rx = regexSearch ? (", " + trc("search", "RX")) : "";
    427                     return "\"" + text + "\" (" + cs + rx + ", " + mode + ")";
     438                    /*case insensitive*/  trc("search", "CI");
     439            String rx = regexSearch ? (", " +
     440                    /*regex search*/ trc("search", "RX")) : "";
     441            String all = allElements ? (", " +
     442                    /*all elements*/ trc("search", "A")) : "";
     443            return "\"" + text + "\" (" + cs + rx + all + ", " + mode + ")";
    428444        }
    429445
     
    435451            return (o.caseSensitive == this.caseSensitive
    436452                    && o.regexSearch == this.regexSearch
     453                    && o.allElements == this.allElements
    437454                    && o.mode.equals(this.mode)
    438455                    && o.text.equals(this.text));
     
    463480                } else if (s.charAt(index) == 'R') {
    464481                    result.regexSearch = true;
     482                } else if (s.charAt(index) == 'A') {
     483                    result.allElements = true;
    465484                } else if (s.charAt(index) == ' ') {
    466485                    break;
     
    493512                result.append('R');
    494513            }
     514            if (allElements) {
     515                result.append('A');
     516            }
    495517            result.append(' ');
    496518            result.append(text);
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r3305 r3317  
    583583    private static class Untagged extends Match {
    584584        @Override public boolean match(OsmPrimitive osm) {
    585             return !osm.isTagged();
     585            return !osm.isTagged() && !osm.isIncomplete();
    586586        }
    587587        @Override public String toString() {return "untagged";}
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r3262 r3317  
    439439    private static boolean checkAndConfirmOutlyingDeletes(OsmDataLayer layer, Collection<OsmPrimitive> primitivesToDelete) {
    440440        Area a = layer.data.getDataSourceArea();
     441        boolean outside = false;
     442        boolean incomplete = false;
    441443        if (a != null) {
    442444            for (OsmPrimitive osm : primitivesToDelete) {
    443                 if (osm instanceof Node && !osm.isNew()) {
    444                     Node n = (Node) osm;
    445                     if (!a.contains(n.getCoor())) {
    446                         JPanel msg = new JPanel(new GridBagLayout());
    447                         msg.add(new JLabel(
    448                                 "<html>" +
    449                                 // leave message in one tr() as there is a grammatical
    450                                 // connection.
    451                                 tr("You are about to delete nodes outside of the area you have downloaded."
    452                                         + "<br>"
    453                                         + "This can cause problems because other objects (that you do not see) might use them."
    454                                         + "<br>" + "Do you really want to delete?") + "</html>"));
    455                         return ConditionalOptionPaneUtil.showConfirmationDialog(
    456                                 "delete_outside_nodes",
    457                                 Main.parent,
    458                                 msg,
    459                                 tr("Delete confirmation"),
    460                                 JOptionPane.YES_NO_OPTION,
    461                                 JOptionPane.QUESTION_MESSAGE,
    462                                 JOptionPane.YES_OPTION
    463                         );
    464                     }
    465                 }
    466             }
     445                if (osm.isIncomplete())
     446                    incomplete = true;
     447                else if (osm instanceof Node && !osm.isNew()
     448                && !a.contains(((Node) osm).getCoor()))
     449                    outside = true;
     450            }
     451        }
     452        else
     453        {
     454            for (OsmPrimitive osm : primitivesToDelete)
     455                if (osm.isIncomplete())
     456                    incomplete = true;
     457        }
     458        if(outside)
     459        {
     460            JPanel msg = new JPanel(new GridBagLayout());
     461            msg.add(new JLabel(
     462                    "<html>" +
     463                    // leave message in one tr() as there is a grammatical
     464                    // connection.
     465                    tr("You are about to delete nodes outside of the area you have downloaded."
     466                            + "<br>"
     467                            + "This can cause problems because other objects (that you do not see) might use them."
     468                            + "<br>" + "Do you really want to delete?") + "</html>"));
     469            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     470                    "delete_outside_nodes",
     471                    Main.parent,
     472                    msg,
     473                    tr("Delete confirmation"),
     474                    JOptionPane.YES_NO_OPTION,
     475                    JOptionPane.QUESTION_MESSAGE,
     476                    JOptionPane.YES_OPTION
     477            );
     478            if(!answer)
     479                return false;
     480        }
     481        if(incomplete)
     482        {
     483            JPanel msg = new JPanel(new GridBagLayout());
     484            msg.add(new JLabel(
     485                    "<html>" +
     486                    // leave message in one tr() as there is a grammatical
     487                    // connection.
     488                    tr("You are about to delete incomplete objects."
     489                            + "<br>"
     490                            + "This will cause problems because you don't see the real object."
     491                            + "<br>" + "Do you really want to delete?") + "</html>"));
     492            boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
     493                    "delete_incomplete",
     494                    Main.parent,
     495                    msg,
     496                    tr("Delete confirmation"),
     497                    JOptionPane.YES_NO_OPTION,
     498                    JOptionPane.QUESTION_MESSAGE,
     499                    JOptionPane.YES_OPTION
     500            );
     501            if(!answer)
     502                return false;
    467503        }
    468504        return true;
  • trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java

    r3210 r3317  
    7777        new PrefixSuffixSwitcher("forwards", "backwards"),
    7878        new PrefixSuffixSwitcher("up", "down"),
     79        new PrefixSuffixSwitcher("east", "west"),
     80        new PrefixSuffixSwitcher("north", "south"),
    7981    };
    8082
  • trunk/src/org/openstreetmap/josm/data/osm/Filter.java

    r3300 r3317  
    1515    public Boolean inverted = false;
    1616    public Filter() {
    17         super("", SearchMode.add, false, false);
     17        super("", SearchMode.add, false, false, false);
    1818    }
    19     public Filter(String text, SearchMode mode, boolean caseSensitive, boolean regexSearch) {
    20         super(text, mode, caseSensitive, regexSearch);
     19    public Filter(String text, SearchMode mode, boolean caseSensitive,
     20    boolean regexSearch, boolean allElements) {
     21        super(text, mode, caseSensitive, regexSearch, allElements);
    2122    }
    2223
    2324    public Filter(String prefText){
    24         super("", SearchMode.add, false, false);
     25        super("", SearchMode.add, false, false, false);
    2526        String[] prfs = prefText.split(";");
    2627        if(prfs.length != 10 && !prfs[0].equals(version))
Note: See TracChangeset for help on using the changeset viewer.