New project conventions
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 25 Nov 2014 13:03:32 +0000 (13:03 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 25 Nov 2014 13:03:32 +0000 (13:03 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@7529 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

22 files changed:
org.argeo.eclipse.ui.rcp/.classpath
org.argeo.eclipse.ui.rcp/.settings/org.eclipse.jdt.core.prefs [deleted file]
org.argeo.eclipse.ui.rcp/bnd.bnd [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/build.properties
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/DefaultNLS.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/OpenFile.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ThreadNLS.java [deleted file]
org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java [deleted file]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileHandler.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileProvider.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ThreadNLS.java [new file with mode: 0644]
org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java [new file with mode: 0644]

index 8cf7f48a042a0cc96dfada5bf36efafd90b7b9e4..d2953a684d400476bf716ed6a6c3c3ae486fcd0e 100644 (file)
@@ -1,7 +1,9 @@
 <?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"/>
+       <classpathentry kind="src" path="src" />
+       <classpathentry kind="con"
+               path="org.eclipse.pde.core.requiredPlugins" />
+       <classpathentry kind="con"
+               path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" />
+       <classpathentry kind="output" path="bin" />
 </classpath>
diff --git a/org.argeo.eclipse.ui.rcp/.settings/org.eclipse.jdt.core.prefs b/org.argeo.eclipse.ui.rcp/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644 (file)
index b06d92e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#Tue Mar 01 19:20:51 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/org.argeo.eclipse.ui.rcp/bnd.bnd b/org.argeo.eclipse.ui.rcp/bnd.bnd
new file mode 100644 (file)
index 0000000..8e43cdf
--- /dev/null
@@ -0,0 +1,11 @@
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.argeo.eclipse.ui.ArgeoUiPlugin
+Require-Bundle: org.eclipse.ui,org.eclipse.core.runtime
+Import-Package: org.springframework.beans.factory,\
+org.springframework.core.io.support,\
+org.apache.commons.io,\
+org.argeo,\
+!org.eclipse.core.runtime,\
+!org.eclipse.core.commands,\
+!org.eclipse.ui.plugin,\
+*
index 886a20027b8e2964235765c2ea2c86e67fc2f641..fd806ca059ba42527df5276feeeec97eb6aef7be 100644 (file)
@@ -1,4 +1,2 @@
-source.. = src/main/java/
-output.. = target/classes/
-bin.includes = META-INF/,\
-               .,\
+source.. = src/
+output.. = bin/
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/DefaultNLS.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/DefaultNLS.java
deleted file mode 100644 (file)
index 71a0c89..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.osgi.util.NLS;
-
-/** RCP specific {@link NLS} to be extended */
-public class DefaultNLS extends NLS {
-       public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin";
-
-       public DefaultNLS() {
-               this(DEFAULT_BUNDLE_LOCATION);
-       }
-
-       public DefaultNLS(String bundleName) {
-               NLS.initializeMessages(bundleName, getClass());
-       }
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java
deleted file mode 100644 (file)
index 2642a35..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.ColumnViewer;
-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 for {@link ColumnViewer} in RCP
-        * 
-        * @see ColumnViewerToolTipSupport#enableFor(Viewer)
-        */
-       public static void enableToolTipSupport(Viewer viewer) {
-               if (viewer instanceof ColumnViewer)
-                       ColumnViewerToolTipSupport.enableFor((ColumnViewer) viewer);
-       }
-
-       private EclipseUiSpecificUtils() {
-       }
-
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileHandler.java
deleted file mode 100644 (file)
index 5da4973..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.awt.Desktop;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.ArgeoException;
-
-/**
- * Abstraction that enable to implement runtime environment specific (typically
- * RCP or RAP) methods while dealing with files in the UI.
- * 
- */
-public class FileHandler {
-
-       private FileProvider provider;
-
-       public FileHandler(FileProvider provider) {
-               this.provider = provider;
-       }
-
-       public void openFile(String fileName, String fileId) {
-               String tmpFileName = fileName;
-               String prefix = "", extension = "";
-               if (fileName != null) {
-                       int ind = fileName.lastIndexOf('.');
-                       if (ind > 0) {
-                               prefix = fileName.substring(0, ind);
-                               extension = fileName.substring(ind);
-                       }
-               }
-
-               InputStream is = null;
-               try {
-                       is = provider.getInputStreamFromFileId(fileId);
-                       File file = createTmpFile(prefix, extension, is);
-                       tmpFileName = file.getName();
-                       Desktop desktop = null;
-                       if (Desktop.isDesktopSupported()) {
-                               desktop = Desktop.getDesktop();
-                       }
-                       desktop.open(file);
-               } catch (IOException e) {
-                       // Note : tmpFileName = fileName if the error has been thrown while
-                       // creating the tmpFile.
-                       throw new ArgeoException("Cannot open file " + tmpFileName, e);
-               } finally {
-                       IOUtils.closeQuietly(is);
-               }
-       }
-
-       private File createTmpFile(String prefix, String suffix, InputStream is) {
-               File tmpFile = null;
-               OutputStream os = null;
-               try {
-                       tmpFile = File.createTempFile(prefix, suffix);
-                       os = new FileOutputStream(tmpFile);
-                       IOUtils.copy(is, os);
-               } catch (IOException e) {
-                       throw new ArgeoException("Cannot open file " + prefix + "."
-                                       + suffix, e);
-               } finally {
-                       IOUtils.closeQuietly(os);
-               }
-               return tmpFile;
-       }
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/FileProvider.java
deleted file mode 100644 (file)
index 5c92260..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.
- * 
- * @author bsinou
- * 
- */
-public interface FileProvider {
-
-       public byte[] getByteArrayFileFromId(String fileId);
-       
-       public InputStream getInputStreamFromFileId(String fileId);
-
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java
deleted file mode 100644 (file)
index 80e1e53..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.argeo.ArgeoException;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * RCP specific composite that provides a control to upload a file. WARNING: for
- * the time being we set a GridLayout(2, false) on th eparent control.
- */
-public class GenericUploadControl extends Composite {
-       // private final static Log log = LogFactory
-       // .getLog(GenericUploadControl.class);
-
-       private FileDialog dialog;
-       private Text filePath;
-
-       public GenericUploadControl(Composite parent, int style, String browseLabel) {
-               super(parent, style);
-               createControl(this, browseLabel);
-
-       }
-
-       private void createControl(final Composite parent, String browseLabel) {
-               parent.setLayout(new GridLayout(2, false));
-
-               filePath = new Text(parent, SWT.BORDER | SWT.SINGLE);
-               GridData gd = new GridData(GridData.GRAB_HORIZONTAL
-                               | GridData.FILL_HORIZONTAL);
-               filePath.setEditable(false);
-               filePath.setLayoutData(gd);
-
-               // Execute button
-               Button execute = new Button(parent, SWT.PUSH);
-               GridData gridData = new GridData();
-               gridData.horizontalAlignment = GridData.BEGINNING;
-               execute.setLayoutData(gridData);
-               execute.setText(browseLabel);
-
-               // Button listener
-               Listener executeListener = new Listener() {
-                       public void handleEvent(Event event) {
-                               dialog = new FileDialog(parent.getShell());
-                               filePath.setText(dialog.open());
-                       }
-               };
-               parent.layout();
-               execute.addListener(SWT.Selection, executeListener);
-       }
-
-       public boolean isControlEmpty() {
-               String path = filePath.getText();
-               if (path == null || "".equals(path.trim()))
-                       return true;
-               else
-                       return false;
-       }
-
-       public byte[] performUpload() {
-               String path = filePath.getText();
-               if (path != null) {
-                       try {
-                               File file = new File(path);
-                               byte[] fileBA = FileUtils.readFileToByteArray(file);
-                               return fileBA;
-                       } catch (IOException e) {
-                               throw new ArgeoException("Unexpected error while "
-                                               + "reading file at path " + path, e);
-                       }
-               }
-               return null;
-       }
-
-       public void addModifyListener(ModifyListener listener) {
-               filePath.addModifyListener(listener);
-       }
-
-       /**
-        * Always returns null in an RCP environment
-        */
-       public String getLastFileUploadedName() {
-               return null;
-       }
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java
deleted file mode 100644 (file)
index 55065bf..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-
-public class ImportToServerWizardPage extends WizardPage {
-
-       public final static String FILE_ITEM_TYPE = "FILE";
-       public final static String FOLDER_ITEM_TYPE = "FOLDER";
-
-       private DirectoryFieldEditor dfe;
-
-       public ImportToServerWizardPage() {
-               super("Import from file system");
-               setDescription("Import files from the local file system into the JCR repository");
-       }
-
-       public void createControl(Composite parent) {
-               dfe = new DirectoryFieldEditor("directory", "From", parent);
-               setControl(dfe.getTextControl(parent));
-       }
-
-       public String getObjectPath() {
-               return dfe.getStringValue();
-       }
-
-       public String getObjectType() {
-               return FOLDER_ITEM_TYPE;
-       }
-
-       public boolean getNeedsProgressMonitor() {
-               return true;
-       }
-
-       // Dummy methods : useless in RCP context but useful for RAP
-       /** WARNING : always return null in RCP context */
-       public String getObjectName() {
-               return null;
-       }
-
-       /** WARNING : do nothing in RCP context */
-       public void performFinish() {
-       }
-
-       /** WARNING : always return null in RCP context */
-       public InputStream getFileInputStream() {
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/OpenFile.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/OpenFile.java
deleted file mode 100644 (file)
index 610020d..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.awt.Desktop;
-import java.io.File;
-import java.io.IOException;
-
-import org.argeo.ArgeoException;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * RCP specific command handler to open a file.
- * 
- * The parameter "URI" is used to determine the correct method to open it.
- * 
- * Various instances of this handler with different command ID might coexist in
- * order to provide context specific open file service.
- * 
- */
-public class OpenFile extends AbstractHandler {
-       // private final static Log log = LogFactory.getLog(OpenFile.class);
-
-       public final static String PARAM_FILE_NAME = "param.fileName";
-       public final static String PARAM_FILE_URI = "param.fileURI";
-
-       private final static String FILE_SCHEME = "file";
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               @SuppressWarnings("unused")
-               @Deprecated
-               String fileName = event.getParameter(PARAM_FILE_NAME);
-               String fileUri = event.getParameter(PARAM_FILE_URI);
-
-               // sanity check
-               if (fileUri == null || "".equals(fileUri.trim()))
-                       return null;
-
-               Desktop desktop = null;
-               if (Desktop.isDesktopSupported()) {
-                       desktop = Desktop.getDesktop();
-               }
-
-               File file = getFileFromUri(fileUri);
-               if (file != null)
-                       try {
-                               desktop.open(file);
-                       } catch (IOException e) {
-                               throw new ArgeoException("Unable to open file with URI: "
-                                               + fileUri, e);
-                       }
-
-               return null;
-       }
-
-       protected File getFileFromUri(String uri) {
-               if (uri.startsWith(FILE_SCHEME)) {
-                       String path = uri.substring((FILE_SCHEME + "://").length());
-                       return new File(path);
-               }
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ThreadNLS.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/ThreadNLS.java
deleted file mode 100644 (file)
index c87f6e5..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.argeo.util.LocaleUtils;
-import org.eclipse.osgi.util.NLS;
-
-/** NLS attached to a given thread */
-public class ThreadNLS<T extends NLS> extends InheritableThreadLocal<T> {
-       public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin";
-
-       private final String bundleLocation;
-
-       private Class<T> type;
-       private Boolean utf8 = false;
-
-       public ThreadNLS(String bundleLocation, Class<T> type, Boolean utf8) {
-               this.bundleLocation = bundleLocation;
-               this.type = type;
-               this.utf8 = utf8;
-       }
-
-       public ThreadNLS(Class<T> type) {
-               this(DEFAULT_BUNDLE_LOCATION, type, false);
-       }
-
-       @Override
-       protected T initialValue() {
-               ResourceBundle bundle = ResourceBundle.getBundle(bundleLocation,
-                               LocaleUtils.threadLocale.get(), type.getClassLoader());
-               T result;
-               try {
-                       NLS.initializeMessages(bundleLocation, type);
-                       Constructor<T> constructor = type.getConstructor();
-                       constructor.setAccessible(true);
-                       result = constructor.newInstance();
-                       final Field[] fieldArray = type.getDeclaredFields();
-                       for (int i = 0; i < fieldArray.length; i++) {
-                               int modifiers = fieldArray[i].getModifiers();
-                               if (String.class.isAssignableFrom(fieldArray[i].getType())
-                                               && Modifier.isPublic(modifiers)
-                                               && !Modifier.isStatic(modifiers)) {
-                                       try {
-                                               String value = bundle
-                                                               .getString(fieldArray[i].getName());
-                                               byte[] bytes = value.getBytes();
-
-                                               String forcedValue;
-                                               if (utf8)
-                                                       forcedValue = new String(bytes, "UTF8");
-                                               else
-                                                       forcedValue = value;
-                                               if (value != null) {
-                                                       fieldArray[i].setAccessible(true);
-                                                       fieldArray[i].set(result, forcedValue);
-                                               }
-                                       } catch (final MissingResourceException mre) {
-                                               fieldArray[i].setAccessible(true);
-                                               fieldArray[i].set(result, "");
-                                               mre.printStackTrace();
-                                       }
-                               }
-                       }
-                       return result;
-               } catch (final Exception ex) {
-                       throw new IllegalStateException(ex.getMessage());
-               }
-       }
-
-}
diff --git a/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java b/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java
deleted file mode 100644 (file)
index 5bdaece..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * 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.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.widgets.Composite;
-
-public class UploadFileWizardPage extends WizardPage {
-
-       public final static String FILE_ITEM_TYPE = "FILE";
-       public final static String FOLDER_ITEM_TYPE = "FOLDER";
-
-       private DirectoryFieldEditor dfe;
-
-       public UploadFileWizardPage() {
-               super("Import from file system");
-               setDescription("Import files from the local file system into the JCR repository");
-       }
-
-       public void createControl(Composite parent) {
-               dfe = new DirectoryFieldEditor("directory", "From", parent);
-               setControl(dfe.getTextControl(parent));
-       }
-
-       public String getObjectPath() {
-               return dfe.getStringValue();
-       }
-
-       public String getObjectType() {
-               return FOLDER_ITEM_TYPE;
-       }
-
-       public boolean getNeedsProgressMonitor() {
-               return true;
-       }
-
-       // Dummy methods : useless in RCP context but useful for RAP
-       /** WARNING : always return null in RCP context */
-       public String getObjectName() {
-               return null;
-       }
-
-       /** WARNING : do nothing in RCP context */
-       public void performFinish() {
-       }
-
-       /** WARNING : always return null in RCP context */
-       public InputStream getFileInputStream() {
-               return null;
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/DefaultNLS.java
new file mode 100644 (file)
index 0000000..71a0c89
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.osgi.util.NLS;
+
+/** RCP specific {@link NLS} to be extended */
+public class DefaultNLS extends NLS {
+       public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin";
+
+       public DefaultNLS() {
+               this(DEFAULT_BUNDLE_LOCATION);
+       }
+
+       public DefaultNLS(String bundleName) {
+               NLS.initializeMessages(bundleName, getClass());
+       }
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/EclipseUiSpecificUtils.java
new file mode 100644 (file)
index 0000000..2642a35
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.ColumnViewer;
+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 for {@link ColumnViewer} in RCP
+        * 
+        * @see ColumnViewerToolTipSupport#enableFor(Viewer)
+        */
+       public static void enableToolTipSupport(Viewer viewer) {
+               if (viewer instanceof ColumnViewer)
+                       ColumnViewerToolTipSupport.enableFor((ColumnViewer) viewer);
+       }
+
+       private EclipseUiSpecificUtils() {
+       }
+
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileHandler.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileHandler.java
new file mode 100644 (file)
index 0000000..5da4973
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.awt.Desktop;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.ArgeoException;
+
+/**
+ * Abstraction that enable to implement runtime environment specific (typically
+ * RCP or RAP) methods while dealing with files in the UI.
+ * 
+ */
+public class FileHandler {
+
+       private FileProvider provider;
+
+       public FileHandler(FileProvider provider) {
+               this.provider = provider;
+       }
+
+       public void openFile(String fileName, String fileId) {
+               String tmpFileName = fileName;
+               String prefix = "", extension = "";
+               if (fileName != null) {
+                       int ind = fileName.lastIndexOf('.');
+                       if (ind > 0) {
+                               prefix = fileName.substring(0, ind);
+                               extension = fileName.substring(ind);
+                       }
+               }
+
+               InputStream is = null;
+               try {
+                       is = provider.getInputStreamFromFileId(fileId);
+                       File file = createTmpFile(prefix, extension, is);
+                       tmpFileName = file.getName();
+                       Desktop desktop = null;
+                       if (Desktop.isDesktopSupported()) {
+                               desktop = Desktop.getDesktop();
+                       }
+                       desktop.open(file);
+               } catch (IOException e) {
+                       // Note : tmpFileName = fileName if the error has been thrown while
+                       // creating the tmpFile.
+                       throw new ArgeoException("Cannot open file " + tmpFileName, e);
+               } finally {
+                       IOUtils.closeQuietly(is);
+               }
+       }
+
+       private File createTmpFile(String prefix, String suffix, InputStream is) {
+               File tmpFile = null;
+               OutputStream os = null;
+               try {
+                       tmpFile = File.createTempFile(prefix, suffix);
+                       os = new FileOutputStream(tmpFile);
+                       IOUtils.copy(is, os);
+               } catch (IOException e) {
+                       throw new ArgeoException("Cannot open file " + prefix + "."
+                                       + suffix, e);
+               } finally {
+                       IOUtils.closeQuietly(os);
+               }
+               return tmpFile;
+       }
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileProvider.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/FileProvider.java
new file mode 100644 (file)
index 0000000..5c92260
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.
+ * 
+ * @author bsinou
+ * 
+ */
+public interface FileProvider {
+
+       public byte[] getByteArrayFileFromId(String fileId);
+       
+       public InputStream getInputStreamFromFileId(String fileId);
+
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java
new file mode 100644 (file)
index 0000000..80e1e53
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.argeo.ArgeoException;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * RCP specific composite that provides a control to upload a file. WARNING: for
+ * the time being we set a GridLayout(2, false) on th eparent control.
+ */
+public class GenericUploadControl extends Composite {
+       // private final static Log log = LogFactory
+       // .getLog(GenericUploadControl.class);
+
+       private FileDialog dialog;
+       private Text filePath;
+
+       public GenericUploadControl(Composite parent, int style, String browseLabel) {
+               super(parent, style);
+               createControl(this, browseLabel);
+
+       }
+
+       private void createControl(final Composite parent, String browseLabel) {
+               parent.setLayout(new GridLayout(2, false));
+
+               filePath = new Text(parent, SWT.BORDER | SWT.SINGLE);
+               GridData gd = new GridData(GridData.GRAB_HORIZONTAL
+                               | GridData.FILL_HORIZONTAL);
+               filePath.setEditable(false);
+               filePath.setLayoutData(gd);
+
+               // Execute button
+               Button execute = new Button(parent, SWT.PUSH);
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.BEGINNING;
+               execute.setLayoutData(gridData);
+               execute.setText(browseLabel);
+
+               // Button listener
+               Listener executeListener = new Listener() {
+                       public void handleEvent(Event event) {
+                               dialog = new FileDialog(parent.getShell());
+                               filePath.setText(dialog.open());
+                       }
+               };
+               parent.layout();
+               execute.addListener(SWT.Selection, executeListener);
+       }
+
+       public boolean isControlEmpty() {
+               String path = filePath.getText();
+               if (path == null || "".equals(path.trim()))
+                       return true;
+               else
+                       return false;
+       }
+
+       public byte[] performUpload() {
+               String path = filePath.getText();
+               if (path != null) {
+                       try {
+                               File file = new File(path);
+                               byte[] fileBA = FileUtils.readFileToByteArray(file);
+                               return fileBA;
+                       } catch (IOException e) {
+                               throw new ArgeoException("Unexpected error while "
+                                               + "reading file at path " + path, e);
+                       }
+               }
+               return null;
+       }
+
+       public void addModifyListener(ModifyListener listener) {
+               filePath.addModifyListener(listener);
+       }
+
+       /**
+        * Always returns null in an RCP environment
+        */
+       public String getLastFileUploadedName() {
+               return null;
+       }
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ImportToServerWizardPage.java
new file mode 100644 (file)
index 0000000..55065bf
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+public class ImportToServerWizardPage extends WizardPage {
+
+       public final static String FILE_ITEM_TYPE = "FILE";
+       public final static String FOLDER_ITEM_TYPE = "FOLDER";
+
+       private DirectoryFieldEditor dfe;
+
+       public ImportToServerWizardPage() {
+               super("Import from file system");
+               setDescription("Import files from the local file system into the JCR repository");
+       }
+
+       public void createControl(Composite parent) {
+               dfe = new DirectoryFieldEditor("directory", "From", parent);
+               setControl(dfe.getTextControl(parent));
+       }
+
+       public String getObjectPath() {
+               return dfe.getStringValue();
+       }
+
+       public String getObjectType() {
+               return FOLDER_ITEM_TYPE;
+       }
+
+       public boolean getNeedsProgressMonitor() {
+               return true;
+       }
+
+       // Dummy methods : useless in RCP context but useful for RAP
+       /** WARNING : always return null in RCP context */
+       public String getObjectName() {
+               return null;
+       }
+
+       /** WARNING : do nothing in RCP context */
+       public void performFinish() {
+       }
+
+       /** WARNING : always return null in RCP context */
+       public InputStream getFileInputStream() {
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/OpenFile.java
new file mode 100644 (file)
index 0000000..610020d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.awt.Desktop;
+import java.io.File;
+import java.io.IOException;
+
+import org.argeo.ArgeoException;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * RCP specific command handler to open a file.
+ * 
+ * The parameter "URI" is used to determine the correct method to open it.
+ * 
+ * Various instances of this handler with different command ID might coexist in
+ * order to provide context specific open file service.
+ * 
+ */
+public class OpenFile extends AbstractHandler {
+       // private final static Log log = LogFactory.getLog(OpenFile.class);
+
+       public final static String PARAM_FILE_NAME = "param.fileName";
+       public final static String PARAM_FILE_URI = "param.fileURI";
+
+       private final static String FILE_SCHEME = "file";
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               @SuppressWarnings("unused")
+               @Deprecated
+               String fileName = event.getParameter(PARAM_FILE_NAME);
+               String fileUri = event.getParameter(PARAM_FILE_URI);
+
+               // sanity check
+               if (fileUri == null || "".equals(fileUri.trim()))
+                       return null;
+
+               Desktop desktop = null;
+               if (Desktop.isDesktopSupported()) {
+                       desktop = Desktop.getDesktop();
+               }
+
+               File file = getFileFromUri(fileUri);
+               if (file != null)
+                       try {
+                               desktop.open(file);
+                       } catch (IOException e) {
+                               throw new ArgeoException("Unable to open file with URI: "
+                                               + fileUri, e);
+                       }
+
+               return null;
+       }
+
+       protected File getFileFromUri(String uri) {
+               if (uri.startsWith(FILE_SCHEME)) {
+                       String path = uri.substring((FILE_SCHEME + "://").length());
+                       return new File(path);
+               }
+               return null;
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ThreadNLS.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/ThreadNLS.java
new file mode 100644 (file)
index 0000000..c87f6e5
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.argeo.util.LocaleUtils;
+import org.eclipse.osgi.util.NLS;
+
+/** NLS attached to a given thread */
+public class ThreadNLS<T extends NLS> extends InheritableThreadLocal<T> {
+       public final static String DEFAULT_BUNDLE_LOCATION = "/properties/plugin";
+
+       private final String bundleLocation;
+
+       private Class<T> type;
+       private Boolean utf8 = false;
+
+       public ThreadNLS(String bundleLocation, Class<T> type, Boolean utf8) {
+               this.bundleLocation = bundleLocation;
+               this.type = type;
+               this.utf8 = utf8;
+       }
+
+       public ThreadNLS(Class<T> type) {
+               this(DEFAULT_BUNDLE_LOCATION, type, false);
+       }
+
+       @Override
+       protected T initialValue() {
+               ResourceBundle bundle = ResourceBundle.getBundle(bundleLocation,
+                               LocaleUtils.threadLocale.get(), type.getClassLoader());
+               T result;
+               try {
+                       NLS.initializeMessages(bundleLocation, type);
+                       Constructor<T> constructor = type.getConstructor();
+                       constructor.setAccessible(true);
+                       result = constructor.newInstance();
+                       final Field[] fieldArray = type.getDeclaredFields();
+                       for (int i = 0; i < fieldArray.length; i++) {
+                               int modifiers = fieldArray[i].getModifiers();
+                               if (String.class.isAssignableFrom(fieldArray[i].getType())
+                                               && Modifier.isPublic(modifiers)
+                                               && !Modifier.isStatic(modifiers)) {
+                                       try {
+                                               String value = bundle
+                                                               .getString(fieldArray[i].getName());
+                                               byte[] bytes = value.getBytes();
+
+                                               String forcedValue;
+                                               if (utf8)
+                                                       forcedValue = new String(bytes, "UTF8");
+                                               else
+                                                       forcedValue = value;
+                                               if (value != null) {
+                                                       fieldArray[i].setAccessible(true);
+                                                       fieldArray[i].set(result, forcedValue);
+                                               }
+                                       } catch (final MissingResourceException mre) {
+                                               fieldArray[i].setAccessible(true);
+                                               fieldArray[i].set(result, "");
+                                               mre.printStackTrace();
+                                       }
+                               }
+                       }
+                       return result;
+               } catch (final Exception ex) {
+                       throw new IllegalStateException(ex.getMessage());
+               }
+       }
+
+}
diff --git a/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java b/org.argeo.eclipse.ui.rcp/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java
new file mode 100644 (file)
index 0000000..5bdaece
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * 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.eclipse.jface.preference.DirectoryFieldEditor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+public class UploadFileWizardPage extends WizardPage {
+
+       public final static String FILE_ITEM_TYPE = "FILE";
+       public final static String FOLDER_ITEM_TYPE = "FOLDER";
+
+       private DirectoryFieldEditor dfe;
+
+       public UploadFileWizardPage() {
+               super("Import from file system");
+               setDescription("Import files from the local file system into the JCR repository");
+       }
+
+       public void createControl(Composite parent) {
+               dfe = new DirectoryFieldEditor("directory", "From", parent);
+               setControl(dfe.getTextControl(parent));
+       }
+
+       public String getObjectPath() {
+               return dfe.getStringValue();
+       }
+
+       public String getObjectType() {
+               return FOLDER_ITEM_TYPE;
+       }
+
+       public boolean getNeedsProgressMonitor() {
+               return true;
+       }
+
+       // Dummy methods : useless in RCP context but useful for RAP
+       /** WARNING : always return null in RCP context */
+       public String getObjectName() {
+               return null;
+       }
+
+       /** WARNING : do nothing in RCP context */
+       public void performFinish() {
+       }
+
+       /** WARNING : always return null in RCP context */
+       public InputStream getFileInputStream() {
+               return null;
+       }
+}
\ No newline at end of file