]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - OpenFile.java
46de2c9182e706f8fda7be59bb6783ebf2bad1be
2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.eclipse
.ui
.specific
;
18 import org
.apache
.commons
.logging
.Log
;
19 import org
.apache
.commons
.logging
.LogFactory
;
20 import org
.eclipse
.rap
.rwt
.RWT
;
21 import org
.eclipse
.rap
.rwt
.client
.service
.UrlLauncher
;
24 * RWT specific object to open a file retrieved from the server. It forwards the
25 * request to the correct service after encoding file name and path in the
29 * The parameter "URI" is used to determine the correct file service, the path
30 * and the file name. An optional file name can be added to present the end user
31 * with a different file name as the one used to retrieve it.
36 * The instance specific service is called by its ID and must have been
40 public class OpenFile
{
41 private final static Log log
= LogFactory
.getLog(OpenFile
.class);
43 // /* DEPENDENCY INJECTION */
44 // private String openFileServiceId;
46 // public final static String PARAM_FILE_NAME =
47 // OpenFileService.PARAM_FILE_NAME;
48 // public final static String PARAM_FILE_URI =
49 // OpenFileService.PARAM_FILE_URI; // "param.fileURI";
51 public Object
execute(String openFileServiceId
, String fileUri
,
54 // if (fileUri == null || "".equals(fileUri.trim())
55 // || openFileServiceId == null
56 // || "".equals(openFileServiceId.trim()))
59 StringBuilder url
= new StringBuilder();
60 url
.append(RWT
.getServiceManager().getServiceHandlerUrl(
63 url
.append("&").append(OpenFileService
.PARAM_FILE_NAME
).append("=");
65 url
.append("&").append(OpenFileService
.PARAM_FILE_URI
).append("=");
68 String downloadUrl
= url
.toString();
69 if (log
.isTraceEnabled())
70 log
.debug("URL : " + downloadUrl
);
72 UrlLauncher launcher
= RWT
.getClient().getService(UrlLauncher
.class);
73 launcher
.openURL(downloadUrl
);
77 // /* DEPENDENCY INJECTION */
78 // public void setOpenFileServiceId(String openFileServiceId) {
79 // this.openFileServiceId = openFileServiceId;