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
[32/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/src-archived/views/BarchartSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/BarchartSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/BarchartSpecification.java
new file mode 100644
index 0000000..1b96732
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/BarchartSpecification.java
@@ -0,0 +1,52 @@
+/*
+ * 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.special;
+
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.object.CollectionAdapter;
+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;
+import org.apache.isis.viewer.dnd.basic.WindowDecorator;
+import org.apache.isis.viewer.dnd.core.AbstractCompositeViewSpecification;
+
+public class BarchartSpecification extends AbstractCompositeViewSpecification implements SubviewSpec {
+ private ViewSpecification specification = new BarSpecification();
+
+ public BarchartSpecification() {
+ builder = new WindowDecorator(new StackLayout(new CollectionElementBuilder(this, false)));
+ }
+
+ public View createSubview(Content content, ViewAxis axis) {
+ return specification.createView(content, axis);
+ }
+
+ public String getName() {
+ return "Percentage Barchart";
+ }
+
+ public boolean canDisplay(ObjectAdapter object) {
+ return object instanceof CollectionAdapter;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/GridColumnSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/GridColumnSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/GridColumnSpecification.java
new file mode 100644
index 0000000..5848398
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/GridColumnSpecification.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.viewer.dnd.special;
+
+import org.apache.isis.object.ObjectAdapterRuntimeException;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.OneToManyField;
+import org.apache.isis.viewer.dnd.ValueContent;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+import org.apache.isis.viewer.dnd.core.AbstractCompositeViewSpecification;
+import org.apache.isis.viewer.dnd.util.ViewFactory;
+
+class GridColumnSpecification extends AbstractCompositeViewSpecification{
+
+ GridColumnSpecification() {
+ builder = new ColumnLayout(155, new ObjectFieldBuilder(new ColumnSubviews()));
+ }
+
+ public String getName() {
+ return "Grid Column";
+ }
+
+ private static class ColumnSubviews implements SubviewSpec {
+ public View createSubview(Content content, ViewAxis axis) {
+ ViewFactory factory = Skylark.getViewFactory();
+
+ ViewSpecification specification;
+
+ if (content instanceof OneToManyField) {
+ specification = new ScheduleSpecification();
+ } else if (content instanceof ValueContent) {
+ specification = factory.getValueFieldSpecification((ValueContent) content);
+ } else if (content instanceof ObjectContent) {
+ specification = factory.getIconizedSubViewSpecification((ObjectContent) content);
+ } else {
+ throw new ObjectAdapterRuntimeException();
+ }
+
+ return specification.createView(content, axis);
+ }
+
+ public View decorateSubview(View view) {
+ return view;
+ }
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/GridLayout.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/GridLayout.java b/component/viewer/dnd/impl/src/main/src-archived/views/GridLayout.java
new file mode 100644
index 0000000..31a5a81
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/GridLayout.java
@@ -0,0 +1,68 @@
+/*
+ * 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.special;
+
+import org.apache.isis.viewer.dnd.CompositeViewBuilder;
+import org.apache.isis.viewer.dnd.Location;
+import org.apache.isis.viewer.dnd.Size;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.core.AbstractBuilderDecorator;
+
+public class GridLayout extends AbstractBuilderDecorator {
+ public GridLayout(CompositeViewBuilder design) {
+ super(design);
+ }
+
+ public Size getRequiredSize(View view) {
+ int height = 0;
+ int width = 0;
+ View views[] = view.getSubviews();
+
+ for (int i = 0; i < views.length; i++) {
+ View v = views[i];
+ Size s = v.getRequiredSize();
+ height = Math.max(height, s.getHeight());
+ width += s.getWidth();
+ }
+
+ return new Size(width, height);
+ }
+
+ public boolean isOpen() {
+ return true;
+ }
+
+ public void layout(View view) {
+ int x = 0, y = 0;
+ View views[] = view.getSubviews();
+
+ for (int i = 0; i < views.length; i++) {
+ View v = views[i];
+ Size s = v.getRequiredSize();
+ v.setSize(s);
+ v.setLocation(new Location(x, y));
+ x += s.getWidth();
+ }
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/GridSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/GridSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/GridSpecification.java
new file mode 100644
index 0000000..d90841b
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/GridSpecification.java
@@ -0,0 +1,53 @@
+/*
+ * 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.special;
+
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.object.CollectionAdapter;
+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.basic.WindowDecorator;
+import org.apache.isis.viewer.dnd.core.AbstractCompositeViewSpecification;
+
+public class GridSpecification extends AbstractCompositeViewSpecification implements SubviewSpec {
+ GridColumnSpecification columnSpecification = new GridColumnSpecification();
+
+ public GridSpecification() {
+ builder = new WindowDecorator(new GridLayout(new CollectionElementBuilder(this, false)));
+ }
+
+ public View createSubview(Content content, ViewAxis axis) {
+ return columnSpecification.createView(content, axis);
+ }
+
+ public String getName() {
+ return "Grid";
+ }
+
+ public boolean canDisplay(ObjectAdapter adapter) {
+ return object instanceof CollectionAdapter;
+ }
+
+ public boolean isReplaceable() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/OptionFieldSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/OptionFieldSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/OptionFieldSpecification.java
new file mode 100644
index 0000000..8966d10
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/OptionFieldSpecification.java
@@ -0,0 +1,67 @@
+/*
+ * 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.metal;
+
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.viewer.dnd.Click;
+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.basic.SimpleIdentifier;
+import org.apache.isis.viewer.dnd.core.AbstractFieldSpecification;
+import org.apache.isis.viewer.dnd.special.OpenOptionFieldBorder;
+
+import javax.swing.text.html.Option;
+
+
+
+public class OptionFieldSpecification extends AbstractFieldSpecification {
+ public boolean canDisplay(ObjectAdapter object) {
+ return object instanceof Option;
+ }
+
+ public View createView(Content content, ViewAxis axis) {
+ return new SimpleIdentifier(new OptionSelectionFieldBorder(new OptionSelectionField(content, this, axis)));
+ }
+
+ public String getName() {
+ return "Drop down list";
+ }
+}
+
+
+class OptionSelectionFieldBorder extends OpenOptionFieldBorder {
+
+ public OptionSelectionFieldBorder(OptionSelectionField wrappedView) {
+ super(wrappedView);
+ }
+
+ protected View createOverlay() {
+ return new OptionSelectionFieldOverlay((OptionSelectionField) wrappedView);
+ }
+
+ public void firstClick(Click click) {
+ if (canChangeValue()) {
+ super.firstClick(click);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionField.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionField.java b/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionField.java
new file mode 100644
index 0000000..a45f777
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionField.java
@@ -0,0 +1,96 @@
+/*
+ * 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.value;
+
+import org.apache.isis.object.InvalidEntryException;
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.viewer.dnd.Click;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+import org.apache.isis.viewer.dnd.basic.SimpleIdentifier;
+import org.apache.isis.viewer.dnd.core.AbstractFieldSpecification;
+import org.apache.isis.viewer.dnd.special.OpenOptionFieldBorder;
+
+import javax.swing.text.html.Option;
+
+public class OptionSelectionField extends TextField {
+
+ private String selected;
+
+ public static class Specification extends AbstractFieldSpecification {
+ public boolean canDisplay(ObjectAdapter object) {
+ return object.getObject() instanceof Option;
+ }
+
+ public View createView(Content content, ViewAxis axis) {
+ return new SimpleIdentifier(new OptionSelectionFieldBorder(new OptionSelectionField(content, this, axis)));
+ }
+
+ public String getName() {
+ return "Drop down list";
+ }
+ }
+
+ public OptionSelectionField(Content content, ViewSpecification specification, ViewAxis axis) {
+ super(content, specification, axis, false);
+ }
+
+ Option getOption() {
+ ObjectContent content = ((ObjectContent) getContent());
+ Option value = (Option) content.getObject().getObject();
+
+ return value;
+ }
+
+ void set(String selected) {
+ this.selected = selected;
+ initiateSave();
+ }
+
+ protected void save() {
+ try {
+ parseEntry(selected);
+ } catch (InvalidEntryException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
+
+class OptionSelectionFieldBorder extends OpenOptionFieldBorder {
+
+ public OptionSelectionFieldBorder(OptionSelectionField wrappedView) {
+ super(wrappedView);
+ }
+
+ protected View createOverlay() {
+ return new OptionSelectionFieldOverlay((OptionSelectionField) wrappedView);
+ }
+
+ public void firstClick(Click click) {
+ if (canChangeValue()) {
+ super.firstClick(click);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionFieldOverlay.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionFieldOverlay.java b/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionFieldOverlay.java
new file mode 100644
index 0000000..cc3e987
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/OptionSelectionFieldOverlay.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.viewer.dnd.value;
+
+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.Size;
+import org.apache.isis.viewer.dnd.Style;
+import org.apache.isis.viewer.dnd.Text;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.core.AbstractView;
+
+public class OptionSelectionFieldOverlay extends AbstractView implements View {
+ private String options[];
+ private int rowHeight;
+
+ private OptionSelectionField field;
+ private static final Text STYLE = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
+
+ public OptionSelectionFieldOverlay(OptionSelectionField field) {
+ super(field.getContent(), null, null);
+ this.field = field;
+
+ options = field.getOption().getOptions();
+ rowHeight = STYLE.getHeight();
+ }
+
+ public Size getRequiredSize() {
+ Size size = new Size();
+ for (int i = 0; i < options.length; i++) {
+ size.extendHeight(rowHeight);
+ size.ensureWidth(STYLE.stringWidth(options[i]));
+ }
+ size.extendHeight(2 * VPADDING);
+ size.extendWidth(2 * HPADDING);
+ return size;
+ }
+
+ public int getBaseline() {
+ return STYLE.getAscent();
+ }
+
+ public void draw(Canvas canvas) {
+ Size size = getSize();
+ canvas.drawSolidRectangle(0,0, size.getWidth() - 1, size.getHeight() - 1, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
+ canvas.drawRectangle(0,0, size.getWidth() - 1, size.getHeight() - 1, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2));
+ int x = HPADDING;
+ int y = VPADDING;
+ for (int i = 0; i < options.length; i++) {
+ canvas.drawText(options[i], x, y + getBaseline(), Toolkit.getColor(ColorsAndFonts.COLOR_BLACK), STYLE);
+ y += rowHeight;
+ }
+ }
+
+ public void firstClick(Click click) {
+ int y = click.getLocation().getY() - VPADDING;
+ int row = y / rowHeight;
+ field.set(options[row]);
+ dispose();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/PercentageBarField.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/PercentageBarField.java b/component/viewer/dnd/impl/src/main/src-archived/views/PercentageBarField.java
new file mode 100644
index 0000000..54226ac
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/PercentageBarField.java
@@ -0,0 +1,124 @@
+/*
+ * 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.value;
+
+import org.apache.isis.object.ObjectAdapter;
+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.Color;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.InternalDrag;
+import org.apache.isis.viewer.dnd.Size;
+import org.apache.isis.viewer.dnd.Style;
+import org.apache.isis.viewer.dnd.ValueContent;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+import org.apache.isis.viewer.dnd.basic.SimpleIdentifier;
+import org.apache.isis.viewer.dnd.core.AbstractFieldSpecification;
+
+
+public class PercentageBarField extends AbstractField {
+
+ public static class Specification extends AbstractFieldSpecification {
+ public View createView(Content content, ViewAxis axis) {
+ return new SimpleIdentifier(new PercentageBarField(content, this, axis));
+ }
+
+ public String getName() {
+ return "Percentage graph";
+ }
+
+ public boolean canDisplay(ObjectAdapter object) {
+ return object.getObject() instanceof Percentage;
+ }
+ }
+
+ protected PercentageBarField(Content content, ViewSpecification specification, ViewAxis axis) {
+ super(content, specification, axis);
+ }
+
+ private Percentage entry = new Percentage();
+
+ public void drag(InternalDrag drag) {
+ float x = drag.getLocation().getX() - 2;
+ setValue(x);
+ }
+
+ private void setValue(float x) {
+ float max = getSize().getWidth() - 4;
+
+ if ((x >= 0) && (x <= max)) {
+ entry.setValue(x / max);
+ initiateSave();
+ }
+ }
+
+ protected void save() {
+ /* try {
+ saveValue(entry);
+ } catch(InvalidEntryException e) {
+ throw new NotImplementedException();
+ }
+ */
+ }
+
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+
+ Color color = getState().isObjectIdentified() ? Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2) : Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY1);
+ Size size = getSize();
+ int width = size.getWidth();
+ int height = size.getHeight();
+ canvas.drawRectangle(0, 0, width - 1, height - 1, color);
+
+ Percentage p = getPercentage();
+ int length = (int) ((width - 4) * p.floatValue());
+ canvas.drawSolidRectangle(2, 2, length, height - 5, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3));
+ canvas.drawRectangle(2, 2, length, height - 5, color);
+ canvas.drawText(p.title().toString(), 6, height - 5 - Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getDescent(), color,
+ Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ }
+
+ public void firstClick(Click click) {
+ float x = click.getLocation().getX() - 2;
+ setValue(x);
+ }
+
+ private Percentage getPercentage() {
+ ValueContent content = ((ValueContent) getContent());
+ Percentage percentage = (Percentage) content.getObject().getObject();
+
+ return percentage;
+ }
+
+ public Size getRequiredSize() {
+ Size size = super.getRequiredSize();
+ size.extendWidth(304);
+ return size;
+
+ }
+/*
+ public void refresh() {
+ }
+*/
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockSpecification.java
new file mode 100644
index 0000000..a7b5fa7
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockSpecification.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.special;
+
+import org.apache.isis.object.ObjectAdapterRuntimeException;
+import org.apache.isis.object.ObjectSpecification;
+import org.apache.isis.object.ObjectSpecificationLoader;
+import org.apache.isis.object.reflect.ObjectField;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.basic.SimpleIdentifier;
+import org.apache.isis.viewer.dnd.core.AbstractCompositeViewSpecification;
+
+import org.apache.log4j.Logger;
+
+public class ScheduleBlockSpecification extends AbstractCompositeViewSpecification{
+ private static final Logger LOG = Logger.getLogger(ScheduleBlockView.class);
+
+ public View createView(Content content, ViewAxis axis) {
+ ObjectSpecification nc = ((ObjectContent) content).getObject().getSpecification();
+ ObjectField[] flds = nc.getFields();
+ ObjectField timePeriodField = null;
+ ObjectField colorField = null;
+ for (int i = 0; i < flds.length; i++) {
+ ObjectField field = flds[i];
+ if(field.getType().isOfType(Isis.getSpecificationLoader().loadSpecification(TimePeriod.class))) {
+ LOG.debug("found TimePeriod field " + field);
+ timePeriodField = field;
+ }
+ if(field.getType().isOfType(Isis.getSpecificationLoader().loadSpecification(org.apache.isis.application.value.Color.class))) {
+ LOG.debug("found Color field " + field);
+ colorField = field;
+ }
+ }
+ if(timePeriodField == null) {
+ throw new ObjectAdapterRuntimeException("Can't create Shedule view without a TimePeriod");
+ } else {
+ return new SimpleIdentifier(new ScheduleBlockView(content, this, axis, timePeriodField, colorField));
+ }
+ }
+
+ public String getName() {
+ return "Schedule Block";
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockView.java b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockView.java
new file mode 100644
index 0000000..8dc163f
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleBlockView.java
@@ -0,0 +1,149 @@
+/*
+ * 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.special;
+
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.object.reflect.ObjectField;
+import org.apache.isis.extensions.dndviewer.ColorsAndFonts;
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Color;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.InternalDrag;
+import org.apache.isis.viewer.dnd.Location;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.Size;
+import org.apache.isis.viewer.dnd.Style;
+import org.apache.isis.viewer.dnd.ViewAreaType;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+import org.apache.isis.viewer.dnd.basic.IconGraphic;
+import org.apache.isis.viewer.dnd.basic.ObjectTitleText;
+import org.apache.isis.viewer.dnd.basic.TitleText;
+import org.apache.isis.viewer.dnd.core.ObjectView;
+
+import org.apache.log4j.Logger;
+
+
+public class ScheduleBlockView extends ObjectView {
+ private static final Logger LOG = Logger.getLogger(ScheduleBlockView.class);
+ private ObjectField timePeriodField;
+ private ObjectField colorField;
+ private TitleText text;
+ private IconGraphic icon;
+
+ public ScheduleBlockView(Content content, ViewSpecification specification, ViewAxis axis, ObjectField timePeriodField, ObjectField colorField) {
+ super(content, specification, axis);
+ this.timePeriodField = timePeriodField;
+ this.colorField = colorField;
+
+ icon = new IconGraphic(this, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ text = new ObjectTitleText(this, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ }
+
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+
+ Color color;
+ if(colorField == null) {
+ color = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3);
+ } else {
+ ObjectAdapter object = ((ObjectContent) getContent()).getObject();
+ org.apache.isis.application.value.Color fieldColor = (org.apache.isis.application.value.Color) object.getField(colorField);
+ color = new Color((fieldColor).intValue());
+ }
+
+
+ Size size = getSize();
+ int width = size.getWidth() - 1;
+ int height = size.getHeight() - 1;
+ canvas.drawSolidRectangle(0, 0, width, height, color);
+ canvas.drawRectangle(0, 0, width, height, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY2));
+
+ int x = 0;
+ int baseline = icon.getBaseline();
+ icon.draw(canvas, x, baseline);
+ x += icon.getSize().getWidth();
+ text.draw(canvas, x, baseline);
+
+ }
+
+ public ViewAreaType viewAreaType(Location mouseLocation) {
+ int objectBoundary = icon.getSize().getWidth();
+
+ return mouseLocation.getX() > objectBoundary ? ViewAreaType.INTERNAL : ViewAreaType.CONTENT;
+ }
+ /*
+ public View dragFrom(Location location) {
+ int direction;
+
+ if(location.getY() <= 8) {
+ direction = ViewResizeOutline.TOP;
+ } else if(location.getY() >= getSize().getHeight() - 8) {
+ direction = ViewResizeOutline.BOTTOM;
+ } else {
+ direction = ViewResizeOutline.CENTER;
+ }
+
+ // TODO this should be done via static method that creates and displays overlay
+ ViewResizeOutline outlineView =new ViewResizeOutline(this, direction);
+
+// outlineView.setLocation(getView().getLocationWithinViewer());
+// outlineView.setSize(getView().getSize());
+
+ getViewManager().setOverlayView(outlineView);
+ LOG.debug("drag view start " + location);
+ return outlineView;
+ }
+ */
+
+ public void dragTo(InternalDrag drag) {
+ ObjectAdapter object = ((ObjectContent) getContent()).getObject();
+ TimePeriod tp = calculate(drag);
+ TimePeriod timePeriod = (TimePeriod) getObject().getField(timePeriodField);
+ ((TimePeriod) timePeriod.getValue()).copyObject(tp);
+// ((Appointment) object).getTime().copyObject(tp);
+ invalidateLayout();
+ }
+
+ public void drag(InternalDrag drag) {
+ ViewResizeOutline outlineView = (ViewResizeOutline) drag.getOverlay();
+ outlineView.setDisplay(calculate(drag).title().toString());
+ }
+
+ private TimePeriod calculate(InternalDrag drag) {
+ // TODO this fails when the layout decorator is itself decorated (e.g. by a WindowBorder!
+ ScheduleLayout layout = (ScheduleLayout) getParent().getSpecification();
+
+ Location location = drag.getLocation();
+ location.move(0, -getView().getLocation().getY());
+ int top = drag.getOverlay().getLocation().getY() - location.getY();
+ int bottom = top + drag.getOverlay().getSize().getHeight();
+
+ LOG.debug(top + " " + bottom);
+
+ TimePeriod tp = new TimePeriod();
+ tp.setValue(layout.getTime(getParent(), top), layout.getTime(getParent(), bottom));
+
+ return tp;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleLayout.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleLayout.java b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleLayout.java
new file mode 100644
index 0000000..99ccf3d
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleLayout.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.special;
+
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.object.ObjectSpecification;
+import org.apache.isis.object.ObjectSpecificationLoader;
+import org.apache.isis.object.reflect.ObjectField;
+import org.apache.isis.viewer.dnd.Location;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.Size;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.core.AbstractBuilderDecorator;
+
+import java.sql.Time;
+
+class ScheduleLayout extends AbstractBuilderDecorator {
+ private final int from = 7 * Time.HOUR;
+ private final int to = Time.HOUR * 10;
+
+ public ScheduleLayout(CollectionElementBuilder viewer) {
+ super(viewer);
+ }
+
+ public Size getRequiredSize(View view) {
+ return new Size(155, 400);
+ }
+
+ public void layout(View view) {
+ ObjectField field = null;
+ int x = 0;
+ Size size = view.getSize();
+ size.contract(view.getPadding());
+
+ int width = size.getWidth();
+ int maxHeight = size.getHeight();
+
+ View[] views = view.getSubviews();
+
+ for (int i = 0; i < views.length; i++) {
+ View v = views[i];
+ ObjectAdapter object = ((ObjectContent) v.getContent()).getObject();
+
+ if (field == null) {
+ ObjectSpecification nc = object.getSpecification();
+ ObjectField[] fields = nc.getFields();
+
+ for (int j = 0; j < fields.length; j++) {
+ field = fields[j];
+
+ if (field.getType().isOfType(Isis.getSpecificationLoader().loadSpecification(TimePeriod.class))) {
+ break;
+ }
+ }
+ }
+
+ TimePeriod tp = (TimePeriod) object.getField(field);
+ int y = (int) (((tp.getStart().longValue() - from) * maxHeight) / to);
+ int height = (int) (((tp.getEnd().longValue() - tp.getStart().longValue()) * maxHeight) / to);
+
+ v.setLocation(new Location(x, y));
+ v.setSize(new Size(width, height));
+ }
+ }
+
+ public Time getTime(View view, int y) {
+ Size size = view.getSize();
+ int maxHeight = size.getHeight();
+
+ int longtime = (y * to) / maxHeight + from;
+ Time t = new Time();
+ t.setValue(longtime);
+ return t;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleSpecification.java b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleSpecification.java
new file mode 100644
index 0000000..edda47f
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/ScheduleSpecification.java
@@ -0,0 +1,51 @@
+/*
+ * 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.special;
+
+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.core.AbstractCompositeViewSpecification;
+
+public class ScheduleSpecification extends AbstractCompositeViewSpecification{
+
+ ScheduleSpecification() {
+ builder = new ScheduleLayout(new CollectionElementBuilder(new ScheduleBlockSubviews(), true));
+ }
+
+ public String getName() {
+ return "Schedule";
+ }
+
+ private static class ScheduleBlockSubviews implements SubviewSpec {
+ private ScheduleBlockSpecification blockSpecification = new ScheduleBlockSpecification();
+
+ public View createSubview(Content content, ViewAxis axis) {
+ return blockSpecification.createView(content, axis);
+ }
+
+ public View decorateSubview(View view) {
+ return view;
+ }
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/main/src-archived/views/TimePeriodBarField.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/main/src-archived/views/TimePeriodBarField.java b/component/viewer/dnd/impl/src/main/src-archived/views/TimePeriodBarField.java
new file mode 100644
index 0000000..cd2e8de
--- /dev/null
+++ b/component/viewer/dnd/impl/src/main/src-archived/views/TimePeriodBarField.java
@@ -0,0 +1,132 @@
+/*
+ * 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.value;
+
+import org.apache.isis.object.InvalidEntryException;
+import org.apache.isis.object.ObjectAdapter;
+import org.apache.isis.extensions.dndviewer.ColorsAndFonts;
+import org.apache.isis.utility.NotImplementedException;
+import org.apache.isis.viewer.dnd.Canvas;
+import org.apache.isis.viewer.dnd.Color;
+import org.apache.isis.viewer.dnd.Content;
+import org.apache.isis.viewer.dnd.InternalDrag;
+import org.apache.isis.viewer.dnd.ObjectContent;
+import org.apache.isis.viewer.dnd.Size;
+import org.apache.isis.viewer.dnd.Style;
+import org.apache.isis.viewer.dnd.View;
+import org.apache.isis.viewer.dnd.ViewAxis;
+import org.apache.isis.viewer.dnd.ViewSpecification;
+import org.apache.isis.viewer.dnd.core.AbstractFieldSpecification;
+
+import java.sql.Time;
+
+import org.apache.log4j.Logger;
+
+
+public class TimePeriodBarField extends AbstractField {
+
+ public static class Specification extends AbstractFieldSpecification {
+ public View createView(Content content, ViewAxis axis) {
+ return new TimePeriodBarField(content, this, axis);
+ }
+
+ public String getName() {
+ return "Period graph";
+ }
+
+ public boolean canDisplay(ObjectAdapter object) {
+ return object instanceof TimePeriod;
+ }
+ }
+ private static final Logger LOG = Logger.getLogger(TimePeriodBarField.class);
+ private int endTime;
+ // private int startTime;
+
+ protected TimePeriodBarField(Content content, ViewSpecification specification, ViewAxis axis) {
+ super(content, specification, axis);
+ }
+
+ public void drag(InternalDrag drag) {
+ float x = drag.getLocation().getX() - 2;
+ float max = getSize().getWidth() - 4;
+
+ if ((x >= 0) && (x <= max)) {
+ int time = (int) (x / max * 3600 * 24);
+ endTime = time;
+ initiateSave();
+ }
+ }
+
+ protected void save() {
+ Time end = getPeriod().getEnd();
+ end.setValue(endTime);
+
+ Time start = getPeriod().getStart();
+
+ TimePeriod tp = new TimePeriod();
+ tp.setValue(start, end);
+ try {
+ parseEntry(tp.title().toString());
+ } catch (InvalidEntryException e) {
+ throw new NotImplementedException();
+ }
+ LOG.debug("adjust time " + endTime + " " + getPeriod());
+ markDamaged();
+ }
+
+ public void draw(Canvas canvas) {
+ super.draw(canvas);
+
+ Color color = getState().isObjectIdentified() ? Toolkit.getColor("primary2") : Toolkit.getColor("secondary1");
+ Size size = getSize();
+ int width = size.getWidth();
+ int height = size.getHeight();
+ canvas.drawRectangle(0, 0, width - 1, height - 1, color);
+
+ TimePeriod p = getPeriod();
+
+ int max = width - 4;
+ int start = (int) ((p.isEmpty() ? 0 : (p.getStart().longValue() * max)) / (3600 * 24)) + 2;
+ int end = (int) ((p.isEmpty() ? max : (p.getEnd().longValue() * max)) / (3600 * 24)) + 2;
+ canvas.drawSolidRectangle(start, 2, end - start, height - 5, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY3));
+ canvas.drawRectangle(start, 2, end - start, height - 5, color);
+ canvas.drawText(p.title().toString(), start + 3, height - 5 - Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getDescent(),
+ color, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
+ }
+
+ private TimePeriod getPeriod() {
+ ObjectContent content = ((ObjectContent) getContent());
+ TimePeriod period = (TimePeriod) content.getObject().getObject();
+
+ return period;
+ }
+
+ public Size getRequiredSize() {
+ Size size = super.getRequiredSize();
+ size.extendWidth(304);
+ return size;
+ }
+/*
+ public void refresh() {
+ }
+ */
+}
+
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/site/apt/index.apt b/component/viewer/dnd/impl/src/site/apt/index.apt
new file mode 100644
index 0000000..830ae9f
--- /dev/null
+++ b/component/viewer/dnd/impl/src/site/apt/index.apt
@@ -0,0 +1,37 @@
+~~ 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.
+
+
+
+DnD Viewer
+
+ The Drag and Drop (DnD) viewer is non-web graphical user interface that employs a
+ desktop metaphor for interacting with domain objects. It renders each domain object
+ as an icon or a window and allows the user to manage and manipulate them using the mouse
+ and keyboard. Dragging and dropping domain objects plays a major role in
+ this interface, hence its name.
+
+Customization
+
+ The DnD viewer defines its own API to allow new views to be defined. These can be for
+ entities, for entity properties (and action parameters), for entity collections, and
+ for collections of entities.
+
+Further Info
+
+ See this module's {{{./apidocs/index.html}Javadoc}} and the {{{./docbkx/html/guide/isis-dnd-viewer.html}user guide}} for more information.
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/site/apt/jottings.apt b/component/viewer/dnd/impl/src/site/apt/jottings.apt
new file mode 100644
index 0000000..7391f77
--- /dev/null
+++ b/component/viewer/dnd/impl/src/site/apt/jottings.apt
@@ -0,0 +1,38 @@
+~~ 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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
+
+Useful tools for the DND developer
+
+ When space is limited us the limitText method in the TextUtils class. This will return the maximum amount of text to fit a specified space.
+
+------
+TextUtils.limitText(title, TITLE_STYLE, availableWidth);
+----
+
+
+User Profiles
+
+ When the DND viewer is exited (DndViewer.quit()) a call is made to saveDesktop() that will
+ cause the UserProifile to be persisted under the user's name. This is stored using the UserProfileStore
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/site/site.xml
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/site/site.xml b/component/viewer/dnd/impl/src/site/site.xml
new file mode 100644
index 0000000..edde1f3
--- /dev/null
+++ b/component/viewer/dnd/impl/src/site/site.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project>
+
+ <body>
+ <breadcrumbs>
+ <item name="DnD"/>
+ </breadcrumbs>
+
+ <menu name="DnD Viewer">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="Viewer Modules">
+ <item name="HTML" href="../html/index.html" />
+ <item name="Scimpi" href="../scimpi/index.html" />
+ <item name="Wicket" href="../wicket/index.html" />
+ <item name="RestfulObjects" href="../restfulobjects/index.html" />
+ <item name="JUnit Support" href="../junit/index.html" />
+ <item name="BDD Integration" href="../bdd/index.html" />
+ <item name="DnD" href="../dnd/index.html" />
+ </menu>
+
+ <menu name="Documentation">
+ <item name="${docbkxGuideTitle} (PDF)" href="docbkx/pdf/${docbkxGuideName}.pdf" />
+ <item name="${docbkxGuideTitle} (HTML)" href="docbkx/html/guide/${docbkxGuideName}.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/ContentDragTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/ContentDragTest.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/ContentDragTest.java
new file mode 100644
index 0000000..570e9d4
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/ContentDragTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.interaction.ContentDragImpl;
+import org.apache.isis.viewer.dnd.view.ContentDrag;
+
+public class ContentDragTest extends TestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testLocation() {
+ final DummyView sourceView = new DummyView();
+ sourceView.setParent(new DummyWorkspaceView());
+ sourceView.setupLocation(new Location(1000, 1000));
+
+ final ContentDrag drag = new ContentDragImpl(sourceView, new Location(10, 10), new DummyView());
+ assertEquals(new Location(10, 10), drag.getOffset());
+
+ final DummyView targetView = new DummyView();
+ targetView.setupAbsoluteLocation(new Location(100, 100));
+
+ // drag.drag(targetView, new Location(120, 120), 0);
+ // assertEquals(new Location(20, 20), drag.getTargetLocation());
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyCanvas.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyCanvas.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyCanvas.java
new file mode 100644
index 0000000..dd6812e
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyCanvas.java
@@ -0,0 +1,132 @@
+/*
+ * 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.viewer.dnd.drawing.Bounds;
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.Color;
+import org.apache.isis.viewer.dnd.drawing.Image;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Shape;
+import org.apache.isis.viewer.dnd.drawing.Text;
+
+public class DummyCanvas implements Canvas {
+
+ public DummyCanvas() {
+ super();
+ }
+
+ @Override
+ public Canvas createSubcanvas() {
+ return null;
+ }
+
+ @Override
+ public Canvas createSubcanvas(final Bounds bounds) {
+ return null;
+ }
+
+ @Override
+ public Canvas createSubcanvas(final int x, final int y, final int width, final int height) {
+ return null;
+ }
+
+ @Override
+ public void draw3DRectangle(final int x, final int y, final int width, final int height, final Color color, final boolean raised) {
+ }
+
+ @Override
+ public void drawImage(final Image icon, final int x, final int y) {
+ }
+
+ @Override
+ public void drawImage(final Image icon, final int x, final int y, final int width, final int height) {
+ }
+
+ @Override
+ public void drawLine(final int x, final int y, final int x2, final int y2, final Color color) {
+ }
+
+ @Override
+ public void drawLine(final Location start, final int xExtent, final int yExtent, final Color color) {
+ }
+
+ @Override
+ public void drawOval(final int x, final int y, final int width, final int height, final Color color) {
+ }
+
+ @Override
+ public void drawRectangle(final int x, final int y, final int width, final int height, final Color color) {
+ }
+
+ @Override
+ public void drawRectangleAround(final Bounds bounds, final Color color) {
+ }
+
+ @Override
+ public void drawRoundedRectangle(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight, final Color color) {
+ }
+
+ @Override
+ public void drawShape(final Shape shape, final Color color) {
+ }
+
+ @Override
+ public void drawShape(final Shape shape, final int x, final int y, final Color color) {
+ }
+
+ @Override
+ public void drawSolidOval(final int x, final int y, final int width, final int height, final Color color) {
+ }
+
+ @Override
+ public void drawSolidRectangle(final int x, final int y, final int width, final int height, final Color color) {
+ }
+
+ @Override
+ public void drawSolidShape(final Shape shape, final Color color) {
+ }
+
+ @Override
+ public void drawSolidShape(final Shape shape, final int x, final int y, final Color color) {
+ }
+
+ @Override
+ public void drawText(final String text, final int x, final int y, final Color color, final Text style) {
+ }
+
+ @Override
+ public void drawText(final String text, final int x, final int y, final int maxWidth, final Color color, final Text style) {
+ }
+
+ @Override
+ public void offset(final int x, final int y) {
+ }
+
+ @Override
+ public boolean overlaps(final Bounds bounds) {
+ return false;
+ }
+
+ @Override
+ public void drawDebugOutline(final Bounds bounds, final int baseline, final Color color) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyContent.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyContent.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyContent.java
new file mode 100644
index 0000000..128f13e
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyContent.java
@@ -0,0 +1,154 @@
+/*
+ * 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.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.consent.Veto;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.viewer.dnd.drawing.Image;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.UserActionSet;
+
+public class DummyContent implements Content {
+
+ private String iconName;
+ private String title;
+ private String windowTitle;
+
+ @Override
+ public Consent canDrop(final Content sourceContent) {
+ return Veto.DEFAULT;
+ }
+
+ @Override
+ public void debugDetails(final DebugBuilder debug) {
+ }
+
+ @Override
+ public ObjectAdapter drop(final Content sourceContent) {
+ return null;
+ }
+
+ @Override
+ public String getIconName() {
+ return iconName;
+ }
+
+ @Override
+ public Image getIconPicture(final int iconHeight) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public ObjectAdapter getAdapter() {
+ return null;
+ }
+
+ @Override
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public boolean isObject() {
+ return false;
+ }
+
+ @Override
+ public boolean isPersistable() {
+ return false;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return false;
+ }
+
+ @Override
+ public boolean isTextParseable() {
+ return false;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public String title() {
+ return title;
+ }
+
+ @Override
+ public String windowTitle() {
+ return windowTitle;
+ }
+
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return null;
+ }
+
+ @Override
+ public void viewMenuOptions(final UserActionSet options) {
+ }
+
+ @Override
+ public String getHelp() {
+ return null;
+ }
+
+ @Override
+ public ObjectAdapter[] getOptions() {
+ return null;
+ }
+
+ @Override
+ public boolean isOptionEnabled() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyView.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyView.java
new file mode 100644
index 0000000..f0f9d54
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyView.java
@@ -0,0 +1,537 @@
+/*
+ * 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 java.util.Vector;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.consent.Veto;
+import org.apache.isis.core.runtime.userprofile.Options;
+import org.apache.isis.viewer.dnd.drawing.Bounds;
+import org.apache.isis.viewer.dnd.drawing.Canvas;
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.drawing.Padding;
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.view.Axes;
+import org.apache.isis.viewer.dnd.view.Click;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.ContentDrag;
+import org.apache.isis.viewer.dnd.view.DragEvent;
+import org.apache.isis.viewer.dnd.view.DragStart;
+import org.apache.isis.viewer.dnd.view.Feedback;
+import org.apache.isis.viewer.dnd.view.FocusManager;
+import org.apache.isis.viewer.dnd.view.InternalDrag;
+import org.apache.isis.viewer.dnd.view.KeyboardAction;
+import org.apache.isis.viewer.dnd.view.Placement;
+import org.apache.isis.viewer.dnd.view.UserActionSet;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.ViewAreaType;
+import org.apache.isis.viewer.dnd.view.ViewDrag;
+import org.apache.isis.viewer.dnd.view.ViewSpecification;
+import org.apache.isis.viewer.dnd.view.ViewState;
+import org.apache.isis.viewer.dnd.view.Viewer;
+import org.apache.isis.viewer.dnd.view.Workspace;
+import org.apache.isis.viewer.dnd.view.base.Layout;
+
+public class DummyView implements View {
+ private Size requiredSize = new Size(100, 10);
+ private Size size;
+ private View parent;
+ private View view;
+ private Location location = new Location(0, 0);
+ private Location absoluteLocation;
+ private Content content;
+ private ViewSpecification specification;
+ public int invlidateLayout;
+ public int invalidateContent;
+ private final ViewState state = new ViewState();
+ private final Vector<View> subviews = new Vector<View>();
+ private boolean allowSubviewsToBeAdded;
+ private final Axes axes = new Axes();
+
+ public DummyView() {
+ setView(this);
+ }
+
+ public DummyView(final int width, final int height) {
+ this();
+ setupRequiredSize(new Size(width, height));
+ }
+
+ @Override
+ public Size getRequiredSize(final Size availableSpace) {
+ return new Size(requiredSize);
+ }
+
+ @Override
+ public Consent canChangeValue() {
+ return Veto.DEFAULT;
+ }
+
+ @Override
+ public boolean canFocus() {
+ return false;
+ }
+
+ @Override
+ public boolean contains(final View view) {
+ return false;
+ }
+
+ @Override
+ public boolean containsFocus() {
+ return false;
+ }
+
+ @Override
+ public void contentMenuOptions(final UserActionSet menuOptions) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void debug(final DebugBuilder debug) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void debugStructure(final DebugBuilder b) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void dispose() {
+ final Workspace workspace = getWorkspace();
+ if (workspace != null) {
+ workspace.removeView(this);
+ }
+ }
+
+ @Override
+ public void drag(final InternalDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void drag(final ViewDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void dragCancel(final InternalDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public View dragFrom(final Location location) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void drag(final ContentDrag contentDrag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void dragIn(final ContentDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void dragOut(final ContentDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public DragEvent dragStart(final DragStart drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void dragTo(final InternalDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void draw(final Canvas canvas) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void drop(final ContentDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void drop(final ViewDrag drag) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void editComplete(final boolean moveFocus, final boolean toNextField) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void entered() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void exited() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void firstClick(final Click click) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void focusLost() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void focusReceived() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public Location getAbsoluteLocation() {
+ return absoluteLocation;
+ }
+
+ @Override
+ public int getBaseline() {
+ return 0;
+ }
+
+ @Override
+ public Bounds getBounds() {
+ return new Bounds(location, size);
+ }
+
+ @Override
+ public Content getContent() {
+ return content;
+ }
+
+ @Override
+ public FocusManager getFocusManager() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public int getId() {
+ return 0;
+ }
+
+ @Override
+ public Location getLocation() {
+ return location;
+ }
+
+ @Override
+ public Padding getPadding() {
+ return new Padding();
+ }
+
+ @Override
+ public View getParent() {
+ return parent;
+ }
+
+ @Override
+ public Size getSize() {
+ return size;
+ }
+
+ @Override
+ public ViewSpecification getSpecification() {
+ return specification;
+ }
+
+ @Override
+ public ViewState getState() {
+ return state;
+ }
+
+ @Override
+ public void addView(final View view) {
+ if (allowSubviewsToBeAdded) {
+ subviews.add(view);
+ } else {
+ throw new IsisException("Can't add view. Do you need to set the allowSubviewsToBeAdded flag?");
+ }
+ }
+
+ @Override
+ public void removeView(final View view) {
+ if (allowSubviewsToBeAdded) {
+ subviews.remove(view);
+ } else {
+ throw new IsisException("Can't remove view. Do you need to set the allowSubviewsToBeAdded flag?");
+ }
+ }
+
+ @Override
+ public View[] getSubviews() {
+ return subviews.toArray(new View[subviews.size()]);
+ }
+
+ @Override
+ public View getView() {
+ return view;
+ }
+
+ @Override
+ public Viewer getViewManager() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public Feedback getFeedbackManager() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public Workspace getWorkspace() {
+ return getParent() == null ? null : getParent().getWorkspace();
+ }
+
+ @Override
+ public boolean hasFocus() {
+ return false;
+ }
+
+ @Override
+ public View identify(final Location mouseLocation) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void invalidateContent() {
+ invalidateContent++;
+ }
+
+ @Override
+ public void invalidateLayout() {
+ invlidateLayout++;
+ }
+
+ @Override
+ public void keyPressed(final KeyboardAction key) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void keyReleased(final KeyboardAction action) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void keyTyped(final KeyboardAction action) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void layout() {
+ }
+
+ @Override
+ public void limitBoundsWithin(final Size size) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void markDamaged() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void markDamaged(final Bounds bounds) {
+ }
+
+ @Override
+ public void mouseDown(final Click click) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void mouseMoved(final Location location) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void objectActionResult(final ObjectAdapter result, final Placement placement) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public View pickupContent(final Location location) {
+ return null;
+ }
+
+ @Override
+ public View pickupView(final Location location) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void print(final Canvas canvas) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void refresh() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void replaceView(final View toReplace, final View replacement) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void secondClick(final Click click) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void setBounds(final Bounds bounds) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void setFocusManager(final FocusManager focusManager) {
+ throw new NotYetImplementedException();
+ }
+
+ public void setLayout(final Layout layout) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void setLocation(final Location location) {
+ this.location = location;
+ }
+
+ @Override
+ public void setParent(final View view) {
+ parent = view.getView();
+ }
+
+ @Override
+ public void setSize(final Size size) {
+ this.size = size;
+ }
+
+ @Override
+ public void setView(final View view) {
+ this.view = view;
+ }
+
+ @Override
+ public View subviewFor(final Location location) {
+ for (final View view : getSubviews()) {
+ if (view.getBounds().contains(location)) {
+ return view;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void thirdClick(final Click click) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void update(final ObjectAdapter object) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void updateView() {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public ViewAreaType viewAreaType(final Location mouseLocation) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public void viewMenuOptions(final UserActionSet menuOptions) {
+ throw new NotYetImplementedException();
+ }
+
+ public void setupLocation(final Location location) {
+ this.location = location;
+ }
+
+ public void setupAbsoluteLocation(final Location location) {
+ this.absoluteLocation = location;
+ }
+
+ public void setupContent(final Content content) {
+ this.content = content;
+ }
+
+ public void setupRequiredSize(final Size size) {
+ this.requiredSize = size;
+ }
+
+ public void setupSpecification(final ViewSpecification specification) {
+ this.specification = specification;
+ }
+
+ public void setupSubviews(final View[] views) {
+ for (final View view : views) {
+ subviews.add(view);
+ }
+ }
+
+ @Override
+ public void mouseUp(final Click click) {
+ throw new NotYetImplementedException();
+ }
+
+ @Override
+ public Axes getViewAxes() {
+ return axes;
+ }
+
+ public void setupAllowSubviewsToBeAdded(final boolean allowSubviewsToBeAdded) {
+ this.allowSubviewsToBeAdded = allowSubviewsToBeAdded;
+ }
+
+ @Override
+ public void loadOptions(final Options viewOptions) {
+ }
+
+ @Override
+ public void saveOptions(final Options viewOptions) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyViewSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyViewSpecification.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyViewSpecification.java
new file mode 100644
index 0000000..9764b82
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyViewSpecification.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.dnd;
+
+import org.apache.isis.viewer.dnd.drawing.Size;
+import org.apache.isis.viewer.dnd.view.Axes;
+import org.apache.isis.viewer.dnd.view.Content;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.ViewRequirement;
+import org.apache.isis.viewer.dnd.view.ViewSpecification;
+
+public class DummyViewSpecification implements ViewSpecification {
+
+ private Size size;
+
+ public DummyViewSpecification() {
+ }
+
+ public DummyViewSpecification(final Size size) {
+ this.size = size;
+ }
+
+ @Override
+ public View createView(final Content content, final Axes axes, final int sequence) {
+ final DummyView dummyView = new DummyView();
+ dummyView.setupRequiredSize(new Size(size));
+ return dummyView;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public boolean isAligned() {
+ return false;
+ }
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public boolean isReplaceable() {
+ return false;
+ }
+
+ @Override
+ public boolean isResizeable() {
+ return false;
+ }
+
+ @Override
+ public boolean isSubView() {
+ return false;
+ }
+
+ @Override
+ public boolean canDisplay(final ViewRequirement requirement) {
+ return false;
+ }
+
+ public void setupCreatedViewsSize(final Size size) {
+ this.size = size;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyWorkspaceView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyWorkspaceView.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyWorkspaceView.java
new file mode 100644
index 0000000..989fcbe
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/DummyWorkspaceView.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;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.dnd.view.Placement;
+import org.apache.isis.viewer.dnd.view.View;
+import org.apache.isis.viewer.dnd.view.Workspace;
+
+public class DummyWorkspaceView extends DummyView implements Workspace {
+
+ public DummyWorkspaceView() {
+ setupAllowSubviewsToBeAdded(true);
+ }
+
+ @Override
+ public View addIconFor(final ObjectAdapter adapter, final Placement placement) {
+ return createAndAddView();
+ }
+
+ private DummyView createAndAddView() {
+ final DummyView view = new DummyView();
+ addView(view);
+ return view;
+ }
+
+ @Override
+ public View addWindowFor(final ObjectAdapter object, final Placement placement) {
+ return createAndAddView();
+ }
+
+ public View createSubviewFor(final ObjectAdapter object, final boolean asIcon) {
+ return createAndAddView();
+ }
+
+ @Override
+ public void lower(final View view) {
+ }
+
+ @Override
+ public void raise(final View view) {
+ }
+
+ public void removeViewsFor(final ObjectAdapter object) {
+ }
+
+ @Override
+ public Workspace getWorkspace() {
+ return this;
+ }
+
+ public void removeObject(final ObjectAdapter object) {
+ }
+
+ @Override
+ public void addDialog(final View dialog, final Placement placement) {
+ }
+
+ @Override
+ public void addWindow(final View window, final Placement placement) {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/InternalDragTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/InternalDragTest.java b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/InternalDragTest.java
new file mode 100644
index 0000000..bd43adc
--- /dev/null
+++ b/component/viewer/dnd/impl/src/test/java/org/apache/isis/viewer/dnd/InternalDragTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.isis.viewer.dnd.drawing.Location;
+import org.apache.isis.viewer.dnd.interaction.SimpleInternalDrag;
+import org.apache.isis.viewer.dnd.view.InternalDrag;
+
+public class InternalDragTest extends TestCase {
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(InternalDragTest.class);
+ }
+
+ public void testDragStart() {
+ final DummyView view = new DummyView();
+ view.setupAbsoluteLocation(new Location(30, 60));
+
+ final InternalDrag id = new SimpleInternalDrag(view, new Location(100, 110));
+ assertEquals(new Location(70, 50), id.getLocation());
+
+ // id.drag(null, new Location(110, 130), 0);
+ // assertEquals(new Location(80, 70), id.getLocation());
+ }
+}