Changeset 6332 in josm for trunk/src/org


Ignore:
Timestamp:
2013-10-27T03:04:38+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #9201 - fix remote control usage examples for handlers with several commands + typo

Location:
trunk/src/org/openstreetmap/josm/io/remotecontrol
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

    r6265 r6332  
    373373                r.append(", ");
    374374            }
    375             r.append(getHanldlerInfoAsJSON(p.getKey()));
     375            r.append(getHandlerInfoAsJSON(p.getKey()));
    376376        }
    377377        r.append("]");
     
    380380    }
    381381
    382     public static String getHanldlerInfoAsJSON(String cmd) {
     382    public static String getHandlerInfoAsJSON(String cmd) {
    383383        StringWriter w = new StringWriter();
    384384        PrintWriter r = new PrintWriter(w);
     
    421421       
    422422        r.append("], \"examples\" : [");
    423         String examples[] = handler.getUsageExamples();
     423        String examples[] = handler.getUsageExamples(cmd.substring(1));
    424424        if (examples != null) {
    425425            for (int i = 0; i < examples.length; i++) {
     
    443443    }
    444444
    445 
    446445    /**
    447446     * Reports HTML message with the description of all available commands
     
    451450     */
    452451    public static String getUsageAsHtml() throws IllegalAccessException, InstantiationException {
    453         // no handler found
    454452        StringBuilder usage = new StringBuilder(1024);
    455453        for (Entry<String, Class<? extends RequestHandler>> handler : handlers.entrySet()) {
     
    457455            String[] mandatory = sample.getMandatoryParams();
    458456            String[] optional = sample.getOptionalParams();
    459             String[] examples = sample.getUsageExamples();
     457            String[] examples = sample.getUsageExamples(handler.getKey().substring(1));
    460458            usage.append("<li>");
    461459            usage.append(handler.getKey());
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/FeaturesHandler.java

    r6091 r6332  
    3333                   buf.append(", ");
    3434               }
    35                String info = RequestProcessor.getHanldlerInfoAsJSON("/"+s);
     35               String info = RequestProcessor.getHandlerInfoAsJSON("/"+s);
    3636               if (info!=null) {
    3737                   buf.append(info);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r6248 r6332  
    8080    @Override
    8181    public String[] getUsageExamples() {
    82         if (command.equals(myCommand)) {
     82        return getUsageExamples(myCommand);
     83    }
     84   
     85    @Override
     86    public String[] getUsageExamples(String cmd) {
     87        if (command.equals(cmd)) {
    8388            return new String[] {
    84                 "/load_and_zoom?addtags=wikipedia:de=Wei%C3%9Fe_Gasse|maxspeed=5&select=way23071688,way23076176,way23076177,&left=13.740&right=13.741&top=51.05&bottom=51.049",
    85                 "/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999&new_layer=true"};
     89                    "/load_and_zoom?addtags=wikipedia:de=Wei%C3%9Fe_Gasse|maxspeed=5&select=way23071688,way23076176,way23076177,&left=13.740&right=13.741&top=51.05&bottom=51.049",
     90                    "/load_and_zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999&new_layer=true"};
    8691        } else {
    8792            return new String[] {
    88                 "/zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999"};
    89         }
    90     }
    91    
     93            "/zoom?left=8.19&right=8.20&top=48.605&bottom=48.590&select=node413602999"};
     94        }
     95    }
     96
    9297    @Override
    9398    protected void handleRequest() throws RequestHandlerErrorException
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r6316 r6332  
    116116    public String[] getUsageExamples() {
    117117        return null;
     118    }
     119
     120    /**
     121     * Returns usage examples for the given command. To be overriden only my handlers that define several commands.
     122     * @param cmd The command asked
     123     * @return Usage examples for the given command
     124     * @since 6332
     125     */
     126    public String[] getUsageExamples(String cmd) {
     127        return getUsageExamples();
    118128    }
    119129
Note: See TracChangeset for help on using the changeset viewer.