You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/06/13 18:55:53 UTC
svn commit: r1492758 -
/isis/site/trunk/content/getting-started/resources/isis-templates.xml
Author: danhaywood
Date: Thu Jun 13 16:55:52 2013
New Revision: 1492758
URL: http://svn.apache.org/r1492758
Log:
new templates
Modified:
isis/site/trunk/content/getting-started/resources/isis-templates.xml
Modified: isis/site/trunk/content/getting-started/resources/isis-templates.xml
URL: http://svn.apache.org/viewvc/isis/site/trunk/content/getting-started/resources/isis-templates.xml?rev=1492758&r1=1492757&r2=1492758&view=diff
==============================================================================
--- isis/site/trunk/content/getting-started/resources/isis-templates.xml (original)
+++ isis/site/trunk/content/getting-started/resources/isis-templates.xml Thu Jun 13 16:55:52 2013
@@ -128,6 +128,48 @@ public void removeFrom${CollectionName}(
protected void onAddTo${CollectionName}(final ${ElementType} ${elementName}) {
}
protected void onRemoveFrom${CollectionName}(final ${ElementType} ${elementName}) {
+}</template><template autoinsert="true" context="java-members" deleted="false" description="Collection modify (with actions)" enabled="true" name="iscmoda">${:import(org.apache.isis.applib.annotation.MemberOrder)}// Action.
+@MemberOrder(name="${collectionName}", sequence="1")
+public ${enclosing_type} insertInto${CollectionName}(final ${ElementType} ${elementName}) {
+ addTo${CollectionName}(${elementName});
+ return this;
+}
+
+// Programming model.
+public void addTo${CollectionName}(final ${ElementType} ${elementName}) {
+ // check for no-op
+ if (${elementName} == null ||
+ get${CollectionName}().contains(${elementName})) {
+ return;
+ }
+ // associate new
+ get${CollectionName}().add(${elementName});
+ // additional business logic
+ onAddTo${CollectionName}(${elementName});
+}
+
+// Action.
+@MemberOrder(name="${collectionName}", sequence="2")
+public ${enclosing_type} deleteFrom${CollectionName}(final ${ElementType} ${elementName}) {
+ removeFrom${CollectionName}(${elementName});
+ return this;
+}
+
+// Programming model.
+public void removeFrom${CollectionName}(final ${ElementType} ${elementName}) {
+ // check for no-op
+ if (${elementName} == null ||
+ !get${CollectionName}().contains(${elementName})) {
+ return;
+ }
+ // dissociate existing
+ get${CollectionName}().remove(${elementName});
+ // additional business logic
+ onRemoveFrom${CollectionName}(${elementName});
+}
+protected void onAddTo${CollectionName}(final ${ElementType} ${elementName}) {
+}
+protected void onRemoveFrom${CollectionName}(final ${ElementType} ${elementName}) {
}</template><template autoinsert="true" context="java-members" deleted="false" description="Collection (set)" enabled="true" name="iscs">// {{ ${CollectionName} (Collection)
${:import(java.util.Set,java.util.LinkedHashSet,org.apache.isis.applib.annotation.MemberOrder)}private Set<${ElementType}> ${collectionName} = new LinkedHashSet<${ElementType}>();
@MemberOrder(sequence="1")
@@ -143,10 +185,62 @@ public void set${CollectionName}(final S
${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder)}private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
@MemberOrder(sequence="1")
public SortedSet<${ElementType}> get${CollectionName}() {
- return ${collectionName};
+ return ${collectionName};
+}
+public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
+ this.${collectionName} = ${collectionName};
+}
+// }}</template><template autoinsert="true" context="java-members" deleted="false" description="Collection (set-sorted-with actions)" enabled="true" name="iscssa">// {{ ${CollectionName} (Collection)
+${:import(java.util.SortedSet,java.util.TreeSet,org.apache.isis.applib.annotation.MemberOrder)}private SortedSet<${ElementType}> ${collectionName} = new TreeSet<${ElementType}>();
+@MemberOrder(sequence="1")
+public SortedSet<${ElementType}> get${CollectionName}() {
+ return ${collectionName};
}
public void set${CollectionName}(final SortedSet<${ElementType}> ${collectionName}) {
- this.${collectionName} = ${collectionName};
+ this.${collectionName} = ${collectionName};
+}
+
+@MemberOrder(name="${collectionName}", sequence="1")
+public ${enclosing_type} insertInto${CollectionName}(final ${ElementType} ${elementName}) {
+ addTo${CollectionName}(${elementName});
+ return this;
+}
+
+// Programming model.
+public void addTo${CollectionName}(final ${ElementType} ${elementName}) {
+ // check for no-op
+ if (${elementName} == null ||
+ get${CollectionName}().contains(${elementName})) {
+ return;
+ }
+ // associate new
+ get${CollectionName}().add(${elementName});
+ // additional business logic
+ onAddTo${CollectionName}(${elementName});
+}
+
+// Action.
+@MemberOrder(name="${collectionName}", sequence="2")
+public ${enclosing_type} deleteFrom${CollectionName}(final ${ElementType} ${elementName}) {
+ removeFrom${CollectionName}(${elementName});
+ return this;
+}
+
+// Programming model.
+public void removeFrom${CollectionName}(final ${ElementType} ${elementName}) {
+ // check for no-op
+ if (${elementName} == null ||
+ !get${CollectionName}().contains(${elementName})) {
+ return;
+ }
+ // dissociate existing
+ get${CollectionName}().remove(${elementName});
+ // additional business logic
+ onRemoveFrom${CollectionName}(${elementName});
+}
+protected void onAddTo${CollectionName}(final ${ElementType} ${elementName}) {
+}
+protected void onRemoveFrom${CollectionName}(final ${ElementType} ${elementName}) {
}
// }}</template><template autoinsert="true" context="java-members" deleted="false" description="Collection validation" enabled="true" name="iscval">public String validateAddTo${CollectionName}(final ${ElementType} ${elementName}) {
return ${cursor}null; // TODO: return reason why argument cannot be added, null if ok to add