+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.argeo.slc.client.rcp</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+++ /dev/null
-#Wed Aug 04 16:32:22 CEST 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <!-- RCP Specific open JCR file command -->
- <bean id="org.argeo.slc.client.rcp.openJcrFile" class="org.argeo.slc.client.ui.specific.OpenJcrFile"
- scope="prototype">
- <property name="repoService" ref="repoService" />
- </bean>
-
- <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="nodeRepository" ref="nodeRepository" />
- </bean>
-</beans>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
- xmlns:osgi="http://www.springframework.org/schema/osgi"\r
- xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
- http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
- http://www.springframework.org/schema/beans \r
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
- osgi:default-timeout="30000">\r
-\r
- <beans:description>SLC UI RCP</beans:description>\r
-\r
- <reference id="nodeRepository" interface="javax.jcr.Repository"\r
- filter="(argeo.jcr.repository.alias=node)" />\r
- <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
- <reference id="keyring" interface="org.argeo.security.crypto.CryptoKeyring" />\r
-\r
-</beans:beans>
\ No newline at end of file
+++ /dev/null
-source.. = src/main/java
-output.. = target/classes
-bin.includes = plugin.xml,\
- META-INF/,\
- .,\
- icons/,\
- splash.bmp,\
- plugin_customization.ini
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- id="org.argeo.slc.client.rcp.product"
- point="org.eclipse.core.runtime.products">
- <product
- application="org.argeo.slc.client.rcp.application"
- name="SLC">
- <property
- name="windowImages"
- value="icons/argeo-icon-256.png">
- </property>
- <property
- name="appName"
- value="SLC">
- </property>
- <property
- name="preferenceCustomization"
- value="plugin_customization.ini">
- </property>
- </product>
- </extension>
- <extension
- id="org.argeo.slc.client.rcp.application"
- point="org.eclipse.core.runtime.applications">
- <application>
- <run
- class="org.argeo.slc.client.rcp.SlcSecureClientApplication">
- </run>
- </application>
- </extension>
-
- <!-- COMMANDS -->
- <extension
- point="org.eclipse.ui.commands">
- <command
- id="org.argeo.slc.client.rcp.openJcrFile"
- defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
- name="Open Workspace Editor">
- <commandParameter
- id="param.repoNodePath"
- name="Repo node path">
- </commandParameter>
- <commandParameter
- id="param.repoUri"
- name="Repo URI">
- </commandParameter>
- <commandParameter
- id="param.workspaceName"
- name="Workspace name">
- </commandParameter>
- <commandParameter
- id="param.filePath"
- name="File Path">
- </commandParameter>
- </command>
- </extension>
-
- <!-- RCP Specific, does not work with RAP -->
- <extension
- point="org.eclipse.ui.bindings">
- <!-- <key
- commandId="org.argeo.slc.client.ui.refreshExecutionModulesView"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="CTRL+R">
- </key> -->
- </extension>
-</plugin>
+++ /dev/null
-org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
-org.eclipse.ui/SHOW_TEXT_ON_PERSPECTIVE_BAR=false
-org.eclipse.ui/PERSPECTIVE_BAR_SIZE=100
-org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=true
-org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false
+++ /dev/null
-<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.slc</groupId>
- <artifactId>plugins</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>org.argeo.slc.client.rcp</artifactId>
- <name>SLC Client RCP</name>
- <packaging>jar</packaging>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>org.argeo.slc.client.rcp.SlcRcpPlugin</Bundle-Activator>
- <Require-Bundle>
- org.eclipse.ui,
- org.eclipse.core.runtime
- </Require-Bundle>
- <Import-Package>
- org.argeo.eclipse.spring,
- org.argeo.slc.repo.core,
- javax.jcr.nodetype,
- *,
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <!-- SLC -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.repo</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
-
- <!-- Bundles to start -->
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.node.jackrabbit</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.slc</groupId>
- <artifactId>org.argeo.slc.agent</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.argeo.commons.security</groupId>
- <artifactId>org.argeo.security.dao.jackrabbit</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons.server</groupId>
- <artifactId>org.argeo.node.repo.jackrabbit</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
-
- <!-- Security UI -->
- <dependency>
- <groupId>org.argeo.commons.base</groupId>
- <artifactId>org.argeo.eclipse.dep.rcp</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- <dependency>
- <groupId>org.argeo.commons.security</groupId>
- <artifactId>org.argeo.security.ui.rcp</artifactId>
- <version>${version.argeo-commons}</version>
- </dependency>
- </dependencies>
-</project>
+++ /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.slc.client.rcp;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class SlcRcpPlugin extends AbstractUIPlugin {
- public static final String PLUGIN_ID = "org.argeo.slc.client.rcp";
- private static SlcRcpPlugin plugin;
-
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- public static SlcRcpPlugin getDefault() {
- return plugin;
- }
-
- @Override
- protected void initializeImageRegistry(ImageRegistry reg) {
- // TODO make it configurable
- reg.put("argeoTrayIcon",
- getImageDescriptor("icons/argeo-trayIcon-256.png"));
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-}
+++ /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.slc.client.rcp;
-
-import org.argeo.security.ui.rcp.SecureRcp;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.window.Window.IExceptionHandler;
-import org.eclipse.ui.application.WorkbenchAdvisor;
-
-/**
- * This class controls all aspects of the application's execution
- */
-public class SlcSecureClientApplication extends SecureRcp {
-
- @Override
- protected WorkbenchAdvisor createWorkbenchAdvisor(String username) {
- Window.setExceptionHandler(new IExceptionHandler() {
-
- public void handleException(Throwable t) {
- System.err.println("Unexpected SLC UI exception: " + t);
-
- }
- });
-
- return new SlcSecureWorkbenchAdvisor(username);
- }
-
-}
+++ /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.slc.client.rcp;
-
-import org.argeo.security.ui.rcp.SecureWorkbenchAdvisor;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.application.WorkbenchWindowAdvisor;
-
-/**
- * Custom {@link SecureWorkbenchAdvisor} in order to create a
- * {@link SlcSecureWorkbenchWindowAdvisor}.
- */
-public class SlcSecureWorkbenchAdvisor extends SecureWorkbenchAdvisor {
- public SlcSecureWorkbenchAdvisor(String username) {
- super(username);
- }
-
- public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer) {
- return new SlcSecureWorkbenchWindowAdvisor(configurer, getUsername());
- }
-}
+++ /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.slc.client.rcp;
-
-import org.argeo.security.ui.rcp.SecureWorkbenchWindowAdvisor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tray;
-import org.eclipse.swt.widgets.TrayItem;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.part.EditorInputTransfer;
-
-/**
- * Custom {@link SecureWorkbenchWindowAdvisor} which can add a tray. TODO: to
- * be factorized in Argeo Commons and made more generic.
- */
-public class SlcSecureWorkbenchWindowAdvisor extends
- SecureWorkbenchWindowAdvisor {
- public final static String IN_TRAY_PROPERTY = "org.argeo.slc.ui.inTray";
-
- private TrayItem trayItem;
-
- public SlcSecureWorkbenchWindowAdvisor(
- IWorkbenchWindowConfigurer configurer, String username) {
- super(configurer, username);
- }
-
- public void postWindowOpen() {
- String inTray = System.getProperty(IN_TRAY_PROPERTY);
- if (inTray != null && inTray.equals("true")) {
- initTray();
- }
- }
-
- @Override
- public void preWindowOpen() {
- getWindowConfigurer().addEditorAreaTransfer(
- EditorInputTransfer.getInstance());
- getWindowConfigurer().configureEditorAreaDropListener(
- new DropTargetAdapter() {
-
- @Override
- public void dragEnter(DropTargetEvent event) {
- System.out.println("DROP enter!!! " + event);
- }
-
- @Override
- public void dragLeave(DropTargetEvent event) {
- System.out.println("DROP leave!!! " + event);
- }
-
- public void drop(DropTargetEvent event) {
- System.out.println("DROP drop!!! " + event);
-
- }
-
- @Override
- public void dropAccept(DropTargetEvent event) {
- System.out.println("DROP accept!!! " + event);
- super.dropAccept(event);
- }
-
- });
- super.preWindowOpen();
- }
-
- @Override
- public boolean preWindowShellClose() {
- // hide but do not dispose if tray is supported
- if (trayItem != null) {
- getWindowConfigurer().getWindow().getShell().setVisible(false);
- return false;
- } else
- return true;
- }
-
- /** Init tray support */
- protected void initTray() {
- IWorkbenchWindow window = getWindowConfigurer().getWindow();
- Shell shell = window.getShell();
- final Tray tray = shell.getDisplay().getSystemTray();
- trayItem = new TrayItem(tray, SWT.NONE);
- if (trayItem == null)
- return;
-
- // image
- Image trayImage = SlcRcpPlugin.getDefault().getImageRegistry()
- .get("argeoTrayIcon");
- trayItem.setImage(trayImage);
- trayItem.setToolTipText("Argeo SLC");
-
- // add pop-menu
- // TODO: contribute more commands
- trayItem.addListener(SWT.MenuDetect, new Listener() {
- public void handleEvent(Event event) {
- IWorkbenchWindow window = getWindowConfigurer().getWindow();
- Menu menu = new Menu(window.getShell(), SWT.POP_UP);
- MenuItem exit = new MenuItem(menu, SWT.NONE);
- exit.setText("Exit");
- exit.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- getWindowConfigurer().getWorkbenchConfigurer()
- .getWorkbench().close();
- }
- });
- menu.setVisible(true);
- }
- });
-
- // add behavior when clicked upon
- trayItem.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- Shell shell = getWindowConfigurer().getWindow().getShell();
- if (shell.isVisible()) {
- if (shell.getMinimized())
- shell.setMinimized(false);
- else {
- shell.setVisible(false);
- shell.setMinimized(true);
- }
- } else {
- shell.setVisible(true);
- shell.setActive();
- shell.setFocus();
- shell.setMinimized(false);
- }
- }
- });
-
- // start hidden
- // shell.setVisible(false);
- }
-
- @Override
- public void dispose() {
- if (trayItem != null)
- trayItem.dispose();
- }
-
-}
+++ /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.slc.client.ui.specific;
-
-import java.awt.Desktop;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.nodetype.NodeType;
-
-import org.apache.commons.io.IOUtils;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.repo.RepoService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * RCP specific command handler to open a file retrieved from a local or distant
- * JCR Repository.
- */
-public class OpenJcrFile extends AbstractHandler {
- // private final static Log log = LogFactory.getLog(OpenJcrFile.class);
-
- // Here is the trick that enable single sourcing: the ID is determined at
- // runtime so use (new OpenJcrFileCmdId()).getCmdId() instead of the usual
- // public final String ID = SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
-
- public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
- public final static String PARAM_REPO_URI = "param.repoUri";
- public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
- public final static String PARAM_FILE_PATH = "param.filePath";
-
- /* DEPENDENCY INJECTION */
- private RepoService repoService;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
- String repoUri = event.getParameter(PARAM_REPO_URI);
- String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
- String filePath = event.getParameter(PARAM_FILE_PATH);
-
- // TODO sanity check
- if (filePath == null || "".equals(filePath.trim()))
- return null;
- retrieveAndOpen(repoNodePath, repoUri, wkspName, filePath);
-
- return null;
- }
-
- protected void retrieveAndOpen(String repoNodePath, String repoUri,
- String wkspName, String filePath) {
- Session businessSession = null;
- try {
- businessSession = repoService.getRemoteSession(repoNodePath,
- repoUri, wkspName);
- Node result = businessSession.getNode(filePath);
-
- boolean isValid = true;
- Node child = null;
- if (!result.isNodeType(NodeType.NT_FILE))
- isValid = false;
- else {
- child = result.getNode(Property.JCR_CONTENT);
- if (!(child.isNodeType(NodeType.NT_RESOURCE) || child
- .hasProperty(Property.JCR_DATA)))
- isValid = false;
- }
-
- if (!isValid)
- return;
-
- InputStream fis = null;
- String prefix = "", extension = "";
- String fileName = JcrUtils.lastPathElement(filePath);
- int ind = fileName.lastIndexOf('.');
- if (ind > 0) {
- prefix = fileName.substring(0, ind);
- extension = fileName.substring(ind);
- }
- try {
-
- fis = (InputStream) child.getProperty(Property.JCR_DATA)
- .getBinary().getStream();
- File file = createTmpFile(prefix, extension, fis);
- Desktop desktop = null;
- if (Desktop.isDesktopSupported()) {
- desktop = Desktop.getDesktop();
- }
- desktop.open(file);
- } catch (Exception e) {
- throw new SlcException(
- "Stream error while opening file " + filePath
- + " from repo " + repoUri == null ? repoNodePath
- : repoUri, e);
- } finally {
- IOUtils.closeQuietly(fis);
- }
- } catch (RepositoryException e) {
- throw new SlcException("Unexpected error while "
- + "getting repoNode info for repoNode at path "
- + repoNodePath, e);
- } finally {
- JcrUtils.logoutQuietly(businessSession);
- }
- }
-
- private File createTmpFile(String prefix, String suffix, InputStream is) {
- File tmpFile = null;
- OutputStream os = null;
- try {
- tmpFile = File.createTempFile(prefix, suffix);
- os = new FileOutputStream(tmpFile);
- IOUtils.copy(is, os);
- } catch (IOException e) {
- throw new SlcException("Cannot open file " + prefix + "." + suffix,
- e);
- } finally {
- IOUtils.closeQuietly(os);
- }
- return tmpFile;
- }
-
- /* DEPENDENCY INJECTION */
- public void setRepoService(RepoService repoService) {
- this.repoService = repoService;
- }
-}
\ No newline at end of file
+++ /dev/null
-package org.argeo.slc.client.ui.specific;
-
-import org.argeo.slc.client.rcp.SlcRcpPlugin;
-
-/**
- * Workaround a single sourcing problem:
- *
- * final static variable are imported at compilation time (we build against RCP)
- * and we still must have a different ID (the prefix must be the PLUGIN ID) for
- * RAP and RCP in order to be able to inject beans in the corresponding commands
- */
-public class OpenJcrFileCmdId {
-
- public String getCmdId() {
- return SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
- }
-}
+++ /dev/null
-<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.slc</groupId>
- <artifactId>argeo-slc</artifactId>
- <version>2.1.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>plugins</artifactId>
- <name>SLC Eclipse Plugins</name>
- <packaging>pom</packaging>
- <modules>
- <module>org.argeo.slc.client.rcp</module>
- <module>org.argeo.slc.client.rap</module>
- <module>org.argeo.slc.client.ui</module>
- <module>org.argeo.slc.client.ui.dist</module>
- </modules>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
- <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <configuration>
- <!-- Prevents source jars to contain misleading data -->
- <excludes>
- <exclude>plugin.xml</exclude>
- <exclude>META-INF/MANIFEST.MF</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.slc.client.rcp</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Wed Aug 04 16:32:22 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <!-- RCP Specific open JCR file command -->
+ <bean id="org.argeo.slc.client.rcp.openJcrFile" class="org.argeo.slc.client.ui.specific.OpenJcrFile"
+ scope="prototype">
+ <property name="repoService" ref="repoService" />
+ </bean>
+
+ <bean id="repoService" class="org.argeo.slc.repo.core.RepoServiceImpl">
+ <property name="repositoryFactory" ref="repositoryFactory" />
+ <property name="keyring" ref="keyring" />
+ <property name="nodeRepository" ref="nodeRepository" />
+ </bean>
+</beans>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
+ xmlns:osgi="http://www.springframework.org/schema/osgi"\r
+ xsi:schemaLocation="http://www.springframework.org/schema/osgi \r
+ http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
+ http://www.springframework.org/schema/beans \r
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+ osgi:default-timeout="30000">\r
+\r
+ <beans:description>SLC UI RCP</beans:description>\r
+\r
+ <reference id="nodeRepository" interface="javax.jcr.Repository"\r
+ filter="(argeo.jcr.repository.alias=node)" />\r
+ <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
+ <reference id="keyring" interface="org.argeo.security.crypto.CryptoKeyring" />\r
+\r
+</beans:beans>
\ No newline at end of file
--- /dev/null
+Bundle-SymbolicName: org.argeo.slc.client.rcp;singleton=true
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.argeo.slc.client.rcp.SlcRcpPlugin
+Require-Bundle: org.eclipse.ui,\
+org.eclipse.core.runtime
+
+Import-Package: javax.jcr.nodetype,\
+org.argeo.eclipse.spring,\
+org.argeo.slc.repo.core,\
+org.argeo.cms.util,\
+*
+
\ No newline at end of file
--- /dev/null
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ splash.bmp,\
+ plugin_customization.ini
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="org.argeo.slc.client.rcp.product"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="org.argeo.slc.client.rcp.application"
+ name="SLC">
+ <property
+ name="windowImages"
+ value="icons/argeo-icon-256.png">
+ </property>
+ <property
+ name="appName"
+ value="SLC">
+ </property>
+ <property
+ name="preferenceCustomization"
+ value="plugin_customization.ini">
+ </property>
+ </product>
+ </extension>
+ <extension
+ id="org.argeo.slc.client.rcp.application"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run
+ class="org.argeo.slc.client.rcp.SlcSecureClientApplication">
+ </run>
+ </application>
+ </extension>
+
+ <!-- COMMANDS -->
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.argeo.slc.client.rcp.openJcrFile"
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ name="Open Workspace Editor">
+ <commandParameter
+ id="param.repoNodePath"
+ name="Repo node path">
+ </commandParameter>
+ <commandParameter
+ id="param.repoUri"
+ name="Repo URI">
+ </commandParameter>
+ <commandParameter
+ id="param.workspaceName"
+ name="Workspace name">
+ </commandParameter>
+ <commandParameter
+ id="param.filePath"
+ name="File Path">
+ </commandParameter>
+ </command>
+ </extension>
+
+ <!-- RCP Specific, does not work with RAP -->
+ <extension
+ point="org.eclipse.ui.bindings">
+ <!-- <key
+ commandId="org.argeo.slc.client.ui.refreshExecutionModulesView"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="CTRL+R">
+ </key> -->
+ </extension>
+</plugin>
--- /dev/null
+org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
+org.eclipse.ui/SHOW_TEXT_ON_PERSPECTIVE_BAR=false
+org.eclipse.ui/PERSPECTIVE_BAR_SIZE=100
+org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=true
+org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false
--- /dev/null
+<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.slc</groupId>
+ <artifactId>argeo-slc</artifactId>
+ <version>2.1.6-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>org.argeo.slc.client.rcp</artifactId>
+ <name>SLC Client RCP</name>
+ <packaging>jar</packaging>
+ <!-- <build> -->
+ <!-- <plugins> -->
+ <!-- <plugin> -->
+ <!-- <groupId>org.apache.felix</groupId> -->
+ <!-- <artifactId>maven-bundle-plugin</artifactId> -->
+ <!-- <configuration> -->
+ <!-- <instructions> -->
+ <!-- <Bundle-Activator>org.argeo.slc.client.rcp.SlcRcpPlugin</Bundle-Activator> -->
+ <!-- <Require-Bundle> -->
+ <!-- org.eclipse.ui, -->
+ <!-- org.eclipse.core.runtime -->
+ <!-- </Require-Bundle> -->
+ <!-- <Import-Package> -->
+ <!-- org.argeo.eclipse.spring, -->
+ <!-- org.argeo.slc.repo.core, -->
+ <!-- javax.jcr.nodetype, -->
+ <!-- *, -->
+ <!-- </Import-Package> -->
+ <!-- </instructions> -->
+ <!-- </configuration> -->
+ <!-- </plugin> -->
+ <!-- </plugins> -->
+ <!-- </build> -->
+ <dependencies>
+ <!-- SLC -->
+ <dependency>
+ <groupId>org.argeo.slc</groupId>
+ <artifactId>org.argeo.slc.repo</artifactId>
+ <version>2.1.6-SNAPSHOT</version>
+ </dependency>
+ <!-- Argeo common distribution for Secured UI -->
+ <dependency>
+ <groupId>org.argeo.commons.rcp</groupId>
+ <artifactId>org.argeo.cms.ui.workbench.rcp</artifactId>
+ <version>${version.argeo-rcp}</version>
+ </dependency>
+ </dependencies>
+</project>
--- /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.slc.client.rcp;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SlcRcpPlugin extends AbstractUIPlugin {
+ public static final String PLUGIN_ID = "org.argeo.slc.client.rcp";
+ private static SlcRcpPlugin plugin;
+
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ public static SlcRcpPlugin getDefault() {
+ return plugin;
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ // TODO make it configurable
+ reg.put("argeoTrayIcon",
+ getImageDescriptor("icons/argeo-trayIcon-256.png"));
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
--- /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.slc.client.rcp;
+
+import org.argeo.security.ui.rcp.SecureRcp;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.window.Window.IExceptionHandler;
+import org.eclipse.ui.application.WorkbenchAdvisor;
+
+/**
+ * This class controls all aspects of the application's execution
+ */
+public class SlcSecureClientApplication extends SecureRcp {
+
+ @Override
+ protected WorkbenchAdvisor createWorkbenchAdvisor(String username) {
+ Window.setExceptionHandler(new IExceptionHandler() {
+
+ public void handleException(Throwable t) {
+ System.err.println("Unexpected SLC UI exception: " + t);
+
+ }
+ });
+
+ return new SlcSecureWorkbenchAdvisor(username);
+ }
+
+}
--- /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.slc.client.rcp;
+
+import org.argeo.security.ui.rcp.SecureWorkbenchAdvisor;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+
+/**
+ * Custom {@link SecureWorkbenchAdvisor} in order to create a
+ * {@link SlcSecureWorkbenchWindowAdvisor}.
+ */
+public class SlcSecureWorkbenchAdvisor extends SecureWorkbenchAdvisor {
+ public SlcSecureWorkbenchAdvisor(String username) {
+ super(username);
+ }
+
+ public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
+ IWorkbenchWindowConfigurer configurer) {
+ return new SlcSecureWorkbenchWindowAdvisor(configurer, getUsername());
+ }
+}
--- /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.slc.client.rcp;
+
+import org.argeo.security.ui.rcp.SecureWorkbenchWindowAdvisor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tray;
+import org.eclipse.swt.widgets.TrayItem;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
+import org.eclipse.ui.part.EditorInputTransfer;
+
+/**
+ * Custom {@link SecureWorkbenchWindowAdvisor} which can add a tray. TODO: to
+ * be factorized in Argeo Commons and made more generic.
+ */
+public class SlcSecureWorkbenchWindowAdvisor extends
+ SecureWorkbenchWindowAdvisor {
+ public final static String IN_TRAY_PROPERTY = "org.argeo.slc.ui.inTray";
+
+ private TrayItem trayItem;
+
+ public SlcSecureWorkbenchWindowAdvisor(
+ IWorkbenchWindowConfigurer configurer, String username) {
+ super(configurer, username);
+ }
+
+ public void postWindowOpen() {
+ String inTray = System.getProperty(IN_TRAY_PROPERTY);
+ if (inTray != null && inTray.equals("true")) {
+ initTray();
+ }
+ }
+
+ @Override
+ public void preWindowOpen() {
+ getWindowConfigurer().addEditorAreaTransfer(
+ EditorInputTransfer.getInstance());
+ getWindowConfigurer().configureEditorAreaDropListener(
+ new DropTargetAdapter() {
+
+ @Override
+ public void dragEnter(DropTargetEvent event) {
+ System.out.println("DROP enter!!! " + event);
+ }
+
+ @Override
+ public void dragLeave(DropTargetEvent event) {
+ System.out.println("DROP leave!!! " + event);
+ }
+
+ public void drop(DropTargetEvent event) {
+ System.out.println("DROP drop!!! " + event);
+
+ }
+
+ @Override
+ public void dropAccept(DropTargetEvent event) {
+ System.out.println("DROP accept!!! " + event);
+ super.dropAccept(event);
+ }
+
+ });
+ super.preWindowOpen();
+ }
+
+ @Override
+ public boolean preWindowShellClose() {
+ // hide but do not dispose if tray is supported
+ if (trayItem != null) {
+ getWindowConfigurer().getWindow().getShell().setVisible(false);
+ return false;
+ } else
+ return true;
+ }
+
+ /** Init tray support */
+ protected void initTray() {
+ IWorkbenchWindow window = getWindowConfigurer().getWindow();
+ Shell shell = window.getShell();
+ final Tray tray = shell.getDisplay().getSystemTray();
+ trayItem = new TrayItem(tray, SWT.NONE);
+ if (trayItem == null)
+ return;
+
+ // image
+ Image trayImage = SlcRcpPlugin.getDefault().getImageRegistry()
+ .get("argeoTrayIcon");
+ trayItem.setImage(trayImage);
+ trayItem.setToolTipText("Argeo SLC");
+
+ // add pop-menu
+ // TODO: contribute more commands
+ trayItem.addListener(SWT.MenuDetect, new Listener() {
+ public void handleEvent(Event event) {
+ IWorkbenchWindow window = getWindowConfigurer().getWindow();
+ Menu menu = new Menu(window.getShell(), SWT.POP_UP);
+ MenuItem exit = new MenuItem(menu, SWT.NONE);
+ exit.setText("Exit");
+ exit.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ getWindowConfigurer().getWorkbenchConfigurer()
+ .getWorkbench().close();
+ }
+ });
+ menu.setVisible(true);
+ }
+ });
+
+ // add behavior when clicked upon
+ trayItem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ Shell shell = getWindowConfigurer().getWindow().getShell();
+ if (shell.isVisible()) {
+ if (shell.getMinimized())
+ shell.setMinimized(false);
+ else {
+ shell.setVisible(false);
+ shell.setMinimized(true);
+ }
+ } else {
+ shell.setVisible(true);
+ shell.setActive();
+ shell.setFocus();
+ shell.setMinimized(false);
+ }
+ }
+ });
+
+ // start hidden
+ // shell.setVisible(false);
+ }
+
+ @Override
+ public void dispose() {
+ if (trayItem != null)
+ trayItem.dispose();
+ }
+
+}
--- /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.slc.client.ui.specific;
+
+import java.awt.Desktop;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.io.IOUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.repo.RepoService;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * RCP specific command handler to open a file retrieved from a local or distant
+ * JCR Repository.
+ */
+public class OpenJcrFile extends AbstractHandler {
+ // private final static Log log = LogFactory.getLog(OpenJcrFile.class);
+
+ // Here is the trick that enable single sourcing: the ID is determined at
+ // runtime so use (new OpenJcrFileCmdId()).getCmdId() instead of the usual
+ // public final String ID = SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
+
+ public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+ public final static String PARAM_REPO_URI = "param.repoUri";
+ public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+ public final static String PARAM_FILE_PATH = "param.filePath";
+
+ /* DEPENDENCY INJECTION */
+ private RepoService repoService;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+ String repoUri = event.getParameter(PARAM_REPO_URI);
+ String wkspName = event.getParameter(PARAM_WORKSPACE_NAME);
+ String filePath = event.getParameter(PARAM_FILE_PATH);
+
+ // TODO sanity check
+ if (filePath == null || "".equals(filePath.trim()))
+ return null;
+ retrieveAndOpen(repoNodePath, repoUri, wkspName, filePath);
+
+ return null;
+ }
+
+ protected void retrieveAndOpen(String repoNodePath, String repoUri,
+ String wkspName, String filePath) {
+ Session businessSession = null;
+ try {
+ businessSession = repoService.getRemoteSession(repoNodePath,
+ repoUri, wkspName);
+ Node result = businessSession.getNode(filePath);
+
+ boolean isValid = true;
+ Node child = null;
+ if (!result.isNodeType(NodeType.NT_FILE))
+ isValid = false;
+ else {
+ child = result.getNode(Property.JCR_CONTENT);
+ if (!(child.isNodeType(NodeType.NT_RESOURCE) || child
+ .hasProperty(Property.JCR_DATA)))
+ isValid = false;
+ }
+
+ if (!isValid)
+ return;
+
+ InputStream fis = null;
+ String prefix = "", extension = "";
+ String fileName = JcrUtils.lastPathElement(filePath);
+ int ind = fileName.lastIndexOf('.');
+ if (ind > 0) {
+ prefix = fileName.substring(0, ind);
+ extension = fileName.substring(ind);
+ }
+ try {
+
+ fis = (InputStream) child.getProperty(Property.JCR_DATA)
+ .getBinary().getStream();
+ File file = createTmpFile(prefix, extension, fis);
+ Desktop desktop = null;
+ if (Desktop.isDesktopSupported()) {
+ desktop = Desktop.getDesktop();
+ }
+ desktop.open(file);
+ } catch (Exception e) {
+ throw new SlcException(
+ "Stream error while opening file " + filePath
+ + " from repo " + repoUri == null ? repoNodePath
+ : repoUri, e);
+ } finally {
+ IOUtils.closeQuietly(fis);
+ }
+ } catch (RepositoryException e) {
+ throw new SlcException("Unexpected error while "
+ + "getting repoNode info for repoNode at path "
+ + repoNodePath, e);
+ } finally {
+ JcrUtils.logoutQuietly(businessSession);
+ }
+ }
+
+ private File createTmpFile(String prefix, String suffix, InputStream is) {
+ File tmpFile = null;
+ OutputStream os = null;
+ try {
+ tmpFile = File.createTempFile(prefix, suffix);
+ os = new FileOutputStream(tmpFile);
+ IOUtils.copy(is, os);
+ } catch (IOException e) {
+ throw new SlcException("Cannot open file " + prefix + "." + suffix,
+ e);
+ } finally {
+ IOUtils.closeQuietly(os);
+ }
+ return tmpFile;
+ }
+
+ /* DEPENDENCY INJECTION */
+ public void setRepoService(RepoService repoService) {
+ this.repoService = repoService;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.client.ui.specific;
+
+import org.argeo.slc.client.rcp.SlcRcpPlugin;
+
+/**
+ * Workaround a single sourcing problem:
+ *
+ * final static variable are imported at compilation time (we build against RCP)
+ * and we still must have a different ID (the prefix must be the PLUGIN ID) for
+ * RAP and RCP in order to be able to inject beans in the corresponding commands
+ */
+public class OpenJcrFileCmdId {
+
+ public String getCmdId() {
+ return SlcRcpPlugin.PLUGIN_ID + ".openJcrFile";
+ }
+}
<properties>
<developmentCycle.slc>2.1</developmentCycle.slc>
<developmentCycle.startDate>2015-02-12</developmentCycle.startDate>
+ <version.argeo-rcp>2.1.12-SNAPSHOT</version.argeo-rcp>
<version.slc>2.1.6-SNAPSHOT</version.slc>
</properties>
<modules>
<module>org.argeo.slc.client.ui</module>
<module>org.argeo.slc.client.ui.dist</module>
<module>org.argeo.slc.client.rap</module>
+ <module>org.argeo.slc.client.rcp</module>
<module>lib</module>
<module>dep</module>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
+ <repository>
+ <id>argeo-rcp</id>
+ <url>http://forge.argeo.org/data/public/java/argeo-rcp-2.1</url>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+
<!-- Disable Maven default repository -->
<repository>
<id>central</id>