</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>
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>
<?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>
<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>
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,\
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>
setMessage(changePassword.lead(), INFORMATION);
parent.pack();
+ oldPassword.setFocus();
return composite;
}
+++ /dev/null
-/*
- * 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;
- }
-}
/** Constants used across the application. */
public interface WorkbenchConstants {
- /*
- * MISCEALLENEOUS
- */
+ // MISCEALLENEOUS
public final static String DATE_TIME_FORMAT = "dd/MM/yyyy, HH:mm";
-
}
+++ /dev/null
-/*
- * 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);
- }
- }
- }
-}
--- /dev/null
+/*
+ * 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);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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) {
+ }
+}
+++ /dev/null
-/*
- * 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) {
- }
-}
--- /dev/null
+/*
+ * 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;
+ }
+}
*/
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;
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;
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;
// 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;
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);
}
}
}
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);
}
}
+++ /dev/null
-/*
- * 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;
- }
-}
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;
private Node currentNode;
// this page UI components
- private SingleNodeAsTreeContentProvider nodeContentProvider;
+ private JcrTreeContentProvider nodeContentProvider;
private TreeViewer nodesViewer;
public ChildNodesPage(FormEditor editor, String title, Node currentNode) {
managedForm.getToolkit().createLabel(body,
WorkbenchUiPlugin.getMessage("warningNoChildNode"));
} else {
- nodeContentProvider = new SingleNodeAsTreeContentProvider();
+ nodeContentProvider = new JcrTreeContentProvider();
nodesViewer = createNodeViewer(body, nodeContentProvider);
nodesViewer.setInput(currentNode);
}
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;
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;
}
+++ /dev/null
-/*
- * 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();
- }
- }
-}
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;
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);
}
}
/**
* 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) {
+++ /dev/null
-/*
- * 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;
- }
-}
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;
tmpNodeViewer.setContentProvider(nodeContentProvider);
tmpNodeViewer.setLabelProvider(new VersionLabelProvider());
tmpNodeViewer
- .addDoubleClickListener(new GenericNodeDoubleClickListener(
+ .addDoubleClickListener(new JcrDClickListener(
tmpNodeViewer));
return tmpNodeViewer;
}
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;
}
tmpNodeViewer
- .addDoubleClickListener(new GenericNodeDoubleClickListener(
+ .addDoubleClickListener(new JcrDClickListener(
tmpNodeViewer));
return tmpNodeViewer;
}
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
Import-Package: org.eclipse.swt,\
org.eclipse.jface.dialogs,\
+ org.argeo.eclipse.ui.utils,\
*
+++ /dev/null
-/*
- * 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;
-// }
-// }
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;
* 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
// 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();
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;
+ }
+}
*/
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;
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;
/**
* 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));
*/
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);
}
}
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);
}
}
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();
}
+++ /dev/null
-/*
- * 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;
-// }
-// }
setMessage(message, IMessageProvider.NONE);
parent.pack();
+ valueT.setFocus();
return composite;
}
--- /dev/null
+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";
+}
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);
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);