Introduce Eclipse 4 support
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 13 Apr 2018 09:32:34 +0000 (11:32 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 13 Apr 2018 09:32:34 +0000 (11:32 +0200)
15 files changed:
dep/org.argeo.slc.dep.e4.rap/.gitignore [new file with mode: 0644]
dep/org.argeo.slc.dep.e4.rap/META-INF/.gitignore [new file with mode: 0644]
dep/org.argeo.slc.dep.e4.rap/bnd.bnd [new file with mode: 0644]
dep/org.argeo.slc.dep.e4.rap/pom.xml [new file with mode: 0644]
dep/pom.xml
org.argeo.slc.e4/.classpath [new file with mode: 0644]
org.argeo.slc.e4/.gitignore [new file with mode: 0644]
org.argeo.slc.e4/.project [new file with mode: 0644]
org.argeo.slc.e4/META-INF/.gitignore [new file with mode: 0644]
org.argeo.slc.e4/bnd.bnd [new file with mode: 0644]
org.argeo.slc.e4/build.properties [new file with mode: 0644]
org.argeo.slc.e4/pom.xml [new file with mode: 0644]
org.argeo.slc.e4/src/org/argeo/slc/e4/SlcImages.java [new file with mode: 0644]
org.argeo.slc.e4/src/org/argeo/slc/e4/parts/JcrExecutionModulesView.java [new file with mode: 0644]
pom.xml

diff --git a/dep/org.argeo.slc.dep.e4.rap/.gitignore b/dep/org.argeo.slc.dep.e4.rap/.gitignore
new file mode 100644 (file)
index 0000000..5931da6
--- /dev/null
@@ -0,0 +1,2 @@
+/target/
+*.target
diff --git a/dep/org.argeo.slc.dep.e4.rap/META-INF/.gitignore b/dep/org.argeo.slc.dep.e4.rap/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/dep/org.argeo.slc.dep.e4.rap/bnd.bnd b/dep/org.argeo.slc.dep.e4.rap/bnd.bnd
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/dep/org.argeo.slc.dep.e4.rap/pom.xml b/dep/org.argeo.slc.dep.e4.rap/pom.xml
new file mode 100644 (file)
index 0000000..cdf502d
--- /dev/null
@@ -0,0 +1,177 @@
+<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>dep</artifactId>
+               <version>2.1.13-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.dep.e4.rap</artifactId>
+       <name>SLC E4 RAP</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               <SLC-ModularDistribution>default</SLC-ModularDistribution>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.argeo.maven.plugins</groupId>
+                               <artifactId>maven-argeo-osgi-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <id>generate-descriptors</id>
+                                               <goals>
+                                                       <goal>descriptors</goal>
+                                               </goals>
+                                               <phase>generate-resources</phase>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <!-- Parent dependencies -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.dep.cms.e4.rap</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.dep.minimal</artifactId>
+                       <version>2.1.13-SNAPSHOT</version>
+               </dependency>
+
+
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.e4</artifactId>
+                       <version>2.1.13-SNAPSHOT</version>
+               </dependency>
+               <!-- SLC Libs -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.lib.repo</artifactId> -->
+               <!-- <version>1.1.14-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+               <!-- <dependency> -->
+               <!-- <groupId>org.argeo.slc</groupId> -->
+               <!-- <artifactId>org.argeo.slc.lib.jcr</artifactId> -->
+               <!-- <version>1.1.14-SNAPSHOT</version> -->
+               <!-- </dependency> -->
+
+               <!-- Extensions <dependency> <groupId>org.argeo.slc</groupId> <artifactId>org.argeo.slc.support</artifactId> 
+                       <version>2.1.13-SNAPSHOT</version> </dependency> -->
+               <!-- UI <dependency> <groupId>org.argeo.slc</groupId> <artifactId>org.argeo.slc.client.ui</artifactId> 
+                       <version>2.1.13-SNAPSHOT</version> </dependency> <dependency> <groupId>org.argeo.slc</groupId> 
+                       <artifactId>org.argeo.slc.client.ui.dist</artifactId> <version>2.1.13-SNAPSHOT</version> 
+                       </dependency> <dependency> <groupId>org.argeo.slc</groupId> <artifactId>org.argeo.slc.client.rap</artifactId> 
+                       <version>2.1.13-SNAPSHOT</version> </dependency> -->
+
+               <!-- For target platform generation <dependency> <groupId>org.argeo.slc</groupId> 
+                       <artifactId>org.argeo.slc.unit</artifactId> <version>2.1.13-SNAPSHOT</version> 
+                       <scope>test</scope> </dependency> -->
+       </dependencies>
+       <profiles>
+               <profile>
+                       <id>rpmbuild</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.apache.maven.plugins</groupId>
+                                               <artifactId>maven-dependency-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>copy-argeo</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>copy-dependencies</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <includeTypes>jar</includeTypes>
+                                                                       <outputDirectory>${project.build.directory}/lib-argeo</outputDirectory>
+                                                                       <includeGroupIds>org.argeo.slc</includeGroupIds>
+                                                                       <excludeTransitive>true</excludeTransitive>
+                                                                       <excludeArtifactIds>org.argeo.slc.dep.minimal</excludeArtifactIds>
+                                                                       <includeTypes>jar</includeTypes>
+                                                                       <includeScope>runtime</includeScope>
+                                                                       <useRepositoryLayout>true</useRepositoryLayout>
+                                                               </configuration>
+                                                       </execution>
+                                                       <!-- <execution> -->
+                                                       <!-- <id>copy-argeo-self</id> -->
+                                                       <!-- <phase>package</phase> -->
+                                                       <!-- <goals> -->
+                                                       <!-- <goal>copy</goal> -->
+                                                       <!-- </goals> -->
+                                                       <!-- <configuration> -->
+                                                       <!-- <outputDirectory>${project.build.directory}/lib-argeo</outputDirectory> -->
+                                                       <!-- <useRepositoryLayout>true</useRepositoryLayout> -->
+                                                       <!-- <artifactItems> -->
+                                                       <!-- <artifactItem> -->
+                                                       <!-- <groupId>${project.groupId}</groupId> -->
+                                                       <!-- <artifactId>${project.artifactId}</artifactId> -->
+                                                       <!-- <version>${project.version}</version> -->
+                                                       <!-- <outputDirectory>${project.build.directory}/lib-argeo</outputDirectory> -->
+                                                       <!-- </artifactItem> -->
+                                                       <!-- </artifactItems> -->
+                                                       <!-- </configuration> -->
+                                                       <!-- </execution> -->
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>rpm-maven-plugin</artifactId>
+                                               <executions>
+                                                       <execution>
+                                                               <id>rpm-argeo</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>rpm</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <name>slc-e4-rap</name>
+                                                                       <mappings>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <filemode>644</filemode>
+                                                                                       <directoryIncluded>true</directoryIncluded>
+                                                                                       <sources>
+                                                                                               <source>
+                                                                                                       <location>${project.build.directory}/lib-argeo</location>
+                                                                                                       <includes>
+                                                                                                               <include>**/*.jar</include>
+                                                                                                       </includes>
+                                                                                               </source>
+                                                                                       </sources>
+                                                                               </mapping>
+                                                                               <mapping>
+                                                                                       <directory>/usr/share/osgi/org/argeo/slc/${project.artifactId}/${project.version}</directory>
+                                                                                       <username>root</username>
+                                                                                       <groupname>root</groupname>
+                                                                                       <directoryIncluded>false</directoryIncluded>
+                                                                                       <artifact />
+                                                                               </mapping>
+                                                                       </mappings>
+                                                                       <requires>
+                                                                               <require>argeo-cms-e4-rap</require>
+                                                                               <require>slc-agent</require>
+                                                                       </requires>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+</project>
\ No newline at end of file
index 0c190f06b1486ecedecbc690eb28e6e0940d6989..bcba342bbee036b781156d4fe72e7a38de39b096 100644 (file)
@@ -12,6 +12,7 @@
        <modules>
                <module>org.argeo.slc.dep.minimal</module>
                <module>org.argeo.slc.dep.backend</module>
+               <module>org.argeo.slc.dep.e4.rap</module>
        </modules>
        <build>
                <plugins>
diff --git a/org.argeo.slc.e4/.classpath b/org.argeo.slc.e4/.classpath
new file mode 100644 (file)
index 0000000..eca7bdb
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.argeo.slc.e4/.gitignore b/org.argeo.slc.e4/.gitignore
new file mode 100644 (file)
index 0000000..e0e1cc4
--- /dev/null
@@ -0,0 +1,2 @@
+/bin/
+/target
diff --git a/org.argeo.slc.e4/.project b/org.argeo.slc.e4/.project
new file mode 100644 (file)
index 0000000..f3db2ea
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.argeo.slc.e4</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>
diff --git a/org.argeo.slc.e4/META-INF/.gitignore b/org.argeo.slc.e4/META-INF/.gitignore
new file mode 100644 (file)
index 0000000..4854a41
--- /dev/null
@@ -0,0 +1 @@
+/MANIFEST.MF
diff --git a/org.argeo.slc.e4/bnd.bnd b/org.argeo.slc.e4/bnd.bnd
new file mode 100644 (file)
index 0000000..d7e5df4
--- /dev/null
@@ -0,0 +1,9 @@
+Import-Package: org.eclipse.swt,\
+org.eclipse.e4.ui.model.application.ui,\
+org.eclipse.e4.ui.model.application,\
+org.eclipse.swt.events,\
+javax.jcr.nodetype,\
+org.argeo.slc.jcr,\
+org.eclipse.core.commands.common,\
+org.eclipse.jface.window,\
+*
diff --git a/org.argeo.slc.e4/build.properties b/org.argeo.slc.e4/build.properties
new file mode 100644 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .
diff --git a/org.argeo.slc.e4/pom.xml b/org.argeo.slc.e4/pom.xml
new file mode 100644 (file)
index 0000000..de67f01
--- /dev/null
@@ -0,0 +1,48 @@
+<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.13-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>org.argeo.slc.e4</artifactId>
+       <name>SLC E4</name>
+       <packaging>jar</packaging>
+       <dependencies>
+               <!-- SLC -->
+               <dependency>
+                       <groupId>org.argeo.slc</groupId>
+                       <artifactId>org.argeo.slc.core</artifactId>
+                       <version>2.1.13-SNAPSHOT</version>
+               </dependency>
+
+               <!-- Argeo Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.eclipse.ui.rap</artifactId>
+                       <version>${version.argeo-commons}</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.cms.e4</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
+
+               <!-- RAP workbench -->
+               <dependency>
+                       <groupId>org.argeo.tp</groupId>
+                       <artifactId>argeo-tp-rap-e4</artifactId>
+                       <version>${version.argeo-tp}</version>
+                       <type>pom</type>
+                       <scope>provided</scope>
+               </dependency>
+
+       </dependencies>
+</project>
diff --git a/org.argeo.slc.e4/src/org/argeo/slc/e4/SlcImages.java b/org.argeo.slc.e4/src/org/argeo/slc/e4/SlcImages.java
new file mode 100644 (file)
index 0000000..0ede859
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.slc.e4;
+
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/** Shared images. */
+public class SlcImages {
+       public final static Image AGENT = img("icons/agent.gif");
+       public final static Image AGENT_FACTORY = img("icons/agentFactory.gif");
+       public final static Image MODULE = img("icons/module.png");
+       public final static Image MODULE_STOPPED = img("icons/module_stopped.gif");
+       public final static Image FOLDER = img("icons/folder.gif");
+       public final static Image MY_RESULTS_FOLDER = img("icons/myResult.png");
+       public final static Image RENAME = img("icons/rename.png");
+       public final static Image FLOW = img("icons/flow.png");
+       public final static Image PROCESSES = img("icons/processes.gif");
+       public final static Image PASSED = img("icons/passed.gif");
+       public final static Image ERROR = img("icons/error.gif");
+       public final static Image LAUNCH = img("icons/launch.gif");
+       public final static Image RELAUNCH = img("icons/relaunch.gif");
+       public final static Image KILL = img("icons/kill.png");
+       public final static Image REMOVE_ONE = img("icons/remove_one.gif");
+       public final static Image REMOVE_ALL = img("icons/removeAll.png");
+       public final static Image EXECUTION_SPECS = img("icons/executionSpecs.gif");
+       public final static Image EXECUTION_SPEC = img("icons/executionSpec.gif");
+       public final static Image EXECUTION_SPEC_ATTRIBUTE = img("icons/executionSpecAttribute.gif");
+       public final static Image CHOICES = img("icons/choices.gif");
+       public final static Image PROCESS_ERROR = img("icons/process_error.png");
+       public final static Image PROCESS_SCHEDULED = img("icons/process_scheduled.gif");
+       public final static Image PROCESS_RUNNING = img("icons/process_running.png");
+       public final static Image PROCESS_COMPLETED = img("icons/process_completed.png");
+
+       // Decorators
+       public final static ImageDescriptor EXECUTION_ERROR = getImageDescriptor("icons/executionError.gif");
+       public final static ImageDescriptor EXECUTION_PASSED = getImageDescriptor("icons/executionPassed.gif");
+
+       /** Creates the image */
+       public static Image img(String path) {
+               return getImageDescriptor(path).createImage();
+       }
+
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin("", path);
+       }
+       
+    public static ImageDescriptor imageDescriptorFromPlugin(String pluginId,
+            String imageFilePath) {
+       return null;
+    }
+
+}
diff --git a/org.argeo.slc.e4/src/org/argeo/slc/e4/parts/JcrExecutionModulesView.java b/org.argeo.slc.e4/src/org/argeo/slc/e4/parts/JcrExecutionModulesView.java
new file mode 100644 (file)
index 0000000..b08b8a4
--- /dev/null
@@ -0,0 +1,426 @@
+/*
+ * 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.e4.parts;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.observation.Event;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
+import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider;
+import org.argeo.eclipse.ui.jcr.NodeElementComparer;
+import org.argeo.eclipse.ui.jcr.SimpleNodeContentProvider;
+import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
+import org.argeo.jcr.JcrUtils;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.SlcNames;
+import org.argeo.slc.SlcTypes;
+import org.argeo.slc.e4.SlcImages;
+import org.argeo.slc.execution.ExecutionModulesManager;
+import org.argeo.slc.jcr.SlcJcrConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+
+/** JCR based view of the execution modules. */
+public class JcrExecutionModulesView implements SlcTypes, SlcNames {
+       private final static Log log = LogFactory.getLog(JcrExecutionModulesView.class);
+
+//     public static final String ID = ClientUiPlugin.ID + ".jcrExecutionModulesView";
+
+       private TreeViewer viewer;
+
+//     private ServerPushSession pushSession;
+
+       /* DEPENDENCY INJECTION */
+       private Repository repository;
+       private Session session;
+       private ExecutionModulesManager modulesManager;
+
+       public void createPartControl(Composite parent) {
+//             pushSession = new ServerPushSession();
+//             pushSession.start();
+
+               try {
+                       session = repository.login();
+               } catch (RepositoryException e1) {
+                       throw new SlcException("Cannot log in to repository");
+               }
+
+               viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+               EclipseUiSpecificUtils.enableToolTipSupport(viewer);
+               ViewContentProvider contentProvider = new ViewContentProvider(session);
+               viewer.setContentProvider(contentProvider);
+               viewer.setComparer(new NodeElementComparer());
+               final ViewLabelProvider viewLabelProvider = new ViewLabelProvider();
+               viewer.setLabelProvider(viewLabelProvider);
+               viewer.setInput(modulesManager);
+//             viewer.setInput(getViewSite());
+               viewer.addDoubleClickListener(new ViewDoubleClickListener());
+               // context menu
+               // addContextMenu(viewer);
+
+//             getViewSite().setSelectionProvider(viewer);
+
+               Transfer[] tt = new Transfer[] { TextTransfer.getInstance() };
+               // Transfer[] tt = new Transfer[] { EditorInputTransfer.getInstance() };
+               int operations = DND.DROP_COPY | DND.DROP_MOVE;
+               viewer.addDragSupport(operations, tt, new ViewDragListener());
+
+               try {
+                       String[] nodeTypes = { SlcTypes.SLC_AGENT, SlcTypes.SLC_AGENT_FACTORY, SlcTypes.SLC_EXECUTION_MODULE };
+                       session.getWorkspace().getObservationManager().addEventListener(
+                                       new VmAgentObserver(viewer.getTree().getDisplay()),
+                                       Event.NODE_ADDED | Event.NODE_REMOVED | Event.NODE_MOVED, SlcJcrConstants.VM_AGENT_FACTORY_PATH,
+                                       true, null, nodeTypes, false);
+               } catch (RepositoryException e) {
+                       throw new SlcException("Cannot add observer", e);
+               }
+       }
+
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       public TreeViewer getViewer() {
+               return viewer;
+       }
+
+       public void refreshView() {
+//             viewer.setInput(getViewSite());
+               viewer.setInput(modulesManager);
+       }
+
+       // Controllers
+       class ViewContentProvider extends SimpleNodeContentProvider {
+               private static final long serialVersionUID = 5117887833174813672L;
+
+               public ViewContentProvider(Session session) {
+                       super(session, new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH });
+               }
+
+               @Override
+               protected Object[] sort(Object parent, Object[] children) {
+                       Object[] sorted = new Object[children.length];
+                       System.arraycopy(children, 0, sorted, 0, children.length);
+                       Arrays.sort(sorted, new ViewComparator());
+                       return sorted;
+               }
+
+               @Override
+               protected List<Node> filterChildren(List<Node> children) throws RepositoryException {
+                       for (Iterator<Node> it = children.iterator(); it.hasNext();) {
+                               Node node = it.next();
+                               // execution spec definitions
+                               if (node.getName().equals(SLC_EXECUTION_SPECS))
+                                       it.remove();
+                               // flow values
+                               else if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                                       it.remove();
+                       }
+                       return super.filterChildren(children);
+               }
+
+               @Override
+               public boolean hasChildren(Object element) {
+                       if (element instanceof Node) {
+                               Node node = (Node) element;
+                               try {
+                                       if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                                               return false;
+                               } catch (RepositoryException e) {
+                                       throw new SlcException("Cannot check has children", e);
+                               }
+                       }
+                       return super.hasChildren(element);
+               }
+       }
+
+       static class ViewComparator implements Comparator<Object> {
+
+               public int compare(Object o1, Object o2) {
+                       try {
+                               if (o1 instanceof Node && o2 instanceof Node) {
+                                       Node node1 = (Node) o1;
+                                       Node node2 = (Node) o2;
+
+                                       if (node1.getName().equals(SLC_EXECUTION_SPECS))
+                                               return -100;
+                                       if (node2.getName().equals(SLC_EXECUTION_SPECS))
+                                               return 100;
+
+                                       if (node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return node1.getName().compareTo(node2.getName());
+                                       } else if (node1.isNodeType(SLC_EXECUTION_FLOW) && !node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return 1;
+                                       } else if (!node1.isNodeType(SLC_EXECUTION_FLOW) && node2.isNodeType(SLC_EXECUTION_FLOW)) {
+                                               return -1;
+                                       } else {
+                                               // TODO: check title
+                                               return node1.getName().compareTo(node2.getName());
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot compare " + o1 + " and " + o2, e);
+                       }
+                       return 0;
+               }
+
+       }
+
+       // private void addContextMenu(TreeViewer flowsViewer) {
+       //
+       // final MenuManager menuMgr = new MenuManager();
+       // menuMgr.setRemoveAllWhenShown(true);
+       // menuMgr.addMenuListener(new IMenuListener() {
+       //
+       // public void menuAboutToShow(IMenuManager manager) {
+       // menuMgr.add(new Action("Test") {
+       // public void run() {
+       // log.debug("do something");
+       // }
+       // });
+       // }
+       // });
+       // Menu menu = menuMgr.createContextMenu(flowsViewer.getControl());
+       // flowsViewer.getTree().setMenu(menu);
+       // getSite().registerContextMenu(menuMgr, flowsViewer);
+       // }
+
+       class VmAgentObserver extends AsyncUiEventListener {
+
+               public VmAgentObserver(Display display) {
+                       super(display);
+               }
+
+               protected void onEventInUiThread(List<Event> events) {
+                       for (Event event : events) {
+                               try {
+                                       String path = event.getPath();
+
+                                       if (session.itemExists(path)) {
+                                               Node parentNode = session.getNode(path);// .getParent();
+                                               if (log.isTraceEnabled())
+                                                       log.trace("Refresh " + parentNode + " after event " + event);
+                                               viewer.refresh(parentNode);
+                                       }
+                               } catch (RepositoryException e) {
+                                       log.warn("Cannot process event " + event + ": " + e);
+                               }
+                       }
+
+                       // TODO: optimize based on event
+                       viewer.refresh();
+               }
+       }
+
+       class ViewLabelProvider extends DefaultNodeLabelProvider implements ITableLabelProvider {
+               private static final long serialVersionUID = 2410754425574656399L;
+
+               @Override
+               protected String getText(Node node) throws RepositoryException {
+                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_TITLE))
+                               return node.getProperty(Property.JCR_TITLE).getString();
+                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
+                               return "Execution Specifications";
+                       else if (node.getPath().equals(SlcJcrConstants.VM_AGENT_FACTORY_PATH))
+                               return "Internal Agents";
+                       return super.getText(node);
+               }
+
+               @Override
+               public Image getImage(Node node) throws RepositoryException {
+                       // we try to optimize a bit by putting deeper nodes first
+                       if (node.getParent().isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                               return SlcImages.CHOICES;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+                               return SlcImages.EXECUTION_SPEC_ATTRIBUTE;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC))
+                               return SlcImages.EXECUTION_SPEC;
+                       else if (node.getName().equals(SLC_EXECUTION_SPECS))
+                               return SlcImages.EXECUTION_SPECS;
+                       else if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
+                               return SlcImages.FLOW;
+                       else if (node.isNodeType(SlcTypes.SLC_MODULE)) {
+                               if (node.getProperty(SLC_STARTED).getBoolean())
+                                       return SlcImages.MODULE;
+                               else
+                                       return SlcImages.MODULE_STOPPED;
+                       } else if (node.isNodeType(SlcTypes.SLC_AGENT))
+                               return SlcImages.AGENT;
+                       else if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY))
+                               return SlcImages.AGENT_FACTORY;
+                       else
+                               return SlcImages.FOLDER;
+               }
+
+               public String getToolTipText(Node node) throws RepositoryException {
+                       if (node.isNodeType(NodeType.MIX_TITLE) && node.hasProperty(Property.JCR_DESCRIPTION))
+                               return node.getProperty(Property.JCR_DESCRIPTION).getString();
+                       return super.getToolTipText(node);
+               }
+
+               public String getColumnText(Object obj, int index) {
+                       return getText(obj);
+               }
+
+               public Image getColumnImage(Object obj, int index) {
+                       return getImage(obj);
+               }
+
+       }
+
+       class ViewDoubleClickListener implements IDoubleClickListener {
+               public void doubleClick(DoubleClickEvent evt) {
+                       Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement();
+                       try {
+                               if (obj instanceof Node) {
+                                       Node node = (Node) obj;
+                                       if (node.isNodeType(SLC_EXECUTION_MODULE)) {
+                                               //ClientUiPlugin.startStopExecutionModule(modulesManager, node);
+                                       } else {
+                                               String path = node.getPath();
+                                               // TODO factorize with editor
+                                               QueryManager qm = node.getSession().getWorkspace().getQueryManager();
+                                               String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW
+                                                               + "] WHERE ISDESCENDANTNODE(['" + path + "']) OR ISSAMENODE(['" + path + "'])";
+                                               // log.debug(statement);
+                                               Query query = qm.createQuery(statement, Query.JCR_SQL2);
+
+                                               // order paths
+                                               SortedSet<String> paths = new TreeSet<String>();
+                                               for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) {
+                                                       paths.add(nit.nextNode().getPath());
+                                               }
+
+//                                             IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+//                                                             .getActivePage();
+//                                             activePage.openEditor(new ProcessEditorInput(new ArrayList<String>(paths), true),
+//                                                             ProcessEditor.ID);
+                                       }
+                               }
+                       } catch (Exception e) {
+                               throw new SlcException("Cannot open " + obj, e);
+                       }
+               }
+
+       }
+
+       /** Listen to drags */
+       class ViewDragListener extends DragSourceAdapter {
+               private static final long serialVersionUID = 250270504802674171L;
+
+               // Check if the drag action should start.
+               public void dragStart(DragSourceEvent event) {
+                       // we only start drag if at least one of the selected elements is
+                       // valid
+                       boolean doIt = false;
+                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                       @SuppressWarnings("rawtypes")
+                       Iterator it = selection.iterator();
+                       try {
+                               while (it.hasNext()) {
+                                       Object obj = it.next();
+                                       if (obj instanceof Node) {
+                                               Node node = (Node) obj;
+                                               if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
+                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) {
+                                                       doIt = true;
+                                               }
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot read node to set drag data", e);
+                       }
+                       event.doit = doIt;
+               }
+
+               public void dragSetData(DragSourceEvent event) {
+                       IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                       StringBuilder buf = new StringBuilder();
+                       @SuppressWarnings("rawtypes")
+                       Iterator it = selection.iterator();
+                       try {
+
+                               while (it.hasNext()) {
+                                       Object obj = it.next();
+
+                                       if (obj instanceof Node) {
+                                               Node node = (Node) obj;
+                                               if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW)
+                                                               || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE))
+                                                               && TextTransfer.getInstance().isSupportedType(event.dataType)) {
+                                                       buf.append(node.getPath()).append('\n');
+                                               }
+                                       }
+                               }
+                       } catch (RepositoryException e) {
+                               throw new SlcException("Cannot read node to set drag data", e);
+                       }
+
+                       if (buf.length() > 0) {
+                               if (buf.charAt(buf.length() - 1) == '\n')
+                                       buf.deleteCharAt(buf.length() - 1);
+                               event.data = buf.toString();
+                               log.debug("data set to : " + buf.toString());
+                       }
+               }
+       }
+
+       public void dispose() {
+               JcrUtils.logoutQuietly(session);
+//             if (pushSession != null)
+//                     pushSession.stop();
+//             super.dispose();
+       }
+
+       // DEPENDENCY INJECTION
+
+       public void setModulesManager(ExecutionModulesManager modulesManager) {
+               this.modulesManager = modulesManager;
+       }
+
+       public void setRepository(Repository repository) {
+               this.repository = repository;
+       }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0bc99514322b9dcd8d108708e9c75a18bb77b383..eeea40713bb17d5c59be0c8cfa432b2c3cd54077 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,6 @@
-<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>
@@ -36,6 +38,9 @@
                <module>org.argeo.slc.agent.jcr</module>
                <module>org.argeo.slc.server.repo</module>
 
+               <!-- E4 -->
+               <module>org.argeo.slc.e4</module>
+
                <!-- UI -->
                <module>org.argeo.slc.client.ui</module>
                <module>org.argeo.slc.client.ui.dist</module>