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 2015/03/30 14:56:34 UTC
[05/22] isis git commit: ISIS-720: mothballing scimpi
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
new file mode 100644
index 0000000..1efad45
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/LongFormView.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.TableView.SimpleTableBuilder;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+
+public class LongFormView extends AbstractFormView {
+
+ @Override
+ protected void addField(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ if (field.isOneToManyAssociation()) {
+ final String noColumnsString = request.getOptionalProperty("no-columns", "3");
+ final String tableClass = request.getOptionalProperty("table-class");
+ final String rowClassesList = request.getOptionalProperty("row-classes", ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ String[] rowClasses = new String[0];
+ if (rowClassesList != null) {
+ rowClasses = rowClassesList.split("[,|/]");
+ }
+ int noColumns;
+ ResolveFieldUtil.resolveField(object, field);
+ final ObjectAdapter collection = field.get(object);
+ final ObjectSpecification elementSpec = collection.getElementSpecification();
+ final List<ObjectAssociation> fields = elementSpec.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.VISIBLE_AT_LEAST_SOMETIMES);
+ if (noColumnsString.equalsIgnoreCase("all")) {
+ noColumns = fields.size();
+ } else {
+ noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
+ }
+ // final boolean isFieldEditable = field.isUsable(IsisContext.getAuthenticationSession(), object).isAllowed();
+ final String summary = "Table of elements in " + field.getName();
+ // TableView.write(request, summary, object, field, collection, noColumns, fields, isFieldEditable, showIconByDefault(), tableClass, rowClasses, linkedObject);
+
+
+ final String headers[] = new String[fields.size()];
+ int h = 0;
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
+
+
+ final TableContentWriter rowBuilder =new SimpleTableBuilder(object.titleString(), true, false, "", noColumns, headers, fields, false,
+ showIcons, false, false, false, field.getName(), linkedFields, null);
+ TableView.write(request, collection, summary, rowBuilder, null, tableClass, rowClasses);
+ } else {
+ super.addField(request, object, field, linkedObject, showIcons);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "long-form";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
new file mode 100644
index 0000000..8ec1420
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Messages.java
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+import org.apache.isis.core.commons.authentication.MessageBroker;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Messages extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String cls = request.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(cls, buffer);
+ if (buffer.length() > 0) {
+ request.appendHtml("<div class=\"feedback\">");
+ request.appendHtml(buffer.toString());
+ request.appendHtml("</div>");
+ }
+
+ }
+
+ public static void write(String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "message";
+ }
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ final List<String> messages = messageBroker.getMessages();
+ for (final String message : messages) {
+ buffer.append("<div class=\"" + cls + "\">" + message + "</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "messages";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
new file mode 100644
index 0000000..7af46ab
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/SelectedObject.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+/**
+ * <swf:selected name="selected" object="${action}" equals="${subaction}" />
+ */
+public class SelectedObject extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String name = request.getOptionalProperty(NAME, "selected");
+ final String objectId = request.getRequiredProperty(OBJECT);
+ final String equalsId = request.getOptionalProperty("equals");
+ final String title = request.getOptionalProperty(BUTTON_TITLE);
+
+ final ObjectAdapter object = request.getContext().getMappedObjectOrResult(objectId);
+ final ObjectAdapter other = request.getContext().getMappedObjectOrResult(equalsId);
+ if (object == other || object.equals(title)) {
+ // TODO title is not being used!
+ request.getContext().addVariable(ID, " id=\"" + name + "\" ", Scope.INTERACTION);
+ } else {
+ request.getContext().addVariable(ID, "", Scope.INTERACTION);
+ }
+ request.closeEmpty();
+ }
+
+ @Override
+ public String getName() {
+ return "selected";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java
new file mode 100644
index 0000000..31e903b
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ShortFormView.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+
+public class ShortFormView extends AbstractFormView {
+
+ @Override
+ protected boolean ignoreField(final ObjectAssociation field) {
+ return field.isOneToManyAssociation();
+ }
+
+ @Override
+ public String getName() {
+ return "short-form";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
new file mode 100644
index 0000000..2927fab
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBlock.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.BlockContent;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+
+public class TableBlock implements BlockContent {
+
+ // {{ collection
+ private ObjectAdapter collection;
+
+ public void setCollection(final ObjectAdapter collection) {
+ this.collection = collection;
+ }
+
+ public ObjectAdapter getCollection() {
+ return collection;
+ }
+ // }}
+
+ // {{ linkView
+ private String linkView;
+
+ public String getlinkView() {
+ return linkView;
+ }
+
+ public void setlinkView(final String linkView) {
+ this.linkView = linkView;
+ }
+ // }}
+
+ // {{ linkName
+ private String linkName;
+
+ public String getlinkName() {
+ return linkName;
+ }
+
+ public void setlinkName(final String linkName) {
+ this.linkName = linkName;
+ }
+ // }}
+
+ // {{ elementName
+ private String elementName;
+
+ public String getElementName() {
+ return elementName;
+ }
+
+ public void setElementName(final String linkObject) {
+ this.elementName = linkObject;
+ }
+ // }}
+
+ private RepeatMarker marker;
+
+ public RepeatMarker getMarker() {
+ return marker;
+ }
+
+ public void setMarker(final RepeatMarker marker) {
+ this.marker = marker;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
new file mode 100644
index 0000000..e726e29
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableBuilder.java
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+
+public class TableBuilder extends AbstractTableView {
+
+ @Override
+ protected TableContentWriter createRowBuilder(final Request request, final RequestContext context, final String parent, final List<ObjectAssociation> allFields, final ObjectAdapter collection) {
+
+ final String title = request.getOptionalProperty(TABLE_TITLE);
+ final String variable = request.getOptionalProperty(ELEMENT_NAME, ELEMENT);
+ final String headerClass = request.getOptionalProperty("head-" + CLASS);
+
+ final TableBlock block = new TableBlock();
+ block.setCollection(collection);
+ block.setElementName(variable);
+ request.setBlockContent(block);
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String headers = request.popBuffer();
+ return new TableContentWriter() {
+
+ @Override
+ public void writeFooters(final PageWriter writer) {
+ }
+
+ public void tidyUp() {
+ request.popBlockContent();
+ }
+
+ @Override
+ public void writeCaption(PageWriter writer) {
+ if (title != null) {
+ writer.appendHtml("<caption>");
+ writer.appendHtml(title);
+ writer.appendHtml("</thead>");
+ }
+ }
+
+ @Override
+ public void writeHeaders(final PageWriter writer) {
+ final String headerSegment = headerClass == null ? "" : (" class=\"" + headerClass + "\"");
+ writer.appendHtml("<thead" + headerSegment + ">");
+ writer.appendHtml(headers);
+ writer.appendHtml("</thead>");
+ }
+
+ @Override
+ public void writeElement(final Request request, final RequestContext context, final ObjectAdapter element) {
+ context.addVariable(variable, context.mapObject(element, Scope.REQUEST), Scope.REQUEST);
+ final RepeatMarker end = request.createMarker();
+ final RepeatMarker marker = block.getMarker();
+ marker.repeat();
+ request.processUtilCloseTag();
+ end.repeat();
+ }
+ };
+ }
+
+ @Override
+ public String getName() {
+ return "table-builder";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
new file mode 100644
index 0000000..3f99218
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableCell.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class TableCell extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
+ // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
+ // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
+ private final Where where = Where.ALL_TABLES;
+
+ @Override
+ public void process(final Request request) {
+ final TableBlock tableBlock = (TableBlock) request.getBlockContent();
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getRequiredProperty(FIELD);
+ final String linkView = request.getOptionalProperty(LINK_VIEW);
+ String className = request.getOptionalProperty(CLASS);
+ className = className == null ? "" : " class=\"" + className + "\"";
+ RequestContext context = request.getContext();
+ final ObjectAdapter object = context.getMappedObjectOrVariable(id, tableBlock.getElementName());
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ request.appendHtml("<td" + className + ">");
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
+ final ObjectAdapter fieldReference = field.get(object);
+ final String source = fieldReference == null ? "" : context.mapObject(fieldReference, Scope.REQUEST);
+ final String name = request.getOptionalProperty(RESULT_NAME, fieldName);
+ context.addVariable(name, Request.getEncoder().encoder(source), Scope.REQUEST);
+
+ if (linkView != null) {
+ final String linkId = context.mapObject(object, Scope.REQUEST);
+ final String linkName = request.getOptionalProperty(LINK_NAME, RequestContext.RESULT);
+ final String linkObject = request.getOptionalProperty(LINK_OBJECT, linkId);
+ request.appendHtml("<a href=\"" + linkView + "?" + linkName + "=" + linkObject + context.encodedInteractionParameters() + "\">");
+ } else if(tableBlock.getlinkView() != null) {
+ String linkObjectInVariable = tableBlock.getElementName();
+ final String linkId = (String) context.getVariable(linkObjectInVariable);
+ request.appendHtml("<a href=\"" + tableBlock.getlinkView() + "?" + tableBlock.getlinkName() + "=" + linkId + context.encodedInteractionParameters() + "\">");
+ }
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String buffer = request.popBuffer();
+ if (buffer.trim().length() == 0) {
+ request.appendAsHtmlEncoded(fieldReference == null ? "" : fieldReference.titleString());
+ } else {
+ request.appendHtml(buffer);
+ }
+ if (linkView != null) {
+ request.appendHtml("</a>");
+ }
+ } else {
+ request.skipUntilClose();
+ }
+ request.appendHtml("</td>");
+ }
+
+ @Override
+ public String getName() {
+ return "table-cell";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
new file mode 100644
index 0000000..10da109
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableContentWriter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public interface TableContentWriter {
+
+ void writeCaption(PageWriter writer);
+
+ void writeHeaders(PageWriter writer);
+
+ void writeFooters(PageWriter writer);
+
+ void writeElement(Request request, RequestContext context, ObjectAdapter element);
+
+ void tidyUp();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
new file mode 100644
index 0000000..5595207
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableEmpty.java
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class TableEmpty extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final TableBlock tableBlock = (TableBlock) request.getBlockContent();
+ final ObjectAdapter collection = tableBlock.getCollection();
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ if (facet.size(collection) == 0) {
+ String className = request.getOptionalProperty(CLASS);
+ className = className == null ? "" : " class=\"" + className + "\"";
+ request.appendHtml("<tr" + className + ">");
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String buffer = request.popBuffer();
+ request.appendHtml(buffer);
+ request.appendHtml("</td>");
+ } else {
+ request.skipUntilClose();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "table-empty";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
new file mode 100644
index 0000000..ff04389
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableHeader.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class TableHeader extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "table-header";
+ }
+
+ @Override
+ public void process(final Request request) {
+ request.appendHtml("<thead><tr>");
+ request.processUtilCloseTag();
+ request.appendHtml("</tr></thead>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
new file mode 100644
index 0000000..eb92656
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableRow.java
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request.RepeatMarker;
+
+public class TableRow extends AbstractElementProcessor {
+
+ @Override
+ public String getName() {
+ return "table-row";
+ }
+
+ @Override
+ public void process(final Request request) {
+ final TableBlock block = (TableBlock) request.getBlockContent();
+
+ final RepeatMarker start = request.createMarker();
+ block.setMarker(start);
+
+ final String linkView = request.getOptionalProperty(LINK_VIEW);
+ if (linkView != null) {
+ block.setlinkView(linkView);
+ block.setlinkName(request.getOptionalProperty(LINK_NAME, RequestContext.RESULT));
+ }
+
+ request.skipUntilClose();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
new file mode 100644
index 0000000..caf984f
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/TableView.java
@@ -0,0 +1,329 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.viewer.scimpi.dispatcher.Dispatcher;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.PageWriter;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+import org.apache.isis.viewer.scimpi.dispatcher.view.simple.RemoveElement;
+
+public class TableView extends AbstractTableView {
+
+ static final class SimpleTableBuilder implements TableContentWriter {
+ private final String parent;
+ private final boolean includeHeader;
+ private final boolean includeFooter;
+ private final String title;
+ private final String[] headers;
+ private final List<ObjectAssociation> fields;
+ private final boolean showTitle;
+ private final boolean showIcons;
+ private final boolean showSelectOption;
+ private final boolean showDeleteOption;
+ private final boolean showEditOption;
+ private final String fieldName;
+ private final LinkedObject[] linkedFields;
+ private final LinkedObject linkRow;
+ private final int noColumns;
+
+ SimpleTableBuilder(
+ final String parent,
+ final boolean includeHeader,
+ final boolean includeFooter,
+ final String title,
+ final int noColumns,
+ final String[] headers,
+ final List<ObjectAssociation> fields,
+ final boolean showTitle,
+ final boolean showIcons,
+ final boolean showSelectOption,
+ final boolean showDeleteOption,
+ final boolean showEditOption,
+ final String fieldName,
+ final LinkedObject[] linkedFields,
+ final LinkedObject linkRow) {
+ this.parent = parent;
+ this.includeHeader = includeHeader;
+ this.includeFooter = includeFooter;
+ this.title = title;
+ this.showTitle = showTitle;
+ this.noColumns = noColumns < 1 ? fields.size() : noColumns;
+ this.headers = headers;
+ this.fields = fields;
+ this.showIcons = showIcons;
+ this.showSelectOption = showSelectOption;
+ this.showDeleteOption = showDeleteOption;
+ this.showEditOption = showEditOption;
+ this.fieldName = fieldName;
+ this.linkedFields = linkedFields;
+ this.linkRow = linkRow;
+ }
+
+ @Override
+ public void writeFooters(final PageWriter writer) {
+ if (includeFooter) {
+ writer.appendHtml("<tfoot>");
+ columnHeaders(writer, headers);
+ writer.appendHtml("</tfoot>");
+ }
+ }
+
+ @Override
+ public void writeCaption(PageWriter writer) {
+ if (title != null) {
+ writer.appendHtml("<caption>");
+ writer.appendHtml(title);
+ writer.appendHtml("</caption>");
+ }
+ }
+
+ @Override
+ public void writeHeaders(final PageWriter writer) {
+ if (includeHeader) {
+ writer.appendHtml("<thead>");
+ columnHeaders(writer, headers);
+ writer.appendHtml("</thead>");
+ }
+ }
+
+ private void columnHeaders(final PageWriter writer, final String[] headers) {
+ writer.appendHtml("<tr class=\"column-headers\">");
+ if (showTitle) {
+ writer.appendHtml("<th></th>");
+ }
+ final String[] columnHeaders = headers;
+ for (final String columnHeader : columnHeaders) {
+ if (columnHeader != null) {
+ writer.appendHtml("<th>");
+ writer.appendAsHtmlEncoded(columnHeader);
+ writer.appendHtml("</th>");
+ }
+ }
+ writer.appendHtml("<th class=\"controls\"></th>");
+ writer.appendHtml("</tr>");
+ }
+
+ public void tidyUp() {
+ // request.popBlockContent();
+
+ // Is it the block that is left over, or is the collection form not being closed?
+ }
+
+ @Override
+ public void writeElement(final Request request, final RequestContext context, final ObjectAdapter element) {
+ final String rowId = context.mapObject(element, Scope.INTERACTION);
+ final String scope = linkRow == null ? "" : "&" + SCOPE + "=" + linkRow.getScope();
+ String result = "";
+ result = context.encodedInteractionParameters();
+
+ if (noColumns == 0) {
+ request.appendHtml("<td>");
+ if (linkRow != null) {
+ request.appendHtml("<td><a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ request.appendAsHtmlEncoded(element.titleString());
+ request.appendHtml("</a>");
+ } else {
+ request.appendAsHtmlEncoded(element.titleString());
+ }
+ request.appendHtml("</td>");
+
+ } else {
+ if (showTitle) {
+ request.appendHtml("<td>");
+ request.appendAsHtmlEncoded(element.titleString());
+ request.appendHtml("</td>");
+ }
+
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ request.appendHtml("<td>");
+ final ObjectAdapter field = fields.get(i).get(element);
+ if (field != null) {
+ if (showIcons && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
+ request.appendHtml("<img class=\"" + "small-icon" + "\" src=\"" + request.getContext().imagePath(field) + "\" alt=\"" + fields.get(i).getSpecification().getShortIdentifier() + "\"/>");
+ }
+ if (linkRow != null) {
+ request.appendHtml("<a href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable() + "=" + rowId + result + scope + "\">");
+ } else if (linkedFields[i] != null) {
+ final ObjectAdapter fieldObject = fields.get(i).get(element);
+ final String id = context.mapObject(fieldObject, Scope.INTERACTION);
+ request.appendHtml("<a href=\"" + linkedFields[i].getForwardView() + "?" + linkedFields[i].getVariable() + "=" + id + "\">");
+ context.mapObject(fieldObject, RequestContext.scope(linkedFields[i].getScope()));
+
+ }
+ try {
+ request.appendAsHtmlEncoded(field.titleString());
+ } catch (final ObjectNotFoundException e) {
+ request.appendAsHtmlEncoded(e.getMessage());
+ }
+ if (linkRow != null || linkedFields[i] != null) {
+ request.appendHtml("</a>");
+ }
+ }
+ request.appendHtml("</td>");
+
+ }
+ }
+ request.appendHtml("<td class=\"controls\">");
+ if (showSelectOption) {
+ request.appendHtml("<a class=\"button element-select\" href=\"" + "_generic." + Dispatcher.EXTENSION + "?" + RequestContext.RESULT + "=" + rowId + result + scope + "\">view</a>");
+ }
+ if (showEditOption) {
+ request.appendHtml(" <a class=\"button element-edit\" href=\"" + "_generic_edit." + Dispatcher.EXTENSION + "?" + RequestContext.RESULT + "=" + rowId + result + scope + "\">edit</a>");
+ }
+
+ if (showDeleteOption && parent != null) {
+ String view = request.getViewPath();
+ view = context.fullFilePath(view == null ? context.getResourceFile() : view);
+ RemoveElement.write(request, context.getMappedObject(parent), fieldName, element, null, view, view, "delete", "action in-line element-delete confirm");
+ }
+
+ request.appendHtml("</td>");
+
+ }
+ }
+
+ @Override
+ protected TableContentWriter createRowBuilder(
+ final Request request,
+ final RequestContext context,
+ final String parent,
+ final List<ObjectAssociation> allFields,
+ final ObjectAdapter collection) {
+ final String fieldName = request.getOptionalProperty(FIELD);
+ final String title = request.getOptionalProperty(FORM_TITLE);
+ return rowBuilder(request, context, title, parent, fieldName, allFields, showIconByDefault());
+ }
+
+ private static TableContentWriter rowBuilder(
+ final Request request,
+ final RequestContext context,
+ final String title,
+ final String object,
+ final String fieldName,
+ final List<ObjectAssociation> allFields,
+ final boolean showIconByDefault) {
+ final String linkRowView = request.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = request.getOptionalProperty(ELEMENT_NAME, RequestContext.RESULT);
+ final String linkObjectScope = request.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ final LinkedObject linkRow = linkRowView == null ? null : new LinkedObject(linkObjectName, linkObjectScope, context.fullUriPath(linkRowView));
+ final boolean includeHeader = request.isRequested(HEADER, true);
+ final boolean includeFooter = request.isRequested(FOOTER, false);
+
+ final boolean linkFields = request.isRequested("link-fields", true);
+ final boolean showTitle = request.isRequested(SHOW_TITLE, false);
+ final boolean showIcons = request.isRequested(SHOW_ICON, showIconByDefault);
+ final boolean showSelectOption = request.isRequested(SHOW_SELECT, true);
+ final boolean showEditOption = request.isRequested(SHOW_EDIT, true);
+ final boolean showDeleteOption = request.isRequested(SHOW_DELETE, true);
+
+ final String noColumnsString = request.getOptionalProperty("no-columns", "3");
+
+ final LinkedFieldsBlock block = new LinkedFieldsBlock();
+ request.setBlockContent(block);
+ request.processUtilCloseTag();
+ final List<ObjectAssociation> fields = block.includedFields(allFields);
+ final LinkedObject[] linkedFields = block.linkedFields(fields);
+ for (int i = 0; i < linkedFields.length; i++) {
+ if (linkedFields[i] == null && linkFields && !fields.get(i).getSpecification().containsFacet(ParseableFacet.class)) {
+ linkedFields[i] = new LinkedObject("_generic.shtml");
+ }
+ if (linkedFields[i] != null) {
+ linkedFields[i].setForwardView(context.fullUriPath(linkedFields[i].getForwardView()));
+ }
+ }
+
+ int noColumns;
+ if (noColumnsString.equalsIgnoreCase("all")) {
+ noColumns = fields.size();
+ } else {
+ noColumns = Math.min(fields.size(), Integer.valueOf(noColumnsString));
+ }
+
+ final String headers[] = new String[noColumns];
+ int h = 0;
+ for (int i = 0; i < noColumns; i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ request.popBlockContent();
+
+ return new SimpleTableBuilder(object, includeHeader, includeFooter, title, noColumns, headers, fields, showTitle,
+ showIcons, showSelectOption, showDeleteOption, showEditOption, fieldName, linkedFields, linkRow);
+ }
+
+ public static void write(
+ final Request request,
+ final String summary,
+ final ObjectAdapter object,
+ final ObjectAssociation field,
+ final ObjectAdapter collection,
+ final int noColumns,
+ final List<ObjectAssociation> fields,
+ final boolean linkAllFields,
+ final boolean showIconByDefault,
+ final String tableClass,
+ final String[] rowClasses,
+ LinkedObject linkedObject) {
+ final LinkedObject[] linkedFields = new LinkedObject[fields.size()];
+ if (linkAllFields) {
+ for (int i = 0; i < linkedFields.length; i++) {
+ if (fields.get(i).isOneToOneAssociation()) {
+ linkedFields[i] = linkedObject == null ? new LinkedObject("_generic.shtml") : linkedObject;
+ }
+ }
+ }
+
+ final String headers[] = new String[fields.size()];
+ int h = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ if (fields.get(i).isOneToManyAssociation()) {
+ continue;
+ }
+ headers[h++] = fields.get(i).getName();
+ }
+
+ final RequestContext context = request.getContext();
+ final TableContentWriter rowBuilder = rowBuilder(request, context, null, context.mapObject(object, Scope.REQUEST), field.getIdentifier().getMemberName(), fields,
+ showIconByDefault);
+ write(request, collection, summary, rowBuilder, null, null, null);
+ }
+
+ @Override
+ public String getName() {
+ return "table";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
new file mode 100644
index 0000000..d3b6904
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Title.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
+
+public class Title extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getOptionalProperty(FIELD);
+ final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
+ final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());
+ String className = request.getOptionalProperty(CLASS);
+ className = className == null ? "title-icon" : className;
+ ObjectAdapter object = MethodsUtils.findObject(request.getContext(), id);
+ if (fieldName != null) {
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.ANYWHERE).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ object = field.get(object);
+ }
+
+ if (object != null) {
+ request.appendHtml("<span class=\"object\">");
+ IsisContext.getPersistenceSession().resolveImmediately(object);
+ if (isIconShowing) {
+ final String iconPath = request.getContext().imagePath(object);
+ request.appendHtml("<img class=\"" + className + "\" src=\"" + iconPath + "\" />");
+ }
+ request.appendTruncated(object.titleString(), truncateTo);
+ request.appendHtml("</span>");
+ }
+ request.closeEmpty();
+ }
+
+ @Override
+ public String getName() {
+ return "title";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
new file mode 100644
index 0000000..52be7d6
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Warnings.java
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+import org.apache.isis.core.commons.authentication.MessageBroker;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Warnings extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String cls = request.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(cls, buffer);
+ if (buffer.length() > 0) {
+ request.appendHtml("<div class=\"feedback\">");
+ request.appendHtml(buffer.toString());
+ request.appendHtml("</div>");
+ }
+ }
+
+ public static void write(String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "warning";
+ }
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ final List<String> warnings = messageBroker.getWarnings();
+ for (final String warning : warnings) {
+ buffer.append("<div class=\"" + cls + "\">" + warning + "</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "warnings";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
new file mode 100644
index 0000000..deafb1a
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/EditObject.java
@@ -0,0 +1,319 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.edit;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.facets.object.choices.enums.EnumFacet;
+import org.apache.isis.core.metamodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.edit.EditAction;
+import org.apache.isis.viewer.scimpi.dispatcher.edit.FieldEditState;
+import org.apache.isis.viewer.scimpi.dispatcher.edit.FormState;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.HiddenInputField;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.HtmlFormBuilder;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
+
+public class EditObject extends AbstractElementProcessor {
+
+ // REVIEW: confirm this rendering context
+ private final Where where = Where.OBJECT_FORMS;
+
+ @Override
+ public void process(final Request request) {
+ final RequestContext context = request.getContext();
+
+ final String objectId = request.getOptionalProperty(OBJECT);
+ final String forwardEditedTo = request.getOptionalProperty(VIEW);
+ final String forwardErrorTo = request.getOptionalProperty(ERROR);
+ final String cancelTo = request.getOptionalProperty(CANCEL_TO);
+ final boolean hideNonEditableFields = request.isRequested(HIDE_UNEDITABLE, false);
+ final boolean showIcon = request.isRequested(SHOW_ICON, showIconByDefault());
+ final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
+ String buttonTitle = request.getOptionalProperty(BUTTON_TITLE);
+ String formTitle = request.getOptionalProperty(FORM_TITLE);
+ final String formId = request.getOptionalProperty(FORM_ID, request.nextFormId());
+ final String variable = request.getOptionalProperty(RESULT_NAME);
+ final String resultOverride = request.getOptionalProperty(RESULT_OVERRIDE);
+ final String scope = request.getOptionalProperty(SCOPE);
+ final String className = request.getOptionalProperty(CLASS, "edit full");
+ final String completionMessage = request.getOptionalProperty(MESSAGE);
+
+ final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
+ final String actualObjectId = context.mapObject(object, Scope.INTERACTION);
+ final String version = context.mapVersion(object);
+
+ final String id = request.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+
+ final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);
+
+ final ObjectSpecification specification = object.getSpecification();
+ final FormFieldBlock containedBlock = new FormFieldBlock() {
+ @Override
+ public boolean isVisible(final String name) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ return isVisible && isUseable;
+ }
+
+ @Override
+ public ObjectAdapter getCurrent(final String name) {
+ ObjectAdapter value = null;
+ if (entryState != null) {
+ final FieldEditState field2 = entryState.getField(name);
+ value = field2.getValue();
+ }
+ if (value == null) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ value = fld.get(object);
+ }
+ return value;
+ }
+
+ @Override
+ public boolean isNullable(final String name) {
+ final ObjectAssociation fld = specification.getAssociation(name);
+ return !fld.isMandatory();
+ }
+ };
+
+ request.setBlockContent(containedBlock);
+ request.processUtilCloseTag();
+
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ List<ObjectAssociation> viewFields = specification.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(session, object, where));
+ viewFields = containedBlock.includedFields(viewFields);
+ final InputField[] formFields = createFields(viewFields);
+
+ initializeFields(context, object, formFields, entryState, !hideNonEditableFields);
+ setDefaults(context, object, formFields, entryState, showIcon);
+
+ copyFieldContent(context, object, formFields, showIcon);
+ overrideWithHtml(context, containedBlock, formFields);
+ String errors = null;
+ if (entryState != null && entryState.isForForm(formId)) {
+ copyEntryState(context, object, formFields, entryState);
+ errors = entryState.getError();
+ }
+
+ final String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile() : forwardErrorTo);
+ final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
+ hiddenFields.add(new HiddenInputField("_" + OBJECT, actualObjectId));
+ hiddenFields.add(new HiddenInputField("_" + VERSION, version));
+ hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));
+ hiddenFields.add(completionMessage == null ? null : new HiddenInputField("_" + MESSAGE, completionMessage));
+ hiddenFields.add(forwardEditedTo == null ? null : new HiddenInputField("_" + VIEW, context.fullFilePath(forwardEditedTo)));
+ hiddenFields.add(new HiddenInputField("_" + ERROR, errorView));
+ hiddenFields.add(variable == null ? null : new HiddenInputField("_" + RESULT_NAME, variable));
+ hiddenFields.add(resultOverride == null ? null : new HiddenInputField("_" + RESULT_OVERRIDE, resultOverride));
+ hiddenFields.add(scope == null ? null : new HiddenInputField("_" + SCOPE, scope));
+
+ if (!object.isTransient()) {
+ // ensure all booleans are included so the pass back TRUE if set.
+ final List<ObjectAssociation> fields2 = object.getSpecification().getAssociations(Contributed.EXCLUDED);
+ for (int i = 0; i < fields2.size(); i++) {
+ final ObjectAssociation field = fields2.get(i);
+ if (!viewFields.contains(field) && field.getSpecification().containsFacet(BooleanValueFacet.class)) {
+ final String fieldId = field.getId();
+ final String value = getValue(context, field.get(object));
+ hiddenFields.add(new HiddenInputField(fieldId, value));
+ }
+ }
+ }
+
+ if (formTitle == null) {
+ formTitle = specification.getSingularName();
+ }
+
+ if (buttonTitle == null) {
+ buttonTitle = "Save " + specification.getSingularName();
+ } else if (buttonTitle.equals("")) {
+ buttonTitle = "Save";
+ }
+
+ final HiddenInputField[] hiddenFieldArray = hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]);
+ HtmlFormBuilder.createForm(request, EditAction.ACTION + ".app", hiddenFieldArray, formFields, className, id, formTitle,
+ labelDelimiter, null, null, buttonTitle, errors, cancelTo);
+ request.popBlockContent();
+ }
+
+ private InputField[] createFields(final List<ObjectAssociation> fields) {
+ final InputField[] formFields = new InputField[fields.size()];
+ int length = 0;
+ for (int i = 0; i < fields.size(); i++) {
+ if (!fields.get(i).isOneToManyAssociation()) {
+ formFields[i] = new InputField(fields.get(i).getId());
+ length++;
+ }
+ }
+ final InputField[] array = new InputField[length];
+ for (int i = 0, j = 0; i < formFields.length; i++) {
+ if (formFields[i] != null) {
+ array[j++] = formFields[i];
+ }
+ }
+ return array;
+ }
+
+ // TODO duplicated in ActionForm#initializeFields
+ private void initializeFields(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean includeUnusableFields) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ final Consent usable = field.isUsable(session, object, where);
+ final ObjectAdapter[] options = field.getChoices(object);
+ FieldFactory.initializeField(context, object, field, options, field.isMandatory(), formField);
+
+ final boolean isEditable = usable.isAllowed();
+ if (!isEditable) {
+ formField.setDescription(usable.getReason());
+ }
+ formField.setEditable(isEditable);
+ final boolean hiddenField = field.isVisible(session, object, where).isVetoed();
+ final boolean unusable = usable.isVetoed();
+ final boolean hideAsUnusable = unusable && !includeUnusableFields;
+ if (hiddenField || hideAsUnusable) {
+ formField.setHidden(true);
+ }
+ }
+ }
+
+ private void copyFieldContent(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final boolean showIcon) {
+ for (final InputField inputField : formFields) {
+ final String fieldName = inputField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
+ ResolveFieldUtil.resolveField(object, field);
+ final ObjectAdapter fieldValue = field.get(object);
+ if (inputField.isEditable()) {
+ final String value = getValue(context, fieldValue);
+ if (!value.equals("") || inputField.getValue() == null) {
+ inputField.setValue(value);
+ }
+ } else {
+ final String entry = getValue(context, fieldValue);
+ inputField.setHtml(entry);
+ inputField.setType(InputField.HTML);
+
+ }
+
+ if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
+ if (fieldValue != null) {
+ final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(field.getSpecification()) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>" : "";
+ final String entry = iconSegment + fieldValue.titleString();
+ inputField.setHtml(entry);
+ } else {
+ final String entry = "<em>none specified</em>";
+ inputField.setHtml(entry);
+ }
+ }
+ }
+ }
+ }
+
+ private void setDefaults(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState, final boolean showIcon) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ final ObjectAdapter defaultValue = field.getDefault(object);
+ if (defaultValue == null) {
+ continue;
+ }
+
+ final String title = defaultValue.titleString();
+ if (field.getSpecification().containsFacet(ParseableFacet.class)) {
+ formField.setValue(title);
+ } else if (field.isOneToOneAssociation()) {
+ final ObjectSpecification objectSpecification = field.getSpecification();
+ if (defaultValue != null) {
+ final String iconSegment = showIcon ? "<img class=\"small-icon\" src=\"" + context.imagePath(objectSpecification) + "\" alt=\"" + objectSpecification.getShortIdentifier() + "\"/>" : "";
+ final String html = iconSegment + title;
+ formField.setHtml(html);
+ final String value = defaultValue == null ? null : context.mapObject(defaultValue, Scope.INTERACTION);
+ formField.setValue(value);
+ }
+ }
+ }
+ }
+
+ private void overrideWithHtml(final RequestContext context, final FormFieldBlock containedBlock, final InputField[] formFields) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ if (containedBlock.hasContent(fieldId)) {
+ final String content = containedBlock.getContent(fieldId);
+ if (content != null) {
+ formField.setHtml(content);
+ formField.setValue(null);
+ formField.setType(InputField.HTML);
+ }
+ }
+ }
+ }
+
+ private void copyEntryState(final RequestContext context, final ObjectAdapter object, final InputField[] formFields, final FormState entryState) {
+ for (final InputField formField : formFields) {
+ final String fieldId = formField.getName();
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldId);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed() && formField.isEditable()) {
+ final FieldEditState fieldState = entryState.getField(field.getId());
+ final String entry = fieldState == null ? "" : fieldState.getEntry();
+ formField.setValue(entry);
+ final String error = fieldState == null ? "" : fieldState.getError();
+ formField.setErrorText(error);
+ }
+ }
+ }
+
+ private String getValue(final RequestContext context, final ObjectAdapter field) {
+ if (field == null || field.isTransient()) {
+ return "";
+ }
+ final ObjectSpecification specification = field.getSpecification();
+ if (specification.containsFacet(EnumFacet.class)) {
+ return String.valueOf(field.getObject());
+ } else if (specification.getFacet(ParseableFacet.class) == null) {
+ return context.mapObject(field, Scope.INTERACTION);
+ } else {
+ return field.titleString();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "edit";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
new file mode 100644
index 0000000..35a9158
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.edit;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.all.help.HelpFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.maxlen.MaxLengthFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.facets.objectvalue.typicallen.TypicalLengthFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.metamodel.facets.value.password.PasswordValueFacet;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.view.form.InputField;
+
+public class FieldFactory {
+
+ public static void initializeField(final RequestContext context, final ObjectAdapter object, final ObjectFeature param, final ObjectAdapter[] optionsForParameter, final boolean isRequired, final InputField field) {
+
+ field.setLabel(param.getName());
+ field.setDescription(param.getDescription());
+ field.setDataType(param.getSpecification().getShortIdentifier());
+ if (param instanceof ObjectMember) {
+ field.setHelpReference(((ObjectMember) param).getHelp());
+ } else {
+ final HelpFacet helpFacet = param.getFacet(HelpFacet.class);
+ final String value = helpFacet.value();
+ field.setHelpReference(value);
+ }
+ field.setRequired(isRequired);
+ field.setHidden(false);
+
+ if (param.getSpecification().getFacet(ParseableFacet.class) != null) {
+ final int maxLength = param.getFacet(MaxLengthFacet.class).value();
+ field.setMaxLength(maxLength);
+
+ final TypicalLengthFacet typicalLengthFacet = param.getFacet(TypicalLengthFacet.class);
+ if (typicalLengthFacet.isDerived() && maxLength > 0) {
+ field.setWidth(maxLength);
+ } else {
+ field.setWidth(typicalLengthFacet.value());
+ }
+
+ final MultiLineFacet multiLineFacet = param.getFacet(MultiLineFacet.class);
+ field.setHeight(multiLineFacet.numberOfLines());
+ field.setWrapped(!multiLineFacet.preventWrapping());
+
+ final ObjectSpecification spec = param.getSpecification();
+ if (spec.containsFacet(BooleanValueFacet.class)) {
+ field.setType(InputField.CHECKBOX);
+ } else if (spec.containsFacet(PasswordValueFacet.class)) {
+ field.setType(InputField.PASSWORD);
+ } else {
+ field.setType(InputField.TEXT);
+ }
+
+ } else {
+ field.setType(InputField.REFERENCE);
+ }
+
+ if (optionsForParameter != null) {
+ final int noOptions = optionsForParameter.length;
+ final String[] optionValues = new String[noOptions];
+ final String[] optionTitles = new String[noOptions];
+ for (int j = 0; j < optionsForParameter.length; j++) {
+ final int i = j; // + (field.isRequired() ? 0 : 1);
+ optionValues[i] = getValue(context, optionsForParameter[j]);
+ optionTitles[i] = optionsForParameter[j].titleString();
+ }
+ field.setOptions(optionTitles, optionValues);
+ }
+ }
+
+ private static String getValue(final RequestContext context, final ObjectAdapter field) {
+ if (field == null) {
+ return "";
+ }
+ if (field.getSpecification().getFacet(ParseableFacet.class) == null) {
+ return context.mapObject(field, Scope.INTERACTION);
+ } else {
+ return field.getObject().toString();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
new file mode 100644
index 0000000..5d57740
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormEntry.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.edit;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class FormEntry extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
+ final String field = request.getRequiredProperty(FIELD);
+ final String value = request.getRequiredProperty(VALUE);
+ final boolean isHidden = request.isRequested(HIDDEN, true);
+ block.exclude(field);
+ // TODO this is replaced because the field is marked as hidden!
+ final String content = "reference <input type=\"" + (isHidden ? "hidden" : "text") + "\" disabled=\"disabled\" name=\"" + field + "\" value=\"" + value + "\" />";
+ block.replaceContent(field, content);
+ }
+
+ @Override
+ public String getName() {
+ return "form-entry";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
new file mode 100644
index 0000000..55c7425
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FormField.java
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.edit;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class FormField extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final FormFieldBlock block = (FormFieldBlock) request.getBlockContent();
+ final String field = request.getRequiredProperty(FIELD);
+ if (block.isVisible(field)) {
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String content = request.popBuffer();
+ block.replaceContent(field, content);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "form-field";
+ }
+
+}