]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java
c20d6b978a98cb4806414ba0f94b9758f5783b84
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui.rap / src / org / argeo / eclipse / ui / specific / UploadFileWizardPage.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.specific;
17
18 /** @deprecated Legacy, do not use */
19 public class UploadFileWizardPage {
20 }
21
22
23 /// **
24 // * RWT Specific convenience page that provides a simple interface to upload
25 /// one
26 // * file in a wizard context
27 // *
28 // * TODO Finalize clean and refactoring using the latest rap version and upload
29 // * dialog addons
30 // *
31 // */
32 // public class UploadFileWizardPage extends WizardPage {
33 // // private final static Log log = LogFactory
34 // // .getLog(UploadFileWizardPage.class);
35 // private static final long serialVersionUID = 8251354244542973179L;
36 // public final static String FILE_ITEM_TYPE = "FILE";
37 // public final static String FOLDER_ITEM_TYPE = "FOLDER";
38 //
39 // private File file;
40 //
41 // private FileUpload fileUpload;
42 // private ServerPushSession pushSession;
43 // private Label fileNameLabel;
44 //
45 // public UploadFileWizardPage() {
46 // super("Import from file system");
47 // setDescription("Import files from the local file system to the server");
48 // }
49 //
50 // public void createControl(Composite parent) {
51 // Composite composite = new Composite(parent, SWT.NONE);
52 // composite.setLayout(new GridLayout(3, false));
53 // composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
54 // new Label(composite, SWT.NONE).setText("Pick up a file");
55 //
56 // fileNameLabel = new Label(composite, SWT.NONE | SWT.BEGINNING);
57 // fileNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
58 // false));
59 //
60 // fileUpload = new FileUpload(composite, SWT.NONE);
61 // fileUpload.setText("Browse...");
62 // fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
63 // false));
64 //
65 // final String url = startUploadReceiver();
66 // pushSession = new ServerPushSession();
67 //
68 // fileUpload.addSelectionListener(new SelectionAdapter() {
69 // private static final long serialVersionUID = 1L;
70 //
71 // @Override
72 // public void widgetSelected(SelectionEvent e) {
73 // String fileName = fileUpload.getFileName();
74 // fileNameLabel.setText(fileName == null ? "" : fileName);
75 // pushSession.start();
76 // fileUpload.submit(url);
77 // }
78 // });
79 //
80 // setControl(composite);
81 // }
82 //
83 // public void performFinish() {
84 // // boolean success = uploadFile.performUpload();
85 // // if (!success)
86 // // throw new ArgeoException("Cannot upload file named "
87 // // + uploadFile.getPath());
88 // }
89 //
90 // private String startUploadReceiver() {
91 // MyFileUploadReceiver receiver = new MyFileUploadReceiver();
92 // FileUploadHandler uploadHandler = new FileUploadHandler(receiver);
93 // uploadHandler.addUploadListener(new FileUploadListener() {
94 //
95 // public void uploadProgress(FileUploadEvent event) {
96 // // handle upload progress
97 // }
98 //
99 // public void uploadFailed(FileUploadEvent event) {
100 // UploadFileWizardPage.this.setErrorMessage("upload failed: "
101 // + event.getException());
102 // }
103 //
104 // public void uploadFinished(FileUploadEvent event) {
105 //
106 // fileNameLabel.getDisplay().asyncExec(new Runnable() {
107 // public void run() {
108 // // UploadFileWizardPage.this.getContainer()
109 // // .updateButtons();
110 // pushSession.stop();
111 // }
112 // });
113 //
114 // // for (FileDetails file : event.getFileDetails()) {
115 // // // addToLog("received: " + file.getFileName());
116 // // }
117 // }
118 // });
119 // return uploadHandler.getUploadUrl();
120 // }
121 //
122 // private class MyFileUploadReceiver extends FileUploadReceiver {
123 //
124 // private static final String TEMP_FILE_PREFIX = "fileupload_";
125 //
126 // @Override
127 // public void receive(InputStream dataStream, FileDetails details)
128 // throws IOException {
129 // File result = File.createTempFile(TEMP_FILE_PREFIX, "");
130 // FileOutputStream outputStream = new FileOutputStream(result);
131 // try {
132 // copy(dataStream, outputStream);
133 // } finally {
134 // dataStream.close();
135 // outputStream.close();
136 // }
137 // file = result;
138 // }
139 // }
140 //
141 // private static void copy(InputStream inputStream, OutputStream outputStream)
142 // throws IOException {
143 // byte[] buffer = new byte[8192];
144 // boolean finished = false;
145 // while (!finished) {
146 // int bytesRead = inputStream.read(buffer);
147 // if (bytesRead != -1) {
148 // outputStream.write(buffer, 0, bytesRead);
149 // } else {
150 // finished = true;
151 // }
152 // }
153 // }
154 //
155 // /**
156 // * The full path including the directory and file drive are only returned,
157 // * if the browser supports reading this properties
158 // *
159 // * @return The full file name of the last uploaded file including the file
160 // * path as selected by the user on his local machine.
161 // */
162 // public String getObjectPath() {
163 // return null;
164 // }
165 //
166 // public String getObjectName() {
167 // return fileUpload.getFileName();
168 // }
169 //
170 // public String getObjectType() {
171 // return FILE_ITEM_TYPE;
172 // }
173 //
174 // // protected void handleUploadFinished(final Upload upload) {
175 // // }
176 //
177 // /** it is caller responsability to close the stream afterwards. */
178 // public InputStream getFileInputStream() throws IOException {
179 // return new FileInputStream(file);
180 // // InputStream fis = null;
181 // //
182 // // try {
183 // // fis = new FileInputStream(file);
184 // // return fis;
185 // // } catch (Exception e) {
186 // // throw new ArgeoException("Unable to retrieve file " + file, e);
187 // // } finally {
188 // // IOUtils.closeQuietly(fis);
189 // // }
190 // }
191 //
192 // public boolean getNeedsProgressMonitor() {
193 // return false;
194 // }
195 // }