Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B1D5C4B1 for ; Fri, 19 Jul 2013 15:03:20 +0000 (UTC) Received: (qmail 65401 invoked by uid 500); 19 Jul 2013 15:03:19 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 65364 invoked by uid 500); 19 Jul 2013 15:03:19 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 65357 invoked by uid 99); 19 Jul 2013 15:03:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 15:03:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 15:03:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1BD982388860; Fri, 19 Jul 2013 15:02:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@sling.apache.org From: rombert@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130719150258.1BD982388860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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);