]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java
1 package org
.argeo
.eclipse
.ui
.specific
;
3 import java
.io
.InputStream
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.ArgeoException
;
8 import org
.eclipse
.jface
.wizard
.WizardPage
;
9 import org
.eclipse
.rwt
.widgets
.Upload
;
10 import org
.eclipse
.swt
.SWT
;
11 import org
.eclipse
.swt
.layout
.GridData
;
12 import org
.eclipse
.swt
.layout
.GridLayout
;
13 import org
.eclipse
.swt
.widgets
.Composite
;
14 import org
.eclipse
.swt
.widgets
.Label
;
16 public class ImportToServerWizardPage
extends WizardPage
{
17 private final static Log log
= LogFactory
18 .getLog(ImportToServerWizardPage
.class);
20 public final static String FILE_ITEM_TYPE
= "FILE";
21 public final static String FOLDER_ITEM_TYPE
= "FOLDER";
23 private Upload uploadFile
;
25 public ImportToServerWizardPage() {
26 super("Import from file system");
27 setDescription("Import files from the local file system to the server");
30 public void createControl(Composite parent
) {
31 Composite composite
= new Composite(parent
, SWT
.NONE
);
32 composite
.setLayout(new GridLayout(2, false));
33 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
34 new Label(composite
, SWT
.NONE
).setText("Pick up a file");
35 uploadFile
= new Upload(composite
, SWT
.BORDER
);
36 uploadFile
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
37 uploadFile
.setBrowseButtonText("Open...");
38 setControl(composite
);
41 public String
getObjectPath() {
42 // NOTE Returns the full file name of the last uploaded file including
43 // the file path as selected by the user on his local machine.
44 // The full path including the directory and file drive are only
45 // returned, if the browser supports reading this properties. In Firefox
46 // 3, only the filename is returned.
47 return uploadFile
.getPath();
50 public String
getObjectName() {
51 return uploadFile
.getUploadItem().getFileName();
54 public String
getObjectType() {
55 return FILE_ITEM_TYPE
;
58 public void performFinish() {
59 boolean success
= uploadFile
.performUpload();
61 throw new ArgeoException("Cannot upload file named "
62 + uploadFile
.getPath());
65 protected void handleUploadFinished(final Upload upload
) {
68 public InputStream
getFileInputStream() {
69 return uploadFile
.getUploadItem().getFileInputStream();
72 public boolean getNeedsProgressMonitor() {