]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/commands/OpenFile.java
Add the ability to remove a JCR privilege from a given node
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui.workbench / src / org / argeo / eclipse / ui / workbench / commands / OpenFile.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.eclipse.ui.workbench.commands;
17
18 import org.argeo.eclipse.ui.specific.OpenFileService;
19 import org.argeo.eclipse.ui.workbench.WorkbenchUiPlugin;
20 import org.eclipse.core.commands.AbstractHandler;
21 import org.eclipse.core.commands.ExecutionEvent;
22 import org.eclipse.core.commands.ExecutionException;
23
24 /**
25 * RWT specific command handler to open a file retrieved from the server. It
26 * forwards the request to the correct service after encoding file name and path
27 * in the request URI.
28 *
29 * <p>
30 * The parameter "URI" is used to determine the correct file service, the path
31 * and the file name. An optional file name can be precized to present a
32 * different file name as the one used to retrieve it to the end user.
33 * </p>
34 *
35 * <p>
36 * Various instances of this handler with different command ID might coexist in
37 * order to provide context specific download service.
38 * </p>
39 *
40 * <p>
41 * The instance specific service is called by its ID and must have been
42 * externally created
43 * </p>
44 */
45 public class OpenFile extends AbstractHandler {
46 // private final static Log log = LogFactory.getLog(OpenFile.class);
47
48 /* DEPENDENCY INJECTION */
49 private String openFileServiceId;
50
51 public final static String ID = WorkbenchUiPlugin.ID + ".dumpNode";
52 public final static String PARAM_FILE_NAME = OpenFileService.PARAM_FILE_NAME;
53 public final static String PARAM_FILE_URI = OpenFileService.PARAM_FILE_URI; // "param.fileURI";
54
55 public Object execute(ExecutionEvent event) throws ExecutionException {
56
57 String fileName = event.getParameter(PARAM_FILE_NAME);
58 String fileUri = event.getParameter(PARAM_FILE_URI);
59 // Sanity check
60 if (fileUri == null || "".equals(fileUri.trim())
61 || openFileServiceId == null
62 || "".equals(openFileServiceId.trim()))
63 return null;
64
65 org.argeo.eclipse.ui.specific.OpenFile openFileClient = new org.argeo.eclipse.ui.specific.OpenFile();
66 openFileClient.execute(openFileServiceId, fileUri, fileName);
67
68 return null;
69 }
70
71 /* DEPENDENCY INJECTION */
72 public void setOpenFileServiceId(String openFileServiceId) {
73 this.openFileServiceId = openFileServiceId;
74 }
75 }