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/03/28 11:35:32 UTC
[08/20] ISIS-381: mothballing HTML viewer, SQL security, LDAP security
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/action/view/util/TableUtil.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/action/view/util/TableUtil.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/action/view/util/TableUtil.java
new file mode 100644
index 0000000..f7b20e4
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/action/view/util/TableUtil.java
@@ -0,0 +1,133 @@
+/*
+ * 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.html.action.view.util;
+
+import static org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters.PROPERTIES;
+import static org.apache.isis.core.metamodel.spec.feature.ObjectAssociationFilters.WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.filter.Filters;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.Persistor;
+import org.apache.isis.viewer.html.component.ComponentFactory;
+import org.apache.isis.viewer.html.component.Table;
+import org.apache.isis.viewer.html.context.Context;
+
+public class TableUtil {
+
+ // 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 static Where where = Where.ALL_TABLES;
+
+ public static Table createTable(final Context context, final String id, final ObjectAdapter object, final OneToManyAssociation collectionField) {
+
+ final ObjectAdapter collection = collectionField.get(object);
+ final String name = collectionField.getName();
+ final ObjectSpecification type = collectionField.getSpecification();
+
+ final String summary = "Table showing elements of " + name + " field";
+ return createTable(context, collectionField != null, collection, summary, type);
+ }
+
+ public static Table createTable(final Context context, final boolean addSelector, final ObjectAdapter collection, final String summary, final ObjectSpecification elementType) {
+
+ final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
+ final List<ObjectAssociation> columnAssociations = elementType.getAssociations(Filters.and(WHEN_VISIBLE_IRRESPECTIVE_OF_WHERE, PROPERTIES));
+
+ final int len = columnAssociations.size();
+
+ final ComponentFactory factory = context.getComponentFactory();
+ final Table table = factory.createTable(len, addSelector);
+ table.setSummary(summary);
+
+ for (final ObjectAssociation columnAssociation : columnAssociations) {
+ table.addColumnHeader(columnAssociation.getName());
+ }
+
+ for (final ObjectAdapter rowAdapter : facet.iterable(collection)) {
+ getPersistenceSession().resolveImmediately(rowAdapter);
+ final String elementId = context.mapObject(rowAdapter);
+ table.addRowHeader(factory.createObjectIcon(rowAdapter, elementId, "icon"));
+
+ for (final ObjectAssociation columnAssociation : columnAssociations) {
+ final ObjectAdapter columnAdapter = columnAssociation.get(rowAdapter);
+
+ final ObjectSpecification columnSpec = columnAssociation.getSpecification();
+
+ if (!columnAssociation.isVisible(getAuthenticationSession(), rowAdapter, where).isAllowed()) {
+ table.addEmptyCell();
+ } else if (columnSpec.isParseable()) {
+ final MultiLineFacet multiline = columnSpec.getFacet(MultiLineFacet.class);
+ final boolean shouldTruncate = multiline != null && multiline.numberOfLines() > 1;
+ final String titleString = columnAdapter != null ? columnAdapter.titleString() : "";
+ table.addCell(titleString, shouldTruncate);
+ } else if (columnAdapter == null) {
+ table.addEmptyCell();
+ } else {
+ getPersistenceSession().resolveImmediately(columnAdapter);
+ final String objectId = context.mapObject(columnAdapter);
+ table.addCell(factory.createObjectIcon(columnAssociation, columnAdapter, objectId, "icon"));
+ }
+ }
+ /*
+ * if (addSelector) {
+ * table.addCell(context.getFactory().createRemoveOption(id,
+ * elementId, collectionField.getId())); }
+ */
+ // TODO add selection box
+ // table.addCell();
+ /*
+ * if (collectionField != null) { if
+ * (collectionField.isValidToRemove(object, element).isAllowed()) {
+ * table.addCell(context.getFactory().createRemoveOption(id,
+ * elementId, collectionField.getId())); } else {
+ * table.addEmptyCell(); } }
+ */
+
+ }
+ return table;
+ }
+
+ // ////////////////////////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ////////////////////////////////////////////////////////////////////////////////
+
+ private static Persistor getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ private static AuthenticationSession getAuthenticationSession() {
+ return IsisContext.getAuthenticationSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Block.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Block.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Block.java
new file mode 100644
index 0000000..40bff7a
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Block.java
@@ -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.
+ */
+
+package org.apache.isis.viewer.html.component;
+
+public interface Block extends Component {
+
+ void add(Component component);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Component.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Component.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Component.java
new file mode 100644
index 0000000..5f9e4de
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Component.java
@@ -0,0 +1,27 @@
+/*
+ * 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.html.component;
+
+import java.io.PrintWriter;
+
+public interface Component {
+
+ void write(PrintWriter writer);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentAbstract.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentAbstract.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentAbstract.java
new file mode 100644
index 0000000..de2625a
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentAbstract.java
@@ -0,0 +1,64 @@
+/*
+ * 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.html.component;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+
+public abstract class ComponentAbstract implements Component {
+
+ private String id;
+ private String cls;
+ protected final PathBuilder pathBuilder;
+
+ public ComponentAbstract(final PathBuilder pathBuilder) {
+ this.pathBuilder = pathBuilder;
+ }
+
+ public void setClass(final String cls) {
+ this.cls = cls;
+ }
+
+ public void setId(final String id) {
+ this.id = id;
+ }
+
+ protected void writeTag(final PrintWriter writer, final String tagName) {
+ tag(writer, tagName);
+ writer.print(">");
+ }
+
+ private void tag(final PrintWriter writer, final String tagName) {
+ writer.print("<");
+ writer.print(tagName);
+ if (id != null) {
+ writer.print(" id=\"");
+ writer.print(id);
+ writer.print("\"");
+ }
+ if (cls != null) {
+ writer.print(" class=\"");
+ writer.print(cls);
+ writer.print("\"");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentComposite.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentComposite.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentComposite.java
new file mode 100644
index 0000000..c4b7559
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentComposite.java
@@ -0,0 +1,66 @@
+/*
+ * 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.html.component;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.viewer.html.PathBuilder;
+
+public class ComponentComposite implements Component {
+
+ private final List<Component> components = new ArrayList<Component>();
+ protected final PathBuilder pathBuilder;
+
+ public ComponentComposite(final PathBuilder pathBuilder) {
+ super();
+ this.pathBuilder = pathBuilder;
+ }
+
+ protected String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writeBefore(writer);
+ for (final Component component : components) {
+ write(writer, component);
+ }
+ writeAfter(writer);
+ writer.println();
+ }
+
+ protected void write(final PrintWriter writer, final Component component) {
+ component.write(writer);
+ }
+
+ protected void writeBefore(final PrintWriter writer) {
+ }
+
+ protected void writeAfter(final PrintWriter writer) {
+ }
+
+ public void add(final Component component) {
+ components.add(component);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentFactory.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentFactory.java
new file mode 100644
index 0000000..da3ecab
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ComponentFactory.java
@@ -0,0 +1,82 @@
+/*
+ * 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.html.component;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.html.PathBuilder;
+
+public interface ComponentFactory extends PathBuilder {
+
+ Component createAddOption(String id, String id2);
+
+ Block createBlock(String style, String description);
+
+ Component createBreadCrumbs(String[] names, boolean[] isLinked);
+
+ Component createCollectionIcon(ObjectAssociation field, ObjectAdapter collection, String id);
+
+ DebugPane createDebugPane();
+
+ Component createEditOption(String id);
+
+ Component createErrorMessage(Exception e, boolean isDebug);
+
+ Form createForm(String id, String action, int step, int noOfPages, boolean b);
+
+ Component createHeading(String string);
+
+ Component createInlineBlock(String style, String text, String description);
+
+ Component createCheckboxBlock(final boolean isEditable, final boolean isSet);
+
+ Component createSubmenu(String menuName, Component[] items);
+
+ Component createMenuItem(String actionId, String name, String description, String reasonDisabled, ActionType type, boolean hasParameters, String targetObjectId);
+
+ Component createCollectionIcon(ObjectAdapter object, String collectionId);
+
+ Component createObjectIcon(ObjectAdapter object, String objectId, String style);
+
+ Component createObjectIcon(ObjectAssociation field, ObjectAdapter object, String objectId, String style);
+
+ Page createPage();
+
+ Component createRemoveOption(String id, String elementId, String id2);
+
+ Component createService(String objectId, String title, String iconName);
+
+ Table createTable(int noColumns, boolean withSelectorColumn);
+
+ Component createUserSwap(final String name);
+
+ /**
+ *
+ * @param field
+ * @param value
+ * - may be <tt>null</tt> so subclass should handle.
+ * @param isEditable
+ * @return
+ */
+ Component createParseableField(ObjectAssociation field, ObjectAdapter value, boolean isEditable);
+
+ Component createLink(String link, String name, String description);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/DebugPane.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/DebugPane.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/DebugPane.java
new file mode 100644
index 0000000..530ae63
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/DebugPane.java
@@ -0,0 +1,32 @@
+/*
+ * 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.html.component;
+
+public interface DebugPane extends Component {
+
+ void addSection(String title);
+
+ void appendln(String text);
+
+ void indent();
+
+ void unindent();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Form.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Form.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Form.java
new file mode 100644
index 0000000..db5789b
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Form.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.html.component;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+public interface Form extends Component {
+
+ void addField(ObjectSpecification type, String fieldLabel, String fieldDescription, String fieldId, String currentEntryTitle, int noLines, boolean wrap, int maxLength, int typicalLength, boolean required, String error);
+
+ /*
+ * REVIEW the form should be asked to create specific types, like see
+ * HTMLForm.addForm()
+ *
+ * void addCheckBox(....)
+ *
+ * void addPasswordField(....)
+ *
+ * void addMultilineField(....)
+ */
+
+ void addLookup(String fieldLabel, String fieldDescription, String fieldId, int selectedIndex, String[] options, String[] ids, boolean required, String errorMessage);
+
+ void addReadOnlyField(String fieldLabel, String title, String fieldDescription);
+
+ void addReadOnlyCheckbox(String fieldLabel, boolean isSet, String fieldDescription);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Page.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Page.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Page.java
new file mode 100644
index 0000000..fada9d1
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Page.java
@@ -0,0 +1,40 @@
+/*
+ * 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.html.component;
+
+public interface Page extends Component {
+
+ void addDebug(String value);
+
+ void addDebug(String label, String value);
+
+ Block getNavigation();
+
+ Block getPageHeader();
+
+ ViewPane getViewPane();
+
+ void setCrumbs(Component component);
+
+ void setDebug(DebugPane debugPane);
+
+ void setTitle(String title);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Table.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Table.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Table.java
new file mode 100644
index 0000000..3a4dd5c
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/Table.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.html.component;
+
+public interface Table extends Component {
+
+ void setSummary(String string);
+
+ void addColumnHeader(String name);
+
+ void addRowHeader(Component component);
+
+ void addCell(String string, boolean truncate);
+
+ void addCell(Component component);
+
+ void addEmptyCell();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ViewPane.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ViewPane.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ViewPane.java
new file mode 100644
index 0000000..5aa6cb0
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/ViewPane.java
@@ -0,0 +1,35 @@
+/*
+ * 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.html.component;
+
+import java.util.List;
+
+public interface ViewPane extends Component {
+
+ void setIconName(String iconName);
+
+ void setTitle(String title, String description);
+
+ void add(Component content);
+
+ void setMenu(Component[] component);
+
+ void setWarningsAndMessages(List<String> list, List<String> list2);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/AbstractHtmlPage.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/AbstractHtmlPage.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/AbstractHtmlPage.java
new file mode 100644
index 0000000..a96b557
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/AbstractHtmlPage.java
@@ -0,0 +1,129 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+import java.util.StringTokenizer;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Block;
+import org.apache.isis.viewer.html.component.Component;
+import org.apache.isis.viewer.html.component.Page;
+
+public abstract class AbstractHtmlPage implements Component, Page {
+
+ private final Block pageHeader;
+ private final String siteFooter;
+ private final String siteHeader;
+ private final String styleSheet;
+ private final StringBuffer debug = new StringBuffer();
+
+ private String title = "Apache Isis";
+ protected final PathBuilder pathBuilder;
+
+ public AbstractHtmlPage(final PathBuilder pathBuilder, final String styleSheet, final String header, final String footer) {
+ this.pathBuilder = pathBuilder;
+ this.pageHeader = new Div(pathBuilder, null, "page-header");
+ this.styleSheet = styleSheet == null ? "default.css" : styleSheet;
+ this.siteHeader = header;
+ this.siteFooter = footer;
+ }
+
+ @Override
+ public void addDebug(final String html) {
+ debug.append("<div class=\"detail\">");
+ debug.append(html);
+ debug.append("</div>");
+ }
+
+ @Override
+ public void addDebug(final String name, final String value) {
+ debug.append("<div class=\"detail\">");
+ debug.append("<span class=\"label\">");
+ debug.append(name);
+ debug.append("</span>: ");
+ debug.append(value);
+ debug.append("</div>");
+ }
+
+ @Override
+ public Block getPageHeader() {
+ return pageHeader;
+ }
+
+ @Override
+ public void setTitle(final String title) {
+ this.title = title;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
+ writer.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">");
+ writer.println(" <head>");
+ writer.print(" <title>");
+ writer.print(title);
+ writer.println("</title>");
+ writer.println(" <meta name=\"description\" content=\"Apache Isis Application Web Page\" />");
+
+ final StringTokenizer st = new StringTokenizer(styleSheet, ",");
+ int i = 0;
+ while (st.hasMoreTokens()) {
+ final String style = st.nextToken().trim();
+ writer.print(" <link rel=\"");
+ if (i++ > 0) {
+ writer.print("alternate ");
+ }
+ writer.print("stylesheet\" title=\"Style " + i + "\" href=\"");
+ writer.print(style);
+ writer.println("\" type=\"text/css\" media=\"all\"/>");
+ }
+ writer.println(" <script src=\"jquery-1.7.1.js\" type=\"text/javascript\"></script>");
+ writer.println(" <script src=\"htmlviewer.js\" type=\"text/javascript\"></script>");
+ writer.println(" </head>");
+ writer.println(" <body onLoad=\"window.document.form.fld0.focus()\">");
+ writer.println(" <div id=\"wrapper\">");
+
+ if (siteHeader != null) {
+ writer.println(" <!-- the following block is added externally via configuration -->");
+ writer.println(siteHeader);
+ }
+
+ writeContent(writer);
+
+ if (siteFooter != null) {
+ writer.println(" <!-- the following block is added externally via configuration -->");
+ writer.println(siteFooter);
+ }
+
+ if (debug.length() > 0) {
+ writer.println("<div id=\"debug\">");
+ writer.println("<h4>Debug</h4>");
+ writer.println(debug);
+ writer.println("</div>");
+ }
+
+ writer.println("</div>");
+ writer.println(" </body>");
+ writer.println("</html>");
+ }
+
+ protected abstract void writeContent(PrintWriter writer);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ActionComponent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ActionComponent.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ActionComponent.java
new file mode 100644
index 0000000..a6b12f6
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ActionComponent.java
@@ -0,0 +1,74 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Component;
+
+class ActionComponent implements Component {
+
+ private final PathBuilder pathBuilder;
+ private final String objectId;
+ private final String name;
+ private final String description;
+ private final String field;
+ private final String action;
+ private final String elementId;
+
+ public ActionComponent(final PathBuilder pathBuilder, final String action, final String name, final String description, final String objectId, final String elementId, final String field) {
+ this.pathBuilder = pathBuilder;
+ this.action = action;
+ this.name = name;
+ this.description = description;
+ this.objectId = objectId;
+ this.elementId = elementId;
+ this.field = field;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.print("<div class=\"action-button\">");
+ writer.print("<a href=\"");
+ writer.print(pathTo(action));
+ writer.print("?id=");
+ writer.print(objectId);
+ if (field != null) {
+ writer.print("&field=");
+ writer.print(field);
+ }
+ if (elementId != null) {
+ writer.print("&element=");
+ writer.print(elementId);
+ }
+ writer.print("\" title=\"");
+ writer.print(description);
+ writer.print("\"> ");
+ writer.print(name);
+ writer.print("</a>");
+ writer.println("</div>");
+ }
+
+ protected String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/BreadCrumbs.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/BreadCrumbs.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/BreadCrumbs.java
new file mode 100644
index 0000000..be454e4
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/BreadCrumbs.java
@@ -0,0 +1,66 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.ComponentAbstract;
+
+public class BreadCrumbs extends ComponentAbstract {
+ private final String[] names;
+ private final boolean[] isLinked;
+
+ public BreadCrumbs(final PathBuilder pathBuilder, final String[] names, final boolean[] isLinked) {
+ super(pathBuilder);
+ this.names = names;
+ this.isLinked = isLinked;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.println("<div id=\"context\">");
+
+ final int length = names.length;
+ for (int i = 0; i < length; i++) {
+ if (i > 0) {
+ writer.print("<span class=\"separator\"> > </span>");
+ }
+ if (isLinked[i]) {
+ writer.print("<a class=\"linked\" href=\"" + pathTo("context") + "?id=");
+ writer.print(i);
+ writer.print("\">");
+ writer.print(names[i]);
+ writer.print("</a>");
+ } else if (!(i == length - 1 && names[i] == null)) {
+ writer.print("<span class=\"disabled\">");
+ writer.print(names[i]);
+ writer.print("</span>");
+ }
+ }
+
+ writer.print("</div>");
+ }
+
+ protected String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Checkbox.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Checkbox.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Checkbox.java
new file mode 100644
index 0000000..b907c5a
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Checkbox.java
@@ -0,0 +1,50 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.component.Component;
+
+final class Checkbox implements Component {
+ private final boolean set;
+
+ private final boolean editable;
+
+ Checkbox(final boolean set, final boolean editable) {
+ this.set = set;
+ this.editable = editable;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.print("<input class=\"value\" type=\"checkbox\"");
+ if (set) {
+ writer.print(" checked");
+ }
+ if (!editable) {
+ writer.print(" disabled");
+ }
+ writer.println("/>");
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionIcon.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionIcon.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionIcon.java
new file mode 100644
index 0000000..b99b351
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionIcon.java
@@ -0,0 +1,80 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Component;
+import org.apache.isis.viewer.html.image.ImageLookup;
+import org.apache.isis.viewer.html.request.Request;
+
+public class CollectionIcon implements Component {
+
+ private final ObjectAdapter collection;
+ private final PathBuilder pathBuilder;
+ private final String id;
+ private final String description;
+
+ public CollectionIcon(final PathBuilder pathBuilder, final ObjectAdapter element, final String description, final String id) {
+ this.pathBuilder = pathBuilder;
+ this.collection = element;
+ this.description = description;
+ this.id = id;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ final TypeOfFacet facet = collection.getSpecification().getFacet(TypeOfFacet.class);
+ final Class<?> elementType = facet.value();
+ final ObjectSpecification elementSpecification = IsisContext.getSpecificationLoader().loadSpecification(elementType);
+
+ writer.print("<div class=\"item\">");
+ writer.print("<a href=\"");
+ writer.print(pathTo(Request.COLLECTION_COMMAND) + "?id=");
+ writer.print(id);
+ writer.print("\"");
+ if (description != null) {
+ writer.print(" title=\"");
+ writer.print(description);
+ writer.print("\"");
+ }
+ writer.print("><img src=\"");
+ writer.print(ImageLookup.image(elementSpecification));
+ writer.print("\" alt=\"");
+ final String singularName = elementSpecification.getSingularName();
+ writer.print(singularName);
+ writer.print(" collection\" />");
+ writer.print(collection.titleString());
+ writer.print("</a>");
+
+ writer.println("</div>");
+
+ }
+
+ protected String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionLink.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionLink.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionLink.java
new file mode 100644
index 0000000..2a12061
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/CollectionLink.java
@@ -0,0 +1,77 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.ComponentAbstract;
+import org.apache.isis.viewer.html.image.ImageLookup;
+import org.apache.isis.viewer.html.request.Request;
+
+class CollectionLink extends ComponentAbstract {
+ private final String objectId;
+ private final String fieldId;
+ private final ObjectSpecification specification;
+ private final String title;
+ private final String description;
+
+ public CollectionLink(final PathBuilder pathBuilder, final ObjectAssociation field, final ObjectAdapter collection, final String description, final String objectId) {
+ super(pathBuilder);
+ this.description = description;
+ this.objectId = objectId;
+ fieldId = field.getId();
+ title = collection.titleString();
+ specification = field.getSpecification();
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.print("<span class=\"value\"");
+ if (description != null) {
+ writer.print(" title=\"");
+ writer.print(description);
+ writer.print("\"");
+ }
+ writer.print(">");
+
+ writer.print("<a href=\"");
+ writer.print(pathTo(Request.FIELD_COLLECTION_COMMAND) + "?id=");
+ writer.print(objectId);
+ writer.print("&field=");
+ writer.print(fieldId);
+ writer.print("\"");
+ writer.print("><img src=\"");
+ writer.print(ImageLookup.image(specification));
+ writer.print("\" alt=\"icon\">");
+ // writer.print(elementType);
+ writer.print(title);
+ writer.print("</a>");
+ writer.println("</span>");
+ }
+
+ protected String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Div.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Div.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Div.java
new file mode 100644
index 0000000..4223071
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Div.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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Block;
+import org.apache.isis.viewer.html.component.Component;
+import org.apache.isis.viewer.html.component.ComponentComposite;
+
+public class Div extends ComponentComposite implements Block {
+
+ private final String className;
+ private final String id;
+ private final String description;
+
+ public Div(final PathBuilder pathBuilder, final String className, final String description) {
+ this(pathBuilder, className, description, null);
+ }
+
+ public Div(final PathBuilder pathBuilder, final String className, final String description, final String id) {
+ super(pathBuilder);
+ this.description = description;
+ this.className = className;
+ this.id = id;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ super.write(writer);
+ }
+
+ @Override
+ protected void writeBefore(final PrintWriter writer) {
+ writer.print("<div");
+ if (className != null) {
+ writer.print(" class=\"");
+ writer.print(className);
+ writer.print("\"");
+ }
+ if (id != null) {
+ writer.print(" id=\"");
+ writer.print(id);
+ writer.print("\"");
+ }
+ if (description != null) {
+ writer.print(" title=\"");
+ writer.print(description);
+ writer.print("\"");
+ }
+ writer.print(">");
+ }
+
+ @Override
+ protected void writeAfter(final PrintWriter writer) {
+ writer.println("</div>");
+ }
+
+ @Override
+ public void add(final Component component) {
+ super.add(component);
+ }
+
+ public void add(final String text) {
+ super.add(new Html(pathBuilder, text));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/DynamicHtmlPage.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/DynamicHtmlPage.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/DynamicHtmlPage.java
new file mode 100644
index 0000000..0a81342
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/DynamicHtmlPage.java
@@ -0,0 +1,81 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Block;
+import org.apache.isis.viewer.html.component.Component;
+import org.apache.isis.viewer.html.component.DebugPane;
+import org.apache.isis.viewer.html.component.Page;
+import org.apache.isis.viewer.html.component.ViewPane;
+
+public class DynamicHtmlPage extends AbstractHtmlPage implements Page {
+
+ private final Block navigation;
+ private final ViewPane viewPane;
+
+ private Component crumbs;
+ private DebugPane debugPane;
+
+ public DynamicHtmlPage(final PathBuilder pathBuilder, final String styleSheet, final String header, final String footer) {
+ super(pathBuilder, styleSheet, header, footer);
+ this.navigation = new Div(pathBuilder, null, "navigation");
+ this.viewPane = new ViewDiv(pathBuilder);
+ }
+
+ @Override
+ public Block getNavigation() {
+ return navigation;
+ }
+
+ @Override
+ public ViewPane getViewPane() {
+ return viewPane;
+ }
+
+ @Override
+ public void setCrumbs(final Component crumbs) {
+ this.crumbs = crumbs;
+ }
+
+ @Override
+ public void setDebug(final DebugPane debugPane) {
+ this.debugPane = debugPane;
+ }
+
+ @Override
+ protected void writeContent(final PrintWriter writer) {
+ if (debugPane != null) {
+ debugPane.write(writer);
+ } else {
+ writer.println();
+ writer.println("<div id=\"body\">");
+ navigation.write(writer);
+ if (crumbs != null) {
+ crumbs.write(writer);
+ }
+ viewPane.write(writer);
+ writer.println();
+ writer.println("</div>");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ErrorMessage.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ErrorMessage.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ErrorMessage.java
new file mode 100644
index 0000000..2482b80
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/ErrorMessage.java
@@ -0,0 +1,48 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.component.Component;
+
+public class ErrorMessage implements Component {
+
+ private final Exception e;
+ private final boolean isDebug;
+
+ public ErrorMessage(final Exception e, final boolean isDebug) {
+ this.e = e;
+ this.isDebug = isDebug;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.println("<div class=\"error\">");
+ writer.println(e.getMessage());
+ writer.println("</div>");
+ if (isDebug) {
+ writer.println("<pre class=\"error-trace\">");
+ e.printStackTrace(writer);
+ writer.println("</pre>");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Heading.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Heading.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Heading.java
new file mode 100644
index 0000000..9e9408c
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Heading.java
@@ -0,0 +1,50 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.ComponentAbstract;
+
+public class Heading extends ComponentAbstract {
+ private final String title;
+ private final int level;
+
+ public Heading(final PathBuilder pathBuilder, final String title) {
+ this(pathBuilder, title, 1);
+ }
+
+ public Heading(final PathBuilder pathBuilder, final String title, final int level) {
+ super(pathBuilder);
+ this.title = title;
+ this.level = level;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writeTag(writer, "h" + level);
+ writer.print(title);
+ writer.print("</h");
+ writer.print(level);
+ writer.println(">");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Html.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Html.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Html.java
new file mode 100644
index 0000000..6a02fd4
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/Html.java
@@ -0,0 +1,40 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.ComponentAbstract;
+
+class Html extends ComponentAbstract {
+
+ private final String code;
+
+ public Html(final PathBuilder pathBuilder, final String code) {
+ super(pathBuilder);
+ this.code = code;
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ writer.print(code);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlComponentFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlComponentFactory.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlComponentFactory.java
new file mode 100644
index 0000000..1b1ec70
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlComponentFactory.java
@@ -0,0 +1,309 @@
+/*
+ * 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.html.component.html;
+
+import static org.apache.isis.viewer.html.HtmlViewerConstants.FOOTER;
+import static org.apache.isis.viewer.html.HtmlViewerConstants.FOOTER_FILE;
+import static org.apache.isis.viewer.html.HtmlViewerConstants.HEADER;
+import static org.apache.isis.viewer.html.HtmlViewerConstants.HEADER_FILE;
+import static org.apache.isis.viewer.html.HtmlViewerConstants.STYLE_SHEET;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.progmodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.html.PathBuilder;
+import org.apache.isis.viewer.html.component.Block;
+import org.apache.isis.viewer.html.component.Component;
+import org.apache.isis.viewer.html.component.ComponentFactory;
+import org.apache.isis.viewer.html.component.DebugPane;
+import org.apache.isis.viewer.html.component.Form;
+import org.apache.isis.viewer.html.component.Page;
+import org.apache.isis.viewer.html.component.Table;
+
+public class HtmlComponentFactory implements ComponentFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final String footer;
+ protected final String header;
+ protected final String styleSheet;
+
+ private final PathBuilder pathBuilder;
+
+ public HtmlComponentFactory(final PathBuilder pathBuilder) {
+ this(pathBuilder, getConfiguration());
+ }
+
+ public HtmlComponentFactory(final PathBuilder pathBuilder, final IsisConfiguration configuration) {
+ this.pathBuilder = pathBuilder;
+ this.styleSheet = configuration.getString(STYLE_SHEET);
+ this.header = loadFileElseDefault(configuration, HEADER_FILE, HEADER);
+ this.footer = loadFileElseDefault(configuration, FOOTER_FILE, FOOTER);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Pages
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Page createPage() {
+ return new DynamicHtmlPage(this, styleSheet, header, footer);
+ }
+
+ public LogonFormPage createLogonPage(final String user, final String password, final boolean registerLink, final String error) {
+ return new LogonFormPage(this, styleSheet, header, footer, user, password, registerLink, error);
+ }
+
+ public RegisterFormPage createRegisterPage(final String user, final String password, final String error) {
+ return new RegisterFormPage(this, styleSheet, header, footer, user, password, error);
+ }
+
+ // /////////////////////////////////////////////////////////////
+ // Menus
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Component createMenuItem(final String actionId, final String name, final String description, final String reasonDisabled, final ActionType type, final boolean hasParameters, final String targetObjectId) {
+ return new MenuItem(this, actionId, name, description, reasonDisabled, type, hasParameters, targetObjectId);
+ }
+
+ @Override
+ public Component createSubmenu(final String menuName, final Component[] items) {
+ return new Submenu(menuName, items);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Icons
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Component createCollectionIcon(final ObjectAssociation field, final ObjectAdapter collection, final String id) {
+ return new CollectionLink(this, field, collection, field.getDescription(), id);
+ }
+
+ @Override
+ public Component createCollectionIcon(final ObjectAdapter collection, final String collectionId) {
+ return new CollectionIcon(this, collection, collection.getSpecification().getDescription(), collectionId);
+ }
+
+ @Override
+ public Component createObjectIcon(final ObjectAdapter object, final String objectId, final String style) {
+ return new ObjectIcon(this, object, object.getSpecification().getDescription(), objectId, style);
+ }
+
+ @Override
+ public Component createObjectIcon(final ObjectAssociation field, final ObjectAdapter object, final String objectId, final String style) {
+ return new ObjectIcon(this, object, field.getDescription(), objectId, style);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Options
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Component createEditOption(final String id) {
+ return new ActionComponent(this, "edit", "Edit Object", "Edit the current object", id, null, null);
+ }
+
+ @Override
+ public Component createRemoveOption(final String id, final String elementId, final String fieldName) {
+ return new ActionComponent(this, "remove", "Remove", "Remove item from collection", id, elementId, fieldName);
+ }
+
+ @Override
+ public Component createAddOption(final String id, final String fieldName) {
+ return new ActionComponent(this, "add", "Add Item", "Add item to collection", id, null, fieldName);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Messages
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Component createErrorMessage(final Exception e, final boolean isDebug) {
+ return new ErrorMessage(e, isDebug);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Form & Form Widgets
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Form createForm(final String id, final String actionName, final int step, final int noOfPages, final boolean isEditing) {
+ return new HtmlForm(this, id, actionName, step, noOfPages, isEditing);
+ }
+
+ @Override
+ public Component createCheckboxBlock(final boolean isEditable, final boolean isSet) {
+ return new Checkbox(isSet, isEditable);
+ }
+
+ @Override
+ public Component createLink(final String link, final String name, final String description) {
+ return new Link(this, link, name, description);
+ }
+
+
+ @Override
+ public Component createParseableField(final ObjectAssociation field, final ObjectAdapter value, final boolean isEditable) {
+ final BooleanValueFacet facet = field.getSpecification().getFacet(BooleanValueFacet.class);
+ if (facet != null) {
+ return createCheckboxBlock(isEditable, facet.isSet(value));
+ } else {
+ final String titleString = value != null ? value.titleString() : "";
+
+ final MultiLineFacet multiLineFacet = field.getSpecification().getFacet(MultiLineFacet.class);
+ final boolean isWrapped = multiLineFacet != null && !multiLineFacet.preventWrapping();
+
+ if (isWrapped) {
+ return createInlineBlock("value", "<pre>" + titleString + "</pre>", null);
+ } else {
+ return createInlineBlock("value", titleString, null);
+ }
+ }
+ }
+
+ @Override
+ public Table createTable(final int noColumns, final boolean withSelectorColumn) {
+ return new HtmlTable(this, noColumns, withSelectorColumn);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // Furniture
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public Block createBlock(final String style, final String description) {
+ return new Div(this, style, description);
+ }
+
+ @Override
+ public Component createBreadCrumbs(final String[] names, final boolean[] isLinked) {
+ return new BreadCrumbs(this, names, isLinked);
+ }
+
+ @Override
+ public Component createInlineBlock(final String style, final String text, final String description) {
+ return new Span(style, text, description);
+ }
+
+ @Override
+ public Component createHeading(final String name) {
+ return new Heading(this, name, 4);
+ }
+
+ @Override
+ public Component createService(final String objectId, final String title, final String iconName) {
+ return new ServiceComponent(this, objectId, title, iconName);
+ }
+
+ @Override
+ public Component createUserSwap(final String name) {
+ return new UserSwapLink(this, name);
+
+ }
+
+ // /////////////////////////////////////////////////////////////
+ // Debug
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public DebugPane createDebugPane() {
+ return new HtmlDebug();
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // PathBuilder impl
+ // /////////////////////////////////////////////////////////////
+
+ @Override
+ public String getSuffix() {
+ return pathBuilder.getSuffix();
+ }
+
+ @Override
+ public String pathTo(final String prefix) {
+ return pathBuilder.pathTo(prefix);
+ }
+
+
+ // /////////////////////////////////////////////////////////////
+ // helpers
+ // /////////////////////////////////////////////////////////////
+
+ private static String loadFileElseDefault(final IsisConfiguration configuration, final String fileConstant, final String literalConstant) {
+ final String fileName = configuration.getString(fileConstant);
+ return fileName != null ? loadFile(fileName) : configuration.getString(literalConstant);
+ }
+
+
+ private static String loadFile(final String file) {
+ final StringBuffer content = new StringBuffer();
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ content.append(line);
+ content.append("\n");
+ }
+ } catch (final FileNotFoundException e) {
+ throw new WebViewerException("Failed to find file " + file);
+ } catch (final IOException e) {
+ throw new WebViewerException("Failed to load file " + file, e);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (final IOException ignore) {
+ }
+ }
+ }
+ return content.toString();
+ }
+
+
+
+ // /////////////////////////////////////////////////////////////
+ // injected services
+ // /////////////////////////////////////////////////////////////
+
+ private static IsisConfiguration getConfiguration() {
+ return IsisContext.getConfiguration();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlDebug.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlDebug.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlDebug.java
new file mode 100644
index 0000000..815b7ff
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlDebug.java
@@ -0,0 +1,69 @@
+/*
+ * 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.html.component.html;
+
+import java.io.PrintWriter;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.viewer.html.component.DebugPane;
+
+public class HtmlDebug implements DebugPane {
+ private static final String SPACES = " ";
+ private final StringBuffer debug = new StringBuffer();
+ private int indent;
+
+ @Override
+ public void addSection(final String title) {
+ if (debug.length() > 0) {
+ appendln("</pre>");
+ }
+ appendln("<h2>");
+ appendln(title);
+ appendln("</h2><pre>");
+ }
+
+ @Override
+ public void appendln(final String text) {
+ debug.append(SPACES.substring(0, indent * 3));
+ debug.append(text);
+ debug.append("\n");
+ }
+
+ @Override
+ public void write(final PrintWriter writer) {
+ if (debug.length() > 0) {
+ writer.print(debug.toString());
+ writer.println("</pre>");
+ }
+ }
+
+ @Override
+ public void indent() {
+ indent++;
+ }
+
+ @Override
+ public void unindent() {
+ if (indent == 0) {
+ throw new IsisException();
+ }
+ indent--;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/91a8000b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlException.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlException.java b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlException.java
new file mode 100644
index 0000000..5a58b0e
--- /dev/null
+++ b/mothballed/component/viewer/html/impl/src/main/java/org/apache/isis/viewer/html/component/html/HtmlException.java
@@ -0,0 +1,42 @@
+/*
+ * 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.html.component.html;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+
+public class HtmlException extends IsisException {
+ private static final long serialVersionUID = 1L;
+
+ public HtmlException() {
+ }
+
+ public HtmlException(final String msg) {
+ super(msg);
+ }
+
+ public HtmlException(final String msg, final Throwable cause) {
+ super(msg, cause);
+ }
+
+ public HtmlException(final Throwable cause) {
+ super(cause);
+ }
+
+}