sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1600067 - /sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
Date Wed, 04 Jun 2014 09:44:42 GMT
Author: stefanegli
Date: Wed Jun  4 09:44:42 2014
New Revision: 1600067

URL: http://svn.apache.org/r1600067
Log:
SLING-3640 : handling creation of IFolder and IFile in one 'workspace transaction' to avoid
glitches in refresh

Modified:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java?rev=1600067&r1=1600066&r2=1600067&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
(original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
Wed Jun  4 09:44:42 2014
@@ -779,7 +779,7 @@ public class JcrNode implements IAdaptab
         }
 	}
 	
-	public void createChild(String childNodeName, String childNodeType) {
+	public void createChild(final String childNodeName, final String childNodeType) {
 	    String thisNodeType = getPrimaryType();
 	    final SerializationKind parentSk = getSerializationKind(thisNodeType);
         final SerializationKind childSk = getSerializationKind(childNodeType);
@@ -789,42 +789,60 @@ public class JcrNode implements IAdaptab
 	    } else if (parentSk==SerializationKind.FILE) {
             throw new IllegalStateException("cannot create child of nt:file");
 	    } else if (childSk==SerializationKind.FOLDER) {
-	        IFolder f = (IFolder)resource;
-	        IFolder newFolder = null;
+            IWorkspaceRunnable r = new IWorkspaceRunnable() {
+
+                @Override
+                public void run(IProgressMonitor monitor) throws CoreException {
+                    IFolder f = (IFolder)resource;
+                    IFolder newFolder = null;
+                    newFolder = f.getFolder(childNodeName);
+                    newFolder.create(true, true, new NullProgressMonitor());
+                    if (!childNodeType.equals("nt:folder")) {
+                        createVaultFile(newFolder, ".content.xml", childNodeType);
+                    }
+                }
+            };
+	        
 	        try {
-	            newFolder = f.getFolder(childNodeName);
-	            newFolder.create(true, true, new NullProgressMonitor());
+	            ResourcesPlugin.getWorkspace().run(r, null);
+	            if (childNodeType.equals("nt:folder")) {
+	                // trigger a publish, as folder creation is not propagated to 
+	                // the SlingLaunchpadBehavior otherwise
+	                //TODO: make configurable? Fix in Eclipse/WST?
+	                ServerUtil.triggerIncrementalBuild((IFolder)resource, null);
+	            }
 	        } catch (CoreException e) {
+	            Activator.getDefault().getPluginLogger().error("Error creating child "+childNodeName+":
"+e, e);
 	            e.printStackTrace();
 	            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error creating
node", "Error creating child of "+thisNodeType+" with type "+childNodeType+": "+e);
 	            return;
 	        }
-	        
-	        if (!childNodeType.equals("nt:folder")) {
-	            createVaultFile(newFolder, ".content.xml", childNodeType);
-	        } else {
-	            // otherwise trigger a publish, as folder creation is not propagated to 
-	            // the SlingLaunchpadBehavior otherwise
-	            //TODO: make configurable? Fix in Eclipse/WST?
-	            ServerUtil.triggerIncrementalBuild(f, null);
-	        }
 	    } else if (parentSk==SerializationKind.FOLDER && childSk==SerializationKind.METADATA_FULL)
{
             createVaultFile((IFolder)resource, childNodeName+".xml", childNodeType);
 	    } else if (parentSk==SerializationKind.FOLDER && childSk==SerializationKind.METADATA_PARTIAL)
{
 //	        createVaultFile((IFolder)resource, childNodeName+".xml", childNodeType);
 
-            IFolder f = (IFolder)resource;
-            IFolder newFolder = null;
+            IWorkspaceRunnable r = new IWorkspaceRunnable() {
+
+                @Override
+                public void run(IProgressMonitor monitor) throws CoreException {
+                    IFolder f = (IFolder)resource;
+                    IFolder newFolder = null;
+                    newFolder = f.getFolder(childNodeName);
+                    newFolder.create(true, true, new NullProgressMonitor());
+                    createVaultFile(newFolder, ".content.xml", childNodeType);
+                }
+            };
+            
             try {
-                newFolder = f.getFolder(childNodeName);
-                newFolder.create(true, true, new NullProgressMonitor());
+                ResourcesPlugin.getWorkspace().run(r, null);
             } catch (CoreException e) {
+                Activator.getDefault().getPluginLogger().error("Error creating child "+childNodeName+":
"+e, e);
                 e.printStackTrace();
                 MessageDialog.openError(Display.getDefault().getActiveShell(), "Error creating
node", "Error creating child of "+thisNodeType+" with type "+childNodeType+": "+e);
                 return;
             }
             
-            createVaultFile(newFolder, ".content.xml", childNodeType);
 	    } else if (parentSk!=SerializationKind.FOLDER && childSk==SerializationKind.METADATA_PARTIAL)
{
             createDomChild(childNodeName, childNodeType);
 	    } else {



Mime
View raw message