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:21 UTC
[20/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/field/WrappedTextField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/field/WrappedTextField.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/field/WrappedTextField.java
deleted file mode 100644
index 4e6aa2e..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/field/WrappedTextField.java
+++ /dev/null
@@ -1,159 +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.field;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
-import org.apache.isis.viewer.dnd.view.text.CursorPosition;
-import org.apache.isis.viewer.dnd.view.text.TextContent;
-
-public class WrappedTextField extends TextField {
- private static final Logger LOG = LoggerFactory.getLogger(WrappedTextField.class);
-
- public WrappedTextField(final TextParseableContent content, final ViewSpecification specification, final boolean showLines) {
- super(content, specification, showLines, TextContent.WRAPPING);
- }
-
- public void setWrapping(final boolean wrapping) {
- }
-
- @Override
- protected void drawLines(final Canvas canvas, final Color color, final int width) {
- int baseline = getBaseline();
- final int noDisplayLines = textContent.getNoDisplayLines();
- for (int line = 0; line < noDisplayLines; line++) {
- canvas.drawLine(ViewConstants.HPADDING, baseline, ViewConstants.HPADDING + width, baseline, color);
- baseline += getText().getLineHeight();
- }
- }
-
- @Override
- protected void drawHighlight(final Canvas canvas, final int maxWidth) {
- final int baseline = getBaseline();
- int top = baseline - style.getAscent();
-
- final CursorPosition from = selection.from();
- final CursorPosition to = selection.to();
-
- final String[] lines = textContent.getDisplayLines();
- final int displayFromLine = textContent.getDisplayFromLine();
- final int displayToLine = displayFromLine + lines.length;
- for (int i = displayFromLine; i <= displayToLine; i++) {
- if ((i >= from.getLine()) && (i <= to.getLine())) {
- final String line = textContent.getText(i);
- int start = 0;
- int end = style.stringWidth(line);
-
- if (from.getLine() == i) {
- final int at = Math.min(from.getCharacter(), line.length());
- start = style.stringWidth(line.substring(0, at));
- }
-
- if (to.getLine() == i) {
- final int at = Math.min(to.getCharacter(), line.length());
- end = style.stringWidth(line.substring(0, at));
- }
-
- canvas.drawSolidRectangle(start + (ViewConstants.HPADDING), top, end - start, getText().getLineHeight(), Toolkit.getColor(ColorsAndFonts.COLOR_TEXT_HIGHLIGHT));
- }
-
- top += getText().getLineHeight();
- }
- }
-
- @Override
- protected void drawText(final Canvas canvas, final Color textColor, final int width) {
- int baseline = getBaseline();
- final String[] lines = textContent.getDisplayLines();
- final int cursorLine = cursor.getLine() - textContent.getDisplayFromLine();
- for (int i = 0; i < lines.length; i++) {
- final String chars = lines[i];
- if (chars == null) {
- throw new IsisException();
- }
- if (chars.endsWith("\n")) {
- throw new RuntimeException();
- }
-
- // draw cursor
- if (hasFocus() && canChangeValue().isAllowed() && cursorLine == i) {
- final int at = Math.min(cursor.getCharacter(), chars.length());
- final int pos = style.stringWidth(chars.substring(0, at)) + ViewConstants.HPADDING;
- canvas.drawLine(pos, (baseline + style.getDescent()), pos, baseline - style.getAscent(), Toolkit.getColor(ColorsAndFonts.COLOR_TEXT_CURSOR));
- }
-
- // draw text
- canvas.drawText(chars, ViewConstants.HPADDING, baseline, textColor, style);
- baseline += getText().getLineHeight();
- }
- /*
- * if (end < entryLength) { int x = style.stringWidth(new String(buffer,
- * start, end)); g.setColor(Color.red); g.drawString("\u00bb", x,
- * baseline - lineHeight()); }
- */
- }
-
- @Override
- protected boolean enter() {
- textContent.breakBlock(cursor);
- cursor.lineDown();
- cursor.home();
- markDamaged();
- return true;
- }
-
- /**
- * Sets the number of lines to display
- */
- public void setNoLines(final int noLines) {
- textContent.setNoDisplayLines(noLines);
- }
-
- @Override
- public void setSize(final Size size) {
- super.setSize(size);
- textContent.setNoDisplayLines(size.getHeight() / style.getLineHeight());
- }
-
- @Override
- public void setMaximumSize(final Size size) {
- final int lines = Math.max(1, size.getHeight() / getText().getLineHeight());
- setNoLines(lines);
- final int width = Math.max(180, size.getWidth() - ViewConstants.HPADDING);
- setWidth(width);
- LOG.debug(lines + " x " + width);
- invalidateLayout();
- }
-
- @Override
- protected void align() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractFormSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractFormSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractFormSpecification.java
deleted file mode 100644
index 70cb041..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractFormSpecification.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.form;
-
-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.composite.StandardFields;
-
-public abstract class AbstractFormSpecification extends AbstractObjectViewSpecification {
-
- @Override
- protected ViewFactory createFieldFactory() {
- return new StandardFields() {
- @Override
- protected int collectionRequirement() {
- return AbstractFormSpecification.this.collectionRequirement();
- }
-
- @Override
- protected boolean include(final Content content, final int sequence) {
- return AbstractFormSpecification.this.include(content, sequence);
- }
- };
- }
-
- protected int collectionRequirement() {
- return ViewRequirement.OPEN | ViewRequirement.SUBVIEW;
- }
-
- protected boolean include(final Content content, final int sequence) {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractObjectViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractObjectViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractObjectViewSpecification.java
deleted file mode 100644
index 65feca0..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/AbstractObjectViewSpecification.java
+++ /dev/null
@@ -1,55 +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.form;
-
-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;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewSpecification;
-import org.apache.isis.viewer.dnd.view.composite.ObjectFieldBuilder;
-import org.apache.isis.viewer.dnd.view.composite.StackLayout;
-import org.apache.isis.viewer.dnd.view.composite.StandardFields;
-
-public abstract class AbstractObjectViewSpecification extends CompositeViewSpecification {
-
- public AbstractObjectViewSpecification() {
- builder = new ObjectFieldBuilder(createFieldFactory());
- init();
- }
-
- protected void init() {
- }
-
- protected ViewFactory createFieldFactory() {
- return new StandardFields();
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- return new StackLayout();
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isObject() && !requirement.isTextParseable() && requirement.hasReference() && requirement.isOpen();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableFormSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableFormSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableFormSpecification.java
deleted file mode 100644
index 173eb26..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableFormSpecification.java
+++ /dev/null
@@ -1,49 +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.form;
-
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.border.IconBorder;
-import org.apache.isis.viewer.dnd.view.composite.FieldLabelsDecorator;
-
-public class ExpandableFormSpecification extends AbstractFormSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return super.canDisplay(requirement) && !requirement.is(ViewRequirement.SUBVIEW);
- }
-
- @Override
- protected void init() {
- addSubviewDecorator(new ExpandableViewBorder.Factory());
- addSubviewDecorator(new FieldLabelsDecorator());
- addViewDecorator(new IconBorder.Factory());
- }
-
- @Override
- protected int collectionRequirement() {
- return super.collectionRequirement() | ViewRequirement.EXPANDABLE;
- }
-
- @Override
- public String getName() {
- return "Expanding Form (experimental)";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableViewBorder.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableViewBorder.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableViewBorder.java
deleted file mode 100644
index ff9a757..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/ExpandableViewBorder.java
+++ /dev/null
@@ -1,246 +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.form;
-
-import java.util.List;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-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.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Shape;
-import org.apache.isis.viewer.dnd.icon.SubviewIconSpecification;
-import org.apache.isis.viewer.dnd.list.InternalListSpecification;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Click;
-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.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.AbstractBorder;
-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.content.FieldContent;
-import org.apache.isis.viewer.dnd.view.field.OneToOneFieldImpl;
-
-public class ExpandableViewBorder extends AbstractBorder {
- public static final int CAN_OPEN = 1;
- public static final int CANT_OPEN = 2;
- public static final int UNKNOWN = 0;
-
- public static class Factory implements SubviewDecorator {
- private final ViewSpecification openObjectViewSpecification;
- private final ViewSpecification closedViewSpecification;
- private final ViewSpecification openCollectionViewSpecification;
-
- public Factory() {
- this.closedViewSpecification = new SubviewIconSpecification();
- this.openObjectViewSpecification = new InternalFormSpecification();
- this.openCollectionViewSpecification = new InternalListSpecification();
- }
-
- public Factory(final ViewSpecification closedViewSpecification, final ViewSpecification openObjectViewSpecification, final ViewSpecification openCollectionViewSpecification) {
- this.closedViewSpecification = closedViewSpecification;
- this.openObjectViewSpecification = openObjectViewSpecification;
- this.openCollectionViewSpecification = openCollectionViewSpecification;
- }
-
- @Override
- public ViewAxis createAxis(final Content content) {
- return null;
- }
-
- @Override
- public View decorate(final Axes axes, final View view) {
- if (view.getContent().isObject()) {
- return new ExpandableViewBorder(view, closedViewSpecification, openObjectViewSpecification);
- } else if (view.getContent().isCollection()) {
- return new ExpandableViewBorder(view, closedViewSpecification, openCollectionViewSpecification);
- } else {
- return view;
- }
- }
- }
-
- private boolean isOpen = false;
- private final ViewSpecification openViewSpecification;
- private final ViewSpecification closedViewSpecification;
- private int canOpen;
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final Where where = Where.ANYWHERE;
-
- public ExpandableViewBorder(final View view, final ViewSpecification closedViewSpecification, final ViewSpecification openViewSpecification) {
- super(view);
- left = Toolkit.defaultFieldHeight();
- this.openViewSpecification = openViewSpecification;
- this.closedViewSpecification = closedViewSpecification;
- canOpen();
- }
-
- @Override
- protected void debugDetails(final DebugBuilder debug) {
- super.debugDetails(debug);
- debug.appendln("open spec", openViewSpecification);
- debug.appendln("closed spec", closedViewSpecification);
- debug.appendln("open", isOpen);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- Shape pointer;
- if (isOpen) {
- pointer = new Shape(0, left / 2);
- pointer.addPoint(left - 2 - 2, left / 2);
- pointer.addPoint(left / 2 - 2, left - 2);
- } else {
- pointer = new Shape(2, 2);
- pointer.addPoint(2, left - 2);
- pointer.addPoint(left / 2, 2 + (left - 2) / 2);
- }
- if (canOpen == CAN_OPEN) {
- canvas.drawSolidShape(pointer, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1));
- } else if (canOpen == UNKNOWN) {
- canvas.drawShape(pointer, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1));
- } else {
- canvas.drawShape(pointer, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3));
- }
-
- super.draw(canvas);
- }
-
- @Override
- public void firstClick(final Click click) {
- if (click.getLocation().getX() < left) {
- if (canOpen == UNKNOWN) {
- resolveContent();
- markDamaged();
- }
- if (canOpen != CANT_OPEN) {
- isOpen = !isOpen;
-
- final View parent = wrappedView.getParent();
-
- getViewManager().removeFromNotificationList(wrappedView);
- if (isOpen) {
- wrappedView = createOpenView();
- } else {
- wrappedView = createClosedView();
- }
- setView(this);
- setParent(parent);
- getParent().invalidateLayout();
- canOpen();
- }
- } else {
- super.firstClick(click);
- }
- }
-
- private View createClosedView() {
- return closedViewSpecification.createView(getContent(), getViewAxes(), -1);
- }
-
- private View createOpenView() {
- return openViewSpecification.createView(getContent(), getViewAxes(), -1);
- }
-
- @Override
- public void update(final ObjectAdapter object) {
- super.update(object);
- canOpen();
- }
-
- private void canOpen() {
- final Content content = getContent();
- if (content.isCollection()) {
- canOpen = canOpenCollection(content);
- } else if (content.isObject()) {
- canOpen = canOpenObject(content);
- }
- }
-
- private int canOpenCollection(final Content content) {
- final ObjectAdapter collection = ((CollectionContent) content).getCollection();
- if (collection.isGhost()) {
- return UNKNOWN;
- } else {
- final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
- return facet.size(collection) > 0 ? CAN_OPEN : CANT_OPEN;
- }
- }
-
- private int canOpenObject(final Content content) {
- final ObjectAdapter object = ((ObjectContent) content).getObject();
- if (object != null) {
- final List<ObjectAssociation> fields = object.getSpecification().getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(IsisContext.getAuthenticationSession(), object, where));
- for (int i = 0; i < fields.size(); i++) {
- if (fields.get(i).isOneToManyAssociation()) {
- return CAN_OPEN;
- } else if (fields.get(i).isOneToOneAssociation() && !fields.get(i).getSpecification().isParseable() && fieldContainsReference(object, fields.get(i))) {
- return CAN_OPEN;
- }
- }
- }
- final boolean openForObjectsWithOutReferences = true;
- return openForObjectsWithOutReferences ? CAN_OPEN : CANT_OPEN;
- }
-
- private boolean fieldContainsReference(final ObjectAdapter parent, final ObjectAssociation field) {
- final OneToOneAssociation association = (OneToOneAssociation) field;
- final OneToOneFieldImpl fieldContent = new OneToOneFieldImpl(parent, field.get(parent), association);
- if (openViewSpecification.canDisplay(new ViewRequirement(fieldContent, ViewRequirement.OPEN))) {
- return true;
- }
- return false;
- }
-
- private void resolveContent() {
- ObjectAdapter parent = getParent().getContent().getAdapter();
- if (!(parent instanceof ObjectAdapter)) {
- parent = getParent().getParent().getContent().getAdapter();
- }
-
- if (getContent() instanceof FieldContent) {
- final ObjectAssociation field = ((FieldContent) getContent()).getField();
- IsisContext.getPersistenceSession().resolveField(parent, field);
- } else if (getContent() instanceof CollectionContent) {
- IsisContext.getPersistenceSession().resolveImmediately(parent);
- } else if (getContent() instanceof CollectionElement) {
- IsisContext.getPersistenceSession().resolveImmediately(getContent().getAdapter());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormSpecification.java
deleted file mode 100644
index b96dc58..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormSpecification.java
+++ /dev/null
@@ -1,43 +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.form;
-
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.border.IconBorder;
-import org.apache.isis.viewer.dnd.view.composite.FieldLabelsDecorator;
-
-public class FormSpecification extends AbstractFormSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return super.canDisplay(requirement) && !requirement.is(ViewRequirement.SUBVIEW);
- }
-
- @Override
- protected void init() {
- addSubviewDecorator(new FieldLabelsDecorator());
- addViewDecorator(new IconBorder.Factory());
- }
-
- @Override
- public String getName() {
- return "Form";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormWithDetailSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormWithDetailSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormWithDetailSpecification.java
deleted file mode 100644
index 98e30b0..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/FormWithDetailSpecification.java
+++ /dev/null
@@ -1,96 +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.form;
-
-import java.util.List;
-
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-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.border.SelectObjectBorder;
-import org.apache.isis.viewer.dnd.view.composite.MasterDetailPanel;
-
-public class FormWithDetailSpecification implements ViewSpecification {
- private final FormSpecification leftHandSideSpecification;
-
- public FormWithDetailSpecification() {
- leftHandSideSpecification = new FormSpecification();
- leftHandSideSpecification.addSubviewDecorator(new SelectObjectBorder.Factory());
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isObject() && requirement.isOpen() && !requirement.isSubview() && containsEnoughFields(requirement.getContent());
- }
-
- private boolean containsEnoughFields(final Content content) {
- final ObjectSpecification specification = content.getSpecification();
- final List<ObjectAssociation> associations = specification.getAssociations(Contributed.EXCLUDED, new Filter<ObjectAssociation>() {
- @Override
- public boolean accept(final ObjectAssociation t) {
- return t.isOneToManyAssociation() || (t.isOneToOneAssociation() && !((OneToOneAssociation) t).getSpecification().isParseable());
- }
- });
- return associations.size() >= 1;
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- return new MasterDetailPanel(content, this, leftHandSideSpecification);
- }
-
- @Override
- public String getName() {
- return "Form and details (experimental)";
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return true;
- }
-
- @Override
- public boolean isResizeable() {
- return true;
- }
-
- @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/form/InternalFormSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/InternalFormSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/InternalFormSpecification.java
deleted file mode 100644
index 05603d2..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/InternalFormSpecification.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.form;
-
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.border.IconBorder;
-import org.apache.isis.viewer.dnd.view.composite.FieldLabelsDecorator;
-
-public class InternalFormSpecification extends AbstractFormSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return super.canDisplay(requirement) && requirement.is(ViewRequirement.SUBVIEW);
- }
-
- @Override
- protected void init() {
- addSubviewDecorator(new FieldLabelsDecorator());
- addViewDecorator(new IconBorder.Factory(Toolkit.getText(ColorsAndFonts.TEXT_NORMAL)));
-
- }
-
- @Override
- public String getName() {
- return "Internal form";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFields.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFields.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFields.java
deleted file mode 100644
index 4d7bacf..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFields.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.form;
-
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.composite.StandardFields;
-
-public class SummaryFields extends StandardFields {
-
- @Override
- protected int collectionRequirement() {
- return ViewRequirement.NONE;
- }
-
- @Override
- protected boolean include(final Content content, final int sequence) {
- return sequence < 4 && content.getAdapter() != 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/form/SummaryFormSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFormSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFormSpecification.java
deleted file mode 100644
index ac2cc27..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/form/SummaryFormSpecification.java
+++ /dev/null
@@ -1,60 +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.form;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.border.BackgroundBorder;
-import org.apache.isis.viewer.dnd.view.border.EmptyBorder;
-import org.apache.isis.viewer.dnd.view.border.IconBorder;
-import org.apache.isis.viewer.dnd.view.border.LineBorder;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewDecorator;
-
-public class SummaryFormSpecification extends AbstractFormSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isObject() && !requirement.isTextParseable() && requirement.hasReference() && requirement.isOpen() && requirement.isSubview() && requirement.isFixed();
- }
-
- @Override
- protected void init() {
- addViewDecorator(new IconBorder.Factory());
- addViewDecorator(new CompositeViewDecorator() {
- @Override
- public View decorate(final View view, final Axes axes) {
- return new EmptyBorder(3, new BackgroundBorder(new LineBorder(1, 8, new EmptyBorder(3, view))));
- }
- });
- }
-
- @Override
- protected ViewFactory createFieldFactory() {
- return new SummaryFields();
- }
-
- @Override
- public String getName() {
- return "Summary";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/grid/GridSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/grid/GridSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/grid/GridSpecification.java
deleted file mode 100644
index c3896ac..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/grid/GridSpecification.java
+++ /dev/null
@@ -1,114 +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.grid;
-
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.form.AbstractFormSpecification;
-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.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.base.AbstractBorder;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-import org.apache.isis.viewer.dnd.view.border.EmptyBorder;
-import org.apache.isis.viewer.dnd.view.composite.CollectionElementBuilder;
-import org.apache.isis.viewer.dnd.view.composite.ColumnLayout;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewDecorator;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewSpecification;
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-
-public class GridSpecification extends CompositeViewSpecification {
-
- public GridSpecification() {
- builder = new CollectionElementBuilder(new AbstractFormSpecification() {
- @Override
- public String getName() {
- return "";
- }
-
- @Override
- protected void init() {
- super.init();
- addSubviewDecorator(new SubviewDecorator() {
- @Override
- public ViewAxis createAxis(final Content content) {
- return null;
- }
-
- @Override
- public View decorate(final Axes axes, final View view) {
- return new EmptyBorder(0, 0, 5, 0, view);
- }
- });
- }
- });
-
- addViewDecorator(new ColumnLabelBorder.Factory());
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- return new ColumnLayout(true);
- }
-
- @Override
- public String getName() {
- return "Grid (experimental)";
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isCollection() && requirement.isOpen();
- }
-}
-
-class ColumnLabelBorder extends AbstractBorder {
-
- public static class Factory implements CompositeViewDecorator {
- @Override
- public View decorate(final View view, final Axes axes) {
- return new ColumnLabelBorder(view);
- }
- }
-
- protected ColumnLabelBorder(final View view) {
- super(view);
- left = 100;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- final View subview = getSubviews()[0];
-
- final int top = subview.getPadding().getTop();
- for (final View view : subview.getSubviews()) {
- final String fieldName = ((FieldContent) view.getContent()).getFieldName();
- canvas.drawText(fieldName + ":", 0, view.getLocation().getY() + top + view.getBaseline(), Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1), Toolkit.getText(ColorsAndFonts.TEXT_LABEL));
- // canvas.drawRectangle(0, view.getLocation().getY() + top, 80, 10,
- // Toolkit.getColor("primary1"));
- }
-
- super.draw(canvas);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
deleted file mode 100644
index 2e9beb1..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
+++ /dev/null
@@ -1,171 +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.help;
-
-import org.apache.isis.core.runtime.about.AboutIsis;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Click;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.content.NullContent;
-import org.apache.isis.viewer.dnd.view.window.SubviewFocusManager;
-
-public class AboutView extends AbstractView {
- private static final int MAX_WIDTH = 300;
- private final int linePadding = -2;
- private final int noticePadding = 45;
- private final int margin = 14;
- private final Image image;
- private final int left;
- private final FocusManager focusManager;
-
- public AboutView() {
- super(new NullContent());
- image = ImageFactory.getInstance().loadImage(AboutIsis.getImageName());
- left = noticePadding;
- setContent(new NullContent(AboutIsis.getFrameworkName()));
-
- focusManager = new SubviewFocusManager(this);
- }
-
- @Override
- public FocusManager getFocusManager() {
- return focusManager;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- final Text titleStyle = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- final Text normalStyle = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
- final Color color = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
-
- clearBackground(canvas, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
- canvas.drawRectangleAround(getBounds(), Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3));
-
- if (showingImage()) {
- canvas.drawImage(image, margin, margin);
- }
-
- int line = margin + image.getHeight() + noticePadding + normalStyle.getAscent();
-
- // application details
- String text = AboutIsis.getApplicationName();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, titleStyle);
- line += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- }
- text = AboutIsis.getApplicationCopyrightNotice();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- }
- text = AboutIsis.getApplicationVersion();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- line += 2 * normalStyle.getLineHeight();
- }
-
- // framework details
- text = AboutIsis.getFrameworkName();
- canvas.drawText(text, left, line, MAX_WIDTH, color, titleStyle);
- line += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
-
- text = AboutIsis.getFrameworkCopyrightNotice();
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
-
- canvas.drawText(frameworkVersion(), left, line, MAX_WIDTH, color, normalStyle);
-
- }
-
- private String frameworkVersion() {
- return AboutIsis.getFrameworkVersion();
- }
-
- private boolean showingImage() {
- return image != null;
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final Text titleStyle = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- final Text normalStyle = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
-
- int height = 0;
-
- String text = AboutIsis.getFrameworkName();
- height += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- int width = titleStyle.stringWidth(text, MAX_WIDTH);
-
- text = AboutIsis.getFrameworkCopyrightNotice();
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
-
- text = frameworkVersion();
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
-
- text = AboutIsis.getApplicationName();
- if (text != null) {
- height += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, titleStyle.stringWidth(text, MAX_WIDTH));
- }
- text = AboutIsis.getApplicationCopyrightNotice();
- if (text != null) {
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
- }
- text = AboutIsis.getApplicationVersion();
- if (text != null) {
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
- }
-
- height += noticePadding;
-
- if (showingImage()) {
- height += image.getHeight();
- width = Math.max(image.getWidth(), width);
- }
-
- return new Size(margin + width + margin, margin + height + margin);
- }
-
- @Override
- public void firstClick(final Click click) {
- // dispose();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
deleted file mode 100644
index f94ef9d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
+++ /dev/null
@@ -1,49 +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.help;
-
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-public class ExternalHelpViewerProgram implements HelpViewer {
- private static final Logger LOG = LoggerFactory.getLogger(ExternalHelpViewerProgram.class);
- private final String program;
-
- public ExternalHelpViewerProgram(final String program) {
- this.program = program;
- }
-
- @Override
- public void open(final Location location, final String name, final String description, final String help) {
- final String exec = program + " " + help;
- try {
- Runtime.getRuntime().exec(exec);
- LOG.debug("executing '" + exec + "'");
- } catch (final IOException e) {
- throw new IsisException("faile to execute '" + exec + "'", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java
deleted file mode 100644
index 62cc21d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.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.help;
-
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Click;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.content.NullContent;
-import org.apache.isis.viewer.dnd.view.text.TextBlockTarget;
-import org.apache.isis.viewer.dnd.view.text.TextContent;
-
-public class HelpView extends AbstractView implements TextBlockTarget {
- private static final int HEIGHT = 350;
- private static final int WIDTH = 400;
- private static final int MAX_TEXT_WIDTH = 375;
- private final TextContent content;
-
- public HelpView(final String name, final String description, final String help) {
- super(new NullContent());
- final String text = (name == null || name.trim().equals("") ? "" : (name + "\n")) + (description == null || description.trim().equals("") ? "" : (description + "\n")) + (help == null ? "" : help);
- content = new TextContent(this, 10, TextContent.WRAPPING);
- content.setText(text);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- int x = 0;
- int y = 0;
- final int xEntent = getSize().getWidth() - 1;
- final int yExtent = getSize().getHeight() - 1;
-
- final int arc = 9;
- canvas.drawSolidRectangle(x + 2, y + 2, xEntent - 4, yExtent - 4, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
- final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- canvas.drawRoundedRectangle(x, y++, xEntent, yExtent, arc, arc, black);
- canvas.drawRoundedRectangle(x + 1, y++, xEntent - 2, yExtent - 2, arc, arc, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2));
- canvas.drawRoundedRectangle(x + 2, y++, xEntent - 4, yExtent - 4, arc, arc, black);
-
- x += 10;
- y += ViewConstants.VPADDING;
- y += Toolkit.getText(ColorsAndFonts.TEXT_TITLE).getTextHeight();
- canvas.drawText("Help", x, y, black, Toolkit.getText(ColorsAndFonts.TEXT_TITLE));
-
- final String[] lines = content.getDisplayLines();
- for (final String line : lines) {
- y += Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getLineHeight();
- canvas.drawText(line, x, y, MAX_TEXT_WIDTH, black, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
- }
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final int height = Math.min(HEIGHT, availableSpace.getHeight());
- final int width = Math.min(WIDTH, availableSpace.getWidth());
- return new Size(width, height);
- }
-
- /**
- * Removes the help view when clicked on.
- */
- @Override
- public void firstClick(final Click click) {
- getViewManager().clearOverlayView(this);
- }
-
- @Override
- public int getMaxFieldWidth() {
- return WIDTH - 20;
- }
-
- @Override
- public Text getText() {
- return Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
deleted file mode 100644
index 05f378d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
+++ /dev/null
@@ -1,31 +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.help;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-/**
- * A HelpSystem is used to launch the help system and bring up contextual help.
- */
-public interface HelpViewer {
-
- void open(Location location, String name, String description, String help);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
deleted file mode 100644
index d5cf93c..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
+++ /dev/null
@@ -1,44 +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.help;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Viewer;
-
-public class InternalHelpViewer implements HelpViewer {
- private final Viewer viewer;
-
- public InternalHelpViewer(final Viewer viewer) {
- this.viewer = viewer;
- }
-
- @Override
- public void open(final Location location, final String name, final String description, final String help) {
- viewer.clearAction();
-
- final View helpView = new HelpView(name, description, help);
- location.add(20, 20);
- helpView.setLocation(location);
-
- viewer.setOverlayView(helpView);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
deleted file mode 100644
index 48339ea..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
+++ /dev/null
@@ -1,68 +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.histogram;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-
-class HistogramAxis implements ViewAxis {
- private final ObjectAssociation fields[];
- private final double maxValues[];
- private final int noBars;
-
- public HistogramAxis(final Content content) {
- final List<? extends ObjectAssociation> associationList = HistogramSpecification.availableFields((CollectionContent) content);
- noBars = associationList.size();
- fields = new ObjectAssociation[noBars];
- maxValues = new double[noBars];
- int i = 0;
- for (final ObjectAssociation association : associationList) {
- fields[i++] = association;
- }
- }
-
- public double getLengthFor(final Content content, final int fieldNo) {
- return NumberAdapters.doubleValue(fields[fieldNo], fields[fieldNo].get(content.getAdapter())) / maxValues[fieldNo];
- }
-
- public void determineMaximum(final Content content) {
- int i = 0;
- for (final ObjectAssociation field : fields) {
- maxValues[i] = 0;
- final CollectionFacet collectionFacet = content.getAdapter().getSpecification().getFacet(CollectionFacet.class);
- for (final ObjectAdapter element : collectionFacet.iterable(content.getAdapter())) {
- final ObjectAdapter value = field.get(element);
- final double doubleValue = NumberAdapters.doubleValue(field, value);
- maxValues[i] = Math.max(maxValues[i], doubleValue);
- }
- i++;
- }
- }
-
- public int getNoBars() {
- return noBars;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
deleted file mode 100644
index 7d64617..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
+++ /dev/null
@@ -1,57 +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.histogram;
-
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.ObjectView;
-
-class HistogramBar extends ObjectView {
- private static final int colors[] = new int[] { 0xccccff, 0x99ff99, 0xffccff };
- private final HistogramAxis histogramAxis;
-
- protected HistogramBar(final Content content, final HistogramAxis histogramAxis, final ViewSpecification specification) {
- super(content, specification);
- this.histogramAxis = histogramAxis;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
- int y = 0;
- final int height = (getSize().getHeight() - 5) / histogramAxis.getNoBars();
- final Text text = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
- final Color color = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
- canvas.drawText(getContent().title(), 0, height / 2 + text.getAscent() / 2, color, text);
-
- for (int i = 0; i < histogramAxis.getNoBars(); i++) {
- final double length = (getSize().getWidth() - 160) * histogramAxis.getLengthFor(getContent(), i);
- canvas.drawSolidRectangle(160, y, (int) length, height, Toolkit.getColor(colors[i % colors.length]));
- canvas.drawRectangle(160, y, (int) length, height, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK));
- y += height + 2;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
deleted file mode 100644
index 91fba77..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
+++ /dev/null
@@ -1,56 +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.histogram;
-
-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.ViewConstants;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-public class HistogramLayout implements Layout {
- private final int width = 500;
- private final int barHeight = 24;
-
- @Override
- public void layout(final View view, final Size maximumSize) {
- final HistogramAxis axis = view.getViewAxes().getAxis(HistogramAxis.class);
- axis.determineMaximum(view.getContent());
- final int noBars = axis.getNoBars();
- final int height = barHeight * noBars;
- final View[] subviews = view.getSubviews();
- int y = ViewConstants.VPADDING;
- for (final View bar : subviews) {
- bar.setSize(new Size(width, height));
- bar.setLocation(new Location(ViewConstants.HPADDING, y));
- y += height;
- }
- }
-
- @Override
- public Size getRequiredSize(final View view) {
- final HistogramAxis axis = view.getViewAxes().getAxis(HistogramAxis.class);
- final int noBars = axis.getNoBars();
- final View[] subviews = view.getSubviews();
- final int graphHeight = subviews.length * barHeight * noBars + ViewConstants.VPADDING * 2;
- return new Size(width + ViewConstants.HPADDING * 2, graphHeight);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
deleted file mode 100644
index 3d2117f..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
+++ /dev/null
@@ -1,100 +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.histogram;
-
-import java.util.List;
-
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.core.metamodel.spec.feature.Contributed;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.View;
-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;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-import org.apache.isis.viewer.dnd.view.composite.CollectionElementBuilder;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewSpecification;
-
-public class HistogramSpecification extends CompositeViewSpecification {
-
- static List<? extends ObjectAssociation> availableFields(final CollectionContent content) {
- List<? extends ObjectAssociation> associationList;
- associationList = content.getElementSpecification().getAssociations(Contributed.EXCLUDED, new Filter<ObjectAssociation>() {
- @Override
- public boolean accept(final ObjectAssociation t) {
- return NumberAdapters.contains(t);
- }
- });
- return associationList;
- }
-
- public HistogramSpecification() {
- builder = new CollectionElementBuilder(new ViewFactory() {
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- return new HistogramBar(content, axes.getAxis(HistogramAxis.class), HistogramSpecification.this);
- }
- });
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- return new HistogramLayout();
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isCollection() && requirement.isOpen() && availableFields((CollectionContent) requirement.getContent()).size() > 0;
- }
-
- @Override
- public void createAxes(final Content content, final Axes axes) {
- super.createAxes(content, axes);
- axes.add(new HistogramAxis(content));
- }
-
- @Override
- public String getName() {
- return "Histogram (experimental)";
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return true;
- }
-
- @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/histogram/NumberAdapters.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java
deleted file mode 100644
index 26ec31b..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java
+++ /dev/null
@@ -1,75 +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.histogram;
-
-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.core.progmodel.facets.value.floats.FloatingPointValueFacet;
-import org.apache.isis.core.progmodel.facets.value.integer.IntegerValueFacet;
-import org.apache.isis.core.progmodel.facets.value.longs.DoubleFloatingPointValueFacet;
-import org.apache.isis.core.progmodel.facets.value.money.MoneyValueFacet;
-
-public class NumberAdapters {
- static interface Converter {
- double value(ObjectAdapter value);
- }
-
- static {
- new Converter() {
- @Override
- public double value(final ObjectAdapter arg0) {
- return 0;
- }
- };
-
- }
-
- public static boolean contains(final ObjectAssociation t) {
- return t.getSpecification().containsFacet(IntegerValueFacet.class) || t.getSpecification().containsFacet(DoubleFloatingPointValueFacet.class) || t.getSpecification().containsFacet(FloatingPointValueFacet.class) || t.getSpecification().containsFacet(MoneyValueFacet.class);
- }
-
- public static double doubleValue(final ObjectAssociation field, final ObjectAdapter value) {
- final ObjectSpecification specification = value.getSpecification();
-
- final IntegerValueFacet intValueFacet = specification.getFacet(IntegerValueFacet.class);
- if (intValueFacet != null) {
- return intValueFacet.integerValue(value).doubleValue();
- }
-
- final DoubleFloatingPointValueFacet doubleValueFacet = specification.getFacet(DoubleFloatingPointValueFacet.class);
- if (doubleValueFacet != null) {
- return doubleValueFacet.doubleValue(value).doubleValue();
- }
-
- final FloatingPointValueFacet floatValueFacet = specification.getFacet(FloatingPointValueFacet.class);
- if (floatValueFacet != null) {
- return floatValueFacet.floatValue(value).doubleValue();
- }
-
- final MoneyValueFacet moneyValueFacet = specification.getFacet(MoneyValueFacet.class);
- if (moneyValueFacet != null) {
- return moneyValueFacet.getAmount(value);
- }
-
- return 0.0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
deleted file mode 100644
index 4d5c137..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
+++ /dev/null
@@ -1,165 +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.icon;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.drawing.Size;
-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.ViewConstants;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.IconGraphic;
-import org.apache.isis.viewer.dnd.view.base.ObjectView;
-import org.apache.isis.viewer.dnd.view.text.ObjectTitleText;
-import org.apache.isis.viewer.dnd.view.text.TitleText;
-
-public class Icon extends ObjectView {
- private IconGraphic icon;
- private boolean isVertical;
- private IconGraphic selectedGraphic;
- private TitleText title;
- private IconGraphic unselectedGraphic;
-
- public Icon(final Content content, final ViewSpecification specification) {
- super(content, specification);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- ensureHasIcon();
-
- int x = 0;
- int y = 0;
- icon.draw(canvas, x, getBaseline());
- if (isVertical) {
- final int w = title.getSize().getWidth();
- x = (w > icon.getSize().getWidth()) ? x : getSize().getWidth() / 2 - w / 2;
- y = icon.getSize().getHeight() + Toolkit.getText(ColorsAndFonts.TEXT_ICON).getAscent() + ViewConstants.VPADDING;
- } else {
- x += icon.getSize().getWidth();
- x += ViewConstants.HPADDING;
- y = icon.getBaseline();
- }
- final int maxWidth = getSize().getWidth() - x;
- title.draw(canvas, x, y, maxWidth);
-
- if (getState().isActive()) {
- final Image busyImage = ImageFactory.getInstance().loadIcon("busy", 16, null);
- canvas.drawImage(busyImage, icon.getSize().getWidth() - 16 - 4, 4);
- }
-
- }
-
- private void ensureHasIcon() {
- if (icon == null) {
- // icon = selectedGraphic;
- }
- }
-
- @Override
- public void entered() {
- icon = selectedGraphic;
- markDamaged();
- super.entered();
- }
-
- @Override
- public void exited() {
- icon = unselectedGraphic;
- markDamaged();
- super.exited();
- }
-
- @Override
- public int getBaseline() {
- ensureHasIcon();
- return icon.getBaseline();
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- if (icon == null) {
- // icon = unselectedGraphic;
- }
-
- final Size size = icon.getSize();
- final Size textSize = title.getSize();
- if (isVertical) {
- size.extendHeight(ViewConstants.VPADDING + textSize.getHeight() + ViewConstants.VPADDING);
- size.ensureWidth(textSize.getWidth());
- } else {
- size.extendWidth(ViewConstants.HPADDING);
- size.extendWidth(textSize.getWidth());
- }
- return size;
- }
-
- /**
- * Set up the graphic to be used when displaying the icon and the icon is
- * selected.
- */
- public void setSelectedGraphic(final IconGraphic selectedGraphic) {
- this.selectedGraphic = selectedGraphic;
- if (unselectedGraphic == null) {
- unselectedGraphic = selectedGraphic;
- icon = selectedGraphic;
- }
- }
-
- /**
- * Set up the title to be used when displaying the icon.
- */
- public void setTitle(final ObjectTitleText text) {
- title = text;
- }
-
- /**
- * Set up the graphic to be used when displaying the icon and the icon is
- * unselected. If this returns null the graphic will not be changed when the
- * icon becomes unselected.
- */
- public void setUnselectedGraphic(final IconGraphic unselectedGraphic) {
- this.unselectedGraphic = unselectedGraphic;
- icon = unselectedGraphic;
- }
-
- /**
- * Specifies if the graphic should be aligned vertical above the label;
- * otherwise aligned horizontally.
- */
- public void setVertical(final boolean isVertical) {
- this.isVertical = isVertical;
- }
-
- @Override
- public void update(final ObjectAdapter object) {
- final View p = getParent();
- if (p != null) {
- p.invalidateLayout();
- }
- }
-}