You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2014/05/21 11:16:22 UTC

svn commit: r1596515 - in /sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards: NewSlingContentProjectWizard.java res/ res/.content.xml res/config.xml res/filter.xml res/html.jsp res/settings.xml

Author: rombert
Date: Wed May 21 09:16:22 2014
New Revision: 1596515

URL: http://svn.apache.org/r1596515
Log:
SLING-3174 - Add new simple project content wizard

Improved the NewSlingContentProjectWizard to create all the needed
files.

Added:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml   (with props)
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml   (with props)
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml   (with props)
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp   (with props)
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml   (with props)
Modified:
    sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/NewSlingContentProjectWizard.java

Modified: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/NewSlingContentProjectWizard.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/NewSlingContentProjectWizard.java?rev=1596515&r1=1596514&r2=1596515&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/NewSlingContentProjectWizard.java (original)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/NewSlingContentProjectWizard.java Wed May 21 09:16:22 2014
@@ -16,9 +16,12 @@
  */
 package org.apache.sling.ide.eclipse.ui.wizards;
 
+import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.sling.ide.eclipse.core.ConfigurationHelper;
 import org.apache.sling.ide.eclipse.ui.internal.SharedImages;
 import org.eclipse.core.resources.IProject;
@@ -43,21 +46,44 @@ public class NewSlingContentProjectWizar
 
     @Override
     protected List<IProject> createProjects(IProgressMonitor monitor) throws CoreException {
+
         IProject project = page.getProjectHandle();
-        project.create(monitor);
-        project.open(monitor);
-        project.getFolder("jcr_root").create(true, true, monitor);
-        project.getFolder("jcr_root/content").create(true, true, monitor);
-        project.getFolder("jcr_root/content/example").create(true, true, monitor);
-        project.getFolder("jcr_root/apps").create(true, true, monitor);
-        project.getFolder("jcr_root/apps/example").create(true, true, monitor);
-        project.getFolder("jcr_root/apps/example/item").create(true, true, monitor);
-        project.getFolder("META-INF").create(true, true, monitor);
-        project.getFolder("META-INF/vault").create(true, true, monitor);
-        // TODO - we need to add more content here
-        // - a default html.jsp script
-        // - the default files from under META-INF/vault
-        // - a little content (nt:unstructured nodes of resource type example/item) under /content/example
+
+        List<Operation> ops = new ArrayList<Operation>();
+
+        ops.add(new CreateProject(project));
+        ops.add(new OpenProject(project));
+
+        ops.add(new CreateFolder(project, "jcr_root"));
+
+        ops.add(new CreateFolder(project, "jcr_root/content"));
+        ops.add(new CreateFolder(project, "jcr_root/content/example"));
+        ops.add(new CreateFile(project, "jcr_root/content/example/.content.xml", getClass().getResourceAsStream(
+                "res/.content.xml")));
+
+        ops.add(new CreateFolder(project, "jcr_root/apps"));
+        ops.add(new CreateFolder(project, "jcr_root/apps/example"));
+        ops.add(new CreateFolder(project, "jcr_root/apps/example/item"));
+        ops.add(new CreateFile(project, "jcr_root/apps/example/item/html.jsp", getClass().getResourceAsStream(
+                "res/html.jsp")));
+
+        ops.add(new CreateFolder(project, "META-INF"));
+        ops.add(new CreateFolder(project, "META-INF/vault"));
+        ops.add(new CreateFile(project, "META-INF/vault/filter.xml", getClass().getResourceAsStream("res/filter.xml")));
+        ops.add(new CreateFile(project, "META-INF/vault/config.xml", getClass().getResourceAsStream("res/config.xml")));
+        ops.add(new CreateFile(project, "META-INF/vault/settings.xml", getClass().getResourceAsStream(
+                "res/settings.xml")));
+
+        monitor.beginTask("Creating project", ops.size());
+        try {
+            for (Operation op : ops) {
+                op.execute(monitor);
+                advance(monitor, 1);
+            }
+        } finally {
+            monitor.done();
+        }
+
         return Collections.singletonList(project);
     }
 
@@ -84,4 +110,73 @@ public class NewSlingContentProjectWizar
         return "New Sling Content Project";
     }
 
+    private static interface Operation {
+        void execute(IProgressMonitor monitor) throws CoreException;
+    }
+
+    public static class CreateProject implements Operation {
+        private final IProject project;
+
+        public CreateProject(IProject project) {
+            this.project = project;
+        }
+
+        @Override
+        public void execute(IProgressMonitor monitor) throws CoreException {
+            project.create(monitor);
+        }
+    }
+
+    public static class OpenProject implements Operation {
+
+        private final IProject project;
+
+        public OpenProject(IProject project) {
+            this.project = project;
+        }
+
+        @Override
+        public void execute(IProgressMonitor monitor) throws CoreException {
+            this.project.open(monitor);
+        }
+    }
+
+    public static class CreateFolder implements Operation {
+        private final IProject project;
+        private final String folderName;
+
+        public CreateFolder(IProject project, String folderName) {
+            this.project = project;
+            this.folderName = folderName;
+        }
+
+        @Override
+        public void execute(IProgressMonitor monitor) throws CoreException {
+            this.project.getFolder(folderName).create(true, true, monitor);
+        }
+
+    }
+
+    public static class CreateFile implements Operation {
+        private final IProject project;
+        private final String fileName;
+        private final InputStream input;
+
+        public CreateFile(IProject project, String fileName, InputStream input) {
+            this.project = project;
+            this.fileName = fileName;
+            this.input = input;
+        }
+
+        @Override
+        public void execute(IProgressMonitor monitor) throws CoreException {
+            try {
+                this.project.getFile(fileName).create(input, true, monitor);
+            } finally {
+                IOUtils.closeQuietly(input);
+            }
+        }
+
+    }
+
 }

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml?rev=1596515&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml Wed May 21 09:16:22 2014
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
+    jcr:primaryType="nt:unstructured"
+    jcr:title="First node"
+    jcr:description="This is a longer description for a node"
+    sling:resourceType="example/item"/>
\ No newline at end of file

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/.content.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml?rev=1596515&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml Wed May 21 09:16:22 2014
@@ -0,0 +1,93 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+  -->
+<vaultfs version="1.1">
+    <!--
+        Defines the content aggregation. The order of the defined aggregates
+        is important for finding the correct aggregator.
+    -->
+    <aggregates>
+        <!--
+            Defines an aggregate that handles nt:file and nt:resource nodes.
+        -->
+        <aggregate type="file" title="File Aggregate"/>
+
+        <!--
+            Defines an aggregate that handles file/folder like nodes. It matches
+            all nt:hierarchyNode nodes that have or define a jcr:content
+            child node and excludes child nodes that are nt:hierarchyNodes.
+        -->
+        <aggregate type="filefolder" title="File/Folder Aggregate"/>
+
+        <!--
+            Defines an aggregate that handles nt:nodeType nodes and serializes
+            them into .cnd notation.
+        -->
+        <aggregate type="nodetype" title="Node Type Aggregate" />
+
+        <!--
+            Defines an aggregate that defines full coverage for certain node
+            types that cannot be covered by the default aggregator.
+        -->
+        <aggregate type="full" title="Full Coverage Aggregate">
+            <matches>
+                <include nodeType="rep:AccessControl" respectSupertype="true" />
+                <include nodeType="rep:Policy" respectSupertype="true" />
+                <include nodeType="cq:Widget" respectSupertype="true" />
+                <include nodeType="cq:EditConfig" respectSupertype="true" />
+                <include nodeType="cq:WorkflowModel" respectSupertype="true" />
+                <include nodeType="vlt:FullCoverage" respectSupertype="true" />
+                <include nodeType="mix:language" respectSupertype="true" />
+                <include nodeType="sling:OsgiConfig" respectSupertype="true" />
+            </matches>
+        </aggregate>
+
+        <!--
+            Defines an aggregate that handles nt:folder like nodes.
+        -->
+        <aggregate type="generic" title="Folder Aggregate">
+            <matches>
+                <include nodeType="nt:folder" respectSupertype="true" />
+            </matches>
+            <contains>
+                <exclude isNode="true" />
+            </contains>
+        </aggregate>
+
+        <!--
+            Defines the default aggregate
+        -->
+        <aggregate type="generic" title="Default Aggregator" isDefault="true">
+            <matches>
+                <!-- all -->
+            </matches>
+            <contains>
+                <exclude nodeType="nt:hierarchyNode" respectSupertype="true" />
+            </contains>
+        </aggregate>
+
+    </aggregates>
+
+    <!--
+      defines the input handlers
+    -->
+    <handlers>
+        <handler type="folder"/>
+        <handler type="file"/>
+        <handler type="nodetype"/>
+        <handler type="generic"/>
+    </handlers>
+</vaultfs>

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/config.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml?rev=1596515&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml Wed May 21 09:16:22 2014
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+  -->
+
+<!--
+    Defines which repository items are generally included
+    
+    See https://jackrabbit.apache.org/filevault/filter.html for details
+-->
+<workspaceFilter vesion="1.0">
+    <filter root="/content/example"/>
+    <filter root="/apps/example"/>
+</workspaceFilter>

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/filter.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp?rev=1596515&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp Wed May 21 09:16:22 2014
@@ -0,0 +1,26 @@
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+-->
+<!-- simple JSP rendering test -->
+<%@page session="false" import="org.apache.sling.api.resource.*, javax.jcr.*"%>
+<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
+<sling:defineObjects/>
+
+<h1><%= resource.adaptTo(ValueMap.class).get("jcr:title") %></h1>
+<p><%= resource.adaptTo(ValueMap.class).get("jcr:description") %></p>

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/html.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml?rev=1596515&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml (added)
+++ sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml Wed May 21 09:16:22 2014
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<vault version="1.0">
+  <ignore name=".svn"/>
+</vault>
\ No newline at end of file

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/wizards/res/settings.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml