Code cleaning to prepare 2.2 release
authorBruno Sinou <bsinou@argeo.org>
Fri, 2 Dec 2016 10:22:49 +0000 (10:22 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 2 Dec 2016 10:22:49 +0000 (10:22 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@9346 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

31 files changed:
org.argeo.cms.ui.workbench.rap/META-INF/spring/commands.xml
org.argeo.cms.ui.workbench.rap/plugin.xml
org.argeo.cms.ui.workbench.rap/pom.xml
org.argeo.cms.ui.workbench/bnd.bnd
org.argeo.cms.ui.workbench/plugin.xml
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/commands/OpenChangePasswordDialog.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/commands/OpenFile.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/WorkbenchConstants.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/GenericNodeDoubleClickListener.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrDClickListener.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrTreeContentProvider.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/SingleNodeAsTreeContentProvider.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ConfigurableNodeDump.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/DumpNode.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/NodeConfigurableDump.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ChildNodesPage.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ChooseNameDialog.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/EmptyNodePage.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/GenericNodeEditorInput.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ImportFileSystemWizard.java [deleted file]
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/NodeVersionHistoryPage.java
org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/jcr/JcrBrowserView.java
org.argeo.cms.ui/bnd.bnd
org.argeo.eclipse.ui.rap/bnd.bnd
org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java [deleted file]
org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/OpenFile.java
org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/OpenFileService.java
org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java [deleted file]
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/SingleSourcingConstants.java [new file with mode: 0644]
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java

index d16946fe7647bdc4407a32cbc3a3906fb368eceb..d9c72b419b22fe895df5db305c278c137d927f5f 100644 (file)
        </bean>
 
        <!-- RAP Specific command and corresponding service to enable open file -->
-       <bean id="org.argeo.cms.ui.workbench.openFile" class="org.argeo.cms.ui.workbench.commands.OpenFile"
+       <bean id="org.argeo.cms.ui.workbench.openFile" class="org.argeo.eclipse.ui.specific.OpenFile"
                scope="prototype">
                <property name="openFileServiceId"
                        value="org.argeo.security.ui.specific.openFileService" />
        </bean>
-       <!-- Useless - nothing to inject -->
-       <!-- <bean id="org.argeo.security.ui.specific.openFileService" class="org.argeo.eclipse.ui.specific.OpenFileService" 
-               scope="prototype"> </bean> -->
 </beans>
index adb4a6ec5b9d67741562d246e488a8662e112ca4..6dc4ba0ef3e3a088852e6b29176b5e3166265979 100644 (file)
                        id="param.fileURI"
                        name="The URI of this file on the server">
                        </commandParameter>
-                       <commandParameter
-                       id="param.filePath"
-                       name="The absolute path of this file on the server file system">
-                       </commandParameter>
                </command>
        </extension>
 
index 4d1876a817902a665f37f701b958070fdc97cb8f..eb6cfca9065f980d6e349003b7bf2ca458e5a1c6 100644 (file)
@@ -1,5 +1,6 @@
 <?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">
+<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</groupId>
@@ -16,6 +17,7 @@
                        <artifactId>org.argeo.cms.ui.workbench</artifactId>
                        <version>2.1.51-SNAPSHOT</version>
                </dependency>
+               <!-- RAP specific -->
                <dependency>
                        <groupId>org.argeo.commons</groupId>
                        <artifactId>org.argeo.eclipse.ui.rap</artifactId>
index 3a91b6aa2ad1932087762396c87ab00674eb4a1f..d5dc91e3096b30da143c42be8696720f462e4326 100644 (file)
@@ -7,6 +7,7 @@ org.eclipse.core.commands
 
 Import-Package:        org.argeo.cms.auth,\
 org.argeo.eclipse.spring,\
+org.argeo.eclipse.ui.utils,\
 org.eclipse.core.runtime.jobs,\
 org.eclipse.jface.window,\
 org.eclipse.swt,\
index f012695b81942af54674096104b79f1cf66621c3..cb50d4909d275aaf8ce1dd1db79dce3598a19394 100644 (file)
                name="Rename Current Selected Node">
                </command>
                <command
-               defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.NodeConfigurableDump"
+               defaultHandler="org.argeo.cms.ui.workbench.internal.jcr.commands.ConfigurableNodeDump"
                id="org.argeo.cms.ui.workbench.nodeConfigurableDump"
                name="Configurable dump of the selected Node">
                </command>
index cd48598746c3e30dd6bff7201626ba1f679a6489..f8c93693875c73cc65fdcc07e780f10dd07787ba 100644 (file)
@@ -124,6 +124,7 @@ public class OpenChangePasswordDialog extends AbstractHandler {
 
                        setMessage(changePassword.lead(), INFORMATION);
                        parent.pack();
+                       oldPassword.setFocus();
                        return composite;
                }
 
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/commands/OpenFile.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/commands/OpenFile.java
deleted file mode 100644 (file)
index 2b88c9d..0000000
+++ /dev/null
@@ -1,74 +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.cms.ui.workbench.commands;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.eclipse.ui.specific.OpenFileService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * RWT specific command handler to open a file retrieved from the server. It
- * forwards the request to the correct service after encoding file name and path
- * in the request URI.
- * 
- * <p>
- * The parameter "URI" is used to determine the correct file service, the path
- * and the file name. An optional file name can be precised to present a
- * different file name as the one used to retrieve it to the end user.
- * </p>
- * 
- * <p>
- * Various instances of this handler with different command ID might coexist in
- * order to provide context specific download service.
- * </p>
- * 
- * <p>
- * The instance specific service is called by its ID and must have been
- * externally created
- * </p>
- */
-public class OpenFile extends AbstractHandler {
-       // private final static Log log = LogFactory.getLog(OpenFile.class);
-       public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".openFile";
-
-       public final static String PARAM_FILE_NAME = OpenFileService.PARAM_FILE_NAME;
-       public final static String PARAM_FILE_URI = OpenFileService.PARAM_FILE_URI; // "param.fileURI";
-       /* DEPENDENCY INJECTION */
-       private String openFileServiceId;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               String fileName = event.getParameter(PARAM_FILE_NAME);
-               String fileUri = event.getParameter(PARAM_FILE_URI);
-               // Sanity check
-               if (fileUri == null || "".equals(fileUri.trim())
-                               || openFileServiceId == null
-                               || "".equals(openFileServiceId.trim()))
-                       return null;
-
-               org.argeo.eclipse.ui.specific.OpenFile openFileClient = new org.argeo.eclipse.ui.specific.OpenFile();
-               openFileClient.execute(openFileServiceId, fileUri, fileName);
-
-               return null;
-       }
-
-       /* DEPENDENCY INJECTION */
-       public void setOpenFileServiceId(String openFileServiceId) {
-               this.openFileServiceId = openFileServiceId;
-       }
-}
index 43cf1074dc92c075a6dd9aa2df14c72db1225684..441d5d10afe06a4876792de838e4b0bd7985b4a0 100644 (file)
@@ -17,9 +17,6 @@ package org.argeo.cms.ui.workbench.internal;
 
 /** Constants used across the application. */
 public interface WorkbenchConstants {
-       /*
-        * MISCEALLENEOUS
-        */
+       // MISCEALLENEOUS
        public final static String DATE_TIME_FORMAT = "dd/MM/yyyy, HH:mm";
-
 }
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/GenericNodeDoubleClickListener.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/GenericNodeDoubleClickListener.java
deleted file mode 100644 (file)
index 3cacd5d..0000000
+++ /dev/null
@@ -1,147 +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.cms.ui.workbench.internal.jcr;
-
-import static javax.jcr.Node.JCR_CONTENT;
-import static javax.jcr.Property.JCR_DATA;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.commands.OpenFile;
-import org.argeo.cms.ui.workbench.internal.jcr.model.RepositoryElem;
-import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
-import org.argeo.cms.ui.workbench.internal.jcr.model.WorkspaceElem;
-import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodeEditorInput;
-import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
-import org.argeo.cms.ui.workbench.util.CommandUtils;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.specific.SingleSourcingException;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.ui.PartInitException;
-
-/** Centralizes the management of double click on a NodeTreeViewer */
-public class GenericNodeDoubleClickListener implements IDoubleClickListener {
-       // private final static Log log = LogFactory
-       // .getLog(GenericNodeDoubleClickListener.class);
-
-       private TreeViewer nodeViewer;
-
-       // private JcrFileProvider jfp;
-       // private FileHandler fileHandler;
-
-       public GenericNodeDoubleClickListener(TreeViewer nodeViewer) {
-               this.nodeViewer = nodeViewer;
-               // jfp = new JcrFileProvider();
-               // Commented out. see https://www.argeo.org/bugzilla/show_bug.cgi?id=188
-               // fileHandler = null;
-               // fileHandler = new FileHandler(jfp);
-       }
-
-       public void doubleClick(DoubleClickEvent event) {
-               if (event.getSelection() == null || event.getSelection().isEmpty())
-                       return;
-               Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
-               if (obj instanceof RepositoryElem) {
-                       RepositoryElem rpNode = (RepositoryElem) obj;
-                       if (!rpNode.isConnected()) {
-                               rpNode.login();
-                               nodeViewer.refresh(obj);
-                       }
-               } else if (obj instanceof WorkspaceElem) {
-                       WorkspaceElem wn = (WorkspaceElem) obj;
-                       if (wn.isConnected())
-                               wn.logout();
-                       else
-                               wn.login();
-                       nodeViewer.refresh(obj);
-               } else if (obj instanceof SingleJcrNodeElem) {
-                       SingleJcrNodeElem sjn = (SingleJcrNodeElem) obj;
-                       Node node = sjn.getNode();
-                       try {
-                               if (node.isNodeType(NodeType.NT_FILE)) {
-                                       // Also open it
-
-                                       String name = node.getName();
-                                       Map<String, String> params = new HashMap<String, String>();
-                                       params.put(OpenFile.PARAM_FILE_NAME, name);
-
-                                       // TODO rather directly transmit the path to the node, once
-                                       // we have defined convention to provide an Absolute URI to
-                                       // a node in a multi repo / workspace / user context
-                                       // params.put(OpenFile.PARAM_FILE_URI,
-                                       // OpenFileService.JCR_SCHEME + node.getPath());
-
-                                       // we copy the node to a tmp file to be opened as a dirty
-                                       // workaround
-                                       File tmpFile = null;
-                                       OutputStream os = null;
-                                       InputStream is = null;
-                                       int i = name.lastIndexOf('.');
-                                       String prefix, suffix;
-                                       if (i == -1) {
-                                               prefix = name;
-                                               suffix = null;
-                                       } else {
-                                               prefix = name.substring(0, i);
-                                               suffix = name.substring(i);
-                                       }
-                                       try {
-                                               tmpFile = File.createTempFile(prefix, suffix);
-                                               tmpFile.deleteOnExit();
-                                               os = new FileOutputStream(tmpFile);
-                                               Binary binary = node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();
-                                               is = binary.getStream();
-                                               IOUtils.copy(is, os);
-                                       } catch (IOException e) {
-                                               throw new SingleSourcingException("Cannot open file " + prefix + "." + suffix, e);
-                                       } finally {
-                                               IOUtils.closeQuietly(is);
-                                               IOUtils.closeQuietly(os);
-                                       }
-                                       Path path = Paths.get(tmpFile.getAbsolutePath());
-                                       String uri = path.toUri().toString();
-                                       params.put(OpenFile.PARAM_FILE_URI, uri);
-                                       CommandUtils.callCommand(OpenFile.ID, params);
-                               }
-                               GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
-                               WorkbenchUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
-                                               .openEditor(gnei, DefaultNodeEditor.ID);
-                       } catch (RepositoryException re) {
-                               throw new EclipseUiException("Repository error while getting node info", re);
-                       } catch (PartInitException pie) {
-                               throw new EclipseUiException("Unexepected exception while opening node editor", pie);
-                       }
-               }
-       }
-}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrDClickListener.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrDClickListener.java
new file mode 100644 (file)
index 0000000..7c06db9
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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.cms.ui.workbench.internal.jcr;
+
+import static javax.jcr.Node.JCR_CONTENT;
+import static javax.jcr.Property.JCR_DATA;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
+import org.argeo.cms.ui.workbench.internal.jcr.model.RepositoryElem;
+import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
+import org.argeo.cms.ui.workbench.internal.jcr.model.WorkspaceElem;
+import org.argeo.cms.ui.workbench.internal.jcr.parts.GenericNodeEditorInput;
+import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
+import org.argeo.cms.ui.workbench.util.CommandUtils;
+import org.argeo.eclipse.ui.EclipseUiException;
+import org.argeo.eclipse.ui.specific.OpenFile;
+import org.argeo.eclipse.ui.specific.SingleSourcingException;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.PartInitException;
+
+/** Centralizes the management of double click on a NodeTreeViewer */
+public class JcrDClickListener implements IDoubleClickListener {
+       // private final static Log log = LogFactory
+       // .getLog(GenericNodeDoubleClickListener.class);
+
+       private TreeViewer nodeViewer;
+
+       // private JcrFileProvider jfp;
+       // private FileHandler fileHandler;
+
+       public JcrDClickListener(TreeViewer nodeViewer) {
+               this.nodeViewer = nodeViewer;
+               // jfp = new JcrFileProvider();
+               // Commented out. see https://www.argeo.org/bugzilla/show_bug.cgi?id=188
+               // fileHandler = null;
+               // fileHandler = new FileHandler(jfp);
+       }
+
+       public void doubleClick(DoubleClickEvent event) {
+               if (event.getSelection() == null || event.getSelection().isEmpty())
+                       return;
+               Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement();
+               if (obj instanceof RepositoryElem) {
+                       RepositoryElem rpNode = (RepositoryElem) obj;
+                       if (!rpNode.isConnected()) {
+                               rpNode.login();
+                               nodeViewer.refresh(obj);
+                       }
+               } else if (obj instanceof WorkspaceElem) {
+                       WorkspaceElem wn = (WorkspaceElem) obj;
+                       if (wn.isConnected())
+                               wn.logout();
+                       else
+                               wn.login();
+                       nodeViewer.refresh(obj);
+               } else if (obj instanceof SingleJcrNodeElem) {
+                       SingleJcrNodeElem sjn = (SingleJcrNodeElem) obj;
+                       Node node = sjn.getNode();
+                       try {
+                               if (node.isNodeType(NodeType.NT_FILE)) {
+                                       // Also open it
+
+                                       String name = node.getName();
+                                       Map<String, String> params = new HashMap<String, String>();
+                                       params.put(OpenFile.PARAM_FILE_NAME, name);
+
+                                       // TODO rather directly transmit the path to the node, once
+                                       // we have defined convention to provide an Absolute URI to
+                                       // a node in a multi repo / workspace / user context
+                                       // params.put(OpenFile.PARAM_FILE_URI,
+                                       // OpenFileService.JCR_SCHEME + node.getPath());
+
+                                       // we copy the node to a tmp file to be opened as a dirty
+                                       // workaround
+                                       File tmpFile = null;
+                                       OutputStream os = null;
+                                       InputStream is = null;
+                                       int i = name.lastIndexOf('.');
+                                       String prefix, suffix;
+                                       if (i == -1) {
+                                               prefix = name;
+                                               suffix = null;
+                                       } else {
+                                               prefix = name.substring(0, i);
+                                               suffix = name.substring(i);
+                                       }
+                                       try {
+                                               tmpFile = File.createTempFile(prefix, suffix);
+                                               tmpFile.deleteOnExit();
+                                               os = new FileOutputStream(tmpFile);
+                                               Binary binary = node.getNode(JCR_CONTENT).getProperty(JCR_DATA).getBinary();
+                                               is = binary.getStream();
+                                               IOUtils.copy(is, os);
+                                       } catch (IOException e) {
+                                               throw new SingleSourcingException("Cannot open file " + prefix + "." + suffix, e);
+                                       } finally {
+                                               IOUtils.closeQuietly(is);
+                                               IOUtils.closeQuietly(os);
+                                       }
+                                       Path path = Paths.get(tmpFile.getAbsolutePath());
+                                       String uri = path.toUri().toString();
+                                       params.put(OpenFile.PARAM_FILE_URI, uri);
+                                       CommandUtils.callCommand(OpenFile.ID, params);
+                               }
+                               GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
+                               WorkbenchUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                                               .openEditor(gnei, DefaultNodeEditor.ID);
+                       } catch (RepositoryException re) {
+                               throw new EclipseUiException("Repository error while getting node info", re);
+                       } catch (PartInitException pie) {
+                               throw new EclipseUiException("Unexepected exception while opening node editor", pie);
+                       }
+               }
+       }
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrTreeContentProvider.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/JcrTreeContentProvider.java
new file mode 100644 (file)
index 0000000..599da9b
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.cms.ui.workbench.internal.jcr;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+import org.argeo.eclipse.ui.EclipseUiException;
+import org.argeo.eclipse.ui.jcr.utils.JcrItemsComparator;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Implementation of the {@code ITreeContentProvider} in order to display a
+ * single JCR node and its children in a tree like structure
+ */
+public class JcrTreeContentProvider implements ITreeContentProvider {
+       private static final long serialVersionUID = -2128326504754297297L;
+       // private Node rootNode;
+       private JcrItemsComparator itemComparator = new JcrItemsComparator();
+
+       /**
+        * Sends back the first level of the Tree. input element must be a single
+        * node object
+        */
+       public Object[] getElements(Object inputElement) {
+               try {
+                       Node rootNode = (Node) inputElement;
+                       List<Node> result = new ArrayList<Node>();
+                       NodeIterator ni = rootNode.getNodes();
+                       while (ni.hasNext())
+                               result.add(ni.nextNode());
+                       return result.toArray();
+               } catch (RepositoryException re) {
+                       throw new EclipseUiException("Unable to retrieve elements for " + inputElement, re);
+               }
+       }
+
+       public Object[] getChildren(Object parentElement) {
+               return childrenNodes((Node) parentElement);
+       }
+
+       public Object getParent(Object element) {
+               try {
+                       Node node = (Node) element;
+                       if (!node.getPath().equals("/"))
+                               return node.getParent();
+                       else
+                               return null;
+               } catch (RepositoryException e) {
+                       return null;
+               }
+       }
+
+       public boolean hasChildren(Object element) {
+               try {
+                       return ((Node) element).hasNodes();
+               } catch (RepositoryException e) {
+                       throw new EclipseUiException("Cannot check children existence on " + element, e);
+               }
+       }
+
+       protected Object[] childrenNodes(Node parentNode) {
+               try {
+                       List<Node> children = new ArrayList<Node>();
+                       NodeIterator nit = parentNode.getNodes();
+                       while (nit.hasNext())
+                               children.add(nit.nextNode());
+                       Node[] arr = children.toArray(new Node[0]);
+                       Arrays.sort(arr, itemComparator);
+                       return arr;
+               } catch (RepositoryException e) {
+                       throw new EclipseUiException("Cannot list children of " + parentNode, e);
+               }
+       }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/SingleNodeAsTreeContentProvider.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/SingleNodeAsTreeContentProvider.java
deleted file mode 100644 (file)
index 83ada24..0000000
+++ /dev/null
@@ -1,100 +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.cms.ui.workbench.internal.jcr;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.jcr.utils.JcrItemsComparator;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Implementation of the {@code ITreeContentProvider} in order to display a
- * single JCR node and its children in a tree like structure
- */
-public class SingleNodeAsTreeContentProvider implements ITreeContentProvider {
-       private static final long serialVersionUID = -2128326504754297297L;
-       // private Node rootNode;
-       private JcrItemsComparator itemComparator = new JcrItemsComparator();
-
-       /**
-        * Sends back the first level of the Tree. input element must be a single
-        * node object
-        */
-       public Object[] getElements(Object inputElement) {
-               try {
-                       Node rootNode = (Node) inputElement;
-                       List<Node> result = new ArrayList<Node>();
-                       NodeIterator ni = rootNode.getNodes();
-                       while (ni.hasNext())
-                               result.add(ni.nextNode());
-                       return result.toArray();
-               } catch (RepositoryException re) {
-                       throw new EclipseUiException("Unable to retrieve elements for " + inputElement, re);
-               }
-       }
-
-       public Object[] getChildren(Object parentElement) {
-               return childrenNodes((Node) parentElement);
-       }
-
-       public Object getParent(Object element) {
-               try {
-                       Node node = (Node) element;
-                       if (!node.getPath().equals("/"))
-                               return node.getParent();
-                       else
-                               return null;
-               } catch (RepositoryException e) {
-                       return null;
-               }
-       }
-
-       public boolean hasChildren(Object element) {
-               try {
-                       return ((Node) element).hasNodes();
-               } catch (RepositoryException e) {
-                       throw new EclipseUiException("Cannot check children existence on " + element, e);
-               }
-       }
-
-       protected Object[] childrenNodes(Node parentNode) {
-               try {
-                       List<Node> children = new ArrayList<Node>();
-                       NodeIterator nit = parentNode.getNodes();
-                       while (nit.hasNext())
-                               children.add(nit.nextNode());
-                       Node[] arr = children.toArray(new Node[0]);
-                       Arrays.sort(arr, itemComparator);
-                       return arr;
-               } catch (RepositoryException e) {
-                       throw new EclipseUiException("Cannot list children of " + parentNode, e);
-               }
-       }
-
-       public void dispose() {
-       }
-
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-       }
-}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ConfigurableNodeDump.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/ConfigurableNodeDump.java
new file mode 100644 (file)
index 0000000..282ed4c
--- /dev/null
@@ -0,0 +1,295 @@
+/*
+ * 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.cms.ui.workbench.internal.jcr.commands;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+
+import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
+import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
+import org.argeo.eclipse.ui.EclipseUiException;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.jcr.JcrUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * First draft of a wizard that enable configurable recursive dump of the
+ * current selected Node (Only one at a time). Enable among other to export
+ * children Nodes and to choose to export binaries or not. It is useful to
+ * retrieve business data from live systems to prepare migration or test locally
+ */
+public class ConfigurableNodeDump extends AbstractHandler {
+       public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
+                       + ".nodeConfigurableDump";
+
+       private final static DateFormat df = new SimpleDateFormat(
+                       "yyyy-MM-dd_HH-mm");
+
+       public final static int EXPORT_NODE = 0;
+       public final static int EXPORT_CHILDREN = 1;
+       public final static int EXPORT_GRAND_CHILDREN = 2;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
+                               .getActivePage().getSelection();
+               if (selection == null || !(selection instanceof IStructuredSelection))
+                       return null;
+
+               Iterator<?> lst = ((IStructuredSelection) selection).iterator();
+               if (lst.hasNext()) {
+                       Object element = lst.next();
+                       if (element instanceof SingleJcrNodeElem) {
+                               SingleJcrNodeElem sjn = (SingleJcrNodeElem) element;
+                               Node node = sjn.getNode();
+
+                               ConfigureDumpWizard wizard = new ConfigureDumpWizard(
+                                               HandlerUtil.getActiveShell(event),
+                                               "Import Resource CSV");
+                               WizardDialog dialog = new WizardDialog(
+                                               HandlerUtil.getActiveShell(event), wizard);
+                               int result = dialog.open();
+
+                               if (result == Window.OK) {
+
+                                       String dateVal = df.format(new GregorianCalendar()
+                                                       .getTime());
+                                       try {
+
+                                               Path tmpDirPath = Files.createTempDirectory(dateVal
+                                                               + "-NodeDump-");
+                                               List<Node> toExport = retrieveToExportNodes(node,
+                                                               wizard.currExportType);
+
+                                               for (Node currNode : toExport) {
+                                                       FileOutputStream fos;
+                                                       String fileName = wizard.prefix
+                                                                       + JcrUtils.replaceInvalidChars(currNode
+                                                                                       .getName()) + "_" + dateVal
+                                                                       + ".xml";
+                                                       File currFile = new File(tmpDirPath.toString()
+                                                                       + "/" + fileName);
+                                                       currFile.createNewFile();
+                                                       fos = new FileOutputStream(currFile);
+                                                       node.getSession().exportSystemView(
+                                                                       currNode.getPath(), fos,
+                                                                       !wizard.includeBinaries, false);
+                                                       fos.flush();
+                                                       fos.close();
+                                               }
+                                       } catch (RepositoryException e) {
+                                               throw new EclipseUiException(
+                                                               "Unable to perform SystemExport on " + node, e);
+                                       } catch (IOException e) {
+                                               throw new EclipseUiException("Unable to SystemExport "
+                                                               + node, e);
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private List<Node> retrieveToExportNodes(Node node, int currExportType)
+                       throws RepositoryException {
+               List<Node> nodes = new ArrayList<Node>();
+               switch (currExportType) {
+               case EXPORT_NODE:
+                       nodes.add(node);
+                       return nodes;
+               case EXPORT_CHILDREN:
+                       return JcrUtils.nodeIteratorToList(node.getNodes());
+               case EXPORT_GRAND_CHILDREN:
+                       NodeIterator nit = node.getNodes();
+                       while (nit.hasNext())
+                               nodes.addAll(JcrUtils.nodeIteratorToList(nit.nextNode()
+                                               .getNodes()));
+                       return nodes;
+
+               default:
+                       return nodes;
+               }
+       }
+
+       // private synchronized void openGeneratedFile(String path, String fileName)
+       // {
+       // Map<String, String> params = new HashMap<String, String>();
+       // params.put(OpenFile.PARAM_FILE_NAME, fileName);
+       // params.put(OpenFile.PARAM_FILE_URI, "file://" + path);
+       // CommandUtils.callCommand("org.argeo.security.ui.specific.openFile",
+       // params);
+       // }
+
+       private class ConfigureDumpWizard extends Wizard {
+
+               // parameters
+               protected String prefix;
+               protected int currExportType = EXPORT_NODE;
+               protected boolean includeBinaries = false;
+
+               // UI Objects
+               private BasicPage page;
+               private Text prefixTxt;
+               private Button includeBinaryBtn;
+               private Button b1, b2, b3;
+
+               public ConfigureDumpWizard(Shell parentShell, String title) {
+                       setWindowTitle(title);
+               }
+
+               @Override
+               public void addPages() {
+                       try {
+                               page = new BasicPage("Main page");
+                               addPage(page);
+                       } catch (Exception e) {
+                               throw new EclipseUiException("Cannot add page to wizard", e);
+                       }
+               }
+
+               @Override
+               public boolean performFinish() {
+                       prefix = prefixTxt.getText();
+                       if (b1.getSelection())
+                               currExportType = EXPORT_NODE;
+                       else if (b2.getSelection())
+                               currExportType = EXPORT_CHILDREN;
+                       else if (b3.getSelection())
+                               currExportType = EXPORT_GRAND_CHILDREN;
+                       includeBinaries = includeBinaryBtn.getSelection();
+                       return true;
+               }
+
+               @Override
+               public boolean performCancel() {
+                       return true;
+               }
+
+               @Override
+               public boolean canFinish() {
+                       String errorMsg = "No prefix defined.";
+                       if ("".equals(prefixTxt.getText().trim())) {
+                               page.setErrorMessage(errorMsg);
+                               return false;
+                       } else {
+                               page.setErrorMessage(null);
+                               return true;
+                       }
+               }
+
+               protected class BasicPage extends WizardPage {
+                       private static final long serialVersionUID = 1L;
+
+                       public BasicPage(String pageName) {
+                               super(pageName);
+                               setTitle("Configure dump before launching");
+                               setMessage("Define the parameters of the dump to launch");
+                       }
+
+                       public void createControl(Composite parent) {
+                               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
+
+                               // Main Layout
+                               Composite mainCmp = new Composite(parent, SWT.NONE);
+                               mainCmp.setLayout(new GridLayout(2, false));
+                               mainCmp.setLayoutData(EclipseUiUtils.fillAll());
+
+                               // The path
+                               createBoldLabel(mainCmp, "Prefix");
+                               prefixTxt = new Text(mainCmp, SWT.SINGLE | SWT.BORDER);
+                               prefixTxt.setLayoutData(EclipseUiUtils.fillAll());
+                               prefixTxt.addModifyListener(new ModifyListener() {
+                                       private static final long serialVersionUID = 1L;
+
+                                       @Override
+                                       public void modifyText(ModifyEvent event) {
+                                               if (prefixTxt.getText() != null)
+                                                       getWizard().getContainer().updateButtons();
+                                       }
+                               });
+
+                               new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
+                                               .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                                               false, 2, 1));
+
+                               // Which node to export
+                               Label typeLbl = new Label(mainCmp, SWT.RIGHT);
+                               typeLbl.setText(" Type");
+                               typeLbl.setFont(EclipseUiUtils.getBoldFont(mainCmp));
+                               typeLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
+                                               false, 1, 3));
+
+                               b1 = new Button(mainCmp, SWT.RADIO);
+                               b1.setText("Export this node");
+                               b1.setSelection(true);
+                               b2 = new Button(mainCmp, SWT.RADIO);
+                               b2.setText("Export children nodes");
+                               b3 = new Button(mainCmp, SWT.RADIO);
+                               b3.setText("Export grand-children nodes");
+
+                               new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
+                                               .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                                               false, 2, 1));
+
+                               createBoldLabel(mainCmp, "Files and images");
+                               includeBinaryBtn = new Button(mainCmp, SWT.CHECK);
+                               includeBinaryBtn.setText("Include binaries");
+
+                               prefixTxt.setFocus();
+                               setControl(mainCmp);
+                       }
+               }
+       }
+
+       private Label createBoldLabel(Composite parent, String value) {
+               Label label = new Label(parent, SWT.RIGHT);
+               label.setText(" " + value);
+               label.setFont(EclipseUiUtils.getBoldFont(parent));
+               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+               return label;
+       }
+}
index 2414f042b95ae830e3391cce3ef868919de65b91..4a7bf734fce4fa5375e78da0da7f744ad0b0e5ea 100644 (file)
@@ -15,6 +15,9 @@
  */
 package org.argeo.cms.ui.workbench.internal.jcr.commands;
 
+import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.FILE_SCHEME;
+import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.SCHEME_HOST_SEPARATOR;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -30,10 +33,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.commands.OpenFile;
 import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
 import org.argeo.cms.ui.workbench.util.CommandUtils;
 import org.argeo.eclipse.ui.EclipseUiException;
+import org.argeo.eclipse.ui.specific.OpenFile;
 import org.argeo.jcr.JcrUtils;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -54,12 +57,10 @@ import org.eclipse.ui.handlers.HandlerUtil;
 public class DumpNode extends AbstractHandler {
        public final static String ID = WorkbenchUiPlugin.PLUGIN_ID + ".dumpNode";
 
-       private final static DateFormat df = new SimpleDateFormat(
-                       "yyyy-MM-dd_HH-mm");
+       private final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
-               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
-                               .getActivePage().getSelection();
+               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
                if (selection == null || !(selection instanceof IStructuredSelection))
                        return null;
 
@@ -73,8 +74,8 @@ public class DumpNode extends AbstractHandler {
                                // TODO add a dialog to configure the export and ask for
                                // confirmation
                                // Boolean ok = MessageDialog.openConfirm(
-                               // HandlerUtil.getActiveShell(event), "Confirm deletion",
-                               // "Do you want to delete " + buf + "?");
+                               // HandlerUtil.getActiveShell(event), "Confirm dump",
+                               // "Do you want to dump " + buf + "?");
 
                                File tmpFile;
                                FileOutputStream fos;
@@ -82,19 +83,14 @@ public class DumpNode extends AbstractHandler {
                                        tmpFile = File.createTempFile("JcrExport", ".xml");
                                        tmpFile.deleteOnExit();
                                        fos = new FileOutputStream(tmpFile);
-                                       String dateVal = df.format(new GregorianCalendar()
-                                                       .getTime());
-                                       node.getSession().exportSystemView(node.getPath(), fos,
-                                                       true, false);
-                                       openGeneratedFile(tmpFile.getAbsolutePath(), "Dump-"
-                                                       + JcrUtils.replaceInvalidChars(node.getName())
-                                                       + "-" + dateVal + ".xml");
+                                       String dateVal = df.format(new GregorianCalendar().getTime());
+                                       node.getSession().exportSystemView(node.getPath(), fos, true, false);
+                                       openGeneratedFile(tmpFile.getAbsolutePath(),
+                                                       "Dump-" + JcrUtils.replaceInvalidChars(node.getName()) + "-" + dateVal + ".xml");
                                } catch (RepositoryException e) {
-                                       throw new EclipseUiException(
-                                                       "Unable to perform SystemExport on " + node, e);
+                                       throw new EclipseUiException("Unable to perform SystemExport on " + node, e);
                                } catch (IOException e) {
-                                       throw new EclipseUiException("Unable to SystemExport "
-                                                       + node, e);
+                                       throw new EclipseUiException("Unable to SystemExport " + node, e);
                                }
                        }
                }
@@ -104,7 +100,7 @@ public class DumpNode extends AbstractHandler {
        private synchronized void openGeneratedFile(String path, String fileName) {
                Map<String, String> params = new HashMap<String, String>();
                params.put(OpenFile.PARAM_FILE_NAME, fileName);
-               params.put(OpenFile.PARAM_FILE_URI, "file://" + path);
+               params.put(OpenFile.PARAM_FILE_URI, FILE_SCHEME + SCHEME_HOST_SEPARATOR + path);
                CommandUtils.callCommand(OpenFile.ID, params);
        }
 }
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/NodeConfigurableDump.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/commands/NodeConfigurableDump.java
deleted file mode 100644 (file)
index ec3ab47..0000000
+++ /dev/null
@@ -1,295 +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.cms.ui.workbench.internal.jcr.commands;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-
-import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.model.SingleJcrNodeElem;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.jcr.JcrUtils;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-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.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * First draft of a wizard that enable configurable recursive dump of the
- * current selected Node (Only one at a time). Enable among other to export
- * children Nodes and to choose to export binaries or not. It is useful to
- * retrieve business data from live systems to prepare migration or test locally
- */
-public class NodeConfigurableDump extends AbstractHandler {
-       public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
-                       + ".nodeConfigurableDump";
-
-       private final static DateFormat df = new SimpleDateFormat(
-                       "yyyy-MM-dd_HH-mm");
-
-       public final static int EXPORT_NODE = 0;
-       public final static int EXPORT_CHILDREN = 1;
-       public final static int EXPORT_GRAND_CHILDREN = 2;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event)
-                               .getActivePage().getSelection();
-               if (selection == null || !(selection instanceof IStructuredSelection))
-                       return null;
-
-               Iterator<?> lst = ((IStructuredSelection) selection).iterator();
-               if (lst.hasNext()) {
-                       Object element = lst.next();
-                       if (element instanceof SingleJcrNodeElem) {
-                               SingleJcrNodeElem sjn = (SingleJcrNodeElem) element;
-                               Node node = sjn.getNode();
-
-                               ConfigureDumpWizard wizard = new ConfigureDumpWizard(
-                                               HandlerUtil.getActiveShell(event),
-                                               "Import Resource CSV");
-                               WizardDialog dialog = new WizardDialog(
-                                               HandlerUtil.getActiveShell(event), wizard);
-                               int result = dialog.open();
-
-                               if (result == Window.OK) {
-
-                                       String dateVal = df.format(new GregorianCalendar()
-                                                       .getTime());
-                                       try {
-
-                                               Path tmpDirPath = Files.createTempDirectory(dateVal
-                                                               + "-NodeDump-");
-                                               List<Node> toExport = retrieveToExportNodes(node,
-                                                               wizard.currExportType);
-
-                                               for (Node currNode : toExport) {
-                                                       FileOutputStream fos;
-                                                       String fileName = wizard.prefix
-                                                                       + JcrUtils.replaceInvalidChars(currNode
-                                                                                       .getName()) + "_" + dateVal
-                                                                       + ".xml";
-                                                       File currFile = new File(tmpDirPath.toString()
-                                                                       + "/" + fileName);
-                                                       currFile.createNewFile();
-                                                       fos = new FileOutputStream(currFile);
-                                                       node.getSession().exportSystemView(
-                                                                       currNode.getPath(), fos,
-                                                                       !wizard.includeBinaries, false);
-                                                       fos.flush();
-                                                       fos.close();
-                                               }
-                                       } catch (RepositoryException e) {
-                                               throw new EclipseUiException(
-                                                               "Unable to perform SystemExport on " + node, e);
-                                       } catch (IOException e) {
-                                               throw new EclipseUiException("Unable to SystemExport "
-                                                               + node, e);
-                                       }
-                               }
-                       }
-               }
-               return null;
-       }
-
-       private List<Node> retrieveToExportNodes(Node node, int currExportType)
-                       throws RepositoryException {
-               List<Node> nodes = new ArrayList<Node>();
-               switch (currExportType) {
-               case EXPORT_NODE:
-                       nodes.add(node);
-                       return nodes;
-               case EXPORT_CHILDREN:
-                       return JcrUtils.nodeIteratorToList(node.getNodes());
-               case EXPORT_GRAND_CHILDREN:
-                       NodeIterator nit = node.getNodes();
-                       while (nit.hasNext())
-                               nodes.addAll(JcrUtils.nodeIteratorToList(nit.nextNode()
-                                               .getNodes()));
-                       return nodes;
-
-               default:
-                       return nodes;
-               }
-       }
-
-       // private synchronized void openGeneratedFile(String path, String fileName)
-       // {
-       // Map<String, String> params = new HashMap<String, String>();
-       // params.put(OpenFile.PARAM_FILE_NAME, fileName);
-       // params.put(OpenFile.PARAM_FILE_URI, "file://" + path);
-       // CommandUtils.callCommand("org.argeo.security.ui.specific.openFile",
-       // params);
-       // }
-
-       private class ConfigureDumpWizard extends Wizard {
-
-               // parameters
-               protected String prefix;
-               protected int currExportType = EXPORT_NODE;
-               protected boolean includeBinaries = false;
-
-               // UI Objects
-               private BasicPage page;
-               private Text prefixTxt;
-               private Button includeBinaryBtn;
-               private Button b1, b2, b3;
-
-               public ConfigureDumpWizard(Shell parentShell, String title) {
-                       setWindowTitle(title);
-               }
-
-               @Override
-               public void addPages() {
-                       try {
-                               page = new BasicPage("Main page");
-                               addPage(page);
-                       } catch (Exception e) {
-                               throw new EclipseUiException("Cannot add page to wizard", e);
-                       }
-               }
-
-               @Override
-               public boolean performFinish() {
-                       prefix = prefixTxt.getText();
-                       if (b1.getSelection())
-                               currExportType = EXPORT_NODE;
-                       else if (b2.getSelection())
-                               currExportType = EXPORT_CHILDREN;
-                       else if (b3.getSelection())
-                               currExportType = EXPORT_GRAND_CHILDREN;
-                       includeBinaries = includeBinaryBtn.getSelection();
-                       return true;
-               }
-
-               @Override
-               public boolean performCancel() {
-                       return true;
-               }
-
-               @Override
-               public boolean canFinish() {
-                       String errorMsg = "No prefix defined.";
-                       if ("".equals(prefixTxt.getText().trim())) {
-                               page.setErrorMessage(errorMsg);
-                               return false;
-                       } else {
-                               page.setErrorMessage(null);
-                               return true;
-                       }
-               }
-
-               protected class BasicPage extends WizardPage {
-                       private static final long serialVersionUID = 1L;
-
-                       public BasicPage(String pageName) {
-                               super(pageName);
-                               setTitle("Configure dump before launching");
-                               setMessage("Define the parameters of the dump to launch");
-                       }
-
-                       public void createControl(Composite parent) {
-                               parent.setLayout(EclipseUiUtils.noSpaceGridLayout());
-
-                               // Main Layout
-                               Composite mainCmp = new Composite(parent, SWT.NONE);
-                               mainCmp.setLayout(new GridLayout(2, false));
-                               mainCmp.setLayoutData(EclipseUiUtils.fillAll());
-
-                               // The path
-                               createBoldLabel(mainCmp, "Prefix");
-                               prefixTxt = new Text(mainCmp, SWT.SINGLE | SWT.BORDER);
-                               prefixTxt.setLayoutData(EclipseUiUtils.fillAll());
-                               prefixTxt.addModifyListener(new ModifyListener() {
-                                       private static final long serialVersionUID = 1L;
-
-                                       @Override
-                                       public void modifyText(ModifyEvent event) {
-                                               if (prefixTxt.getText() != null)
-                                                       getWizard().getContainer().updateButtons();
-                                       }
-                               });
-
-                               new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
-                                               .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                                               false, 2, 1));
-
-                               // Which node to export
-                               Label typeLbl = new Label(mainCmp, SWT.RIGHT);
-                               typeLbl.setText(" Type");
-                               typeLbl.setFont(EclipseUiUtils.getBoldFont(mainCmp));
-                               typeLbl.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false,
-                                               false, 1, 3));
-
-                               b1 = new Button(mainCmp, SWT.RADIO);
-                               b1.setText("Export this node");
-                               b1.setSelection(true);
-                               b2 = new Button(mainCmp, SWT.RADIO);
-                               b2.setText("Export children nodes");
-                               b3 = new Button(mainCmp, SWT.RADIO);
-                               b3.setText("Export grand-children nodes");
-
-                               new Label(mainCmp, SWT.SEPARATOR | SWT.HORIZONTAL)
-                                               .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                                               false, 2, 1));
-
-                               createBoldLabel(mainCmp, "Files and images");
-                               includeBinaryBtn = new Button(mainCmp, SWT.CHECK);
-                               includeBinaryBtn.setText("Include binaries");
-
-                               prefixTxt.setFocus();
-                               setControl(mainCmp);
-                       }
-               }
-       }
-
-       private Label createBoldLabel(Composite parent, String value) {
-               Label label = new Label(parent, SWT.RIGHT);
-               label.setText(" " + value);
-               label.setFont(EclipseUiUtils.getBoldFont(parent));
-               label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-               return label;
-       }
-}
index 40d3d3389e03022c732fbdf675a7695114809a0d..1464f5735690f4009ed06933d1db92a66c33ad27 100644 (file)
@@ -19,7 +19,7 @@ import javax.jcr.Node;
 
 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
 import org.argeo.cms.ui.workbench.internal.jcr.NodeLabelProvider;
-import org.argeo.cms.ui.workbench.internal.jcr.SingleNodeAsTreeContentProvider;
+import org.argeo.cms.ui.workbench.internal.jcr.JcrTreeContentProvider;
 import org.argeo.cms.ui.workbench.jcr.DefaultNodeEditor;
 import org.argeo.eclipse.ui.EclipseUiException;
 import org.argeo.eclipse.ui.EclipseUiUtils;
@@ -49,7 +49,7 @@ public class ChildNodesPage extends FormPage {
        private Node currentNode;
 
        // this page UI components
-       private SingleNodeAsTreeContentProvider nodeContentProvider;
+       private JcrTreeContentProvider nodeContentProvider;
        private TreeViewer nodesViewer;
 
        public ChildNodesPage(FormEditor editor, String title, Node currentNode) {
@@ -69,7 +69,7 @@ public class ChildNodesPage extends FormPage {
                                managedForm.getToolkit().createLabel(body,
                                                WorkbenchUiPlugin.getMessage("warningNoChildNode"));
                        } else {
-                               nodeContentProvider = new SingleNodeAsTreeContentProvider();
+                               nodeContentProvider = new JcrTreeContentProvider();
                                nodesViewer = createNodeViewer(body, nodeContentProvider);
                                nodesViewer.setInput(currentNode);
                        }
index 8d786e8226dcd0afd7efec1692b8bb29a198d5ed..080ea9485f9cd60bf7d73b2f1e6870f226f1e847 100644 (file)
@@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
-/** Dialog to change the current user password */
+/** Ask end user for a name */
 public class ChooseNameDialog extends TitleAreaDialog {
        private static final long serialVersionUID = 280139710002698692L;
        private Text nameTxt;
@@ -48,9 +48,9 @@ public class ChooseNameDialog extends TitleAreaDialog {
                composite.setLayout(new GridLayout(2, false));
                composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
                nameTxt = createLT(composite, "Name");
-
                setMessage("Choose name", IMessageProvider.INFORMATION);
                parent.pack();
+               nameTxt.setFocus();
                return composite;
        }
 
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/EmptyNodePage.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/EmptyNodePage.java
deleted file mode 100644 (file)
index cd3f756..0000000
+++ /dev/null
@@ -1,49 +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.cms.ui.workbench.internal.jcr.parts;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * This page is only used at editor's creation time when current node has not
- * yet been set
- */
-public class EmptyNodePage extends FormPage {
-       // private final static Log log = LogFactory.getLog(EmptyNodePage.class);
-
-       public EmptyNodePage(FormEditor editor, String title) {
-               super(editor, "Empty Page", title);
-       }
-
-       protected void createFormContent(IManagedForm managedForm) {
-               try {
-                       ScrolledForm form = managedForm.getForm();
-                       GridLayout twt = new GridLayout(1, false);
-                       twt.marginWidth = twt.marginHeight = 0;
-                       form.getBody().setLayout(twt);
-                       Label lbl = new Label(form.getBody(), SWT.NONE);
-                       lbl.setText("Empty page");
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-       }
-}
index d27c57e1223811e90a502cc278b18a95c59a90b6..bfb207155382076375ff1f44a9224bb508ad516a 100644 (file)
@@ -23,14 +23,12 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
-/**
- * An editor input based the JCR node object.
- * */
-
+/** Editor input for {@link Node} editors */
 public class GenericNodeEditorInput implements IEditorInput {
        private final Node currentNode;
 
-       // cache key properties at creation time to avoid Exception at recoring time
+       // Caches key properties at creation time to avoid Exception at recovering
+       // time
        // when the session has been closed
        private String path;
        private String uid;
@@ -43,9 +41,7 @@ public class GenericNodeEditorInput implements IEditorInput {
                        uid = currentNode.getIdentifier();
                        path = currentNode.getPath();
                } catch (RepositoryException re) {
-                       throw new EclipseUiException(
-                                       "unexpected error while getting node key values at creation time",
-                                       re);
+                       throw new EclipseUiException("unexpected error while getting node key values at creation time", re);
                }
        }
 
@@ -89,9 +85,9 @@ public class GenericNodeEditorInput implements IEditorInput {
        /**
         * equals method based on UID that is unique within a workspace and path of
         * the node, thus 2 shared node that have same UID as defined in the spec
-        * but 2 different pathes will open two distinct editors.
+        * but 2 different paths will open two distinct editors.
         * 
-        * TODO enhance this method to support multirepository and multiworkspace
+        * TODO enhance this method to support multi repository and multi workspace
         * environments
         */
        public boolean equals(Object obj) {
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ImportFileSystemWizard.java b/org.argeo.cms.ui.workbench/src/org/argeo/cms/ui/workbench/internal/jcr/parts/ImportFileSystemWizard.java
deleted file mode 100644 (file)
index b9acf61..0000000
+++ /dev/null
@@ -1,221 +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.cms.ui.workbench.internal.jcr.parts;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import javax.jcr.Binary;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.argeo.eclipse.ui.EclipseUiException;
-import org.argeo.eclipse.ui.specific.UploadFileWizardPage;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.wizard.Wizard;
-
-public class ImportFileSystemWizard extends Wizard {
-       private final static Log log = LogFactory.getLog(ImportFileSystemWizard.class);
-
-       private UploadFileWizardPage importPage;
-       private final Node folder;
-
-       public ImportFileSystemWizard(Node folder) {
-               this.folder = folder;
-               setWindowTitle("Import from file system");
-               throw new CmsException("Deprecated wizard, cannot be used");
-       }
-
-       @Override
-       public void addPages() {
-               // importPage = new UploadFileWizardPage();
-               // addPage(importPage);
-               // setNeedsProgressMonitor(importPage.getNeedsProgressMonitor());
-       }
-
-       /**
-        * Called when the user click on 'Finish' in the wizard. The real upload to
-        * the JCR repository is done here.
-        */
-       @Override
-       public boolean performFinish() {
-
-               // // Initialization
-               // final String objectType = importPage.getObjectType();
-               // final String objectPath = importPage.getObjectPath();
-               //
-               // // We do not display a progress bar for one file only
-               // if (UploadFileWizardPage.FILE_ITEM_TYPE.equals(objectType)) {
-               // // In Rap we must force the "real" upload of the file
-               // // importPage.performFinish();
-               // try {
-               // Node fileNode = folder.addNode(importPage.getObjectName(),
-               // NodeType.NT_FILE);
-               // Node resNode = fileNode.addNode(Property.JCR_CONTENT,
-               // NodeType.NT_RESOURCE);
-               // Binary binary = null;
-               // InputStream is = null;
-               // try {
-               // is = importPage.getFileInputStream();
-               // binary = folder.getSession().getValueFactory()
-               // .createBinary(is);
-               // resNode.setProperty(Property.JCR_DATA, binary);
-               // } finally {
-               // if (binary != null)
-               // binary.dispose();
-               // IOUtils.closeQuietly(is);
-               // }
-               // folder.getSession().save();
-               // } catch (Exception e) {
-               // e.printStackTrace();
-               // return false;
-               // }
-               // return true;
-               // } else if (UploadFileWizardPage.FOLDER_ITEM_TYPE.equals(objectType))
-               // {
-               // if (objectPath == null || !new File(objectPath).exists()) {
-               // ErrorFeedback.show("Directory " + objectPath
-               // + " does not exist");
-               // return false;
-               // }
-               //
-               // Boolean failed = false;
-               // final File dir = new File(objectPath).getAbsoluteFile();
-               // final Long sizeB = directorySize(dir, 0l);
-               // final Stats stats = new Stats();
-               // Long begin = System.currentTimeMillis();
-               // try {
-               // getContainer().run(true, true, new IRunnableWithProgress() {
-               // public void run(IProgressMonitor monitor) {
-               // try {
-               // Integer sizeKB = (int) (sizeB / FileUtils.ONE_KB);
-               // monitor.beginTask("", sizeKB);
-               // importDirectory(folder, dir, monitor, stats);
-               // monitor.done();
-               // } catch (Exception e) {
-               // if (e instanceof RuntimeException)
-               // throw (RuntimeException) e;
-               // else
-               // throw new EclipseUiException("Cannot import "
-               // + objectPath, e);
-               // }
-               // }
-               // });
-               // } catch (Exception e) {
-               // ErrorFeedback.show("Cannot import " + objectPath, e);
-               // failed = true;
-               // }
-               //
-               // Long duration = System.currentTimeMillis() - begin;
-               // Long durationS = duration / 1000l;
-               // String durationStr = (durationS / 60) + " min " + (durationS % 60)
-               // + " s";
-               // StringBuffer message = new StringBuffer("Imported\n");
-               // message.append(stats.fileCount).append(" files\n");
-               // message.append(stats.dirCount).append(" directories\n");
-               // message.append(FileUtils.byteCountToDisplaySize(stats.sizeB));
-               // if (failed)
-               // message.append(" of planned ").append(
-               // FileUtils.byteCountToDisplaySize(sizeB));
-               // message.append("\n");
-               // message.append("in ").append(durationStr).append("\n");
-               // if (failed)
-               // MessageDialog.openError(getShell(), "Import failed",
-               // message.toString());
-               // else
-               // MessageDialog.openInformation(getShell(), "Import successful",
-               // message.toString());
-               //
-               // return true;
-               // }
-               return false;
-
-       }
-
-       /** Recursively computes the size of the directory in bytes. */
-       protected Long directorySize(File dir, Long currentSize) {
-               Long size = currentSize;
-               File[] files = dir.listFiles();
-               for (File file : files) {
-                       if (file.isDirectory()) {
-                               size = directorySize(file, size);
-                       } else {
-                               size = size + file.length();
-                       }
-               }
-               return size;
-       }
-
-       /**
-        * Import recursively a directory and its content to the repository.
-        */
-       protected void importDirectory(Node folder, File dir, IProgressMonitor monitor, Stats stats) {
-               try {
-                       File[] files = dir.listFiles();
-                       for (File file : files) {
-                               if (file.isDirectory()) {
-                                       Node childFolder = folder.addNode(file.getName(), NodeType.NT_FOLDER);
-                                       importDirectory(childFolder, file, monitor, stats);
-                                       folder.getSession().save();
-                                       stats.dirCount++;
-                               } else {
-                                       Long fileSize = file.length();
-                                       // we skip temporary files that are created by apps when a
-                                       // file is being edited.
-                                       // TODO : make this configurable.
-                                       if (file.getName().lastIndexOf('~') != file.getName().length() - 1) {
-
-                                               monitor.subTask(file.getName() + " (" + FileUtils.byteCountToDisplaySize(fileSize) + ") "
-                                                               + file.getCanonicalPath());
-                                               try {
-                                                       Node fileNode = folder.addNode(file.getName(), NodeType.NT_FILE);
-                                                       Node resNode = fileNode.addNode(Property.JCR_CONTENT, NodeType.NT_RESOURCE);
-                                                       Binary binary = null;
-                                                       try {
-                                                               binary = folder.getSession().getValueFactory().createBinary(new FileInputStream(file));
-                                                               resNode.setProperty(Property.JCR_DATA, binary);
-                                                       } finally {
-                                                               if (binary != null)
-                                                                       binary.dispose();
-                                                       }
-                                                       folder.getSession().save();
-                                                       stats.fileCount++;
-                                                       stats.sizeB = stats.sizeB + fileSize;
-                                               } catch (Exception e) {
-                                                       log.warn("Import of " + file + " (" + FileUtils.byteCountToDisplaySize(fileSize)
-                                                                       + ") failed: " + e);
-                                                       folder.getSession().refresh(false);
-                                               }
-                                               monitor.worked((int) (fileSize / FileUtils.ONE_KB));
-                                       }
-                               }
-                       }
-               } catch (Exception e) {
-                       throw new EclipseUiException("Cannot import " + dir + " to " + folder, e);
-               }
-       }
-
-       static class Stats {
-               public Long fileCount = 0l;
-               public Long dirCount = 0l;
-               public Long sizeB = 0l;
-       }
-}
index 4e3d9932ac8f2aaae7ae932fca2f69cb511502e4..4697b7acfd1bb1f17d7ec3261079b6839a0d3fe1 100644 (file)
@@ -36,7 +36,7 @@ import javax.jcr.version.VersionManager;
 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
 import org.argeo.cms.ui.workbench.internal.WorkbenchConstants;
 import org.argeo.cms.ui.workbench.internal.jcr.FullVersioningTreeContentProvider;
-import org.argeo.cms.ui.workbench.internal.jcr.GenericNodeDoubleClickListener;
+import org.argeo.cms.ui.workbench.internal.jcr.JcrDClickListener;
 import org.argeo.cms.ui.workbench.internal.jcr.VersionLabelProvider;
 import org.argeo.eclipse.ui.EclipseUiException;
 import org.argeo.jcr.JcrUtils;
@@ -141,7 +141,7 @@ public class NodeVersionHistoryPage extends FormPage implements
                tmpNodeViewer.setContentProvider(nodeContentProvider);
                tmpNodeViewer.setLabelProvider(new VersionLabelProvider());
                tmpNodeViewer
-                               .addDoubleClickListener(new GenericNodeDoubleClickListener(
+                               .addDoubleClickListener(new JcrDClickListener(
                                                tmpNodeViewer));
                return tmpNodeViewer;
        }
index e012e0e05415fe1db7f80bc7fc5c5b9a8227db2b..e25512dd7a3c36554ba8d2d6a2a35b9ff55a4034 100644 (file)
@@ -29,7 +29,7 @@ import javax.jcr.observation.EventListener;
 import javax.jcr.observation.ObservationManager;
 
 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
-import org.argeo.cms.ui.workbench.internal.jcr.GenericNodeDoubleClickListener;
+import org.argeo.cms.ui.workbench.internal.jcr.JcrDClickListener;
 import org.argeo.cms.ui.workbench.internal.jcr.JcrBrowserUtils;
 import org.argeo.cms.ui.workbench.internal.jcr.NodeContentProvider;
 import org.argeo.cms.ui.workbench.internal.jcr.NodeLabelProvider;
@@ -189,7 +189,7 @@ public class JcrBrowserView extends ViewPart {
                        }
 
                tmpNodeViewer
-                               .addDoubleClickListener(new GenericNodeDoubleClickListener(
+                               .addDoubleClickListener(new JcrDClickListener(
                                                tmpNodeViewer));
                return tmpNodeViewer;
        }
index facde000f2871e65c39127bbb84414fe2739da0e..68a480b611c35a42fe406ea5318c46e792a7e3a9 100644 (file)
@@ -6,4 +6,17 @@ org.eclipse.jface.window,\
 org.eclipse.core.commands,\
 javax.jcr.security,\
 org.argeo.eclipse.ui.dialogs,\
-*
\ No newline at end of file
+org.eclipse.rap.fileupload;version="[2.1,4)",\
+org.eclipse.rap.rwt;version="[2.1,4)",\
+org.eclipse.rap.rwt.application;version="[2.1,4)",\
+org.eclipse.rap.rwt.client;version="[2.1,4)",\
+org.eclipse.rap.rwt.client.service;version="[2.1,4)",\
+org.eclipse.rap.rwt.service;version="[2.1,4)",\
+org.eclipse.rap.rwt.widgets;version="[2.1,4)",\
+*
+
+## TODO: in order to enable single sourcing, we have introduced dummy RAP packages 
+# in the RCP specific bundle org.argeo.eclipse.ui.rap.
+# this was working with RAP 2.x but since we upgrade Rap to 3.1.x, 
+# there is a version range issue cause org.argeo.eclipse.ui.rap bundle is still in 2.x
+# We enable large RAP version range as a workaround that must be fixed 
\ No newline at end of file
index 460b6b168a0a4f8e61d73ae0ca01415b3ffcd286..9c15f0c2f68b7583d4716696a317dca6b51bba0c 100644 (file)
@@ -1,3 +1,4 @@
 Import-Package: org.eclipse.swt,\
  org.eclipse.jface.dialogs,\
+ org.argeo.eclipse.ui.utils,\
 *
diff --git a/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java b/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/GenericUploadControl.java
deleted file mode 100644 (file)
index b15e691..0000000
+++ /dev/null
@@ -1,110 +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;
-
-public class GenericUploadControl {
-}
-//
-//
-// import java.nio.file.Path;
-// import java.nio.file.Paths;
-//
-// import org.argeo.eclipse.ui.EclipseUiUtils;
-// 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;
-//
-/// **
-// * RAP specific composite that provides a control to upload a single file
-// */
-//
-// public class GenericUploadControl extends Composite {
-// private static final long serialVersionUID = -4079470245651908737L;
-// // private final static Log log =
-// // LogFactory.getLog(GenericUploadControl.class);
-//
-// private FileDialog dialog;
-// private Text filePathTxt;
-//
-// public GenericUploadControl(Composite parent, int style, String browseLabel)
-// {
-// super(parent, style);
-// createControl(this, browseLabel);
-// }
-//
-// private void createControl(final Composite parent, String browseLabel) {
-// GridLayout layout = new GridLayout(2, false);
-// layout.marginHeight = layout.marginWidth = 0;
-// parent.setLayout(layout);
-//
-// filePathTxt = new Text(parent, SWT.BORDER | SWT.SINGLE);
-// filePathTxt.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL |
-// GridData.FILL_HORIZONTAL));
-// filePathTxt.setEditable(false);
-//
-// // Execute button
-// Button execute = new Button(parent, SWT.PUSH);
-// execute.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
-// execute.setText(browseLabel);
-//
-// // Button listener
-// Listener executeListener = new Listener() {
-// private static final long serialVersionUID = -7591211214156101065L;
-//
-// public void handleEvent(Event event) {
-// dialog = new FileDialog(parent.getShell());
-// dialog.setText("File browser");
-// filePathTxt.setText(dialog.open());
-// }
-// };
-// parent.layout();
-// execute.addListener(SWT.Selection, executeListener);
-// }
-//
-// public boolean isControlEmpty() {
-// String path = filePathTxt.getText();
-// if (path == null || "".equals(path.trim()))
-// return true;
-// else
-// return false;
-// }
-//
-// public Path getChosenFile() {
-// String pathStr = filePathTxt.getText();
-// if (EclipseUiUtils.isEmpty(pathStr))
-// return null;
-// else
-// return Paths.get(filePathTxt.getText());
-// }
-//
-// public void addModifyListener(ModifyListener listener) {
-// filePathTxt.addModifyListener(listener);
-// }
-//
-// /**
-// * Always returns null in an RCP environment
-// */
-// public String getLastFileUploadedName() {
-// return null;
-// }
-// }
index 46de2c9182e706f8fda7be59bb6783ebf2bad1be..10682c4ce554ab6071eaf73b3753da79f3f85918 100644 (file)
@@ -17,6 +17,9 @@ package org.argeo.eclipse.ui.specific;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.utils.SingleSourcingConstants;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.rap.rwt.RWT;
 import org.eclipse.rap.rwt.client.service.UrlLauncher;
 
@@ -37,19 +40,29 @@ import org.eclipse.rap.rwt.client.service.UrlLauncher;
  * externally created
  * </p>
  */
-public class OpenFile {
+public class OpenFile extends AbstractHandler {
        private final static Log log = LogFactory.getLog(OpenFile.class);
 
-       // /* DEPENDENCY INJECTION */
-       // private String openFileServiceId;
-       //
-       // public final static String PARAM_FILE_NAME =
-       // OpenFileService.PARAM_FILE_NAME;
-       // public final static String PARAM_FILE_URI =
-       // OpenFileService.PARAM_FILE_URI; // "param.fileURI";
+       public final static String ID = SingleSourcingConstants.OPEN_FILE_CMD_ID;
+       public final static String PARAM_FILE_NAME = SingleSourcingConstants.PARAM_FILE_NAME;
+       public final static String PARAM_FILE_URI = SingleSourcingConstants.PARAM_FILE_URI;;
+       /* DEPENDENCY INJECTION */
+       private String openFileServiceId;
 
-       public Object execute(String openFileServiceId, String fileUri,
-                       String fileName) {
+       public Object execute(ExecutionEvent event) {
+               String fileName = event.getParameter(PARAM_FILE_NAME);
+               String fileUri = event.getParameter(PARAM_FILE_URI);
+               // Sanity check
+               if (fileUri == null || "".equals(fileUri.trim()) || openFileServiceId == null
+                               || "".equals(openFileServiceId.trim()))
+                       return null;
+
+               org.argeo.eclipse.ui.specific.OpenFile openFileClient = new org.argeo.eclipse.ui.specific.OpenFile();
+               openFileClient.execute(openFileServiceId, fileUri, fileName);
+               return null;
+       }
+
+       public Object execute(String openFileServiceId, String fileUri, String fileName) {
                // // Sanity check
                // if (fileUri == null || "".equals(fileUri.trim())
                // || openFileServiceId == null
@@ -57,12 +70,11 @@ public class OpenFile {
                // return null;
 
                StringBuilder url = new StringBuilder();
-               url.append(RWT.getServiceManager().getServiceHandlerUrl(
-                               openFileServiceId));
+               url.append(RWT.getServiceManager().getServiceHandlerUrl(openFileServiceId));
 
-               url.append("&").append(OpenFileService.PARAM_FILE_NAME).append("=");
+               url.append("&").append(SingleSourcingConstants.PARAM_FILE_NAME).append("=");
                url.append(fileName);
-               url.append("&").append(OpenFileService.PARAM_FILE_URI).append("=");
+               url.append("&").append(SingleSourcingConstants.PARAM_FILE_URI).append("=");
                url.append(fileUri);
 
                String downloadUrl = url.toString();
@@ -74,8 +86,8 @@ public class OpenFile {
                return null;
        }
 
-       // /* DEPENDENCY INJECTION */
-       // public void setOpenFileServiceId(String openFileServiceId) {
-       // this.openFileServiceId = openFileServiceId;
-       // }
-}
\ No newline at end of file
+       /* DEPENDENCY INJECTION */
+       public void setOpenFileServiceId(String openFileServiceId) {
+               this.openFileServiceId = openFileServiceId;
+       }
+}
index 890df5bbd9a98864dbab24731cedf4953633a547..0a6f3b6870500b317ad611eb6164869c223b0576 100644 (file)
  */
 package org.argeo.eclipse.ui.specific;
 
+import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.FILE_SCHEME;
+import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.JCR_SCHEME;
+import static org.argeo.eclipse.ui.utils.SingleSourcingConstants.SCHEME_HOST_SEPARATOR;
+
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -25,6 +29,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.eclipse.ui.utils.SingleSourcingConstants;
 import org.eclipse.rap.rwt.service.ServiceHandler;
 
 /**
@@ -35,19 +40,12 @@ import org.eclipse.rap.rwt.service.ServiceHandler;
  * Clients might extend to provide context specific services
  */
 public class OpenFileService implements ServiceHandler {
-       public final static String PARAM_FILE_NAME = "param.fileName";
-       public final static String PARAM_FILE_URI = "param.fileURI";
-
-       public final static String SCHEME_HOST_SEPARATOR = "://";
-       public final static String FILE_SCHEME = "file";
-       public final static String JCR_SCHEME = "jcr";
-
        public OpenFileService() {
        }
 
        public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
-               String fileName = request.getParameter(PARAM_FILE_NAME);
-               String uri = request.getParameter(PARAM_FILE_URI);
+               String fileName = request.getParameter(SingleSourcingConstants.PARAM_FILE_NAME);
+               String uri = request.getParameter(SingleSourcingConstants.PARAM_FILE_URI);
 
                // Set the Metadata
                response.setContentLength((int) getFileSize(uri));
@@ -74,7 +72,7 @@ public class OpenFileService implements ServiceHandler {
         */
        protected byte[] getFileAsByteArray(String uri) {
                try {
-                       if (uri.startsWith(FILE_SCHEME)) {
+                       if (uri.startsWith(SingleSourcingConstants.FILE_SCHEME)) {
                                Path path = Paths.get(getAbsPathFromUri(uri));
                                return Files.readAllBytes(path);
                        }
@@ -90,7 +88,7 @@ public class OpenFileService implements ServiceHandler {
        }
 
        protected long getFileSize(String uri) throws IOException {
-               if (uri.startsWith(FILE_SCHEME)) {
+               if (uri.startsWith(SingleSourcingConstants.FILE_SCHEME)) {
                        Path path = Paths.get(getAbsPathFromUri(uri));
                        return Files.size(path);
                }
@@ -98,7 +96,7 @@ public class OpenFileService implements ServiceHandler {
        }
 
        protected String getFileName(String uri) {
-               if (uri.startsWith(FILE_SCHEME)) {
+               if (uri.startsWith(SingleSourcingConstants.FILE_SCHEME)) {
                        Path path = Paths.get(getAbsPathFromUri(uri));
                        return path.getFileName().toString();
                }
diff --git a/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java b/org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/UploadFileWizardPage.java
deleted file mode 100644 (file)
index c20d6b9..0000000
+++ /dev/null
@@ -1,195 +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;
-
-/** @deprecated Legacy, do not use */
-public class UploadFileWizardPage {
-}
-
-
-/// **
-// * RWT Specific convenience page that provides a simple interface to upload
-/// one
-// * file in a wizard context
-// *
-// * TODO Finalize clean and refactoring using the latest rap version and upload
-// * dialog addons
-// *
-// */
-// public class UploadFileWizardPage extends WizardPage {
-// // private final static Log log = LogFactory
-// // .getLog(UploadFileWizardPage.class);
-// private static final long serialVersionUID = 8251354244542973179L;
-// public final static String FILE_ITEM_TYPE = "FILE";
-// public final static String FOLDER_ITEM_TYPE = "FOLDER";
-//
-// private File file;
-//
-// private FileUpload fileUpload;
-// private ServerPushSession pushSession;
-// private Label fileNameLabel;
-//
-// public UploadFileWizardPage() {
-// 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(3, false));
-// composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-// new Label(composite, SWT.NONE).setText("Pick up a file");
-//
-// fileNameLabel = new Label(composite, SWT.NONE | SWT.BEGINNING);
-// fileNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
-// false));
-//
-// fileUpload = new FileUpload(composite, SWT.NONE);
-// fileUpload.setText("Browse...");
-// fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
-// false));
-//
-// final String url = startUploadReceiver();
-// pushSession = new ServerPushSession();
-//
-// fileUpload.addSelectionListener(new SelectionAdapter() {
-// private static final long serialVersionUID = 1L;
-//
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-// String fileName = fileUpload.getFileName();
-// fileNameLabel.setText(fileName == null ? "" : fileName);
-// pushSession.start();
-// fileUpload.submit(url);
-// }
-// });
-//
-// setControl(composite);
-// }
-//
-// public void performFinish() {
-// // boolean success = uploadFile.performUpload();
-// // if (!success)
-// // throw new ArgeoException("Cannot upload file named "
-// // + uploadFile.getPath());
-// }
-//
-// private String startUploadReceiver() {
-// MyFileUploadReceiver receiver = new MyFileUploadReceiver();
-// FileUploadHandler uploadHandler = new FileUploadHandler(receiver);
-// uploadHandler.addUploadListener(new FileUploadListener() {
-//
-// public void uploadProgress(FileUploadEvent event) {
-// // handle upload progress
-// }
-//
-// public void uploadFailed(FileUploadEvent event) {
-// UploadFileWizardPage.this.setErrorMessage("upload failed: "
-// + event.getException());
-// }
-//
-// public void uploadFinished(FileUploadEvent event) {
-//
-// fileNameLabel.getDisplay().asyncExec(new Runnable() {
-// public void run() {
-// // UploadFileWizardPage.this.getContainer()
-// // .updateButtons();
-// pushSession.stop();
-// }
-// });
-//
-// // for (FileDetails file : event.getFileDetails()) {
-// // // addToLog("received: " + file.getFileName());
-// // }
-// }
-// });
-// return uploadHandler.getUploadUrl();
-// }
-//
-// private class MyFileUploadReceiver extends FileUploadReceiver {
-//
-// private static final String TEMP_FILE_PREFIX = "fileupload_";
-//
-// @Override
-// public void receive(InputStream dataStream, FileDetails details)
-// throws IOException {
-// File result = File.createTempFile(TEMP_FILE_PREFIX, "");
-// FileOutputStream outputStream = new FileOutputStream(result);
-// try {
-// copy(dataStream, outputStream);
-// } finally {
-// dataStream.close();
-// outputStream.close();
-// }
-// file = result;
-// }
-// }
-//
-// private static void copy(InputStream inputStream, OutputStream outputStream)
-// throws IOException {
-// byte[] buffer = new byte[8192];
-// boolean finished = false;
-// while (!finished) {
-// int bytesRead = inputStream.read(buffer);
-// if (bytesRead != -1) {
-// outputStream.write(buffer, 0, bytesRead);
-// } else {
-// finished = true;
-// }
-// }
-// }
-//
-// /**
-// * The full path including the directory and file drive are only returned,
-// * if the browser supports reading this properties
-// *
-// * @return The full file name of the last uploaded file including the file
-// * path as selected by the user on his local machine.
-// */
-// public String getObjectPath() {
-// return null;
-// }
-//
-// public String getObjectName() {
-// return fileUpload.getFileName();
-// }
-//
-// public String getObjectType() {
-// return FILE_ITEM_TYPE;
-// }
-//
-// // protected void handleUploadFinished(final Upload upload) {
-// // }
-//
-// /** it is caller responsability to close the stream afterwards. */
-// public InputStream getFileInputStream() throws IOException {
-// return new FileInputStream(file);
-// // InputStream fis = null;
-// //
-// // try {
-// // fis = new FileInputStream(file);
-// // return fis;
-// // } catch (Exception e) {
-// // throw new ArgeoException("Unable to retrieve file " + file, e);
-// // } finally {
-// // IOUtils.closeQuietly(fis);
-// // }
-// }
-//
-// public boolean getNeedsProgressMonitor() {
-// return false;
-// }
-// }
index d944b66ef4f03f06350038252fdac15165062b20..8cce0e21719469a9d13787072334b2a2d690e463 100644 (file)
@@ -99,6 +99,7 @@ public class SingleValue extends TitleAreaDialog {
                setMessage(message, IMessageProvider.NONE);
 
                parent.pack();
+               valueT.setFocus();
                return composite;
        }
 
diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/SingleSourcingConstants.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/SingleSourcingConstants.java
new file mode 100644 (file)
index 0000000..2698900
--- /dev/null
@@ -0,0 +1,17 @@
+package org.argeo.eclipse.ui.utils;
+
+/**
+ * Centralise constants that are used in both RAP and RCP specific code to avoid
+ * dupplicated declaration
+ */
+public interface SingleSourcingConstants {
+
+       // Single sourced open file command
+       String OPEN_FILE_CMD_ID = "org.argeo.cms.ui.workbench.openFile";
+       String PARAM_FILE_NAME = "param.fileName";
+       String PARAM_FILE_URI = "param.fileURI";
+
+       String SCHEME_HOST_SEPARATOR = "://";
+       String FILE_SCHEME = "file";
+       String JCR_SCHEME = "jcr";
+}
index a726bdb321dae1af2db78fc0c36ac9dd58c7c651..4a53e40313d92ec3c2f4fe0e528507f110073f8a 100644 (file)
@@ -49,7 +49,7 @@ public class ViewerUtils {
        public static TableViewerColumn createTableViewerColumn(TableViewer parent,
                        String name, int style, int width) {
                TableViewerColumn tvc = new TableViewerColumn(parent, style);
-               final TableColumn column = tvc.getColumn();
+               TableColumn column = tvc.getColumn();
                column.setText(name);
                column.setWidth(width);
                column.setResizable(true);
@@ -63,7 +63,7 @@ public class ViewerUtils {
        public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
                        String name, int style, int width) {
                TreeViewerColumn tvc = new TreeViewerColumn(parent, style);
-               final TreeColumn column = tvc.getColumn();
+               TreeColumn column = tvc.getColumn();
                column.setText(name);
                column.setWidth(width);
                column.setResizable(true);