From: Bruno Sinou Date: Tue, 22 Mar 2011 19:38:36 +0000 (+0000) Subject: Update SEBI : X-Git-Tag: argeo-commons-2.1.30~1329 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=0f850ec640d64f9063943afee056176489a16119;p=lgpl%2Fargeo-commons.git Update SEBI : + finalize platform specific upload component + update rap launcher + finalize import wizard + some slight picture and grafical improvment git-svn-id: https://svn.argeo.org/commons/trunk@4339 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/demo/argeo-node-web.properties b/demo/argeo-node-web.properties index cdc985398..02070532d 100644 --- a/demo/argeo-node-web.properties +++ b/demo/argeo-node-web.properties @@ -9,13 +9,18 @@ org.argeo.security.services.admin,\ org.argeo.security.equinox,\ org.eclipse.core.runtime,\ org.eclipse.equinox.common,\ +org.eclipse.equinox.http.registry,\ org.eclipse.equinox.launcher,\ -org.springframework.osgi.web.extender,\ org.argeo.dep.osgi.catalina.start,\ org.argeo.jackrabbit.webapp,\ -org.eclipse.equinox.http.registry,\ -org.argeo.server.osgi.webapp,\ org.argeo.jcr.ui.explorer,\ +org.argeo.node.repo.jackrabbit,\ +org.argeo.security.dao.ldap,\ +org.argeo.security.equinox,\ +org.argeo.security.services,\ +org.argeo.security.services.admin,\ +org.argeo.server.ads.server,\ +org.argeo.server.osgi.webapp,\ org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective 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 new file mode 100644 index 000000000..6fcd21a89 --- /dev/null +++ b/eclipse/runtime/org.argeo.eclipse.ui.rap/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java @@ -0,0 +1,97 @@ +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(); + } + + 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) { + 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.rcp/pom.xml b/eclipse/runtime/org.argeo.eclipse.ui.rcp/pom.xml index 65f75a217..37f3977e9 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui.rcp/pom.xml +++ b/eclipse/runtime/org.argeo.eclipse.ui.rcp/pom.xml @@ -76,5 +76,10 @@ com.springsource.org.apache.commons.io + + + org.slf4j + com.springsource.slf4j.org.apache.commons.logging + \ No newline at end of file diff --git a/eclipse/runtime/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/eclipse/runtime/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java new file mode 100644 index 000000000..8393006f6 --- /dev/null +++ b/eclipse/runtime/org.argeo.eclipse.ui.rcp/src/main/java/org/argeo/eclipse/ui/specific/GenericUploadControl.java @@ -0,0 +1,113 @@ +package org.argeo.eclipse.ui.specific; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +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; + +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) { + Composite composite = new Composite(parent, SWT.FILL); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + filePath = new Text(parent, SWT.BORDER | SWT.SINGLE); + filePath.setEnabled(false); + + // 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()); + dialog.open(); + + } + }; + + 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) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return null; + } + + public void addModifyListener(ModifyListener listener) { + filePath.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()); + // } + // } + // + // } + // + +}