|
Last change
on this file since 10615 was 10615, checked in by Don-vip, 10 years ago |
|
see #11390 - sonar - squid:S1604 - Java 8: Anonymous inner classes containing only one method should become lambdas
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.io.remotecontrol.handler;
|
|---|
| 3 |
|
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 5 |
|
|---|
| 6 | import java.io.File;
|
|---|
| 7 | import java.util.Arrays;
|
|---|
| 8 |
|
|---|
| 9 | import org.openstreetmap.josm.actions.OpenFileAction;
|
|---|
| 10 | import org.openstreetmap.josm.gui.util.GuiHelper;
|
|---|
| 11 | import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
|
|---|
| 12 |
|
|---|
| 13 | /**
|
|---|
| 14 | * Opens a local file
|
|---|
| 15 | */
|
|---|
| 16 | public class OpenFileHandler extends RequestHandler {
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * The remote control command name used to open a local file.
|
|---|
| 20 | */
|
|---|
| 21 | public static final String command = "open_file";
|
|---|
| 22 |
|
|---|
| 23 | @Override
|
|---|
| 24 | public String[] getMandatoryParams() {
|
|---|
| 25 | return new String[]{"filename"};
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | @Override
|
|---|
| 29 | public String getUsage() {
|
|---|
| 30 | return "opens a local file in JOSM";
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | @Override
|
|---|
| 34 | public String[] getUsageExamples() {
|
|---|
| 35 | return new String[] {"/open_file?filename=/tmp/test.osm"};
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | @Override
|
|---|
| 39 | public PermissionPrefWithDefault getPermissionPref() {
|
|---|
| 40 | return PermissionPrefWithDefault.OPEN_FILES;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | @Override
|
|---|
| 44 | protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException {
|
|---|
| 45 | GuiHelper.runInEDTAndWait(() -> OpenFileAction.openFiles(Arrays.asList(new File(args.get("filename")))));
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | @Override
|
|---|
| 49 | public String getPermissionMessage() {
|
|---|
| 50 | return tr("Remote Control has been asked to open a local file.");
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | @Override
|
|---|
| 54 | protected void validateRequest() throws RequestHandlerBadRequestException {
|
|---|
| 55 | // Nothing to do
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.