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 2016/01/25 15:40:56 UTC
[32/50] [abbrv] isis git commit: ISIS-993: metadata has back owners.
Wicket component broken at this point
http://git-wip-us.apache.org/repos/asf/isis/blob/f5c3b104/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java
new file mode 100644
index 0000000..3f9b76f
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanel.java
@@ -0,0 +1,119 @@
+/*
+ * 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.wicket.ui.components.entity.tabgroups;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
+import org.apache.wicket.extensions.markup.html.tabs.ITab;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.Model;
+
+import org.apache.isis.applib.layout.v1_0.DomainObject;
+import org.apache.isis.applib.layout.v1_0.Tab;
+import org.apache.isis.applib.layout.v1_0.TabGroup;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.members.cssclass.CssClassFacet;
+import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet;
+import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.panels.PanelAbstract;
+import org.apache.isis.viewer.wicket.ui.util.CssClassAppender;
+
+import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
+
+/**
+ * {@link PanelAbstract Panel} to represent an entity on a single page made up
+ * of several <div> regions.
+ */
+public class EntityTabGroupsPanel extends PanelAbstract<EntityModel> {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String ID_ENTITY_PROPERTIES_AND_COLLECTIONS = "entityPropertiesAndCollections";
+ private static final String ID_TAB_GROUPS = "tabGroups";
+ private static final String ID_TAB_GROUP = "tabGroup";
+
+ public EntityTabGroupsPanel(final String id, final EntityModel entityModel) {
+ super(id, entityModel);
+ buildGui();
+ }
+
+ private void buildGui() {
+ final EntityModel model = getModel();
+ final ObjectAdapter objectAdapter = model.getObject();
+ final CssClassFacet facet = objectAdapter.getSpecification().getFacet(CssClassFacet.class);
+ if(facet != null) {
+ final String cssClass = facet.cssClass(objectAdapter);
+ CssClassAppender.appendCssClassTo(this, cssClass);
+ }
+
+ // forces metadata to be derived && synced
+ final LayoutXmlFacet layoutXmlFacet = model.getTypeOfSpecification().getFacet(LayoutXmlFacet.class);
+ final DomainObject domainObject = layoutXmlFacet.getLayoutMetadata();
+
+ addOrReplace(ComponentType.ENTITY_SUMMARY, model);
+
+ final List<TabGroup> tabGroups = domainObject.getTabGroups();
+ final ListView<TabGroup> tabGroupsList =
+ new ListView<TabGroup>(ID_TAB_GROUPS, tabGroups) {
+
+ @Override
+ protected void populateItem(final ListItem<TabGroup> item) {
+
+ final List<ITab> tabs = Lists.newArrayList();
+ final TabGroup tabGroup = item.getModelObject();
+ final List<Tab> tabList = tabGroup.getTabs();
+
+ for (final Tab tab : tabList) {
+
+ tabs.add(new AbstractTab(Model.of(tab.getName())) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Panel getPanel(String panelId) {
+ return new EntityTabPanel(panelId, model, tab);
+ }
+ });
+ }
+ item.add(new AjaxBootstrapTabbedPanel(ID_TAB_GROUP, tabs));
+ }
+ };
+ add(tabGroupsList);
+ }
+
+ private static class EntityTabPanel extends PanelAbstract {
+ private static final long serialVersionUID = 1L;
+
+ public EntityTabPanel(String id, final EntityModel model, final Tab tab) {
+ super(id);
+
+ final EntityModel modelWithTabHints = new EntityModel(model.getPageParameters());
+ model.setTab(tab);
+
+ getComponentFactoryRegistry().addOrReplaceComponent(this, ID_ENTITY_PROPERTIES_AND_COLLECTIONS, ComponentType.ENTITY_PROPERTIES, modelWithTabHints);
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f5c3b104/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java
new file mode 100644
index 0000000..825ea59
--- /dev/null
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/entity/tabgroups/EntityTabGroupsPanelFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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.wicket.ui.components.entity.tabgroups;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.model.IModel;
+
+import org.apache.isis.core.metamodel.facets.object.layoutxml.LayoutXmlFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.viewer.wicket.model.models.EntityModel;
+import org.apache.isis.viewer.wicket.ui.ComponentFactory;
+import org.apache.isis.viewer.wicket.ui.ComponentType;
+import org.apache.isis.viewer.wicket.ui.components.entity.EntityComponentFactoryAbstract;
+
+/**
+ * {@link ComponentFactory} for {@link EntityTabGroupsPanel}.
+ */
+public class EntityTabGroupsPanelFactory extends EntityComponentFactoryAbstract {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String NAME = "tabbed";
+
+ public EntityTabGroupsPanelFactory() {
+ super(ComponentType.ENTITY, NAME, EntityTabGroupsPanel.class);
+ }
+
+ @Override
+ protected ApplicationAdvice doAppliesTo(final EntityModel entityModel) {
+ final ObjectSpecification specification = entityModel.getTypeOfSpecification();
+ return appliesIf(specification.containsDoOpFacet(LayoutXmlFacet.class));
+ }
+
+ @Override
+ public Component createComponent(final String id, final IModel<?> model) {
+ final EntityModel entityModel = (EntityModel) model;
+ return new EntityTabGroupsPanel(id, entityModel);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/f5c3b104/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
----------------------------------------------------------------------
diff --git a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
index 036b99d..bb468a5 100644
--- a/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
+++ b/example/application/simpleapp/dom/src/main/java/domainapp/dom/simple/SimpleObject.layout.xml
@@ -31,4 +31,14 @@
</left>
</tab>
</tabGroup>
+ <tabGroup>
+ <tab name="Similar To">
+ <left span="12">
+ <collection id="similarTo">
+ <actions/>
+ <layout/>
+ </collection>
+ </left>
+ </tab>
+ </tabGroup>
</domainObject>
\ No newline at end of file