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/05/21 07:10:12 UTC
[11/56] [abbrv] [partial] isis git commit: ISIS-1335: deleting the
mothballed directory.
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/RootCollection.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/RootCollection.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/RootCollection.java
deleted file mode 100644
index 7df359e..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/RootCollection.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.dnd.view.collection;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.view.Content;
-
-public class RootCollection extends AbstractCollectionContent {
- private final ObjectAdapter collection;
-
- public RootCollection(final ObjectAdapter collection) {
- this.collection = collection;
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("collection", collection);
- super.debugDetails(debug);
- }
-
- @Override
- public ObjectAdapter getCollection() {
- return collection;
- }
-
- @Override
- public String getHelp() {
- return "No help for this collection";
- }
-
- @Override
- public String getIconName() {
- return null;
- }
-
- @Override
- public String getId() {
- return "";
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return collection;
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return collection.getSpecification();
- }
-
- @Override
- public boolean isTransient() {
- return collection != null;
- }
-
- public void setObject(final ObjectAdapter object) {
- throw new IsisException("Invalid call");
- }
-
- @Override
- public String title() {
- return collection.titleString();
- }
-
- @Override
- public String windowTitle() {
- return collection.titleString();
- }
-
- @Override
- public String toString() {
- return "Root Collection: " + collection;
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- return null;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public Image getIconPicture(final int iconHeight) {
- // return ImageFactory.getInstance().loadObjectIcon(getSpecification(),
- // "", iconHeight);
- return ImageFactory.getInstance().loadIcon("root-collection", iconHeight, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/SimpleCollectionSorter.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/SimpleCollectionSorter.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/SimpleCollectionSorter.java
deleted file mode 100644
index 6ecc765..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/SimpleCollectionSorter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.dnd.view.collection;
-
-import java.util.Vector;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-public class SimpleCollectionSorter implements CollectionSorter {
-
- @Override
- public void sort(final ObjectAdapter[] elements, final Comparator order, final boolean reverse) {
- if (order == null) {
- return;
- }
-
- final Vector<ObjectAdapter> sorted = new Vector<ObjectAdapter>(elements.length);
- outer: for (int j = 0; j < elements.length; j++) {
- final ObjectAdapter element = elements[j];
- order.init(element);
- int i = 0;
- for (final ObjectAdapter objectAdapter : sorted) {
- final ObjectAdapter sortedElement = objectAdapter;
- if (sortedElement != null && (order.compare(sortedElement) > 0 ^ reverse)) {
- sorted.insertElementAt(element, i);
- continue outer;
- }
- i++;
- }
- sorted.addElement(element);
- }
- sorted.copyInto(elements);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TitleComparator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TitleComparator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TitleComparator.java
deleted file mode 100644
index a025d08..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TitleComparator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.dnd.view.collection;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-public class TitleComparator implements Comparator {
- private String title;
-
- @Override
- public void init(final ObjectAdapter element) {
- title = element.titleString();
- }
-
- @Override
- public int compare(final ObjectAdapter sortedElement) {
- final String sortedTitle = sortedElement.titleString();
- return sortedTitle.compareTo(title);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TypeComparator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TypeComparator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TypeComparator.java
deleted file mode 100644
index 50956b4..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/collection/TypeComparator.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.dnd.view.collection;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-
-public class TypeComparator implements Comparator {
- private String type;
-
- @Override
- public void init(final ObjectAdapter element) {
- type = element.getSpecification().getShortIdentifier();
- }
-
- @Override
- public int compare(final ObjectAdapter sortedElement) {
- final String sortedType = sortedElement.getSpecification().getShortIdentifier();
- return sortedType.compareTo(type);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractBuilderDecorator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractBuilderDecorator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractBuilderDecorator.java
deleted file mode 100644
index 81e2c82..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractBuilderDecorator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-
-public abstract class AbstractBuilderDecorator implements ViewBuilder {
- protected final ViewBuilder wrappedBuilder;
-
- public AbstractBuilderDecorator(final ViewBuilder design) {
- this.wrappedBuilder = design;
- }
-
- @Override
- public void build(final View view, final Axes axes) {
- wrappedBuilder.build(view, axes);
- }
-
- @Override
- public boolean isOpen() {
- return wrappedBuilder.isOpen();
- }
-
- @Override
- public boolean isReplaceable() {
- return wrappedBuilder.isReplaceable();
- }
-
- @Override
- public boolean isSubView() {
- return wrappedBuilder.isSubView();
- }
-
- @Override
- public String toString() {
- final String name = getClass().getName();
- return wrappedBuilder + "/" + name.substring(name.lastIndexOf('.') + 1);
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet options, final View view) {
- wrappedBuilder.viewMenuOptions(options, view);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractCollectionViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractCollectionViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractCollectionViewSpecification.java
deleted file mode 100644
index 12c64e5..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractCollectionViewSpecification.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-public abstract class AbstractCollectionViewSpecification extends CompositeViewSpecification {
-
- public AbstractCollectionViewSpecification() {
- builder = new CollectionElementBuilder(createElementFactory());
- init();
- }
-
- protected abstract ViewFactory createElementFactory();
-
- protected void init() {
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- return new StackLayout();
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isCollection() && requirement.isOpen();
- }
-
- @Override
- public String getName() {
- return "List";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractViewBuilder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractViewBuilder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractViewBuilder.java
deleted file mode 100644
index 3390e53..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/AbstractViewBuilder.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.SubviewDecorator;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-
-public abstract class AbstractViewBuilder implements ViewBuilder {
- private final List<SubviewDecorator> subviewDecorators = new ArrayList<SubviewDecorator>();
-
- @Override
- public abstract void build(final View view, Axes axes);
-
- @Override
- public void createAxes(final Axes axes, final Content content) {
- for (final SubviewDecorator decorator : subviewDecorators) {
- axes.add(decorator.createAxis(content));
- }
- }
-
- @Override
- public void addSubviewDecorator(final SubviewDecorator decorator) {
- if (decorator != null) {
- subviewDecorators.add(decorator);
- }
- }
-
- public View decorateSubview(final Axes axes, final View child) {
- View view = child;
- for (final SubviewDecorator decorator : subviewDecorators) {
- view = decorator.decorate(axes, view);
- }
- return view;
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
- @Override
- public boolean canDragView() {
- return true;
- }
-
- @Override
- public String toString() {
- final String name = getClass().getName();
- return name.substring(name.lastIndexOf('.') + 1);
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet options, final View view) {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CollectionElementBuilder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CollectionElementBuilder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CollectionElementBuilder.java
deleted file mode 100644
index f2baec2..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CollectionElementBuilder.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import java.util.Enumeration;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.SubviewDecorator;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-import org.apache.isis.viewer.dnd.view.collection.CollectionElement;
-import org.apache.isis.viewer.dnd.view.field.OneToManyField;
-import org.apache.isis.viewer.dnd.view.field.OneToManyFieldElementImpl;
-
-public class CollectionElementBuilder extends AbstractViewBuilder {
- private static final Logger LOG = LoggerFactory.getLogger(CollectionElementBuilder.class);
- private boolean canDragView = true;
- private final ViewFactory subviewDesign;
-
- public CollectionElementBuilder(final ViewFactory subviewDesign) {
- this.subviewDesign = subviewDesign;
- }
-
- public CollectionElementBuilder(final ViewFactory subviewDesign, final SubviewDecorator decorator) {
- this.subviewDesign = subviewDesign;
- addSubviewDecorator(decorator);
- }
-
- @Override
- public void build(final View view, final Axes axes) {
- Assert.assertEquals(view.getView(), view);
-
- final Content content = view.getContent();
- final OneToManyAssociation field = content instanceof OneToManyField ? ((OneToManyField) content).getOneToManyAssociation() : null;
-
- LOG.debug("rebuild view " + view + " for " + content);
-
- final CollectionContent collectionContent = ((CollectionContent) content);
- Enumeration elements;
- elements = collectionContent.allElements();
-
- // addViewAxes(view);
-
- /*
- * remove all subviews from the view and then work through the elements
- * of the collection adding in a view for each element. Where a subview
- * for the that element already exists it should be reused.
- */
- final View[] subviews = view.getSubviews();
- final ObjectAdapter[] existingElements = new ObjectAdapter[subviews.length];
- for (int i = 0; i < subviews.length; i++) {
- view.removeView(subviews[i]);
- existingElements[i] = subviews[i].getContent().getAdapter();
- }
-
- int elementNumber = 0;
- while (elements.hasMoreElements()) {
- final ObjectAdapter element = (ObjectAdapter) elements.nextElement();
- View elementView = null;
- for (int i = 0; i < subviews.length; i++) {
- if (existingElements[i] == element) {
- elementView = subviews[i];
- existingElements[i] = null;
- break;
- }
- }
- if (elementView == null) {
- Content elementContent;
- if (field == null) {
- elementContent = new CollectionElement(element);
- } else {
- final ObjectAdapter obj = ((OneToManyField) view.getContent()).getParent();
- // ObjectAdapter obj =
- // view.getParent().getContent().getAdapter();
- final ObjectAdapter parent = obj;
- elementContent = new OneToManyFieldElementImpl(parent, element, field);
- }
- elementView = subviewDesign.createView(elementContent, axes, elementNumber++);
- }
- // TODO if reusing view then probably should decorate it again!
- if (elementView != null) {
- view.addView(decorateSubview(axes, elementView));
- }
- }
- }
-
- @Override
- public boolean canDragView() {
- return canDragView;
- };
-
- public void setCanDragView(final boolean canDragView) {
- this.canDragView = canDragView;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ColumnLayout.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ColumnLayout.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ColumnLayout.java
deleted file mode 100644
index 20c1a05..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ColumnLayout.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-/**
- * A column layout places component views side by side. Each component is given
- * the space it request. A components width will be give a consistent width if
- * that component's view specification's <code>isAligned</code> method returns
- * <code>true</code>, or the layout's <code>fixedWidth</code> flag is set (via
- * the two parameter constructor).
- */
-public class ColumnLayout implements Layout {
- private final boolean fixedWidth;
-
- public ColumnLayout() {
- this.fixedWidth = false;
- }
-
- public ColumnLayout(final boolean fixedWidth) {
- this.fixedWidth = fixedWidth;
- }
-
- @Override
- public Size getRequiredSize(final View view) {
- int height = 0;
- int width = 0;
- int maxWidth = 0;
- final View views[] = view.getSubviews();
-
- for (final View v : views) {
- final Size s = v.getRequiredSize(new Size(Integer.MAX_VALUE, Integer.MAX_VALUE));
- width += s.getWidth();
- maxWidth = Math.max(maxWidth, s.getWidth());
- height = Math.max(height, s.getHeight());
- }
-
- if (fixedWidth) {
- width = maxWidth / 2 * views.length;
- }
- return new Size(width, height);
- }
-
- @Override
- public void layout(final View view, final Size maximumSize) {
- int x = 0;
- final int y = 0;
- final View subviews[] = view.getSubviews();
-
- int maxWidth = 0;
- for (final View v : subviews) {
- final Size s = v.getRequiredSize(new Size(maximumSize));
- maxWidth = Math.max(maxWidth, s.getWidth());
- }
-
- for (final View v : subviews) {
- final Size s = v.getRequiredSize(new Size(maximumSize));
- v.setLocation(new Location(x, y));
- if (fixedWidth || v.getSpecification().isAligned()) {
- x += maxWidth / 2;
- s.setWidth(maxWidth / 2);
- } else {
- x += s.getWidth();
- }
- v.setSize(s);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeView.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeView.java
deleted file mode 100644
index 17cf111..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeView.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import java.util.Vector;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Bounds;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Padding;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAreaType;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.ObjectView;
-
-public abstract class CompositeView extends ObjectView {
- private static final Logger LOG = LoggerFactory.getLogger(CompositeView.class);
- private int buildCount = 0;
- private boolean buildInvalid = true;
- private boolean canDragView = true;
- private int layoutCount = 0;
- private boolean layoutInvalid = true;
- protected Vector<View> views; // TODO make private
- private FocusManager focusManager;// = new SubviewFocusManager(this);
-
- public CompositeView(final Content content, final ViewSpecification specification) {
- super(content, specification);
- views = new Vector<View>();
- }
-
- @Override
- public void refresh() {
- final View views[] = getSubviews();
- for (final View view : views) {
- view.refresh();
- }
- }
-
- @Override
- public void addView(final View view) {
- add(views, view);
- }
-
- // TODO make private
- protected void add(final Vector<View> views, final View view) {
- LOG.debug("adding " + view + " to " + this);
- views.addElement(view);
- getViewManager().addToNotificationList(view);
- view.setParent(getView());
- invalidateLayout();
- }
-
- public boolean canDragView() {
- return canDragView;
- }
-
- @Override
- public void debugStructure(final DebugBuilder b) {
- b.appendln("Built", (buildInvalid ? "invalid, " : "") + buildCount + " builds");
- b.appendln("Laid out", (layoutInvalid ? "invalid, " : "") + layoutCount + " layouts");
- super.debugStructure(b);
- }
-
- @Override
- public void dispose() {
- disposeContentsOnly();
- super.dispose();
- }
-
- protected void disposeContentsOnly() {
- final View views[] = getSubviews();
- for (final View view : views) {
- view.dispose();
- }
- }
-
- @Override
- public void draw(final Canvas canvas) {
- final View views[] = getSubviews();
- for (final View subview : views) {
- final Bounds bounds = subview.getBounds();
- if (Toolkit.debug) {
- LOG.debug("compare: " + bounds + " " + canvas);
- }
- if (canvas.overlaps(bounds)) {
- // Canvas subCanvas = canvas.createSubcanvas();
- final Canvas subCanvas = canvas.createSubcanvas(bounds.getX(), bounds.getY(), bounds.getWidth() - 0, bounds.getSize().getHeight());
- // subCanvas.offset(subview.getBounds().getX(),
- // subview.getBounds().getY());
- if (Toolkit.debug) {
- LOG.debug("-- repainting " + subview);
- LOG.debug("subcanvas " + subCanvas);
- }
- subview.draw(subCanvas);
- if (Toolkit.debug) {
- canvas.drawRectangle(subview.getBounds().getX(), subview.getBounds().getY(), subview.getBounds().getWidth() - 1, subview.getBounds().getHeight() - 1, Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BOUNDS_BORDER));
- }
- }
- }
- }
-
- @Override
- public int getBaseline() {
- final View[] e = getSubviews();
- if (e.length == 0) {
- return 14;
- } else {
- final View subview = e[0];
- return subview.getBaseline();
- }
- }
-
- @Override
- public FocusManager getFocusManager() {
- return focusManager == null ? super.getFocusManager() : focusManager;
- }
-
- @Override
- public final Size getRequiredSize(final Size availableSpace) {
- ensureBuilt();
- return requiredSize(availableSpace);
- }
-
- protected abstract Size requiredSize(Size availableSpace);
-
- /**
- * Gets the set of subviews for this container. If the container is marked
- * as not being built yet (ie {@link #buildInvalid} is <tt>true</tt> ), then
- * a view building process is initiated and the flag is cleared. During this
- * build process the {@link #buildView()} method is called and then each
- * subview is asked for its subview so that the build process can recurse
- * down the tree if it needs to.
- *
- * This method is synchronised so that two threads do not try to build the
- * same view at the same time
- */
- @Override
- public synchronized View[] getSubviews() {
- ensureBuilt();
- return subviews();
- }
-
- protected void ensureBuilt() {
- if (buildInvalid) {
- getFeedbackManager().setBusy(this, null);
- buildInvalid = false;
- if (subviews().length == 0) {
- buildNewView();
- } else {
- buildModifiedView();
- }
- for (final View view : subviews()) {
- view.getSubviews();
- }
- getFeedbackManager().clearBusy(this);
- buildCount++;
- }
- }
-
- // TODO make abstract
- protected void buildModifiedView() {
- buildView();
- }
-
- // TODO make abstract
- protected void buildNewView() {
- buildView();
- }
-
- /**
- * @deprecated
- */
- // TODO call two different methods instead: buildNewView and
- // buildModifiedView
- @Deprecated
- protected abstract void buildView();
-
- protected View[] subviews() {
- final View v[] = new View[views.size()];
- views.copyInto(v);
- return v;
- }
-
- @Override
- public void invalidateContent() {
- buildInvalid = true;
- invalidateLayout();
- }
-
- @Override
- public void invalidateLayout() {
- layoutInvalid = true;
- super.invalidateLayout();
- }
-
- @Override
- public void layout() {
- if (layoutInvalid) {
- getFeedbackManager().setBusy(this, null);
- markDamaged();
-
- ensureBuilt();
- final Size maximumSize = getSize();
- // maximumSize.contract(getPadding());
- doLayout(maximumSize);
- layoutInvalid = false;
- for (final View view : getSubviews()) {
- view.layout();
- }
- markDamaged();
- getFeedbackManager().clearBusy(this);
- layoutCount++;
- }
- }
-
- protected abstract void doLayout(Size maximumSize);
-
- /**
- * When the specified size is different to the current size the the layout
- * of this component is marked as invalid, forcing its components to re-laid
- * out in turn.
- */
- @Override
- public void setSize(final Size size) {
- final Size previousSize = getSize();
- super.setSize(size);
- if (!size.equals(previousSize)) {
- layoutInvalid = true;
- }
- }
-
- protected boolean isLayoutInvalid() {
- return layoutInvalid;
- }
-
- @Override
- public View subviewFor(final Location location) {
- final Location l = new Location(location);
- final Padding padding = getPadding();
- l.subtract(padding.getLeft(), padding.getTop());
- final View views[] = getSubviews();
- for (int i = views.length - 1; i >= 0; i--) {
- if (views[i].getBounds().contains(l)) {
- return views[i];
- }
- }
- return null;
- }
-
- @Override
- public View pickupView(final Location location) {
- return canDragView ? super.pickupView(location) : null;
- }
-
- @Override
- public void removeView(final View view) {
- LOG.debug("removing " + view + " from " + this);
- if (views.contains(view)) {
- views.removeElement(view);
- getViewManager().removeFromNotificationList(view);
- markDamaged();
- invalidateLayout();
- } else {
- throw new IsisException(view + "\n not in " + getView());
- }
- }
-
- @Override
- public void replaceView(final View toReplace, final View replacement) {
- LOG.debug("replacing " + toReplace + " with " + replacement + " within " + this);
- for (int i = 0; i < views.size(); i++) {
- if (views.elementAt(i) == toReplace) {
- replacement.setParent(getView());
- replacement.setLocation(toReplace.getLocation());
- views.insertElementAt(replacement, i);
- invalidateLayout();
- toReplace.dispose();
- getViewManager().addToNotificationList(replacement);
- return;
- }
- }
-
- throw new IsisException(toReplace + " not found to replace");
- }
-
- public void setCanDragView(final boolean canDragView) {
- this.canDragView = canDragView;
- }
-
- @Override
- public void setFocusManager(final FocusManager focusManager) {
- this.focusManager = focusManager;
- }
-
- @Override
- public String toString() {
- final ToString to = new ToString(this, getId());
- to.append("type", getSpecification().getName());
- return to.toString();
- }
-
- @Override
- public void update(final ObjectAdapter object) {
- LOG.debug("update notify on " + this);
- invalidateContent();
- }
-
- @Override
- public ViewAreaType viewAreaType(final Location location) {
- final View subview = subviewFor(location);
- if (subview == null) {
- return ViewAreaType.VIEW;
- } else {
- location.subtract(subview.getLocation());
- return subview.viewAreaType(location);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewDecorator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewDecorator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewDecorator.java
deleted file mode 100644
index 4a61236..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewDecorator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.View;
-
-public interface CompositeViewDecorator {
-
- View decorate(View view, Axes axes);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewSpecification.java
deleted file mode 100644
index 30adfbe..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewSpecification.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.userprofile.Options;
-import org.apache.isis.viewer.dnd.util.Properties;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.SubviewDecorator;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-import org.apache.isis.viewer.dnd.view.window.SubviewFocusManager;
-
-public abstract class CompositeViewSpecification implements ViewSpecification {
- protected ViewBuilder builder;
- private final List<CompositeViewDecorator> viewDecorators = new ArrayList<CompositeViewDecorator>();
-
- @Override
- public final View createView(final Content content, final Axes axes, final int sequence) {
- resolveObject(content);
-
- createAxes(content, axes);
- builder.createAxes(axes, content);
- final Layout layout = createLayout(content, axes);
- if (layout instanceof ViewAxis) {
- axes.add((ViewAxis) layout);
- }
-
- final CompositeViewUsingBuilder view = new CompositeViewUsingBuilder(content, this, axes, layout, builder);
- view.setCanDragView(builder.canDragView());
- final View decoratedView = decorateView(view, view.getViewAxes());
- final Options options = Properties.getViewConfigurationOptions(this);
- decoratedView.loadOptions(options);
- return decoratedView;
- }
-
- private void resolveObject(final Content content) {
- if (content instanceof ObjectContent) {
- final ObjectAdapter object = ((ObjectContent) content).getObject();
- if (object != null && !object.isResolved()) {
- IsisContext.getPersistenceSession().resolveImmediately(object);
- }
- }
- }
-
- private View decorateView(final View view, final Axes axes) {
- view.setFocusManager(new SubviewFocusManager(view));
- View decorated = view;
- for (final CompositeViewDecorator decorator : viewDecorators) {
- decorated = decorator.decorate(decorated, axes);
- }
- return decorated;
- }
-
- public void addViewDecorator(final CompositeViewDecorator decorator) {
- viewDecorators.add(decorator);
- }
-
- public void addSubviewDecorator(final SubviewDecorator decorator) {
- builder.addSubviewDecorator(decorator);
- }
-
- protected abstract Layout createLayout(Content content, Axes axes);
-
- protected void createAxes(final Content content, final Axes axes) {
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return true;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewUsingBuilder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewUsingBuilder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewUsingBuilder.java
deleted file mode 100644
index 9c52ac3..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/CompositeViewUsingBuilder.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-public class CompositeViewUsingBuilder extends CompositeView {
- private final ViewBuilder builder;
- private final Layout layout;
- private final Axes axes = new Axes();
-
- public CompositeViewUsingBuilder(final Content content, final ViewSpecification specification, final Axes axes, final Layout layout, final ViewBuilder builder) {
- super(content, specification);
- this.layout = layout;
- this.builder = builder;
- this.axes.add(axes);
- }
-
- @Override
- public void debugStructure(final DebugBuilder debug) {
- debug.appendln("Builder", builder);
- debug.appendln("Axes", axes);
- super.debugStructure(debug);
- }
-
- @Override
- public Size requiredSize(final Size availableSpace) {
- final Size size = layout.getRequiredSize(this);
- size.extend(getPadding());
- size.ensureHeight(1);
- return size;
- }
-
- @Override
- protected void buildView() {
- builder.build(getView(), axes);
- }
-
- @Override
- protected void doLayout(final Size maximumSize) {
- layout.layout(getView(), new Size(maximumSize));
- }
-
- @Override
- public Axes getViewAxes() {
- return axes;
- }
-
- @Override
- protected void appendDebug(final DebugBuilder debug) {
- super.appendDebug(debug);
- debug.appendln("Layout", layout);
- }
-
- public Layout getLayout() {
- return layout;
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet options) {
- super.viewMenuOptions(options);
- builder.viewMenuOptions(options, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/FieldLabelsDecorator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/FieldLabelsDecorator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/FieldLabelsDecorator.java
deleted file mode 100644
index 3dc11d7..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/FieldLabelsDecorator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.SubviewDecorator;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.axis.LabelAxis;
-import org.apache.isis.viewer.dnd.view.border.DroppableLabelBorder;
-import org.apache.isis.viewer.dnd.view.border.LabelBorder;
-
-public class FieldLabelsDecorator implements SubviewDecorator {
-
- @Override
- public ViewAxis createAxis(final Content content) {
- return new LabelAxis();
- }
-
- @Override
- public View decorate(final Axes axes, final View view) {
- final LabelAxis axis = axes.getAxis(LabelAxis.class);
- if (view.getContent().isObject() && !view.getContent().isTextParseable()) {
- return DroppableLabelBorder.createObjectFieldLabelBorder(axis, view);
- } else {
- return LabelBorder.createFieldLabelBorder(axis, view);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayout.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayout.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayout.java
deleted file mode 100644
index 6ae56e2..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayout.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-/**
- */
-public class GridLayout implements Layout, ViewAxis {
- public final static int COLUMNS = 0;
- public final static int ROWS = 1;
- private int orientation = COLUMNS;
- private int size = 1;
-
- @Override
- public Size getRequiredSize(final View view) {
- final View views[] = view.getSubviews();
-
- final int max[] = new int[size];
- final int total[] = new int[size];
-
- int column = 0;
- for (final View v : views) {
- final Size s = v.getRequiredSize(new Size(Integer.MAX_VALUE, Integer.MAX_VALUE));
- if (orientation == COLUMNS) {
- total[column] += s.getHeight();
- max[column] = Math.max(max[column], s.getWidth());
- } else {
- total[column] += s.getWidth();
- max[column] = Math.max(max[column], s.getHeight());
- }
- column++;
- if (column >= size) {
- column = 0;
- }
- }
-
- int height = 0;
- int width = 0;
- for (int i = 0; i < size; i++) {
- if (orientation == COLUMNS) {
- height = Math.max(height, total[i]);
- width += max[i];
- } else {
- width = Math.max(width, total[i]);
- height += max[i];
- }
- }
- return new Size(width, height);
- }
-
- @Override
- public void layout(final View view, final Size maximumSize) {
- int x = 0;
- int y = 0;
- final View views[] = view.getSubviews();
- final int max[] = new int[size];
-
- int column = 0;
- for (final View v : views) {
- final Size s = v.getRequiredSize(new Size(maximumSize));
- if (orientation == COLUMNS) {
- max[column] = Math.max(max[column], s.getWidth());
- } else {
- max[column] = Math.max(max[column], s.getHeight());
- }
- column++;
- if (column >= size) {
- column = 0;
- }
- }
-
- column = 0;
- for (final View v : views) {
- final Size s = v.getRequiredSize(new Size(maximumSize));
- v.setLocation(new Location(x, y));
- if (orientation == COLUMNS) {
- x += max[column];
- s.ensureWidth(max[column]);
- } else {
- y += max[column];
- s.ensureHeight(max[column]);
- }
- v.setSize(s);
- column++;
- if (column >= size) {
- column = 0;
- if (orientation == COLUMNS) {
- x = 0;
- y += s.getHeight();
- } else {
- y = 0;
- x += s.getWidth();
- }
- }
-
- }
- }
-
- public int getOrientation() {
- return orientation;
- }
-
- public void setOrientation(final int orientation) {
- this.orientation = orientation;
- }
-
- public int getSize() {
- return size;
- }
-
- public void setSize(final int size) {
- this.size = size;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayoutControlBorder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayoutControlBorder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayoutControlBorder.java
deleted file mode 100644
index 13615da..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/GridLayoutControlBorder.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.core.runtime.userprofile.Options;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.base.AbstractBorder;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-public class GridLayoutControlBorder extends AbstractBorder {
-
- public static final class Factory implements CompositeViewDecorator {
- @Override
- public View decorate(final View view, final Axes axes) {
- return new GridLayoutControlBorder(view);
- }
- }
-
- protected GridLayoutControlBorder(final View view) {
- super(view);
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet menuOptions) {
- super.viewMenuOptions(menuOptions);
-
- final GridLayout layout = getViewAxes().getAxis(GridLayout.class);
-
- final boolean columnOrientation = layout.getOrientation() == GridLayout.COLUMNS;
-
- final UserActionSet submenu = menuOptions.addNewActionSet("Grid");
-
- submenu.add(new UserActionAbstract("Add " + (columnOrientation ? "Column" : "Row")) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- layout.setSize(layout.getSize() + 1);
- invalidateLayout();
- }
- });
-
- if (layout.getSize() > 1) {
- submenu.add(new UserActionAbstract("Remove " + (columnOrientation ? "Column" : "Row")) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- layout.setSize(layout.getSize() - 1);
- invalidateLayout();
- }
- });
- }
-
- submenu.add(new UserActionAbstract(columnOrientation ? "In Rows" : "In Columns") {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- layout.setOrientation(columnOrientation ? GridLayout.ROWS : GridLayout.COLUMNS);
- invalidateLayout();
- }
- });
- }
-
- @Override
- public void saveOptions(final Options viewOptions) {
- super.saveOptions(viewOptions);
-
- final GridLayout layout = getViewAxes().getAxis(GridLayout.class);
- viewOptions.addOption("orientation", layout.getOrientation() == GridLayout.COLUMNS ? "columns" : "rows");
- viewOptions.addOption("size", layout.getSize() + "");
- }
-
- @Override
- public void loadOptions(final Options viewOptions) {
- super.loadOptions(viewOptions);
-
- final GridLayout layout = getViewAxes().getAxis(GridLayout.class);
- layout.setOrientation(viewOptions.getString("orientation", "columns").equals("columns") ? GridLayout.COLUMNS : GridLayout.ROWS);
- layout.setSize(viewOptions.getInteger("size", 1));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/IconGridViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/IconGridViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/IconGridViewSpecification.java
deleted file mode 100644
index 43bf01b..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/IconGridViewSpecification.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-import org.apache.isis.viewer.dnd.view.border.IconBorder;
-import org.apache.isis.viewer.dnd.view.border.LineBorder;
-
-public class IconGridViewSpecification extends AbstractCollectionViewSpecification {
-
- public IconGridViewSpecification() {
- addViewDecorator(new IconBorder.Factory());
- }
-
- @Override
- protected ViewFactory createElementFactory() {
- return new ViewFactory() {
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final View icon = new ImageViewSpecification().createView(content, axes, sequence);
- /*
- * Icon icon = new Icon(content,
- * IconGridViewSpecification.this); Text textStyle =
- * Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- * icon.setTitle(new ObjectTitleText(icon, textStyle));
- * icon.setSelectedGraphic(new IconGraphic(icon, 68));
- * icon.setUnselectedGraphic(new IconGraphic(icon, 60));
- * icon.setVertical(true);
- *
- * // return icon;
- */
- final LineBorder lineBorderedIcon = new LineBorder(icon);
- lineBorderedIcon.setPadding(4);
- lineBorderedIcon.setColor(Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3));
-
- // return lineBorderedIcon;
-
- return new ReplaceViewBorder(lineBorderedIcon);
- }
- };
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- final GridLayout gridLayout = new GridLayout();
- gridLayout.setSize(3);
- return gridLayout;
- }
-
- @Override
- public String getName() {
- return "Icon Grid";
- }
-
- /*
- * private static final ObjectSpecification BOOK_SPECIFICATION =
- * IsisContext.getSpecificationLoader().loadSpecification(
- * "org.apache.isis.example.library.dom.Book"); public boolean
- * canDisplay(ViewRequirement requirement) { return
- * super.canDisplay(requirement) &&
- * requirement.getAdapter().getTypeOfFacet().valueSpec() ==
- * BOOK_SPECIFICATION; }
- */
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ImageViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ImageViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ImageViewSpecification.java
deleted file mode 100644
index 7a5ed88..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/ImageViewSpecification.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.icon.Icon;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.IconGraphic;
-import org.apache.isis.viewer.dnd.view.text.ObjectTitleText;
-
-public class ImageViewSpecification implements ViewSpecification {
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final Icon icon = new Icon(content, ImageViewSpecification.this);
- final Text textStyle = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- icon.setTitle(new ObjectTitleText(icon, textStyle));
- icon.setSelectedGraphic(new IconGraphic(icon, 68));
- icon.setUnselectedGraphic(new IconGraphic(icon, 60));
- icon.setVertical(true);
-
- return icon;
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isObject() && requirement.isClosed();
- }
-
- @Override
- public String getName() {
- return "Image";
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return false;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/LineBorderDecorator.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/LineBorderDecorator.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/LineBorderDecorator.java
deleted file mode 100644
index ed46eaa..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/LineBorderDecorator.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.SubviewDecorator;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.border.LineBorder;
-
-public class LineBorderDecorator implements SubviewDecorator {
-
- @Override
- public View decorate(final Axes axes, final View view) {
- return new LineBorder(view);
- }
-
- @Override
- public ViewAxis createAxis(final org.apache.isis.viewer.dnd.view.Content content) {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/MasterDetailPanel.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/MasterDetailPanel.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/MasterDetailPanel.java
deleted file mode 100644
index 0ace123..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/composite/MasterDetailPanel.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * 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.dnd.view.composite;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.Selectable;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.BlankView;
-import org.apache.isis.viewer.dnd.view.border.ScrollBorder;
-import org.apache.isis.viewer.dnd.view.border.SelectableViewAxis;
-import org.apache.isis.viewer.dnd.view.border.ViewResizeBorder;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-import org.apache.isis.viewer.dnd.view.content.NullContent;
-
-public class MasterDetailPanel extends CompositeView implements Selectable {
- private static final int MINIMUM_WIDTH = 120;
- private final ViewSpecification leftHandSideSpecification;
- private final Axes axes;
-
- public MasterDetailPanel(final Content content, final ViewSpecification specification, final ViewSpecification leftHandSideSpecification) {
- super(content, specification);
- this.leftHandSideSpecification = leftHandSideSpecification;
- axes = new Axes();
- axes.add(new SelectableViewAxis(this));
- }
-
- @Override
- protected void buildView() {
- final Content content = getContent();
- View leftHandView = leftHandSideSpecification.createView(content, axes, -1);
- leftHandView = new ViewResizeBorder(new ScrollBorder(leftHandView));
- leftHandView.setParent(getView());
- addView(leftHandView);
-
- final Size blankViewSize = new Size(MINIMUM_WIDTH, 0);
- final View blankView = new BlankView(new NullContent(), blankViewSize);
- blankView.setParent(getView());
- addView(blankView);
-
- selectFirstSuitableObject(content);
- }
-
- private void selectFirstSuitableObject(final Content content) {
- if (content instanceof CollectionContent) {
- final ObjectAdapter[] elements = ((CollectionContent) content).elements();
- if (elements.length > 0) {
- final ObjectAdapter firstElement = elements[0];
- final Content firstElementContent = Toolkit.getContentFactory().createRootContent(firstElement);
- setSelectedNode(firstElementContent);
- }
- } else if (content instanceof ObjectContent) {
- /*
- * TODO provide a view that shows first useful object (not
- * redisplaying parent)
- *
- * ObjectAssociation[] associations =
- * content.getSpecification().getAssociations(); for (int i = 0; i <
- * associations.length; i++) { ObjectAssociation assoc =
- * associations[i]; if (assoc.isOneToManyAssociation()) {
- * ObjectAdapter collection = assoc.get(content.getAdapter()); final
- * Content collectionContent =
- * Toolkit.getContentFactory().createRootContent(collection);
- * setSelectedNode(collectionContent); break; } else if
- * (assoc.isOneToOneAssociation() &&
- * !((OneToOneAssociation)assoc).getSpecification().isParseable()) {
- * ObjectAdapter object = assoc.get(content.getAdapter()); if
- * (object == null) { continue; } final Content objectContent =
- * Toolkit.getContentFactory().createRootContent(object);
- * setSelectedNode(objectContent); break; } }
- */
- setSelectedNode(content);
- }
- }
-
- @Override
- protected void doLayout(final Size availableSpace) {
- availableSpace.contract(getView().getPadding());
-
- final View[] subviews = getSubviews();
- final View left = subviews[0];
- final View right = subviews[1];
- final Size leftPanelRequiredSize = left.getRequiredSize(new Size(availableSpace));
- final Size rightPanelRequiredSize = right == null ? new Size() : right.getRequiredSize(new Size(availableSpace));
-
- // combine the two sizes
- final Size totalSize = new Size(leftPanelRequiredSize);
- totalSize.extendWidth(rightPanelRequiredSize.getWidth());
- totalSize.ensureHeight(rightPanelRequiredSize.getHeight());
-
- if (totalSize.getWidth() > availableSpace.getWidth()) {
- /*
- * If the combined width is greater than the available then we need
- * to divide the space between the two sides and recalculate
- */
- if (rightPanelRequiredSize.getWidth() <= MINIMUM_WIDTH) {
- leftPanelRequiredSize.setWidth(availableSpace.getWidth() - rightPanelRequiredSize.getWidth());
- } else {
- final int availableWidth = availableSpace.getWidth();
- final int requiredWidth = totalSize.getWidth();
- leftPanelRequiredSize.setWidth(leftPanelRequiredSize.getWidth() * availableWidth / requiredWidth);
- rightPanelRequiredSize.setWidth(rightPanelRequiredSize.getWidth() * availableWidth / requiredWidth);
- }
- /*
- * final int leftWidth = Math.max(MINIMUM_WIDTH,
- * leftPanelRequiredSize.getWidth()); final int rightWidth =
- * rightPanelRequiredSize.getWidth(); final int totalWidth =
- * leftWidth + rightWidth;
- *
- * final int bestWidth = (int) (1.0 * leftWidth / totalWidth *
- * availableWidth); final Size maximumSizeLeft = new Size(bestWidth,
- * maximumSize.getHeight()); leftPanelRequiredSize =
- * left.getRequiredSize(maximumSizeLeft);
- *
- * final Size maximumSizeRight = new Size(availableWidth -
- * leftPanelRequiredSize.getWidth(), maximumSize.getHeight());
- * rightPanelRequiredSize = right.getRequiredSize(maximumSizeRight);
- */
- }
-
- // combinedSize.setHeight(Math.min(combinedSize.getHeight(),
- // maximumSize.getHeight()));
- // totalSize.limitSize(availableSpace);
-
- left.setSize(new Size(leftPanelRequiredSize.getWidth(), totalSize.getHeight()));
- left.layout();
-
- if (right != null) {
- right.setLocation(new Location(left.getSize().getWidth(), 0));
-
- rightPanelRequiredSize.setHeight(totalSize.getHeight());
- right.setSize(rightPanelRequiredSize);
- right.layout();
- }
- }
-
- @Override
- public Size requiredSize(final Size availableSpace) {
- final View[] subviews = getSubviews();
- final View left = subviews[0];
- final View right = subviews.length > 1 ? subviews[1] : null;
-
- Size leftPanelRequiredSize = left.getRequiredSize(new Size(availableSpace));
- Size rightPanelRequiredSize = right == null ? new Size() : right.getRequiredSize(new Size(availableSpace));
-
- if (leftPanelRequiredSize.getWidth() + rightPanelRequiredSize.getWidth() > availableSpace.getWidth()) {
- /*
- * If the combined width is greater than the available then we need
- * to divide the space between the two sides and recalculate
- */
-
- final int availableWidth = availableSpace.getWidth();
- final int leftWidth = leftPanelRequiredSize.getWidth();
- final int rightWidth = Math.max(MINIMUM_WIDTH, rightPanelRequiredSize.getWidth());
- final int totalWidth = leftWidth + rightWidth;
-
- final int bestWidth = (int) (1.0 * leftWidth / totalWidth * availableWidth);
- final Size maximumSizeLeft = new Size(bestWidth, availableSpace.getHeight());
- leftPanelRequiredSize = left.getRequiredSize(maximumSizeLeft);
-
- final Size maximumSizeRight = new Size(availableWidth - leftPanelRequiredSize.getWidth(), availableSpace.getHeight());
- rightPanelRequiredSize = right == null ? new Size() : right.getRequiredSize(maximumSizeRight);
- }
-
- // combine the two required sizes
- final Size combinedSize = new Size(leftPanelRequiredSize);
- combinedSize.extendWidth(rightPanelRequiredSize.getWidth());
- combinedSize.ensureHeight(rightPanelRequiredSize.getHeight());
- return combinedSize;
- }
-
- protected void showInRightPane(final View view) {
- replaceView(getSubviews()[1], view);
- }
-
- @Override
- public void setSelectedNode(final View view) {
- final Content content = view.getContent();
- setSelectedNode(content);
- }
-
- private void setSelectedNode(final Content content) {
- final ViewRequirement requirement = new ViewRequirement(content, ViewRequirement.OPEN | ViewRequirement.SUBVIEW | ViewRequirement.FIXED);
- /*
- * final ObjectAdapter object = content.getAdapter(); final
- * ObjectSpecification specification = object.getSpecification(); final
- * CollectionFacet facet =
- * specification.getFacet(CollectionFacet.class); if (facet != null &&
- * facet.size(object) > 0) { if
- * (mainViewTableSpec.canDisplay(requirement)) {
- * showInRightPane(mainViewTableSpec.createView(content, axes, -1)); }
- * else if (mainViewListSpec.canDisplay(requirement)) {
- * showInRightPane(mainViewListSpec.createView(content, axes, -1)); }
- *
- * } else if (specification.isObject()) { if (object != null &&
- * mainViewFormSpec.canDisplay(requirement)) {
- * showInRightPane(mainViewFormSpec.createView(content, axes, -1)); } }
- */
- final View createView = Toolkit.getViewFactory().createView(requirement);
- showInRightPane(createView);
- }
-
- @Override
- public String toString() {
- return "MasterDetailPanel" + getId();
- }
-
-}