sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1504900 - in /sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal: SlingContentModuleFactory.java SlingLaunchpadBehaviour.java
Date Fri, 19 Jul 2013 15:02:58 GMT
Author: rombert
Date: Fri Jul 19 15:02:57 2013
New Revision: 1504900

URL: http://svn.apache.org/r1504900
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure

Allow creating directories individually additionally to files. There
seem to be some timing issues - at least with Eclipse 3.7.2 as directory
events are not fired immediately.

Modified:
    sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
    sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java

Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java?rev=1504900&r1=1504899&r2=1504900&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingContentModuleFactory.java
Fri Jul 19 15:02:57 2013
@@ -81,6 +81,8 @@ public class SlingContentModuleFactory e
 
                     IPath relativePath = resource.getProjectRelativePath();
 
+                    System.out.println("Visiting " + resource + " ...");
+
                     // only recurse in the expected content path
                     // TODO make configurable
                     if (!SlingclipseHelper.JCR_ROOT.equals(relativePath.segment(0))) {
@@ -89,12 +91,19 @@ public class SlingContentModuleFactory e
 
                     IPath modulePath = relativePath.removeFirstSegments(1); // remove jcr_root
 
+                    IModuleResource moduleFile = null;
+
                     if (resource.getType() == IResource.FILE) {
+                        moduleFile = new ModuleFile((IFile) resource, resource.getName(),
modulePath);
+                    } else if (resource.getType() == IResource.FOLDER) {
+                        moduleFile = new ModuleFolder((IFolder) resource, resource.getName(),
modulePath);
+                    }
 
-                        ModuleFile moduleFile = new ModuleFile((IFile) resource, resource.getName(),
modulePath);
+                    if (moduleFile != null)
                         resources.add(moduleFile);
-                        System.out.println("Converted " + resource + " to " + moduleFile);
-                    }
+
+                    System.out.println("Converted " + resource + " to " + moduleFile);
+
                     return true;
                 }
             });

Modified: sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java?rev=1504900&r1=1504899&r2=1504900&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/slingclipse-wst/src/org/apache/sling/ide/eclipse/wst/internal/SlingLaunchpadBehaviour.java
Fri Jul 19 15:02:57 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.sling.ide.eclipse.wst.internal;
 
-import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Arrays;
@@ -28,6 +27,8 @@ import org.apache.sling.slingclipse.api.
 import org.apache.sling.slingclipse.api.RepositoryInfo;
 import org.apache.sling.slingclipse.api.Result;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -35,7 +36,6 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.IModuleFile;
 import org.eclipse.wst.server.core.model.IModuleResource;
 import org.eclipse.wst.server.core.model.IModuleResourceDelta;
 import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
@@ -155,18 +155,15 @@ public class SlingLaunchpadBehaviour ext
 
                     System.out.println(deltaTrace);
 
-                    if (resourceDelta.getModuleResource() instanceof IModuleFile) {
-
-                        switch (resourceDelta.getKind()) {
-                            case IModuleResourceDelta.ADDED:
-                            case IModuleResourceDelta.CHANGED:
-                            case IModuleResourceDelta.NO_CHANGE: // TODO is this needed?
-                                execute(addFileCommand(repository, (IModuleFile) resourceDelta.getModuleResource()));
-                                break;
-                            case IModuleResourceDelta.REMOVED:
-                                execute(removeFileCommand(repository, (IModuleFile) resourceDelta.getModuleResource()));
-                                break;
-                        }
+                    switch (resourceDelta.getKind()) {
+                        case IModuleResourceDelta.ADDED:
+                        case IModuleResourceDelta.CHANGED:
+                        case IModuleResourceDelta.NO_CHANGE: // TODO is this needed?
+                            execute(addFileCommand(repository, resourceDelta.getModuleResource()));
+                            break;
+                        case IModuleResourceDelta.REMOVED:
+                            execute(removeFileCommand(repository, resourceDelta.getModuleResource()));
+                            break;
                     }
                 }
                 break;
@@ -174,22 +171,12 @@ public class SlingLaunchpadBehaviour ext
             case ServerBehaviourDelegate.ADDED:
             case ServerBehaviourDelegate.NO_CHANGE: // TODO is this correct ?
                 for (IModuleResource resource : moduleResources) {
-
-                    if (resource instanceof IModuleFile) {
-                        execute(addFileCommand(repository, (IModuleFile) resource));
-                    } else {
-                        // TODO log/barf
-                    }
+                    execute(addFileCommand(repository, resource));
                 }
                 break;
             case ServerBehaviourDelegate.REMOVED:
                 for (IModuleResource resource : moduleResources) {
-
-                    if (resource instanceof IModuleFile) {
-                        execute(removeFileCommand(repository, (IModuleFile) resource));
-                    } else {
-                        // TODO log/barf
-                    }
+                    execute(removeFileCommand(repository, resource));
                 }
                 break;
         }
@@ -211,7 +198,7 @@ public class SlingLaunchpadBehaviour ext
             throw new CoreException(new Status(Status.ERROR, "some.plugin", result.toString()));
     }
 
-    private Command<?> addFileCommand(Repository repository, IModuleFile resource)
{
+    private Command<?> addFileCommand(Repository repository, IModuleResource resource)
{
 
         FileInfo info = createFileInfo(resource);
 
@@ -223,13 +210,17 @@ public class SlingLaunchpadBehaviour ext
         return repository.newAddNodeCommand(info);
     }
 
-    private FileInfo createFileInfo(IModuleFile resource) {
+    private FileInfo createFileInfo(IModuleResource resource) {
 
-        IFile file = (IFile) resource.getAdapter(IFile.class);
+        IResource file = (IFile) resource.getAdapter(IFile.class);
+        if (file == null) {
+            file = (IFolder) resource.getAdapter(IFolder.class);
+        }
 
         if (file == null) {
             // Usually happens on server startup, it seems to be safe to ignore for now
-            System.out.println("Got null '" + IFile.class.getSimpleName() + "' for " + resource);
+            System.out.println("Got null '" + IFile.class.getSimpleName() + "' and '" + IFolder.class.getSimpleName()
+                    + "'for " + resource);
             return null;
         }
 
@@ -244,7 +235,7 @@ public class SlingLaunchpadBehaviour ext
         return info;
     }
 
-    private Command<?> removeFileCommand(Repository repository, IModuleFile resource)
{
+    private Command<?> removeFileCommand(Repository repository, IModuleResource resource)
{
 
         FileInfo info = createFileInfo(resource);
 



Mime
View raw message