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 ImportFileSystemWizardPage
extends WizardPage
{
17 private final static Log log
= LogFactory
.getLog(ImportFileSystemWizardPage
.class);
19 private Upload uploadFile
;
21 public ImportFileSystemWizardPage() {
22 super("Import from file system");
23 setDescription("Import files from the local file system into the JCR repository");
26 public void createControl(Composite parent
) {
27 Composite composite
= new Composite(parent
, SWT
.NONE
);
28 composite
.setLayout(new GridLayout(2, false));
29 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
30 new Label(composite
, SWT
.NONE
).setText("Pick up a file");
31 uploadFile
= new Upload(composite
, SWT
.BORDER
);
32 uploadFile
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
33 uploadFile
.setBrowseButtonText("Open...");
34 setControl(composite
);
37 public String
getObjectPath() {
38 // NOTE Returns the full file name of the last uploaded file including
39 // the file path as selected by the user on his local machine.
40 // The full path including the directory and file drive are only
41 // returned, if the browser supports reading this properties. In Firefox
42 // 3, only the filename is returned.
43 return uploadFile
.getPath();
46 public String
getObjectName() {
47 return uploadFile
.getUploadItem().getFileName();
50 public String
getObjectType() {
54 public void performFinish() {
55 boolean success
= uploadFile
.performUpload();
57 throw new ArgeoException("Cannot upload file named "
58 + uploadFile
.getPath());
61 protected void handleUploadFinished(final Upload upload
) {
64 public InputStream
getFileInputStream() {
65 return uploadFile
.getUploadItem().getFileInputStream();