|
Last change
on this file since 5844 was 5844, checked in by akks, 13 years ago |
|
Remote control: fix table cell editing in add_tags dialog, fixed all EDT violations
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | package org.openstreetmap.josm.io.remotecontrol.handler;
|
|---|
| 2 |
|
|---|
| 3 | import java.io.File;
|
|---|
| 4 | import java.util.Arrays;
|
|---|
| 5 | import org.openstreetmap.josm.actions.OpenFileAction;
|
|---|
| 6 | import org.openstreetmap.josm.gui.util.GuiHelper;
|
|---|
| 7 | import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
|
|---|
| 8 | import static org.openstreetmap.josm.tools.I18n.tr;
|
|---|
| 9 |
|
|---|
| 10 | /**
|
|---|
| 11 | * Opens a local file
|
|---|
| 12 | */
|
|---|
| 13 | public class OpenFileHandler extends RequestHandler {
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * The remote control command name used to open a local file.
|
|---|
| 17 | */
|
|---|
| 18 | public static final String command = "open_file";
|
|---|
| 19 |
|
|---|
| 20 | @Override
|
|---|
| 21 | public String[] getMandatoryParams() {
|
|---|
| 22 | return new String[]{"filename"};
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | @Override
|
|---|
| 26 | public PermissionPrefWithDefault getPermissionPref() {
|
|---|
| 27 | return PermissionPrefWithDefault.OPEN_FILES;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | @Override
|
|---|
| 31 | protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException {
|
|---|
| 32 | GuiHelper.runInEDTAndWait(new Runnable() {
|
|---|
| 33 | @Override public void run() {
|
|---|
| 34 | OpenFileAction.openFiles(Arrays.asList(new File(args.get("filename"))));
|
|---|
| 35 | }
|
|---|
| 36 | });
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | @Override
|
|---|
| 40 | public String getPermissionMessage() {
|
|---|
| 41 | return tr("Remote Control has been asked to open a local file.");
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | @Override
|
|---|
| 45 | protected void validateRequest() throws RequestHandlerBadRequestException {
|
|---|
| 46 | // Nothing to do
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.