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 2012/12/08 15:56:02 UTC
[30/53] [partial] ISIS-188: making structure of component viewers
consistent
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/NullFocusManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/NullFocusManager.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/NullFocusManager.java
new file mode 100644
index 0000000..941953f
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/NullFocusManager.java
@@ -0,0 +1,62 @@
+/*
+ * 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.viewer.basic;
+
+import org.apache.isis.viewer.dnd.view.FocusManager;
+import org.apache.isis.viewer.dnd.view.View;
+
+public class NullFocusManager implements FocusManager {
+ private View focus;
+
+ @Override
+ public void focusNextView() {
+ }
+
+ @Override
+ public void focusPreviousView() {
+ }
+
+ @Override
+ public void focusParentView() {
+ }
+
+ @Override
+ public void focusFirstChildView() {
+ }
+
+ @Override
+ public void focusLastChildView() {
+ }
+
+ @Override
+ public void focusInitialChildView() {
+ }
+
+ @Override
+ public View getFocus() {
+ return focus;
+ }
+
+ @Override
+ public void setFocus(final View view) {
+ focus = view;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/RootWorkspaceSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/RootWorkspaceSpecification.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/RootWorkspaceSpecification.java
new file mode 100644
index 0000000..b128419
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/RootWorkspaceSpecification.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.dnd.viewer.basic;
+
+import org.apache.isis.viewer.dnd.view.Axes;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.View;
+
+public class RootWorkspaceSpecification extends WorkspaceSpecification {
+ @Override
+ public View createView(final Content content, final Axes axes, final int sequence) {
+ View workspace;
+ workspace = super.createView(content, axes, sequence);
+ workspace.setFocusManager(new WorkspaceFocusManager());
+ return workspace;
+ }
+
+ @Override
+ public String getName() {
+ return "Root Workspace";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/SimpleIdentifier.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/SimpleIdentifier.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/SimpleIdentifier.java
new file mode 100644
index 0000000..177c1b2
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/SimpleIdentifier.java
@@ -0,0 +1,93 @@
+/*
+ * 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.viewer.basic;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+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.ContentDrag;
+import org.apache.isis.viewer.dnd.view.Toolkit;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.base.AbstractViewDecorator;
+
+public class SimpleIdentifier extends AbstractViewDecorator {
+
+ public SimpleIdentifier(final View wrappedView) {
+ super(wrappedView);
+ }
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ debug.append("SimpleIdentifier");
+ }
+
+ @Override
+ public void dragIn(final ContentDrag drag) {
+ wrappedView.dragIn(drag);
+ markDamaged();
+ }
+
+ @Override
+ public void dragOut(final ContentDrag drag) {
+ wrappedView.dragOut(drag);
+ markDamaged();
+ }
+
+ @Override
+ public void draw(final Canvas canvas) {
+ Color color = null;
+ if (getState().canDrop()) {
+ color = Toolkit.getColor(ColorsAndFonts.COLOR_VALID);
+ } else if (getState().cantDrop()) {
+ color = Toolkit.getColor(ColorsAndFonts.COLOR_INVALID);
+ } else if (getState().isViewIdentified() || getState().isObjectIdentified()) {
+ color = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
+ }
+
+ wrappedView.draw(canvas.createSubcanvas());
+
+ if (color != null) {
+ final Size s = getSize();
+ canvas.drawRectangle(0, 0, s.getWidth() - 1, s.getHeight() - 1, color);
+ canvas.drawRectangle(1, 1, s.getWidth() - 3, s.getHeight() - 3, color);
+ }
+ }
+
+ @Override
+ public void entered() {
+ getState().setContentIdentified();
+ wrappedView.entered();
+ markDamaged();
+ }
+
+ @Override
+ public void exited() {
+ getState().clearObjectIdentified();
+ wrappedView.exited();
+ markDamaged();
+ }
+
+ @Override
+ public String toString() {
+ return wrappedView.toString() + "/SimpleIdentifier";
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/TableFocusManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/TableFocusManager.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/TableFocusManager.java
new file mode 100755
index 0000000..5c355f9
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/TableFocusManager.java
@@ -0,0 +1,172 @@
+/*
+ * 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.viewer.basic;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.viewer.dnd.view.FocusManager;
+import org.apache.isis.viewer.dnd.view.View;
+
+public class TableFocusManager implements FocusManager {
+ private int row;
+ private int cell;
+ private final View table;
+
+ public TableFocusManager(final View table) {
+ this.table = table;
+
+ focusInitialChildView();
+ }
+
+ @Override
+ public void focusNextView() {
+ View r = table.getSubviews()[row];
+ View[] cells = r.getSubviews();
+ for (int j = cell + 1; j < cells.length; j++) {
+ if (cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ // setFocus(cells[cell]);
+ cells[j].markDamaged();
+ return;
+ }
+ }
+
+ row++;
+ if (row == table.getSubviews().length) {
+ row = 0;
+ }
+
+ r = table.getSubviews()[row];
+ cells = r.getSubviews();
+ for (int j = 0; j < cells.length; j++) {
+ if (cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ cells[j].markDamaged();
+ // setFocus(cells[cell]);
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void focusPreviousView() {
+ View r = table.getSubviews()[row];
+ View[] cells = r.getSubviews();
+ for (int j = cell - 1; j >= 0; j--) {
+ if (cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ cells[j].markDamaged();
+ return;
+ }
+ }
+
+ row--;
+ if (row == -1) {
+ row = table.getSubviews().length - 1;
+ }
+
+ r = table.getSubviews()[row];
+ cells = r.getSubviews();
+ for (int j = cells.length - 1; j >= 0; j--) {
+ if (cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ cells[j].markDamaged();
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void focusParentView() {
+ }
+
+ @Override
+ public void focusFirstChildView() {
+ }
+
+ @Override
+ public void focusLastChildView() {
+ }
+
+ @Override
+ public void focusInitialChildView() {
+ row = cell = 0;
+
+ final View[] rows = table.getSubviews();
+ if (rows.length > 0) {
+ row = 0;
+ final View[] cells = rows[0].getSubviews();
+ for (int j = 0; j < cells.length; j++) {
+ if (cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ cells[j].markDamaged();
+ // setFocus(cells[cell]);
+ return;
+ }
+ }
+ }
+ }
+
+ @Override
+ public View getFocus() {
+ final View[] rows = table.getSubviews();
+ if (row < 0 || row >= rows.length) {
+ return table;
+ }
+ final View rowView = rows[row];
+ final View[] cells = rowView.getSubviews();
+ if (cell < 0 || cell >= cells.length) {
+ return rowView;
+ }
+ return cells[cell];
+ }
+
+ @Override
+ public void setFocus(final View view) {
+ if (view == table) {
+ return;
+ }
+
+ final View[] rows = table.getSubviews();
+ for (row = 0; row < rows.length; row++) {
+ final View[] cells = rows[row].getSubviews();
+ for (int j = 0; j < cells.length; j++) {
+ if (view == cells[j] && cells[j].canFocus()) {
+ cells[cell].markDamaged();
+ cell = j;
+ cells[j].markDamaged();
+ return;
+ }
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ final ToString str = new ToString(this);
+ str.append("row", row);
+ str.append("cell", cell);
+ return str.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/UnlinedTextFieldSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/UnlinedTextFieldSpecification.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/UnlinedTextFieldSpecification.java
new file mode 100644
index 0000000..767ce0b
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/UnlinedTextFieldSpecification.java
@@ -0,0 +1,54 @@
+/*
+ * 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.viewer.basic;
+
+import org.apache.isis.viewer.dnd.field.SingleLineTextField;
+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.base.AbstractFieldSpecification;
+import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
+
+/**
+ * Creates a single line text field without the baseline being drawn.
+ */
+public class UnlinedTextFieldSpecification extends AbstractFieldSpecification {
+ @Override
+ public boolean canDisplay(final ViewRequirement requirement) {
+ return requirement.isTextParseable() && ((TextParseableContent) requirement.getContent()).getNoLines() == 1;
+ }
+
+ @Override
+ public View createView(final Content content, final Axes axes, final int sequence) {
+ return new SingleLineTextField((TextParseableContent) content, this, false);
+ }
+
+ @Override
+ public String getName() {
+ return "Single Line Text Field";
+ }
+
+ @Override
+ public boolean isAligned() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceFocusManager.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceFocusManager.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceFocusManager.java
new file mode 100755
index 0000000..4694c3f
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceFocusManager.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.dnd.viewer.basic;
+
+import org.apache.isis.viewer.dnd.view.FocusManager;
+import org.apache.isis.viewer.dnd.view.View;
+
+public class WorkspaceFocusManager implements FocusManager {
+
+ public WorkspaceFocusManager() {
+ super();
+ }
+
+ @Override
+ public void focusNextView() {
+ }
+
+ @Override
+ public void focusPreviousView() {
+ }
+
+ @Override
+ public void focusParentView() {
+ }
+
+ @Override
+ public void focusFirstChildView() {
+ }
+
+ @Override
+ public void focusLastChildView() {
+ }
+
+ @Override
+ public void focusInitialChildView() {
+ }
+
+ @Override
+ public View getFocus() {
+ return null;
+ }
+
+ @Override
+ public void setFocus(final View view) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceSpecification.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceSpecification.java
new file mode 100644
index 0000000..1f99910
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WorkspaceSpecification.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.dnd.viewer.basic;
+
+import org.apache.isis.viewer.dnd.service.PerspectiveContent;
+import org.apache.isis.viewer.dnd.view.Axes;
+import org.apache.isis.viewer.dnd.view.CompositeViewSpecification;
+import org.apache.isis.viewer.dnd.view.Content;
+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.Workspace;
+import org.apache.isis.viewer.dnd.view.base.Layout;
+import org.apache.isis.viewer.dnd.view.composite.ViewBuilder;
+
+public class WorkspaceSpecification implements CompositeViewSpecification {
+ ApplicationWorkspaceBuilder builder = new ApplicationWorkspaceBuilder();
+
+ @Override
+ public View createView(final Content content, final Axes axes, final int sequence) {
+ Workspace workspace;
+ workspace = new ApplicationWorkspace(content, axes, this, createLayout(content, axes), builder);
+ // workspace.setFocusManager(new WorkspaceFocusManager());
+ return workspace;
+ }
+
+ public Layout createLayout(final Content content, final Axes axes) {
+ return new ApplicationWorkspaceBuilder.ApplicationLayout();
+ }
+
+ public void createAxes(final Content content, final Axes axes) {
+ }
+
+ public ViewAxis axis(final Content content) {
+ return null;
+ }
+
+ public ViewBuilder getSubviewBuilder() {
+ return builder;
+ }
+
+ @Override
+ public String getName() {
+ return "Root Workspace";
+ }
+
+ @Override
+ public boolean isAligned() {
+ return false;
+ }
+
+ @Override
+ public boolean isOpen() {
+ return true;
+ }
+
+ @Override
+ public boolean isReplaceable() {
+ return false;
+ }
+
+ @Override
+ public boolean isResizeable() {
+ return false;
+ }
+
+ @Override
+ public boolean isSubView() {
+ return false;
+ }
+
+ @Override
+ public boolean canDisplay(final ViewRequirement requirement) {
+ return requirement.isFor(PerspectiveContent.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WrappedTextFieldSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WrappedTextFieldSpecification.java b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WrappedTextFieldSpecification.java
new file mode 100644
index 0000000..790ab6a
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/viewer/basic/WrappedTextFieldSpecification.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.dnd.viewer.basic;
+
+import org.apache.isis.viewer.dnd.field.WrappedTextField;
+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.base.AbstractFieldSpecification;
+import org.apache.isis.viewer.dnd.view.border.TextFieldResizeBorder;
+import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
+
+public class WrappedTextFieldSpecification extends AbstractFieldSpecification {
+ @Override
+ public boolean canDisplay(final ViewRequirement requirement) {
+ return requirement.isTextParseable() && ((TextParseableContent) requirement.getContent()).getNoLines() > 1;
+ }
+
+ @Override
+ public View createView(final Content content, final Axes axes, final int sequence) {
+ final WrappedTextField wrappedTextField = new WrappedTextField((TextParseableContent) content, this, true);
+ wrappedTextField.setNoLines(((TextParseableContent) content).getNoLines());
+ wrappedTextField.setWrapping(((TextParseableContent) content).canWrap());
+ return new TextFieldResizeBorder(wrappedTextField);
+ }
+
+ @Override
+ public String getName() {
+ return "Wrapped Text Field";
+ }
+
+ @Override
+ public boolean isAligned() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/application-error.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/application-error.png b/component/viewer/dnd/impl/src/main/resources/images/application-error.png
new file mode 100644
index 0000000..7233d45
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/application-error.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/application-logo.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/application-logo.png b/component/viewer/dnd/impl/src/main/resources/images/application-logo.png
new file mode 100755
index 0000000..a211397
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/application-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/busy-old.gif
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/busy-old.gif b/component/viewer/dnd/impl/src/main/resources/images/busy-old.gif
new file mode 100644
index 0000000..80ff48b
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/busy-old.gif differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/busy.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/busy.png b/component/viewer/dnd/impl/src/main/resources/images/busy.png
new file mode 100644
index 0000000..a574c30
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/busy.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/button1.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/button1.png b/component/viewer/dnd/impl/src/main/resources/images/button1.png
new file mode 100644
index 0000000..8fdef85
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/button1.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/button2.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/button2.png b/component/viewer/dnd/impl/src/main/resources/images/button2.png
new file mode 100644
index 0000000..9c0fd5e
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/button2.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/button3.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/button3.png b/component/viewer/dnd/impl/src/main/resources/images/button3.png
new file mode 100644
index 0000000..aa2ebb5
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/button3.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/button4.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/button4.png b/component/viewer/dnd/impl/src/main/resources/images/button4.png
new file mode 100644
index 0000000..bd1503e
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/button4.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/check-mark.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/check-mark.png b/component/viewer/dnd/impl/src/main/resources/images/check-mark.png
new file mode 100644
index 0000000..8c82dd3
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/check-mark.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/concurrency-error.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/concurrency-error.png b/component/viewer/dnd/impl/src/main/resources/images/concurrency-error.png
new file mode 100644
index 0000000..428aaa5
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/concurrency-error.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/day2.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/day2.png b/component/viewer/dnd/impl/src/main/resources/images/day2.png
new file mode 100644
index 0000000..7fb2692
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/day2.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/decadedown.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/decadedown.png b/component/viewer/dnd/impl/src/main/resources/images/decadedown.png
new file mode 100644
index 0000000..14f6eb0
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/decadedown.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/decadeup.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/decadeup.png b/component/viewer/dnd/impl/src/main/resources/images/decadeup.png
new file mode 100644
index 0000000..559c859
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/decadeup.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/empty-field.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/empty-field.png b/component/viewer/dnd/impl/src/main/resources/images/empty-field.png
new file mode 100644
index 0000000..542237a
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/empty-field.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/highlight2.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/highlight2.png b/component/viewer/dnd/impl/src/main/resources/images/highlight2.png
new file mode 100644
index 0000000..7e25493
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/highlight2.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/invalid-entry.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/invalid-entry.png b/component/viewer/dnd/impl/src/main/resources/images/invalid-entry.png
new file mode 100644
index 0000000..a9e4ff3
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/invalid-entry.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/login-logo.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/login-logo.png b/component/viewer/dnd/impl/src/main/resources/images/login-logo.png
new file mode 100755
index 0000000..a211397
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/login-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/message.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/message.png b/component/viewer/dnd/impl/src/main/resources/images/message.png
new file mode 100644
index 0000000..2ac5747
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/message.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/monthdown.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/monthdown.png b/component/viewer/dnd/impl/src/main/resources/images/monthdown.png
new file mode 100644
index 0000000..9a737a6
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/monthdown.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/monthup.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/monthup.png b/component/viewer/dnd/impl/src/main/resources/images/monthup.png
new file mode 100644
index 0000000..7f5c976
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/monthup.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/shutdown-logo.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/shutdown-logo.png b/component/viewer/dnd/impl/src/main/resources/images/shutdown-logo.png
new file mode 100755
index 0000000..a211397
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/shutdown-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/system-error.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/system-error.png b/component/viewer/dnd/impl/src/main/resources/images/system-error.png
new file mode 100644
index 0000000..cdd95ba
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/system-error.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/transient.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/transient.png b/component/viewer/dnd/impl/src/main/resources/images/transient.png
new file mode 100644
index 0000000..43f034b
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/transient.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/unknown.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/unknown.png b/component/viewer/dnd/impl/src/main/resources/images/unknown.png
new file mode 100644
index 0000000..096e848
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/unknown.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/yeardown.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/yeardown.png b/component/viewer/dnd/impl/src/main/resources/images/yeardown.png
new file mode 100644
index 0000000..b18eaca
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/yeardown.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/resources/images/yearup.png
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/resources/images/yearup.png b/component/viewer/dnd/impl/src/main/resources/images/yearup.png
new file mode 100644
index 0000000..94a98e9
Binary files /dev/null and b/component/viewer/dnd/impl/src/main/resources/images/yearup.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/ExampleContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/ExampleContent.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/ExampleContent.java
new file mode 100644
index 0000000..ab1de66
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/ExampleContent.java
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.Veto;
+import org.apache.isis.noa.spec.ObjectSpecification;
+import org.apache.isis.noa.util.DebugString;
+import org.apache.isis.viewer.dnd.drawing.Image;
+
+
+public class ExampleContent implements Content {
+
+ private String iconName;
+ private String title;
+ private String windowTitle;
+
+ public Consent canDrop(final Content sourceContent) {
+ return Veto.DEFAULT;
+ }
+
+ public void debugDetails(final DebugString debug) {}
+
+ public ObjectAdapter drop(final Content sourceContent) {
+ return null;
+ }
+
+ public String getIconName() {
+ return iconName;
+ }
+
+ public Image getIconPicture(final int iconHeight) {
+ return null;
+ }
+
+ public ObjectAdapter getAdapter() {
+ return null;
+ }
+
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+ public boolean isCollection() {
+ return false;
+ }
+
+ public boolean isObject() {
+ return false;
+ }
+
+ public boolean isPersistable() {
+ return false;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public boolean isTextParseable() {
+ return false;
+ }
+
+ public void contentMenuOptions(final UserActionSet options) {}
+
+ public void parseTextEntry(final String entryText) {}
+
+ public void setupIconName(final String iconName) {
+ this.iconName = iconName;
+ }
+
+ public void setupTitle(final String title) {
+ this.title = title;
+ }
+
+ public void setupWindowTitle(final String windowTitle) {
+ this.windowTitle = windowTitle;
+ }
+
+ public String title() {
+ return title;
+ }
+
+ public String windowTitle() {
+ return windowTitle;
+ }
+
+ public String getDescription() {
+ return "";
+ }
+
+ public String getId() {
+ return "";
+ }
+
+ public void viewMenuOptions(final UserActionSet options) {}
+
+ public String getHelp() {
+ return null;
+ }
+
+ public ObjectAdapter[] getOptions() {
+ return null;
+ }
+
+ public boolean isOptionEnabled() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ButtonExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ButtonExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ButtonExample.java
new file mode 100644
index 0000000..2836d7a
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ButtonExample.java
@@ -0,0 +1,117 @@
+/*
+ * 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.example;
+
+import org.apache.isis.noa.reflect.Allow;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.ObjectActionType;
+import org.apache.isis.noa.reflect.Veto;
+import org.apache.isis.viewer.dnd.ButtonAction;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.Workspace;
+import org.apache.isis.viewer.dnd.action.Button;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.example.view.TestViews;
+
+
+public class ButtonExample extends TestViews {
+
+ public static void main(final String[] args) {
+ new ButtonExample();
+ }
+
+ protected void views(final Workspace workspace) {
+ ButtonAction action = new ButtonAction() {
+
+ public Consent disabled(final View view) {
+ return Allow.DEFAULT;
+ }
+
+ public void execute(final Workspace workspace, final View view, final Location at) {
+ view.getFeedbackManager().setAction("Button 1 pressed");
+ }
+
+ public String getDescription(final View view) {
+ return "Button that can be pressed";
+ }
+
+ public ObjectActionType getType() {
+ return USER;
+ }
+
+ public String getName(final View view) {
+ return "Action";
+ }
+
+ public boolean isDefault() {
+ return true;
+ }
+
+ public String getHelp(final View view) {
+ return null;
+ }
+ };
+
+ View view = new Button(action, workspace);
+ view.setLocation(new Location(100, 100));
+ view.setSize(view.getRequiredSize(new Size()));
+ workspace.addView(view);
+
+ ButtonAction action2 = new ButtonAction() {
+
+ public Consent disabled(final View view) {
+ return Veto.DEFAULT;
+ }
+
+ public void execute(final Workspace workspace, final View view, final Location at) {
+ view.getFeedbackManager().setViewDetail("Button 1 pressed");
+ }
+
+ public String getDescription(final View view) {
+ return "Button that can't be pressed";
+ }
+
+ public ObjectActionType getType() {
+ return USER;
+ }
+
+ public String getName(final View view) {
+ return "Press Me Now!";
+ }
+
+ public boolean isDefault() {
+ return false;
+ }
+
+ public String getHelp(final View view) {
+ return null;
+ }
+
+ };
+
+ View view2 = new Button(action2, workspace);
+ view2.setLocation(new Location(200, 100));
+ view2.setSize(view2.getRequiredSize(new Size()));
+ workspace.addView(view2);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/CanvasExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/CanvasExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/CanvasExample.java
new file mode 100644
index 0000000..8275644
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/CanvasExample.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.viewer.dnd.example;
+
+import org.apache.isis.nof.core.util.IsisConfiguration;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.Workspace;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.example.view.TestViews;
+
+
+public class CanvasExample extends TestViews {
+
+ public static void main(final String[] args) {
+ new CanvasExample();
+
+ }
+
+ protected void configure(final IsisConfiguration configuration) {
+ configuration.add("isis.viewer.skylark.ascent-adjust", "true");
+ }
+
+ protected void views(final Workspace workspace) {
+ // AbstractView.debug = true;
+
+ View view = new TestCanvasView();
+ view.setLocation(new Location(50, 60));
+ view.setSize(new Size(216, 300));
+ workspace.addView(view);
+
+ view = new TestCanvasView();
+ view.setLocation(new Location(300, 60));
+ view.setSize(new Size(216, 300));
+ workspace.addView(view);
+
+ view = new TestCanvasView2();
+ view.setLocation(new Location(570, 60));
+ view.setSize(new Size(50, 70));
+ workspace.addView(view);
+
+ view = new TestCanvasView2();
+ view.setLocation(new Location(570, 160));
+ view.setSize(new Size(8, 5));
+ workspace.addView(view);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ColorsAndFontsExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ColorsAndFontsExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ColorsAndFontsExample.java
new file mode 100644
index 0000000..3ab5422
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ColorsAndFontsExample.java
@@ -0,0 +1,113 @@
+/*
+ * 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.example;
+
+import org.apache.isis.nof.core.context.IsisContext;
+import org.apache.isis.nof.core.image.java.AwtTemplateImageLoaderInstaller;
+import org.apache.isis.nof.testsystem.TestProxyConfiguration;
+import org.apache.isis.extensions.dndviewer.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.Toolkit;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.image.ImageFactory;
+import org.apache.isis.viewer.dnd.viewer.AwtColor;
+import org.apache.isis.viewer.dnd.viewer.AwtText;
+import org.apache.isis.viewer.dnd.viewer.AwtToolkit;
+
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.event.WindowAdapter;
+
+
+public class ColorsAndFontsExample extends Frame {
+ private static final int SPACE = 22;
+ private Color[] colors;
+ private Text[] fonts;
+
+ public ColorsAndFontsExample(final String title) {
+ super(title);
+
+ colors = new Color[] { Toolkit.getColor("black"), Toolkit.getColor("white"), Toolkit.getColor("primary1"),
+ Toolkit.getColor("primary2"), Toolkit.getColor("primary3"), Toolkit.getColor("secondary1"),
+ Toolkit.getColor("secondary2"), Toolkit.getColor("secondary3"),
+
+ Toolkit.getColor("background.application"), Toolkit.getColor("background.window"),
+ Toolkit.getColor("background.content-menu"), Toolkit.getColor("background.value-menu"),
+ Toolkit.getColor("background.view-menu"), Toolkit.getColor("background.workspace-menu"),
+
+ Toolkit.getColor("menu.normal"), Toolkit.getColor("menu.disabled"), Toolkit.getColor("menu.reversed"),
+
+ Toolkit.getColor("text.edit"), Toolkit.getColor("text.cursor"), Toolkit.getColor("text.highlight"),
+ Toolkit.getColor("text.saved"),
+
+ Toolkit.getColor("identified"), Toolkit.getColor("invalid"), Toolkit.getColor("out-of-sync"),
+ Toolkit.getColor("error"), Toolkit.getColor("valid"), Toolkit.getColor("active"), };
+
+ fonts = new Text[] { Toolkit.getText(ColorsAndFonts.TEXT_ICON), Toolkit.getText(ColorsAndFonts.TEXT_CONTROL),
+ Toolkit.getText(ColorsAndFonts.TEXT_TITLE_SMALL), Toolkit.getText(ColorsAndFonts.TEXT_LABEL),
+ Toolkit.getText(ColorsAndFonts.TEXT_MENU), Toolkit.getText(ColorsAndFonts.TEXT_NORMAL),
+ Toolkit.getText(ColorsAndFonts.TEXT_STATUS), Toolkit.getText(ColorsAndFonts.TEXT_TITLE) };
+ }
+
+ public static void main(final String[] args) {
+ IsisContext.setConfiguration(new TestProxyConfiguration());
+
+ new ImageFactory(new AwtTemplateImageLoaderInstaller().createLoader());
+ new AwtToolkit();
+
+ final ColorsAndFontsExample f = new ColorsAndFontsExample("Colors and Fonts");
+ f.setSize(800, 600);
+ f.show();
+
+ f.addWindowListener(new WindowAdapter() {
+ public void windowClosing(final java.awt.event.WindowEvent e) {
+ f.dispose();
+ }
+ });
+ }
+
+ public Insets getInsets() {
+ return new Insets(30, 10, 30, 10);
+ }
+
+ public void paint(final Graphics g) {
+ int x = 10;
+
+ for (int i = 0; i < colors.length; i++) {
+ g.setColor(java.awt.Color.black);
+ g.drawString(colors[i].getName(), x, 50 + SPACE * i);
+
+ g.setColor(((AwtColor) colors[i]).getAwtColor());
+ g.fillRect(x + 200, 40 + SPACE * i, 40, 12);
+ }
+
+ x += 300;
+ g.setColor(java.awt.Color.black);
+ for (int i = 0; i < fonts.length; i++) {
+ g.setFont(((AwtText) fonts[i]).getAwtFont());
+ g.drawString(fonts[i].getName(), x, 50 + SPACE * i);
+ g.drawString("Abcdefghijkl", x + 200, 50 + SPACE * i);
+
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/DrawingView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/DrawingView.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/DrawingView.java
new file mode 100644
index 0000000..825607e
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/DrawingView.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.viewer.dnd.example;
+
+import org.apache.isis.nof.core.util.AsString;
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.Toolkit;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.view.simple.AbstractView;
+
+
+public abstract class DrawingView extends AbstractView {
+ private Size requiredSize;
+
+ public DrawingView(final Content content) {
+ super(content, null, null);
+ }
+
+ public void draw(final Canvas canvas) {
+ final int width = requiredSize.getWidth();
+ final int height = requiredSize.getHeight();
+ final int left = 0, top = 0;
+ final int right = 10 + width - 1 + 10;
+ final int bottom = 10 + height - 1 + 10;
+
+ Color gray = Toolkit.getColor(0xcccccc);
+ // horizontal lines
+ canvas.drawLine(left, top + 10, right, top + 10, gray);
+ canvas.drawLine(left, bottom - 10, right, bottom - 10, gray);
+
+ // vertical lines
+ canvas.drawLine(left + 10, top, left + 10, bottom, gray);
+ canvas.drawLine(right - 10, top, right - 10, bottom, gray);
+
+ canvas.drawRectangle(left + 10, top + 10, width - 1, height - 1, Toolkit.getColor(0xeeeeee));
+
+ draw(canvas, left + 10, top + 10);
+ }
+
+ protected abstract void draw(final Canvas canvas, final int x, final int y);
+
+ public Size getRequiredSize(final Size maximumSize) {
+ Size s = new Size(requiredSize);
+ s.extend(20, 20);
+ return s;
+ }
+
+ public void setMaximumSize(final Size size) {
+ this.requiredSize = size;
+ }
+
+ public String toString() {
+ AsString ts = new AsString(this);
+ ts.append("size", requiredSize);
+ toString(ts);
+ return ts.toString();
+ }
+
+ protected abstract void toString(final AsString ts);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ExampleViewSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ExampleViewSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ExampleViewSpecification.java
new file mode 100644
index 0000000..306d311
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/ExampleViewSpecification.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.viewer.dnd.example;
+
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+
+
+public class ExampleViewSpecification implements ViewSpecification {
+
+ public View createView(final Content content, final ViewAxis axis) {
+ return null;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public boolean isAligned() {
+ return false;
+ }
+
+ public boolean isOpen() {
+ return false;
+ }
+
+ public boolean isReplaceable() {
+ return false;
+ }
+
+ public boolean isSubView() {
+ return false;
+ }
+
+ public boolean canDisplay(final Content content) {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/FontMetricsExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/FontMetricsExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/FontMetricsExample.java
new file mode 100644
index 0000000..f29e675
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/FontMetricsExample.java
@@ -0,0 +1,111 @@
+/*
+ * 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.example;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Toolkit;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.font.LineMetrics;
+
+
+public class FontMetricsExample extends Frame {
+
+ public static void main(final String[] args) {
+ final FontMetricsExample frame = new FontMetricsExample();
+ frame.setSize(400, 400);
+ frame.show();
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(final WindowEvent e) {
+ frame.dispose();
+ }
+ });
+
+ String fonts[] = Toolkit.getDefaultToolkit().getFontList();
+ for (int i = 0; i < fonts.length; i++) {
+ System.out.println(fonts[i].toString());
+ }
+ }
+
+ final int left = 40 + getInsets().left;
+ final int top = 60 + getInsets().top;
+ final int width = 300;
+
+ public void show() {
+ super.show();
+ // left = 10 + getInsets().left;
+ // top = 10 + getInsets().top;
+ }
+
+ public void paint(final Graphics g) {
+ System.out.println("\nfont size: height = leading + ascent + descent\n max_ascent + max_descent");
+ int sizes[] = new int[] { 10, 12, 16, 24, 26, 48, 60 };
+ int y = top;
+ for (int i = 0; i < sizes.length; i++) {
+ y += drawText(g, y, sizes[i]);
+ }
+ }
+
+ private int drawText(final Graphics g, final int top, final int size) {
+ Font font = new Font("sansserif", 0, size);
+ g.setFont(font);
+ FontMetrics fm = g.getFontMetrics();
+
+ int lineHeight = fm.getHeight();
+ int baselineOffset = fm.getLeading() + fm.getAscent();
+
+ g.setColor(Color.LIGHT_GRAY);
+ g.drawRect(left - 10, top, width + 20, lineHeight - 1);
+
+ g.setColor(Color.LIGHT_GRAY);
+ g.drawLine(left - 10, top + baselineOffset, left + 10 + width, top + baselineOffset);
+
+ g.setColor(Color.BLUE);
+ g.drawLine(left, top + fm.getLeading(), left + width, top + fm.getLeading());
+
+ g.setColor(Color.GREEN);
+ g.drawLine(left, top + baselineOffset + fm.getDescent(), left + width, top + baselineOffset + fm.getDescent());
+
+ g.setColor(Color.RED);
+ g.drawLine(left, top + baselineOffset - fm.getAscent() - 1, left + width, top + baselineOffset - fm.getAscent() -1);
+
+ g.setColor(Color.ORANGE);
+ g.drawLine(left, top + fm.getDescent(), left + width, top + fm.getDescent());
+
+
+ g.setColor(Color.BLACK);
+ g.drawString("Xy � \u00c3", left, top + baselineOffset);
+
+ System.out.println(font.getFontName() + " " + size + ": " + fm.getHeight() + " = " + fm.getLeading() + " + " + fm.getAscent() + " + "
+ + fm.getDescent());
+ System.out.println(" " + fm.getMaxAscent() + " + " + fm.getMaxDescent());
+
+ LineMetrics lm = fm.getLineMetrics("test", g);
+
+ System.out.println(" " + lm.getLeading() + " " + lm.getAscent() + " + " + lm.getDescent());
+
+ return fm.getHeight() + 14;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/HelpViewExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/HelpViewExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/HelpViewExample.java
new file mode 100644
index 0000000..356f012
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/HelpViewExample.java
@@ -0,0 +1,60 @@
+/*
+ * 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.example;
+
+import org.apache.isis.nof.core.util.IsisConfiguration;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.Workspace;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.example.view.TestViews;
+import org.apache.isis.viewer.dnd.view.help.HelpView;
+
+
+public class HelpViewExample extends TestViews {
+
+ public static void main(final String[] args) {
+ new HelpViewExample();
+
+ }
+
+ protected void configure(final IsisConfiguration configuration) {
+ configuration.add("isis.viewer.skylark.ascent-adjust", "true");
+ }
+
+ protected void views(final Workspace workspace) {
+ // AbstractView.debug = true;
+
+ View view = new HelpView("Name", "Description summerising the named feature", "A very log help text");
+ view.setLocation(new Location(50, 60));
+ view.setSize(view.getMaximumSize());
+ workspace.addView(view);
+ /*
+ * view = new TestCanvasView(); view.setLocation(new Location(300, 60)); view.setSize(new Size(216,
+ * 300)); workspace.addView(view);
+ *
+ * view = new TestCanvasView2(); view.setLocation(new Location(570, 60)); view.setSize(new Size(50,
+ * 70)); workspace.addView(view);
+ *
+ * view = new TestCanvasView2(); view.setLocation(new Location(570, 160)); view.setSize(new Size(8,
+ * 5)); workspace.addView(view);
+ */}
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/IconGraphicExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/IconGraphicExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/IconGraphicExample.java
new file mode 100644
index 0000000..da685be
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/IconGraphicExample.java
@@ -0,0 +1,178 @@
+/*
+ * 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.example;
+
+import org.apache.isis.nof.core.util.AsString;
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.ExampleContent;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.Workspace;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.drawing.Text;
+import org.apache.isis.viewer.dnd.example.view.TestViews;
+import org.apache.isis.viewer.dnd.view.graphic.IconGraphic;
+import org.apache.isis.viewer.dnd.viewer.AwtColor;
+import org.apache.isis.viewer.dnd.viewer.AwtText;
+
+
+public class IconGraphicExample extends TestViews {
+
+ public static void main(final String[] args) {
+ new IconGraphicExample();
+ }
+
+ protected void views(final Workspace workspace) {
+ ExampleContent content = new ExampleContent();
+ content.setupIconName("icon-a");
+
+ int[] size = new int[] { 12, 20, 40, 60, 85, 100 };
+ int x = 160;
+ for (int i = 0; i < size.length; i++) {
+ View view = new ExampleIconView(content, size[i]);
+ view.setLocation(new Location(x, 80));
+ x += view.getRequiredSize(new Size()).getWidth() + 15;
+ view.setSize(view.getRequiredSize(new Size()));
+ workspace.addView(view);
+ }
+
+ x = 160;
+ for (int i = 0; i < size.length; i++) {
+ View view = new ExampleClassIconView(content, size[i]);
+ view.setLocation(new Location(x, 230));
+ x += view.getRequiredSize(new Size()).getWidth() + 15;
+ view.setSize(view.getRequiredSize(new Size()));
+ workspace.addView(view);
+ }
+
+ size = new int[] { 10, 12, 14, 16, 18, 20, 24, 36, 60 };
+ int y = 80;
+ for (int i = 0; i < size.length; i++) {
+ View view = new ExampleIconViewWithText(content, new ExampleText("Arial-plain-" + size[i]), true);
+ view.setLocation(new Location(10, y));
+ y += view.getRequiredSize(new Size()).getHeight() + 10;
+ view.setSize(view.getRequiredSize(new Size()));
+ workspace.addView(view);
+ }
+
+ y = 80;
+ for (int i = 0; i < size.length; i++) {
+ View view = new ExampleIconViewWithText(content, new ExampleText("Arial-plain-" + size[i]), false);
+ view.setLocation(new Location(600, y));
+ y += view.getRequiredSize(new Size()).getHeight() + 10;
+ view.setSize(view.getRequiredSize(new Size()));
+ workspace.addView(view);
+ }
+ }
+}
+
+class ExampleText extends AwtText {
+
+ protected ExampleText(final String font) {
+ super("dont-find", font);
+ }
+
+}
+
+class ExampleIconView extends DrawingView {
+ private IconGraphic icon;
+
+ public ExampleIconView(final Content content, final int size) {
+ super(content);
+ icon = new IconGraphic(this, size, 0);
+ setMaximumSize(icon.getSize());
+ }
+
+ protected void draw(final Canvas canvas, final int x, final int y) {
+ int baseline = icon.getBaseline() + 10;
+ icon.draw(canvas, x, baseline);
+ // canvas.drawLine(x, baseline, 40, baseline, Color.RED);
+ }
+
+ protected void toString(final AsString ts) {
+ ts.append("icon", icon.getSize());
+ ts.append("baseline", icon.getBaseline());
+ }
+}
+
+class ExampleIconViewWithText extends DrawingView {
+ private final IconGraphic icon;
+ private final Text text;
+ private final String string = "OpqrST";
+ private final boolean showBounds;
+
+ public ExampleIconViewWithText(final Content content, final Text text, final boolean showBounds) {
+ super(content);
+ this.text = text;
+ this.showBounds = showBounds;
+ icon = new IconGraphic(this, text);
+ Size size = icon.getSize();
+ size.extendWidth(text.stringWidth(string));
+ setMaximumSize(size);
+ }
+
+ protected void draw(final Canvas canvas, final int x, final int y) {
+ int baseline = icon.getBaseline() + y;
+ // int baseline = - (text.getAscent() - text.getDescent() - icon.getSize().getHeight()) / 2;
+ if (showBounds) {
+ int right = getRequiredSize(new Size()).getWidth();
+
+ int centre = y + icon.getSize().getHeight() / 2;
+ canvas.drawLine(x, centre, right, centre, AwtColor.BLACK);
+
+ int ascendTo = baseline - text.getAscent() + text.getDescent();
+ int descendTo = baseline + text.getDescent();
+ int midline = baseline - (text.getAscent() - text.getDescent()) / 2;
+ canvas.drawLine(0, ascendTo, right, ascendTo, AwtColor.RED);
+ canvas.drawLine(0, midline, right, midline, AwtColor.WHITE);
+ canvas.drawLine(0, baseline, right, baseline, AwtColor.RED);
+ canvas.drawLine(0, descendTo, right, descendTo, AwtColor.RED);
+ }
+ canvas.drawText(string, x + icon.getSize().getWidth(), baseline, AwtColor.BLACK, text);
+ icon.draw(canvas, x, baseline);
+ }
+
+ protected void toString(final AsString ts) {
+ ts.append("icon", icon.getSize());
+ ts.append("baseline", icon.getBaseline());
+ }
+}
+
+class ExampleClassIconView extends DrawingView {
+ private IconGraphic icon;
+
+ public ExampleClassIconView(final Content content, final int size) {
+ super(content);
+ icon = new IconGraphic(this, size, 0);
+ setMaximumSize(icon.getSize());
+ }
+
+ protected void draw(final Canvas canvas, final int x, final int y) {
+ int baseline = icon.getBaseline() + 10;
+ icon.draw(canvas, x, baseline);
+ }
+
+ protected void toString(final AsString ts) {
+ ts.append("icon", icon.getSize());
+ ts.append("baseline", icon.getBaseline());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/MouseEventExample.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/MouseEventExample.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/MouseEventExample.java
new file mode 100644
index 0000000..1f929f3
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/MouseEventExample.java
@@ -0,0 +1,78 @@
+/*
+ * 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.example;
+
+import java.awt.Frame;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+
+public class MouseEventExample extends Frame {
+
+ public static void main(final String[] args) {
+ final MouseEventExample frame = new MouseEventExample();
+ frame.setSize(300, 400);
+ frame.show();
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(final WindowEvent e) {
+ frame.dispose();
+ }
+ });
+
+ frame.addMouseListener(new Mouse());
+ }
+
+ int left = 10 + getInsets().left;
+ int top = 40 + getInsets().top;
+ int width = 100;
+ int height;
+
+ public void show() {
+ super.show();
+ left = 10 + getInsets().left;
+ top = 10 + getInsets().top;
+ }
+}
+
+class Mouse implements MouseListener {
+
+ public void mouseClicked(MouseEvent e) {
+ System.out.print(e.isPopupTrigger() ? "POPUP " : "");
+ System.out.println(e);
+ }
+
+ public void mouseEntered(MouseEvent e) {}
+
+ public void mouseExited(MouseEvent e) {}
+
+ public void mousePressed(MouseEvent e) {
+ System.out.print(e.isPopupTrigger() ? "POPUP " : "");
+ System.out.println(e);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ System.out.print(e.isPopupTrigger() ? "POPUP " : "");
+ System.out.println(e);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView.java
new file mode 100644
index 0000000..9824e90
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView.java
@@ -0,0 +1,171 @@
+/*
+ * 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.example;
+
+import org.apache.isis.extensions.dndviewer.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Click;
+import org.apache.isis.viewer.dnd.Drag;
+import org.apache.isis.viewer.dnd.DragStart;
+import org.apache.isis.viewer.dnd.Toolkit;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.view.simple.AbstractView;
+
+
+class TestCanvasView extends AbstractView {
+ Color white = Toolkit.getColor(0xffffff);
+ Color black = Toolkit.getColor(0);
+ Color gray = Toolkit.getColor(0xaaaaaa);
+ Color lightGray = Toolkit.getColor(0xdddddd);
+ Color red = Toolkit.getColor(0xff0000);
+ Color green = Toolkit.getColor(0x00ff00);
+ Color blue = Toolkit.getColor(0x0000ff);
+ Color yellow = Toolkit.getColor(0xff00ff);
+
+ public void draw(final Canvas canvas) {
+ canvas.clearBackground(this, white);
+
+ int canvasWidth = getSize().getWidth();
+ int canvasHeight = getSize().getHeight();
+
+ canvas.drawRectangle(0, 0, canvasWidth, canvasHeight, black);
+
+ int x = 10;
+ int y = 10;
+ int width = 50;
+ int height = 90;
+ // outline shapes
+ canvas.drawRectangle(x, y, width, height, gray);
+ canvas.drawRoundedRectangle(x, y, width, height, 20, 20, black);
+ canvas.drawOval(x, y, width, height, green);
+ canvas.drawLine(x, y, x + width - 1, y + height - 1, red);
+ canvas.drawLine(x, y + height - 1, x + width - 1, y, red);
+
+ // subcanvas
+ x = 80;
+ canvas.drawRectangle(x, y, width, height, gray);
+
+ Canvas subcanvas = canvas.createSubcanvas(x + 1, y + 1, width - 1, height - 1);
+ subcanvas.drawRectangle(0, 0, width - 2, height - 2, blue);
+
+ x = 150;
+ canvas.drawRectangle(x, y, width, height, gray);
+
+ subcanvas = canvas.createSubcanvas(x + 1, y + 1, width - 1, height - 1);
+ subcanvas.offset(-100, -200);
+
+ subcanvas.drawRectangle(100, 200, width - 2, height - 2, red);
+ subcanvas.drawRectangle(0, 0, 120, 220, green);
+
+ // solid shapes
+ x = 10;
+ y = 105;
+
+ canvas.drawRectangle(x - 1, y - 1, width + 2, height + 2, gray);
+ canvas.drawSolidRectangle(x, y, width, height, black);
+ canvas.drawSolidOval(x, y, width, height, green);
+ canvas.drawLine(x, y, x + width - 1, y + height - 1, red);
+ canvas.drawLine(x, y + height - 1, x + width - 1, y, red);
+
+ x = 80;
+ canvas.drawSolidRectangle(x, y, width, height, black);
+
+ subcanvas = canvas.createSubcanvas(x + 1, y + 1, width - 1, height - 1);
+ subcanvas.drawSolidRectangle(0, 0, width - 2, height - 2, blue);
+
+ x = 150;
+ canvas.drawRectangle(x, y, width, width, black);
+ canvas.drawOval(x, y, width, width, green);
+
+ // 3D rectangles
+ canvas.drawRectangle(x, y + 10 + width, 20, 20, black);
+ canvas.draw3DRectangle(x, y + 10 + width, 20, 20, gray, true);
+
+ canvas.drawRectangle(x + 30, y + 10 + width, 20, 20, black);
+ canvas.draw3DRectangle(x + 30, y + 10 + width, 20, 20, gray, true);
+
+ x = 10;
+ y = 240;
+
+ int ascent = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getAscent();
+ int descent = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getDescent();
+ int midpoint = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getMidPoint();
+ int lineHeight = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getLineHeight();
+
+ // canvas.drawRectangle(left, top, 200, line, gray);
+ int baseline = y + ascent;
+ drawText(canvas, x, lineHeight, baseline, ascent, descent, midpoint);
+ baseline += lineHeight;
+ drawText(canvas, x, lineHeight, baseline, ascent, descent, midpoint);
+ baseline += lineHeight;
+ drawText(canvas, x, lineHeight, baseline, ascent, descent, midpoint);
+
+ /*
+ * int width = getSize().getWidth(); int height = getSize().getHeight(); canvas.drawRectangle(0,0,
+ * width - 1, height - 1, gray); canvas.drawLine(0, 0, width - 1, height - 1, red);
+ * canvas.drawLine(width - 1, 0, 0, height - 1, red);
+ */
+ }
+
+ private void drawText(
+ final Canvas canvas,
+ final int x,
+ final int lineHeight,
+ final int baseline,
+ final int ascent,
+ final int descent,
+ final int midpoint) {
+ canvas.drawLine(x, baseline, x + 200 - 1, baseline, gray); // baseline
+ // canvas.drawLine(x, baseline - (ascent - descent) / 2, x + 200 - 1, baseline - (ascent - descent) /
+ // 2, red); // mid-point
+ canvas.drawLine(x, baseline - midpoint, x + 200 - 1, baseline - midpoint, red); // mid-point
+ canvas.drawLine(x, baseline - ascent, x + 200 - 1, baseline - ascent, lightGray); // ascent
+ // canvas.drawLine(x, baseline - ascent + descent, x + 200 - 1, baseline - ascent + descent,
+ // lightGray); // ascent
+ canvas.drawLine(x, baseline + descent, x + 200 - 1, baseline + descent, yellow); // descent
+ canvas.drawText("12345 abcdefghijk ABCDEFG", x, baseline, black, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ }
+
+ public void firstClick(final Click click) {
+ debug("first click " + click);
+ super.firstClick(click);
+ }
+
+ public void secondClick(final Click click) {
+ debug("second click " + click);
+ super.secondClick(click);
+ }
+
+ public void mouseMoved(final Location location) {
+ debug("mouse moved " + location);
+ super.mouseMoved(location);
+ }
+
+ private void debug(final String str) {
+ getViewManager().getSpy().addAction(str);
+ }
+
+ public Drag dragStart(final DragStart drag) {
+ debug("drag start " + drag);
+ return super.dragStart(drag);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView2.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView2.java b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView2.java
new file mode 100644
index 0000000..8abdb8c
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/dnd/example/TestCanvasView2.java
@@ -0,0 +1,41 @@
+/*
+ * 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.example;
+
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Toolkit;
+import org.apache.isis.viewer.dnd.view.simple.AbstractView;
+
+
+class TestCanvasView2 extends AbstractView {
+
+ public void draw(final Canvas canvas) {
+ canvas.clearBackground(this, Toolkit.getColor(0xfffff));
+
+ int canvasWidth = getSize().getWidth();
+ int canvasHeight = getSize().getHeight();
+
+ canvas.drawRectangleAround(this, Toolkit.getColor(0xff0000));
+ canvas.drawRectangle(1, 1, canvasWidth - 2, canvasHeight - 2, Toolkit.getColor(0xdddddd));
+ canvas.drawSolidRectangle(2, 2, canvasWidth - 4, canvasHeight - 4, Toolkit.getColor(0x00ff00));
+
+ }
+}