Move to Commons Base
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 17 Jul 2012 12:30:40 +0000 (12:30 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 17 Jul 2012 12:30:40 +0000 (12:30 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@5477 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

22 files changed:
base/runtime/org.argeo.eclipse.ui.rap/.classpath [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/.project [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/build.properties [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/pom.xml [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java [new file with mode: 0644]
base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java [new file with mode: 0644]
eclipse/runtime/org.argeo.eclipse.ui.rap/.classpath [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/.project [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/build.properties [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/pom.xml [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java [deleted file]
eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java [deleted file]

diff --git a/base/runtime/org.argeo.eclipse.ui.rap/.classpath b/base/runtime/org.argeo.eclipse.ui.rap/.classpath
new file mode 100644 (file)
index 0000000..8cf7f48
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src/main/java"/>
+       <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/.project b/base/runtime/org.argeo.eclipse.ui.rap/.project
new file mode 100644 (file)
index 0000000..df496c2
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.eclipse.ui.rap</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs b/base/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..ffba01e
--- /dev/null
@@ -0,0 +1,8 @@
+#Wed Mar 02 13:27:08 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/build.properties b/base/runtime/org.argeo.eclipse.ui.rap/build.properties
new file mode 100644 (file)
index 0000000..7cc98e7
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = target/classes/
+bin.includes = META-INF/,\
+               .,\
\ No newline at end of file
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/pom.xml b/base/runtime/org.argeo.eclipse.ui.rap/pom.xml
new file mode 100644 (file)
index 0000000..dd4aceb
--- /dev/null
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.argeo.commons.eclipse</groupId>
+               <version>1.1.4-SNAPSHOT</version>
+               <artifactId>runtime</artifactId>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
+       <name>Commons Eclipse UI RAP</name>
+       <packaging>jar</packaging>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-source-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+
+                               <configuration>
+                                       <instructions>
+                                               <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
+                                               <Bundle-Activator>org.argeo.eclipse.ui.ArgeoUiPlugin</Bundle-Activator>
+                                               <Require-Bundle>org.eclipse.rap.ui,org.eclipse.rwt.widgets.upload,org.eclipse.core.runtime</Require-Bundle>
+                                               <!-- IMPORTANT : Note that we must exclude certain packages that are 
+                                                       provided by dependencies to be sure that packages used in the current workspace 
+                                                       are those provided by the require-bundles. Especially rwt.widgets.upload 
+                                                       by instance. -->
+                                               <Import-Package>
+                                                       org.apache.commons.io,
+                                                       org.argeo,
+                                                       org.springframework.beans.factory,
+                                                       org.springframework.core.io.support,
+                                                       !org.eclipse.rwt.widgets,
+                                                       !org.eclipse.core.runtime,
+                                                       !org.eclipse.core.commands,
+                                                       !org.eclipse.ui.plugin,
+                                                       *
+                                               </Import-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <!-- deleted from import package : javax.servlet, javax.servlet.http,org.argeo.eclipse.ui.dialogs, 
+               org.eclipse.jface.dialogs, -->
+       <dependencies>
+                       <dependency>
+                       <groupId>org.argeo.commons.basic</groupId>
+                       <artifactId>org.argeo.basic.nodeps</artifactId>
+                       <version>1.1.4-SNAPSHOT</version>
+               </dependency>
+       
+               <!-- Argeo common distribution for RAP projects -->
+               <dependency>
+                       <groupId>org.argeo.commons.eclipse</groupId>
+                       <artifactId>org.argeo.eclipse.dep.rap</artifactId>
+                       <version>1.1.4-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Logging -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>slf4j.org.apache.commons.logging</artifactId>
+               </dependency>
+       </dependencies>
+</project>
\ No newline at end of file
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java
new file mode 100644 (file)
index 0000000..a8e2c34
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.argeo.ArgeoException;
+import org.eclipse.rwt.RWT;
+import org.eclipse.rwt.service.IServiceHandler;
+
+public class DownloadServiceHandler implements IServiceHandler {
+
+       private FileProvider provider;
+
+       public DownloadServiceHandler(FileProvider provider) {
+               this.provider = provider;
+       }
+
+       public void service() throws IOException, ServletException {
+               // Which file to download?
+               String fileName = RWT.getRequest().getParameter("filename");
+               String fileId = RWT.getRequest().getParameter("fileid");
+
+               // Get the file content
+               byte[] download = provider.getByteArrayFileFromId(fileId);
+
+               // Send the file in the response
+               HttpServletResponse response = RWT.getResponse();
+               response.setContentType("application/octet-stream");
+               response.setContentLength(download.length);
+               String contentDisposition = "attachment; filename=\"" + fileName + "\"";
+               response.setHeader("Content-Disposition", contentDisposition);
+
+               // Various header fields that can be set to solve some issues with some
+               // old browsers.
+               // Unused.
+               // String contentType = "application/force-download; name=\"" + fileName
+               // + "\"";
+               // response.setContentType(contentType);
+               // response.setHeader("Content-Transfer-Encoding", "binary");
+               // response.setHeader("Pragma", "no-cache");
+               // response.setHeader("Cache-Control", "no-cache, must-revalidate");
+               // response.setHeader("Expires", "0");
+               // response.setHeader("Connection", "Keep-Alive");
+               // response.setHeader("Keep-Alive", "timeout=5, max=86");
+               // response.setHeader("transfer-Encoding", "chunked");
+
+               try {
+                       response.getOutputStream().write(download);
+               } catch (IOException ioe) {
+                       throw new ArgeoException("Error while writing the file " + fileName
+                                       + " to the servlet response", ioe);
+               }
+       }
+}
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java
new file mode 100644 (file)
index 0000000..932d65b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import org.eclipse.jface.viewers.AbstractTableViewer;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.Viewer;
+
+/** Static utilities to bridge differences between RCP and RAP */
+public class EclipseUiSpecificUtils {
+       /**
+        * TootlTip support is supported only for {@link AbstractTableViewer} in RAP
+        * 
+        * @see ColumnViewerToolTipSupport#enableFor(AbstractTableViewer)
+        */
+       public static void enableToolTipSupport(Viewer viewer) {
+               if (viewer instanceof AbstractTableViewer)
+                       ColumnViewerToolTipSupport.enableFor((AbstractTableViewer) viewer);
+       }
+
+       private EclipseUiSpecificUtils() {
+       }
+
+}
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java
new file mode 100644 (file)
index 0000000..ad551b4
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import java.net.URL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.rwt.RWT;
+import org.eclipse.rwt.service.IServiceHandler;
+import org.eclipse.rwt.service.IServiceManager;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * RAP SPECIFIC handler to enable the opening of a download dialog box triggered
+ * by whatever action in the UI
+ * 
+ * Manages the registration of the effective DownloadServiceHandler at
+ * instantiation time.
+ * 
+ * Manages the process of forwarding the request to the handler at runtime to
+ * open the dialog box
+ * 
+ */
+public class FileHandler {
+       public final static String FORCED_DOWNLOAD_URL_BASE_PROPERTY = "argeo.rap.specific.forcedDownloadUrlBase";
+
+       private final static Log log = LogFactory.getLog(FileHandler.class);
+
+       public FileHandler(FileProvider provider) {
+               // Instantiate and register the DownloadServicHandler.
+               IServiceManager manager = RWT.getServiceManager();
+               IServiceHandler handler = new DownloadServiceHandler(provider);
+               manager.registerServiceHandler("downloadServiceHandler", handler);
+       }
+
+       public void openFile(String fileName, String fileId) {
+
+               // See RAP FAQ:
+               // http://wiki.eclipse.org/RAP/FAQ#How_to_provide_download_link.3F
+               // And forum discussion :
+               // http://www.eclipse.org/forums/index.php?t=msg&th=205487&start=0&S=43d85dacc88b505402420592109c7240
+
+               try {
+                       if (log.isTraceEnabled())
+                               log.trace("URL : " + createFullDownloadUrl(fileName, fileId));
+
+                       URL url = new URL(createFullDownloadUrl(fileName, fileId));
+                       PlatformUI.getWorkbench().getBrowserSupport()
+                                       .createBrowser("DownloadDialog").openURL(url);
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+               // These lines are useless in the current use case but might be
+               // necessary with new browsers. Stored here for memo
+               // response.setContentType("application/force-download");
+               // response.setHeader("Content-Disposition", contentDisposition);
+               // response.setHeader("Content-Transfer-Encoding", "binary");
+               // response.setHeader("Pragma", "no-cache");
+               // response.setHeader("Cache-Control", "no-cache, must-revalidate");
+       }
+
+       private String createFullDownloadUrl(String fileName, String fileId) {
+               StringBuilder url = new StringBuilder();
+               // in case RAP is proxied we need to specify the actual base URL
+               // TODO find a cleaner way
+               String forcedDownloadUrlBase = System
+                               .getProperty(FORCED_DOWNLOAD_URL_BASE_PROPERTY);
+               if (forcedDownloadUrlBase != null)
+                       url.append(forcedDownloadUrlBase);
+               else
+                       url.append(RWT.getRequest().getRequestURL());
+               url.append(createParamUrl(fileName, fileId));
+               return url.toString();
+       }
+
+       private String createParamUrl(String filename, String fileId) {
+               StringBuilder url = new StringBuilder();
+               url.append("?");
+               url.append(IServiceHandler.REQUEST_PARAM);
+               url.append("=downloadServiceHandler");
+               url.append("&filename=");
+               url.append(filename);
+               url.append("&fileid=");
+               url.append(fileId);
+               String encodedURL = RWT.getResponse().encodeURL(url.toString());
+               return encodedURL;
+       }
+}
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java
new file mode 100644 (file)
index 0000000..ca7dc08
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import java.io.InputStream;
+
+/**
+ * Used for file download : subclasses must implement model specific methods to
+ * get a byte array representing a file given is ID.
+ */
+public interface FileProvider {
+
+       public byte[] getByteArrayFileFromId(String fileId);
+
+       public InputStream getInputStreamFromFileId(String fileId);
+
+}
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java
new file mode 100644 (file)
index 0000000..13e695d
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.eclipse.rwt.widgets.Upload;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+public class GenericUploadControl extends Composite {
+       private final static Log log = LogFactory
+                       .getLog(GenericUploadControl.class);
+
+       private Upload upload;
+
+       public GenericUploadControl(Composite parent, int style, String browseLabel) {
+               super(parent, style);
+               createControl(this, browseLabel);
+
+       }
+
+       private void createControl(Composite parent, String browseLabel) {
+               parent.setLayout(new GridLayout(1, false));
+               parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+               upload = new Upload(parent, SWT.BORDER);
+               upload.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               upload.setBrowseButtonText(browseLabel);
+               // upload.addModifyListener(new UploadListener());
+               parent.pack();
+       }
+
+       /**
+        * Wrap upload.getLastFileUploaded(). Gets the name of the last uploaded
+        * file. This method can be called even if the upload has not finished yet.
+        */
+       public String getLastFileUploadedName() {
+               return upload.getLastFileUploaded();
+       }
+
+       public boolean isControlEmpty() {
+               String path = upload.getPath();
+               if (log.isTraceEnabled())
+                       log.trace("UploadControl chosen path : " + path);
+               if (path == null || "".equals(path.trim()))
+                       return true;
+               else
+                       return false;
+       }
+
+       public byte[] performUpload() {
+               boolean success = upload.performUpload();
+               if (success) {
+                       if (upload.getUploadItem().getFileSize() == -1)
+                               throw new ArgeoException("File "
+                                               + upload.getUploadItem().getFileName()
+                                               + " has not been uploaded, its size is -1");
+
+                       InputStream inStream = null;
+                       byte[] fileBA = null;
+                       try {
+                               inStream = upload.getUploadItem().getFileInputStream();
+                               fileBA = IOUtils.toByteArray(inStream);
+                       } catch (Exception e) {
+                               throw new ArgeoException("Cannot read uploaded data", e);
+                       } finally {
+                               IOUtils.closeQuietly(inStream);
+                       }
+                       return fileBA;
+               }
+               return null;
+       }
+
+       public void addModifyListener(ModifyListener listener) {
+               upload.addModifyListener(listener);
+       }
+
+       // private class UploadManager extends UploadAdapter {
+       // private Upload upload;
+       //
+       // public UploadManager(Upload upload) {
+       // super();
+       // this.upload = upload;
+       // }
+       //
+       // public void uploadFinished(UploadEvent uploadEvent) {
+       // handleUploadFinished(upload);
+       // }
+       //
+       // public void uploadInProgress(UploadEvent uploadEvent) {
+       // }
+       //
+       // public void uploadException(UploadEvent uploadEvent) {
+       // Exception exc = uploadEvent.getUploadException();
+       // if (exc != null) {
+       // MessageDialog.openError(Display.getCurrent().getActiveShell(),
+       // "Error", exc.getMessage());
+       // }
+       // }
+       //
+       // }
+       //
+
+}
diff --git a/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java b/base/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java
new file mode 100644 (file)
index 0000000..d087ebe
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.eclipse.ui.specific;
+
+import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.ArgeoException;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.rwt.widgets.Upload;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+public class ImportToServerWizardPage extends WizardPage {
+       private final static Log log = LogFactory
+                       .getLog(ImportToServerWizardPage.class);
+
+       public final static String FILE_ITEM_TYPE = "FILE";
+       public final static String FOLDER_ITEM_TYPE = "FOLDER";
+
+       private Upload uploadFile;
+
+       public ImportToServerWizardPage() {
+               super("Import from file system");
+               setDescription("Import files from the local file system to the server");
+       }
+
+       public void createControl(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout(2, false));
+               composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               new Label(composite, SWT.NONE).setText("Pick up a file");
+               uploadFile = new Upload(composite, SWT.BORDER);
+               uploadFile.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               uploadFile.setBrowseButtonText("Open...");
+               setControl(composite);
+       }
+
+       public String getObjectPath() {
+               // NOTE Returns the full file name of the last uploaded file including
+               // the file path as selected by the user on his local machine.
+               // The full path including the directory and file drive are only
+               // returned, if the browser supports reading this properties. In Firefox
+               // 3, only the filename is returned.
+               return uploadFile.getPath();
+       }
+
+       public String getObjectName() {
+               return uploadFile.getUploadItem().getFileName();
+       }
+
+       public String getObjectType() {
+               return FILE_ITEM_TYPE;
+       }
+
+       public void performFinish() {
+               boolean success = uploadFile.performUpload();
+               if (!success)
+                       throw new ArgeoException("Cannot upload file named "
+                                       + uploadFile.getPath());
+       }
+
+       protected void handleUploadFinished(final Upload upload) {
+       }
+
+       public InputStream getFileInputStream() {
+               return uploadFile.getUploadItem().getFileInputStream();
+       }
+
+       public boolean getNeedsProgressMonitor() {
+               return false;
+       }
+
+}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/.classpath b/eclipse/runtime/org.argeo.eclipse.ui.rap/.classpath
deleted file mode 100644 (file)
index 8cf7f48..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
-       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-       <classpathentry kind="src" path="src/main/java"/>
-       <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/.project b/eclipse/runtime/org.argeo.eclipse.ui.rap/.project
deleted file mode 100644 (file)
index df496c2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.eclipse.ui.rap</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs b/eclipse/runtime/org.argeo.eclipse.ui.rap/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index ffba01e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#Wed Mar 02 13:27:08 CET 2011
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/build.properties b/eclipse/runtime/org.argeo.eclipse.ui.rap/build.properties
deleted file mode 100644 (file)
index 7cc98e7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-source.. = src/main/java/
-output.. = target/classes/
-bin.includes = META-INF/,\
-               .,\
\ No newline at end of file
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/pom.xml b/eclipse/runtime/org.argeo.eclipse.ui.rap/pom.xml
deleted file mode 100644 (file)
index dd4aceb..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.commons.eclipse</groupId>
-               <version>1.1.4-SNAPSHOT</version>
-               <artifactId>runtime</artifactId>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
-       <name>Commons Eclipse UI RAP</name>
-       <packaging>jar</packaging>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-compiler-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-source-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-jar-plugin</artifactId>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-
-                               <configuration>
-                                       <instructions>
-                                               <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
-                                               <Bundle-Activator>org.argeo.eclipse.ui.ArgeoUiPlugin</Bundle-Activator>
-                                               <Require-Bundle>org.eclipse.rap.ui,org.eclipse.rwt.widgets.upload,org.eclipse.core.runtime</Require-Bundle>
-                                               <!-- IMPORTANT : Note that we must exclude certain packages that are 
-                                                       provided by dependencies to be sure that packages used in the current workspace 
-                                                       are those provided by the require-bundles. Especially rwt.widgets.upload 
-                                                       by instance. -->
-                                               <Import-Package>
-                                                       org.apache.commons.io,
-                                                       org.argeo,
-                                                       org.springframework.beans.factory,
-                                                       org.springframework.core.io.support,
-                                                       !org.eclipse.rwt.widgets,
-                                                       !org.eclipse.core.runtime,
-                                                       !org.eclipse.core.commands,
-                                                       !org.eclipse.ui.plugin,
-                                                       *
-                                               </Import-Package>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
-
-       <!-- deleted from import package : javax.servlet, javax.servlet.http,org.argeo.eclipse.ui.dialogs, 
-               org.eclipse.jface.dialogs, -->
-       <dependencies>
-                       <dependency>
-                       <groupId>org.argeo.commons.basic</groupId>
-                       <artifactId>org.argeo.basic.nodeps</artifactId>
-                       <version>1.1.4-SNAPSHOT</version>
-               </dependency>
-       
-               <!-- Argeo common distribution for RAP projects -->
-               <dependency>
-                       <groupId>org.argeo.commons.eclipse</groupId>
-                       <artifactId>org.argeo.eclipse.dep.rap</artifactId>
-                       <version>1.1.4-SNAPSHOT</version>
-               </dependency>
-
-               <!-- Logging -->
-               <dependency>
-                       <groupId>org.argeo.tp</groupId>
-                       <artifactId>slf4j.org.apache.commons.logging</artifactId>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/DownloadServiceHandler.java
deleted file mode 100644 (file)
index a8e2c34..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-
-import org.argeo.ArgeoException;
-import org.eclipse.rwt.RWT;
-import org.eclipse.rwt.service.IServiceHandler;
-
-public class DownloadServiceHandler implements IServiceHandler {
-
-       private FileProvider provider;
-
-       public DownloadServiceHandler(FileProvider provider) {
-               this.provider = provider;
-       }
-
-       public void service() throws IOException, ServletException {
-               // Which file to download?
-               String fileName = RWT.getRequest().getParameter("filename");
-               String fileId = RWT.getRequest().getParameter("fileid");
-
-               // Get the file content
-               byte[] download = provider.getByteArrayFileFromId(fileId);
-
-               // Send the file in the response
-               HttpServletResponse response = RWT.getResponse();
-               response.setContentType("application/octet-stream");
-               response.setContentLength(download.length);
-               String contentDisposition = "attachment; filename=\"" + fileName + "\"";
-               response.setHeader("Content-Disposition", contentDisposition);
-
-               // Various header fields that can be set to solve some issues with some
-               // old browsers.
-               // Unused.
-               // String contentType = "application/force-download; name=\"" + fileName
-               // + "\"";
-               // response.setContentType(contentType);
-               // response.setHeader("Content-Transfer-Encoding", "binary");
-               // response.setHeader("Pragma", "no-cache");
-               // response.setHeader("Cache-Control", "no-cache, must-revalidate");
-               // response.setHeader("Expires", "0");
-               // response.setHeader("Connection", "Keep-Alive");
-               // response.setHeader("Keep-Alive", "timeout=5, max=86");
-               // response.setHeader("transfer-Encoding", "chunked");
-
-               try {
-                       response.getOutputStream().write(download);
-               } catch (IOException ioe) {
-                       throw new ArgeoException("Error while writing the file " + fileName
-                                       + " to the servlet response", ioe);
-               }
-       }
-}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java
deleted file mode 100644 (file)
index 932d65b..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import org.eclipse.jface.viewers.AbstractTableViewer;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.Viewer;
-
-/** Static utilities to bridge differences between RCP and RAP */
-public class EclipseUiSpecificUtils {
-       /**
-        * TootlTip support is supported only for {@link AbstractTableViewer} in RAP
-        * 
-        * @see ColumnViewerToolTipSupport#enableFor(AbstractTableViewer)
-        */
-       public static void enableToolTipSupport(Viewer viewer) {
-               if (viewer instanceof AbstractTableViewer)
-                       ColumnViewerToolTipSupport.enableFor((AbstractTableViewer) viewer);
-       }
-
-       private EclipseUiSpecificUtils() {
-       }
-
-}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java
deleted file mode 100644 (file)
index ad551b4..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import java.net.URL;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.rwt.RWT;
-import org.eclipse.rwt.service.IServiceHandler;
-import org.eclipse.rwt.service.IServiceManager;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * RAP SPECIFIC handler to enable the opening of a download dialog box triggered
- * by whatever action in the UI
- * 
- * Manages the registration of the effective DownloadServiceHandler at
- * instantiation time.
- * 
- * Manages the process of forwarding the request to the handler at runtime to
- * open the dialog box
- * 
- */
-public class FileHandler {
-       public final static String FORCED_DOWNLOAD_URL_BASE_PROPERTY = "argeo.rap.specific.forcedDownloadUrlBase";
-
-       private final static Log log = LogFactory.getLog(FileHandler.class);
-
-       public FileHandler(FileProvider provider) {
-               // Instantiate and register the DownloadServicHandler.
-               IServiceManager manager = RWT.getServiceManager();
-               IServiceHandler handler = new DownloadServiceHandler(provider);
-               manager.registerServiceHandler("downloadServiceHandler", handler);
-       }
-
-       public void openFile(String fileName, String fileId) {
-
-               // See RAP FAQ:
-               // http://wiki.eclipse.org/RAP/FAQ#How_to_provide_download_link.3F
-               // And forum discussion :
-               // http://www.eclipse.org/forums/index.php?t=msg&th=205487&start=0&S=43d85dacc88b505402420592109c7240
-
-               try {
-                       if (log.isTraceEnabled())
-                               log.trace("URL : " + createFullDownloadUrl(fileName, fileId));
-
-                       URL url = new URL(createFullDownloadUrl(fileName, fileId));
-                       PlatformUI.getWorkbench().getBrowserSupport()
-                                       .createBrowser("DownloadDialog").openURL(url);
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-
-               // These lines are useless in the current use case but might be
-               // necessary with new browsers. Stored here for memo
-               // response.setContentType("application/force-download");
-               // response.setHeader("Content-Disposition", contentDisposition);
-               // response.setHeader("Content-Transfer-Encoding", "binary");
-               // response.setHeader("Pragma", "no-cache");
-               // response.setHeader("Cache-Control", "no-cache, must-revalidate");
-       }
-
-       private String createFullDownloadUrl(String fileName, String fileId) {
-               StringBuilder url = new StringBuilder();
-               // in case RAP is proxied we need to specify the actual base URL
-               // TODO find a cleaner way
-               String forcedDownloadUrlBase = System
-                               .getProperty(FORCED_DOWNLOAD_URL_BASE_PROPERTY);
-               if (forcedDownloadUrlBase != null)
-                       url.append(forcedDownloadUrlBase);
-               else
-                       url.append(RWT.getRequest().getRequestURL());
-               url.append(createParamUrl(fileName, fileId));
-               return url.toString();
-       }
-
-       private String createParamUrl(String filename, String fileId) {
-               StringBuilder url = new StringBuilder();
-               url.append("?");
-               url.append(IServiceHandler.REQUEST_PARAM);
-               url.append("=downloadServiceHandler");
-               url.append("&filename=");
-               url.append(filename);
-               url.append("&fileid=");
-               url.append(fileId);
-               String encodedURL = RWT.getResponse().encodeURL(url.toString());
-               return encodedURL;
-       }
-}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java
deleted file mode 100644 (file)
index ca7dc08..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import java.io.InputStream;
-
-/**
- * Used for file download : subclasses must implement model specific methods to
- * get a byte array representing a file given is ID.
- */
-public interface FileProvider {
-
-       public byte[] getByteArrayFileFromId(String fileId);
-
-       public InputStream getInputStreamFromFileId(String fileId);
-
-}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java
deleted file mode 100644 (file)
index 13e695d..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import java.io.InputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.eclipse.rwt.widgets.Upload;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-public class GenericUploadControl extends Composite {
-       private final static Log log = LogFactory
-                       .getLog(GenericUploadControl.class);
-
-       private Upload upload;
-
-       public GenericUploadControl(Composite parent, int style, String browseLabel) {
-               super(parent, style);
-               createControl(this, browseLabel);
-
-       }
-
-       private void createControl(Composite parent, String browseLabel) {
-               parent.setLayout(new GridLayout(1, false));
-               parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-               upload = new Upload(parent, SWT.BORDER);
-               upload.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-               upload.setBrowseButtonText(browseLabel);
-               // upload.addModifyListener(new UploadListener());
-               parent.pack();
-       }
-
-       /**
-        * Wrap upload.getLastFileUploaded(). Gets the name of the last uploaded
-        * file. This method can be called even if the upload has not finished yet.
-        */
-       public String getLastFileUploadedName() {
-               return upload.getLastFileUploaded();
-       }
-
-       public boolean isControlEmpty() {
-               String path = upload.getPath();
-               if (log.isTraceEnabled())
-                       log.trace("UploadControl chosen path : " + path);
-               if (path == null || "".equals(path.trim()))
-                       return true;
-               else
-                       return false;
-       }
-
-       public byte[] performUpload() {
-               boolean success = upload.performUpload();
-               if (success) {
-                       if (upload.getUploadItem().getFileSize() == -1)
-                               throw new ArgeoException("File "
-                                               + upload.getUploadItem().getFileName()
-                                               + " has not been uploaded, its size is -1");
-
-                       InputStream inStream = null;
-                       byte[] fileBA = null;
-                       try {
-                               inStream = upload.getUploadItem().getFileInputStream();
-                               fileBA = IOUtils.toByteArray(inStream);
-                       } catch (Exception e) {
-                               throw new ArgeoException("Cannot read uploaded data", e);
-                       } finally {
-                               IOUtils.closeQuietly(inStream);
-                       }
-                       return fileBA;
-               }
-               return null;
-       }
-
-       public void addModifyListener(ModifyListener listener) {
-               upload.addModifyListener(listener);
-       }
-
-       // private class UploadManager extends UploadAdapter {
-       // private Upload upload;
-       //
-       // public UploadManager(Upload upload) {
-       // super();
-       // this.upload = upload;
-       // }
-       //
-       // public void uploadFinished(UploadEvent uploadEvent) {
-       // handleUploadFinished(upload);
-       // }
-       //
-       // public void uploadInProgress(UploadEvent uploadEvent) {
-       // }
-       //
-       // public void uploadException(UploadEvent uploadEvent) {
-       // Exception exc = uploadEvent.getUploadException();
-       // if (exc != null) {
-       // MessageDialog.openError(Display.getCurrent().getActiveShell(),
-       // "Error", exc.getMessage());
-       // }
-       // }
-       //
-       // }
-       //
-
-}
diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java
deleted file mode 100644 (file)
index d087ebe..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Mathieu Baudier
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.eclipse.ui.specific;
-
-import java.io.InputStream;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.rwt.widgets.Upload;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public class ImportToServerWizardPage extends WizardPage {
-       private final static Log log = LogFactory
-                       .getLog(ImportToServerWizardPage.class);
-
-       public final static String FILE_ITEM_TYPE = "FILE";
-       public final static String FOLDER_ITEM_TYPE = "FOLDER";
-
-       private Upload uploadFile;
-
-       public ImportToServerWizardPage() {
-               super("Import from file system");
-               setDescription("Import files from the local file system to the server");
-       }
-
-       public void createControl(Composite parent) {
-               Composite composite = new Composite(parent, SWT.NONE);
-               composite.setLayout(new GridLayout(2, false));
-               composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-               new Label(composite, SWT.NONE).setText("Pick up a file");
-               uploadFile = new Upload(composite, SWT.BORDER);
-               uploadFile.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-               uploadFile.setBrowseButtonText("Open...");
-               setControl(composite);
-       }
-
-       public String getObjectPath() {
-               // NOTE Returns the full file name of the last uploaded file including
-               // the file path as selected by the user on his local machine.
-               // The full path including the directory and file drive are only
-               // returned, if the browser supports reading this properties. In Firefox
-               // 3, only the filename is returned.
-               return uploadFile.getPath();
-       }
-
-       public String getObjectName() {
-               return uploadFile.getUploadItem().getFileName();
-       }
-
-       public String getObjectType() {
-               return FILE_ITEM_TYPE;
-       }
-
-       public void performFinish() {
-               boolean success = uploadFile.performUpload();
-               if (!success)
-                       throw new ArgeoException("Cannot upload file named "
-                                       + uploadFile.getPath());
-       }
-
-       protected void handleUploadFinished(final Upload upload) {
-       }
-
-       public InputStream getFileInputStream() {
-               return uploadFile.getUploadItem().getFileInputStream();
-       }
-
-       public boolean getNeedsProgressMonitor() {
-               return false;
-       }
-
-}