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
[43/53] [partial] ISIS-188: making structure of component viewers
consistent
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
deleted file mode 100644
index 2e9beb1..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/AboutView.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.help;
-
-import org.apache.isis.core.runtime.about.AboutIsis;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Click;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.content.NullContent;
-import org.apache.isis.viewer.dnd.view.window.SubviewFocusManager;
-
-public class AboutView extends AbstractView {
- private static final int MAX_WIDTH = 300;
- private final int linePadding = -2;
- private final int noticePadding = 45;
- private final int margin = 14;
- private final Image image;
- private final int left;
- private final FocusManager focusManager;
-
- public AboutView() {
- super(new NullContent());
- image = ImageFactory.getInstance().loadImage(AboutIsis.getImageName());
- left = noticePadding;
- setContent(new NullContent(AboutIsis.getFrameworkName()));
-
- focusManager = new SubviewFocusManager(this);
- }
-
- @Override
- public FocusManager getFocusManager() {
- return focusManager;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- final Text titleStyle = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- final Text normalStyle = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
- final Color color = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
-
- clearBackground(canvas, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
- canvas.drawRectangleAround(getBounds(), Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY3));
-
- if (showingImage()) {
- canvas.drawImage(image, margin, margin);
- }
-
- int line = margin + image.getHeight() + noticePadding + normalStyle.getAscent();
-
- // application details
- String text = AboutIsis.getApplicationName();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, titleStyle);
- line += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- }
- text = AboutIsis.getApplicationCopyrightNotice();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- }
- text = AboutIsis.getApplicationVersion();
- if (text != null) {
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- line += 2 * normalStyle.getLineHeight();
- }
-
- // framework details
- text = AboutIsis.getFrameworkName();
- canvas.drawText(text, left, line, MAX_WIDTH, color, titleStyle);
- line += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
-
- text = AboutIsis.getFrameworkCopyrightNotice();
- canvas.drawText(text, left, line, MAX_WIDTH, color, normalStyle);
- line += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
-
- canvas.drawText(frameworkVersion(), left, line, MAX_WIDTH, color, normalStyle);
-
- }
-
- private String frameworkVersion() {
- return AboutIsis.getFrameworkVersion();
- }
-
- private boolean showingImage() {
- return image != null;
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final Text titleStyle = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- final Text normalStyle = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
-
- int height = 0;
-
- String text = AboutIsis.getFrameworkName();
- height += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- int width = titleStyle.stringWidth(text, MAX_WIDTH);
-
- text = AboutIsis.getFrameworkCopyrightNotice();
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
-
- text = frameworkVersion();
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
-
- text = AboutIsis.getApplicationName();
- if (text != null) {
- height += titleStyle.stringHeight(text, MAX_WIDTH) + titleStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, titleStyle.stringWidth(text, MAX_WIDTH));
- }
- text = AboutIsis.getApplicationCopyrightNotice();
- if (text != null) {
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
- }
- text = AboutIsis.getApplicationVersion();
- if (text != null) {
- height += normalStyle.stringHeight(text, MAX_WIDTH) + normalStyle.getLineSpacing() + linePadding;
- // height += normalStyle.getLineHeight();
- width = Math.max(width, normalStyle.stringWidth(text, MAX_WIDTH));
- }
-
- height += noticePadding;
-
- if (showingImage()) {
- height += image.getHeight();
- width = Math.max(image.getWidth(), width);
- }
-
- return new Size(margin + width + margin, margin + height + margin);
- }
-
- @Override
- public void firstClick(final Click click) {
- // dispose();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
deleted file mode 100644
index ec05f71..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/ExternalHelpViewerProgram.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.help;
-
-import java.io.IOException;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-public class ExternalHelpViewerProgram implements HelpViewer {
- private static final Logger LOG = Logger.getLogger(ExternalHelpViewerProgram.class);
- private final String program;
-
- public ExternalHelpViewerProgram(final String program) {
- this.program = program;
- }
-
- @Override
- public void open(final Location location, final String name, final String description, final String help) {
- final String exec = program + " " + help;
- try {
- Runtime.getRuntime().exec(exec);
- LOG.debug("executing '" + exec + "'");
- } catch (final IOException e) {
- throw new IsisException("faile to execute '" + exec + "'", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java
deleted file mode 100644
index 62cc21d..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpView.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.help;
-
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Click;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.content.NullContent;
-import org.apache.isis.viewer.dnd.view.text.TextBlockTarget;
-import org.apache.isis.viewer.dnd.view.text.TextContent;
-
-public class HelpView extends AbstractView implements TextBlockTarget {
- private static final int HEIGHT = 350;
- private static final int WIDTH = 400;
- private static final int MAX_TEXT_WIDTH = 375;
- private final TextContent content;
-
- public HelpView(final String name, final String description, final String help) {
- super(new NullContent());
- final String text = (name == null || name.trim().equals("") ? "" : (name + "\n")) + (description == null || description.trim().equals("") ? "" : (description + "\n")) + (help == null ? "" : help);
- content = new TextContent(this, 10, TextContent.WRAPPING);
- content.setText(text);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- int x = 0;
- int y = 0;
- final int xEntent = getSize().getWidth() - 1;
- final int yExtent = getSize().getHeight() - 1;
-
- final int arc = 9;
- canvas.drawSolidRectangle(x + 2, y + 2, xEntent - 4, yExtent - 4, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
- final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- canvas.drawRoundedRectangle(x, y++, xEntent, yExtent, arc, arc, black);
- canvas.drawRoundedRectangle(x + 1, y++, xEntent - 2, yExtent - 2, arc, arc, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2));
- canvas.drawRoundedRectangle(x + 2, y++, xEntent - 4, yExtent - 4, arc, arc, black);
-
- x += 10;
- y += ViewConstants.VPADDING;
- y += Toolkit.getText(ColorsAndFonts.TEXT_TITLE).getTextHeight();
- canvas.drawText("Help", x, y, black, Toolkit.getText(ColorsAndFonts.TEXT_TITLE));
-
- final String[] lines = content.getDisplayLines();
- for (final String line : lines) {
- y += Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getLineHeight();
- canvas.drawText(line, x, y, MAX_TEXT_WIDTH, black, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
- }
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final int height = Math.min(HEIGHT, availableSpace.getHeight());
- final int width = Math.min(WIDTH, availableSpace.getWidth());
- return new Size(width, height);
- }
-
- /**
- * Removes the help view when clicked on.
- */
- @Override
- public void firstClick(final Click click) {
- getViewManager().clearOverlayView(this);
- }
-
- @Override
- public int getMaxFieldWidth() {
- return WIDTH - 20;
- }
-
- @Override
- public Text getText() {
- return Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
deleted file mode 100644
index 05f378d..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/HelpViewer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.help;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-/**
- * A HelpSystem is used to launch the help system and bring up contextual help.
- */
-public interface HelpViewer {
-
- void open(Location location, String name, String description, String help);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
deleted file mode 100644
index d5cf93c..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/help/InternalHelpViewer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.help;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Viewer;
-
-public class InternalHelpViewer implements HelpViewer {
- private final Viewer viewer;
-
- public InternalHelpViewer(final Viewer viewer) {
- this.viewer = viewer;
- }
-
- @Override
- public void open(final Location location, final String name, final String description, final String help) {
- viewer.clearAction();
-
- final View helpView = new HelpView(name, description, help);
- location.add(20, 20);
- helpView.setLocation(location);
-
- viewer.setOverlayView(helpView);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
deleted file mode 100644
index 48339ea..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramAxis.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.histogram;
-
-import java.util.List;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ViewAxis;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-
-class HistogramAxis implements ViewAxis {
- private final ObjectAssociation fields[];
- private final double maxValues[];
- private final int noBars;
-
- public HistogramAxis(final Content content) {
- final List<? extends ObjectAssociation> associationList = HistogramSpecification.availableFields((CollectionContent) content);
- noBars = associationList.size();
- fields = new ObjectAssociation[noBars];
- maxValues = new double[noBars];
- int i = 0;
- for (final ObjectAssociation association : associationList) {
- fields[i++] = association;
- }
- }
-
- public double getLengthFor(final Content content, final int fieldNo) {
- return NumberAdapters.doubleValue(fields[fieldNo], fields[fieldNo].get(content.getAdapter())) / maxValues[fieldNo];
- }
-
- public void determineMaximum(final Content content) {
- int i = 0;
- for (final ObjectAssociation field : fields) {
- maxValues[i] = 0;
- final CollectionFacet collectionFacet = content.getAdapter().getSpecification().getFacet(CollectionFacet.class);
- for (final ObjectAdapter element : collectionFacet.iterable(content.getAdapter())) {
- final ObjectAdapter value = field.get(element);
- final double doubleValue = NumberAdapters.doubleValue(field, value);
- maxValues[i] = Math.max(maxValues[i], doubleValue);
- }
- i++;
- }
- }
-
- public int getNoBars() {
- return noBars;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
deleted file mode 100644
index 7d64617..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramBar.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.histogram;
-
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.ObjectView;
-
-class HistogramBar extends ObjectView {
- private static final int colors[] = new int[] { 0xccccff, 0x99ff99, 0xffccff };
- private final HistogramAxis histogramAxis;
-
- protected HistogramBar(final Content content, final HistogramAxis histogramAxis, final ViewSpecification specification) {
- super(content, specification);
- this.histogramAxis = histogramAxis;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
- int y = 0;
- final int height = (getSize().getHeight() - 5) / histogramAxis.getNoBars();
- final Text text = Toolkit.getText(ColorsAndFonts.TEXT_LABEL);
- final Color color = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
- canvas.drawText(getContent().title(), 0, height / 2 + text.getAscent() / 2, color, text);
-
- for (int i = 0; i < histogramAxis.getNoBars(); i++) {
- final double length = (getSize().getWidth() - 160) * histogramAxis.getLengthFor(getContent(), i);
- canvas.drawSolidRectangle(160, y, (int) length, height, Toolkit.getColor(colors[i % colors.length]));
- canvas.drawRectangle(160, y, (int) length, height, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK));
- y += height + 2;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
deleted file mode 100644
index 91fba77..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramLayout.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.histogram;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-
-public class HistogramLayout implements Layout {
- private final int width = 500;
- private final int barHeight = 24;
-
- @Override
- public void layout(final View view, final Size maximumSize) {
- final HistogramAxis axis = view.getViewAxes().getAxis(HistogramAxis.class);
- axis.determineMaximum(view.getContent());
- final int noBars = axis.getNoBars();
- final int height = barHeight * noBars;
- final View[] subviews = view.getSubviews();
- int y = ViewConstants.VPADDING;
- for (final View bar : subviews) {
- bar.setSize(new Size(width, height));
- bar.setLocation(new Location(ViewConstants.HPADDING, y));
- y += height;
- }
- }
-
- @Override
- public Size getRequiredSize(final View view) {
- final HistogramAxis axis = view.getViewAxes().getAxis(HistogramAxis.class);
- final int noBars = axis.getNoBars();
- final View[] subviews = view.getSubviews();
- final int graphHeight = subviews.length * barHeight * noBars + ViewConstants.VPADDING * 2;
- return new Size(width + ViewConstants.HPADDING * 2, graphHeight);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
deleted file mode 100644
index c39c4bc..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/HistogramSpecification.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.histogram;
-
-import java.util.List;
-
-import org.apache.isis.applib.filter.Filter;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.base.Layout;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-import org.apache.isis.viewer.dnd.view.composite.CollectionElementBuilder;
-import org.apache.isis.viewer.dnd.view.composite.CompositeViewSpecification;
-
-public class HistogramSpecification extends CompositeViewSpecification {
-
- static List<? extends ObjectAssociation> availableFields(final CollectionContent content) {
- List<? extends ObjectAssociation> associationList;
- associationList = content.getElementSpecification().getAssociations(new Filter<ObjectAssociation>() {
- @Override
- public boolean accept(final ObjectAssociation t) {
- return NumberAdapters.contains(t);
- }
- });
- return associationList;
- }
-
- public HistogramSpecification() {
- builder = new CollectionElementBuilder(new ViewFactory() {
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- return new HistogramBar(content, axes.getAxis(HistogramAxis.class), HistogramSpecification.this);
- }
- });
- }
-
- @Override
- public Layout createLayout(final Content content, final Axes axes) {
- return new HistogramLayout();
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isCollection() && requirement.isOpen() && availableFields((CollectionContent) requirement.getContent()).size() > 0;
- }
-
- @Override
- public void createAxes(final Content content, final Axes axes) {
- super.createAxes(content, axes);
- axes.add(new HistogramAxis(content));
- }
-
- @Override
- public String getName() {
- return "Histogram (experimental)";
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return true;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java
deleted file mode 100644
index 26ec31b..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/histogram/NumberAdapters.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.histogram;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.progmodel.facets.value.floats.FloatingPointValueFacet;
-import org.apache.isis.core.progmodel.facets.value.integer.IntegerValueFacet;
-import org.apache.isis.core.progmodel.facets.value.longs.DoubleFloatingPointValueFacet;
-import org.apache.isis.core.progmodel.facets.value.money.MoneyValueFacet;
-
-public class NumberAdapters {
- static interface Converter {
- double value(ObjectAdapter value);
- }
-
- static {
- new Converter() {
- @Override
- public double value(final ObjectAdapter arg0) {
- return 0;
- }
- };
-
- }
-
- public static boolean contains(final ObjectAssociation t) {
- return t.getSpecification().containsFacet(IntegerValueFacet.class) || t.getSpecification().containsFacet(DoubleFloatingPointValueFacet.class) || t.getSpecification().containsFacet(FloatingPointValueFacet.class) || t.getSpecification().containsFacet(MoneyValueFacet.class);
- }
-
- public static double doubleValue(final ObjectAssociation field, final ObjectAdapter value) {
- final ObjectSpecification specification = value.getSpecification();
-
- final IntegerValueFacet intValueFacet = specification.getFacet(IntegerValueFacet.class);
- if (intValueFacet != null) {
- return intValueFacet.integerValue(value).doubleValue();
- }
-
- final DoubleFloatingPointValueFacet doubleValueFacet = specification.getFacet(DoubleFloatingPointValueFacet.class);
- if (doubleValueFacet != null) {
- return doubleValueFacet.doubleValue(value).doubleValue();
- }
-
- final FloatingPointValueFacet floatValueFacet = specification.getFacet(FloatingPointValueFacet.class);
- if (floatValueFacet != null) {
- return floatValueFacet.floatValue(value).doubleValue();
- }
-
- final MoneyValueFacet moneyValueFacet = specification.getFacet(MoneyValueFacet.class);
- if (moneyValueFacet != null) {
- return moneyValueFacet.getAmount(value);
- }
-
- return 0.0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
deleted file mode 100644
index 4d5c137..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/Icon.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.IconGraphic;
-import org.apache.isis.viewer.dnd.view.base.ObjectView;
-import org.apache.isis.viewer.dnd.view.text.ObjectTitleText;
-import org.apache.isis.viewer.dnd.view.text.TitleText;
-
-public class Icon extends ObjectView {
- private IconGraphic icon;
- private boolean isVertical;
- private IconGraphic selectedGraphic;
- private TitleText title;
- private IconGraphic unselectedGraphic;
-
- public Icon(final Content content, final ViewSpecification specification) {
- super(content, specification);
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- ensureHasIcon();
-
- int x = 0;
- int y = 0;
- icon.draw(canvas, x, getBaseline());
- if (isVertical) {
- final int w = title.getSize().getWidth();
- x = (w > icon.getSize().getWidth()) ? x : getSize().getWidth() / 2 - w / 2;
- y = icon.getSize().getHeight() + Toolkit.getText(ColorsAndFonts.TEXT_ICON).getAscent() + ViewConstants.VPADDING;
- } else {
- x += icon.getSize().getWidth();
- x += ViewConstants.HPADDING;
- y = icon.getBaseline();
- }
- final int maxWidth = getSize().getWidth() - x;
- title.draw(canvas, x, y, maxWidth);
-
- if (getState().isActive()) {
- final Image busyImage = ImageFactory.getInstance().loadIcon("busy", 16, null);
- canvas.drawImage(busyImage, icon.getSize().getWidth() - 16 - 4, 4);
- }
-
- }
-
- private void ensureHasIcon() {
- if (icon == null) {
- // icon = selectedGraphic;
- }
- }
-
- @Override
- public void entered() {
- icon = selectedGraphic;
- markDamaged();
- super.entered();
- }
-
- @Override
- public void exited() {
- icon = unselectedGraphic;
- markDamaged();
- super.exited();
- }
-
- @Override
- public int getBaseline() {
- ensureHasIcon();
- return icon.getBaseline();
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- if (icon == null) {
- // icon = unselectedGraphic;
- }
-
- final Size size = icon.getSize();
- final Size textSize = title.getSize();
- if (isVertical) {
- size.extendHeight(ViewConstants.VPADDING + textSize.getHeight() + ViewConstants.VPADDING);
- size.ensureWidth(textSize.getWidth());
- } else {
- size.extendWidth(ViewConstants.HPADDING);
- size.extendWidth(textSize.getWidth());
- }
- return size;
- }
-
- /**
- * Set up the graphic to be used when displaying the icon and the icon is
- * selected.
- */
- public void setSelectedGraphic(final IconGraphic selectedGraphic) {
- this.selectedGraphic = selectedGraphic;
- if (unselectedGraphic == null) {
- unselectedGraphic = selectedGraphic;
- icon = selectedGraphic;
- }
- }
-
- /**
- * Set up the title to be used when displaying the icon.
- */
- public void setTitle(final ObjectTitleText text) {
- title = text;
- }
-
- /**
- * Set up the graphic to be used when displaying the icon and the icon is
- * unselected. If this returns null the graphic will not be changed when the
- * icon becomes unselected.
- */
- public void setUnselectedGraphic(final IconGraphic unselectedGraphic) {
- this.unselectedGraphic = unselectedGraphic;
- icon = unselectedGraphic;
- }
-
- /**
- * Specifies if the graphic should be aligned vertical above the label;
- * otherwise aligned horizontally.
- */
- public void setVertical(final boolean isVertical) {
- this.isVertical = isVertical;
- }
-
- @Override
- public void update(final ObjectAdapter object) {
- final View p = getParent();
- if (p != null) {
- p.invalidateLayout();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconElementFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconElementFactory.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconElementFactory.java
deleted file mode 100644
index 4f16f27..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconElementFactory.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewFactory;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.BlankView;
-
-public class IconElementFactory implements ViewFactory {
- private final ViewSpecification objectSpec;
- private final ViewSpecification collectionSpec;
- private final boolean createViewsForEmptyContent;
-
- public IconElementFactory() {
- this(null, null, false);
- }
-
- public IconElementFactory(final ViewSpecification objectSpec, final ViewSpecification collectionSpec, final boolean createViewsForEmptyContent) {
- this.objectSpec = this.objectSpec == null ? new SubviewIconSpecification() : objectSpec;
- this.collectionSpec = this.collectionSpec == null ? new SubviewIconSpecification() : collectionSpec;
- this.createViewsForEmptyContent = createViewsForEmptyContent;
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- if (content.isObject()) {
- if (content.getAdapter() == null) {
- return createViewsForEmptyContent ? new BlankView(content) : null;
- } else {
- return objectSpec.createView(content, axes, -1);
- }
- } else if (content.isCollection()) {
- return collectionSpec.createView(content, axes, -1);
- } else {
- // TODO decide what to do with values: use factory, use another
- // SubviewSpec, or ignore always
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconSpecification.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconSpecification.java
deleted file mode 100644
index 9aefbc2..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/IconSpecification.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.IconGraphic;
-import org.apache.isis.viewer.dnd.view.text.ObjectTitleText;
-
-public class IconSpecification implements ViewSpecification {
- private final boolean isSubView;
- private final boolean isReplaceable;
-
- public IconSpecification() {
- this(true, true);
- }
-
- IconSpecification(final boolean isSubView, final boolean isReplaceable) {
- this.isSubView = isSubView;
- this.isReplaceable = isReplaceable;
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isClosed() && requirement.isObject() && requirement.hasReference();
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- final Icon icon = new Icon(content, this);
- icon.setTitle(new ObjectTitleText(icon, style));
- icon.setSelectedGraphic(new IconGraphic(icon, style));
- return icon;
- }
-
- @Override
- public String getName() {
- return "Icon";
- }
-
- @Override
- public boolean isSubView() {
- return isSubView;
- }
-
- @Override
- public boolean isReplaceable() {
- return isReplaceable;
- }
-
- @Override
- public boolean isResizeable() {
- return false;
- }
-
- public View decorateSubview(final View subview) {
- return subview;
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/LargeIconSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/LargeIconSpecification.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/LargeIconSpecification.java
deleted file mode 100644
index 6fdb2ba..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/LargeIconSpecification.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.base.IconGraphic;
-import org.apache.isis.viewer.dnd.view.border.ObjectBorder;
-import org.apache.isis.viewer.dnd.view.text.ObjectTitleText;
-
-public class LargeIconSpecification implements ViewSpecification {
- private static final int DEFAULT_SIZE = 64;
- private final int size;
-
- public LargeIconSpecification() {
- this(DEFAULT_SIZE);
- }
-
- LargeIconSpecification(final int size) {
- this.size = size;
- }
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.isClosed() && requirement.isObject() && requirement.hasReference() && requirement.isSubview();
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final Text style = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- final Icon icon = new Icon(content, this);
- icon.setTitle(new ObjectTitleText(icon, style));
- icon.setSelectedGraphic(new IconGraphic(icon, size));
- icon.setVertical(true);
- return new ObjectBorder(icon);
- }
-
- @Override
- public String getName() {
- return "Image";
- }
-
- @Override
- public boolean isSubView() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/RootIconSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/RootIconSpecification.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/RootIconSpecification.java
deleted file mode 100644
index eeba48a..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/RootIconSpecification.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-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.Placement;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.base.AbstractViewDecorator;
-import org.apache.isis.viewer.dnd.view.border.ObjectBorder;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-class IconOpenAction extends AbstractViewDecorator {
- protected IconOpenAction(final View wrappedView) {
- super(wrappedView);
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet menuOptions) {
- super.viewMenuOptions(menuOptions);
- menuOptions.add(new UserActionAbstract("Close") {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- getView().dispose();
- // getWorkspace().removeObject((ObjectAdapter)
- // view.getContent().getAdapter());
- }
- });
- }
-
- private void openIcon() {
- getWorkspace().addWindowFor(getContent().getAdapter(), new Placement(getLocation()));
- }
-
- @Override
- public void secondClick(final Click click) {
- openIcon();
- }
-}
-
-public class RootIconSpecification extends IconSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return super.canDisplay(requirement) && requirement.is(ViewRequirement.ROOT);
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final View icon = super.createView(content, axes, sequence);
- return new ObjectBorder(new IconOpenAction(icon));
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/SubviewIconSpecification.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/SubviewIconSpecification.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/SubviewIconSpecification.java
deleted file mode 100644
index 6d0d6d0..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/icon/SubviewIconSpecification.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.icon;
-
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.border.ObjectBorder;
-import org.apache.isis.viewer.dnd.view.field.OneToOneField;
-import org.apache.isis.viewer.dnd.view.lookup.OpenObjectDropDownBorder;
-
-public class SubviewIconSpecification extends IconSpecification {
- private static final ViewSpecification spec = new IconSpecification();
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return super.canDisplay(requirement) && requirement.is(ViewRequirement.CLOSED) && requirement.is(ViewRequirement.SUBVIEW);
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final View view = super.createView(content, axes, sequence);
- /*
- * boolean isEditable = content instanceof OneToOneField &&
- * ((OneToOneField) content).isEditable().isAllowed(); boolean
- * hasOptions = content.isOptionEnabled(); if (isEditable && hasOptions)
- * { return new OpenObjectDropDownBorder(view, spec); } return view;
- */
-
- if (content instanceof OneToOneField && ((OneToOneField) content).isEditable().isVetoed()) {
- return new ObjectBorder(view);
- } else {
- if (content.isOptionEnabled()) {
- return new ObjectBorder(new OpenObjectDropDownBorder(view, spec));
- } else {
- return new ObjectBorder(view);
- }
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ClickImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ClickImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ClickImpl.java
deleted file mode 100644
index 1c4e4ec..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ClickImpl.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Offset;
-import org.apache.isis.viewer.dnd.view.Click;
-
-/**
- * Describes a mouse click event.
- */
-public class ClickImpl extends PointerEvent implements Click {
- private final Location location;
- private final Location locationWithinViewer;
-
- /**
- * Creates a new click event object.
- *
- * @param mouseLocation
- * the location of the mouse relative to the viewer
- * @param modifiers
- * the button and key held down during the click (@see
- * java.awt.event.MouseEvent)
- */
- public ClickImpl(final Location mouseLocation, final int modifiers) {
- super(modifiers);
-
- this.location = new Location(mouseLocation);
- this.locationWithinViewer = new Location(mouseLocation);
- }
-
- @Override
- public Location getLocation() {
- return location;
- }
-
- @Override
- public Location getLocationWithinViewer() {
- return locationWithinViewer;
- }
-
- /**
- * Translate the location of this event by the specified offset.
- */
- @Override
- public void subtract(final int x, final int y) {
- location.subtract(x, y);
- }
-
- @Override
- public String toString() {
- return "Click [location=" + location + "," + super.toString() + "]";
- }
-
- public void add(final Offset offset) {
- location.add(offset.getDeltaX(), offset.getDeltaY());
- }
-
- public void subtract(final Offset offset) {
- subtract(offset.getDeltaX(), offset.getDeltaY());
- }
-
- @Override
- public void subtract(final Location location) {
- subtract(location.getX(), location.getY());
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ContentDragImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ContentDragImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ContentDragImpl.java
deleted file mode 100644
index cb5ddb7..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ContentDragImpl.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ContentDrag;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Viewer;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class ContentDragImpl extends DragImpl implements ContentDrag {
- private final View dragView;
- private Location location;
- private View previousTarget;
- private final Content sourceContent;
- private View target;
- private final Workspace workspace;
- private final Location offset;
- private final View source;
-
- /**
- * Creates a new drag event. The source view has its pickup(), and then,
- * exited() methods called on it. The view returned by the pickup method
- * becomes this event overlay view, which is moved continuously so that it
- * tracks the pointer,
- *
- * @param source
- * the view over which the pointer was when this event started
- */
- public ContentDragImpl(final View source, final Location offset, final View dragView) {
- if (dragView == null) {
- throw new NullPointerException();
- }
- workspace = source.getWorkspace();
- sourceContent = source.getContent();
- this.dragView = dragView;
- this.offset = offset;
- this.source = source.getView();
- }
-
- /**
- * Cancels drag by calling dragOut() on the current target, and changes the
- * cursor back to the default.
- */
- @Override
- public void cancel(final Viewer viewer) {
- if (target != null) {
- target.dragOut(this);
- }
- viewer.clearAction();
- }
-
- @Override
- public void drag(final View target, final Location location, final int mods) {
- this.location = location;
- this.target = target;
- this.mods = mods;
-
- moveDragView();
- crossBoundary(target);
- target.drag(this);
- }
-
- private void crossBoundary(final View target) {
- if (target != previousTarget) {
- if (previousTarget != null) {
- previousTarget.dragOut(this);
- previousTarget = null;
- }
-
- target.dragIn(this);
- previousTarget = target;
- }
- }
-
- private void moveDragView() {
- if (dragView != null) {
- dragView.markDamaged();
- final Location newLocation = new Location(this.location);
- newLocation.subtract(offset);
- dragView.setLocation(newLocation);
- dragView.limitBoundsWithin(workspace.getSize());
- dragView.markDamaged();
- }
- }
-
- /**
- * Ends the drag by calling drop() on the current target, and changes the
- * cursor back to the default.
- */
- @Override
- public void end(final Viewer viewer) {
- viewer.getSpy().addAction("drop on " + target);
- target.drop(this);
- viewer.clearAction();
- }
-
- @Override
- public View getOverlay() {
- return dragView;
- }
-
- @Override
- public View getSource() {
- return source;
- }
-
- /**
- * Returns the Content object from the source view.
- */
- @Override
- public Content getSourceContent() {
- return sourceContent;
- }
-
- @Override
- public Location getTargetLocation() {
- final Location location = new Location(this.location);
- location.subtract(target.getAbsoluteLocation());
- // location.add(-getOffset().getX(), -getOffset().getY());
- // location.add(-getOffset().getX(), -getOffset().getY());
-
- return location;
- }
-
- @Override
- public Location getOffset() {
- return offset;
- }
-
- /**
- * Returns the current target view.
- */
- @Override
- public View getTargetView() {
- return target;
- }
-
- @Override
- public String toString() {
- return "ContentDrag [" + super.toString() + "]";
- }
-
- @Override
- public void subtract(final int left, final int top) {
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragImpl.java
deleted file mode 100644
index 55a1f89..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.DragEvent;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Viewer;
-
-public abstract class DragImpl extends PointerEvent implements DragEvent {
- protected DragImpl() {
- super(0);
- }
-
- /**
- * Indicates the drag has been cancelled; no action should be taken.
- */
- @Override
- public abstract void cancel(final Viewer viewer);
-
- /**
- * Indicates that the drag state has changed.
- */
- @Override
- public abstract void drag(final View target, final Location location, final int mods);
-
- /**
- * Indicates the drag has properly ended (the mouse button has been
- * released)
- *
- */
- @Override
- public abstract void end(final Viewer viewer);
-
- @Override
- public abstract View getOverlay();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragStartImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragStartImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragStartImpl.java
deleted file mode 100644
index e825fc2..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/DragStartImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.core.commons.lang.ToString;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Offset;
-import org.apache.isis.viewer.dnd.view.DragStart;
-
-public class DragStartImpl extends PointerEvent implements DragStart {
- private final Location location;
-
- public DragStartImpl(final Location location, final int mods) {
- super(mods);
- this.location = location;
- }
-
- @Override
- public Location getLocation() {
- return location;
- }
-
- @Override
- public void subtract(final Location location) {
- this.location.subtract(location);
- }
-
- @Override
- public void subtract(final int x, final int y) {
- location.subtract(x, y);
- }
-
- public void add(final Offset offset) {
- location.add(offset.getDeltaX(), offset.getDeltaY());
- }
-
- @Override
- public String toString() {
- final ToString str = new ToString(this);
- str.append("location", location);
- str.append("buttons", super.toString());
- return str.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/KeyboardActionImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/KeyboardActionImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/KeyboardActionImpl.java
deleted file mode 100644
index 7fcab94..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/KeyboardActionImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.viewer.dnd.view.KeyboardAction;
-
-public class KeyboardActionImpl implements KeyboardAction {
-
- final int keyCode;
- final int modifiers;
- private boolean isConsumed;
-
- public KeyboardActionImpl(final int keyCode, final int modifiers) {
- this.keyCode = keyCode;
- this.modifiers = modifiers;
- isConsumed = false;
- }
-
- @Override
- public int getKeyCode() {
- return keyCode;
- }
-
- @Override
- public char getKeyChar() {
- return (char) keyCode;
- }
-
- @Override
- public int getModifiers() {
- return modifiers;
- }
-
- @Override
- public boolean isConsumed() {
- return isConsumed;
- }
-
- @Override
- public void consume() {
- isConsumed = true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/PointerEvent.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/PointerEvent.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/PointerEvent.java
deleted file mode 100644
index 8367021..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/PointerEvent.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import java.awt.event.InputEvent;
-
-/**
- * Details an event involving the pointer, such as a click or drag.
- */
-public abstract class PointerEvent {
- protected int mods;
-
- /**
- * Creates a new pointer event object.
- *
- * @param mods
- * the button and key modifiers (@see java.awt.event.MouseEvent)
- */
- PointerEvent(final int mods) {
- this.mods = mods;
- }
-
- public boolean button1() {
- return (isButton1() && !isShift()) || (isButton2() && isShift());
- }
-
- public boolean button2() {
- return (isButton2() && !isShift()) || (isButton1() && isShift());
- }
-
- public boolean button3() {
- return isButton3();
- }
-
- /**
- * Returns true if the 'Alt' key is depressed
- */
- public boolean isAlt() {
- return (mods & InputEvent.ALT_MASK) > 0;
- }
-
- /**
- * Returns true if the left-hand button on the mouse is depressed
- */
- private boolean isButton1() {
- return (mods & InputEvent.BUTTON1_MASK) > 0;
- }
-
- /**
- * Returns true if the middle button on the mouse is depressed
- */
- private boolean isButton2() {
- return (mods & InputEvent.BUTTON2_MASK) > 0;
- }
-
- /**
- * Returns true if the right-hand button on the mouse is depressed
- */
- private boolean isButton3() {
- return (mods & InputEvent.BUTTON3_MASK) > 0;
- }
-
- /**
- * Returns true if the control key is depressed
- */
- public boolean isCtrl() {
- return (mods & InputEvent.CTRL_MASK) > 0;
- }
-
- /**
- * Returns true if the 'Alt' key is depressed
- */
- public boolean isMeta() {
- return (mods & InputEvent.META_MASK) > 0;
- }
-
- /**
- * Returns true if the shift key is depressed
- */
- public boolean isShift() {
- return (mods & InputEvent.SHIFT_MASK) > 0;
- }
-
- @Override
- public String toString() {
- final String buttons = (isButton1() ? "^" : "-") + (isButton2() ? "^" : "-") + (isButton3() ? "^" : "-");
- final String modifiers = (isShift() ? "S" : "-") + (isAlt() ? "A" : "-") + (isCtrl() ? "C" : "-");
-
- return "buttons=" + buttons + ",modifiers=" + modifiers;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/SimpleInternalDrag.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/SimpleInternalDrag.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/SimpleInternalDrag.java
deleted file mode 100644
index 3a3e418..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/SimpleInternalDrag.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.core.commons.lang.ToString;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Offset;
-import org.apache.isis.viewer.dnd.drawing.Padding;
-import org.apache.isis.viewer.dnd.view.InternalDrag;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Viewer;
-
-public class SimpleInternalDrag extends DragImpl implements InternalDrag {
- private final Location location;
- // TODO replace Location with Offset
- private final Location offset;
- private final View view;
-
- /**
- * Creates a new drag event. The source view has its pickup(), and then,
- * exited() methods called on it. The view returned by the pickup method
- * becomes this event overlay view, which is moved continuously so that it
- * tracks the pointer,
- *
- * @param view
- * the view over which the pointer was when this event started
- * @param location
- * the location within the viewer (the Frame/Applet/Window etc)
- *
- * TODO combine the two constructors
- */
- public SimpleInternalDrag(final View view, final Location location) {
- this.view = view;
-
- this.location = new Location(location);
- offset = view.getAbsoluteLocation();
-
- final Padding targetPadding = view.getPadding();
- final Padding containerPadding = view.getView().getPadding();
- offset.add(containerPadding.getLeft() - targetPadding.getLeft(), containerPadding.getTop() - targetPadding.getTop());
-
- this.location.subtract(offset);
- }
-
- public SimpleInternalDrag(final View view, final Offset off) {
- this.view = view;
-
- location = new Location();
-
- offset = new Location(off.getDeltaX(), off.getDeltaY());
-
- final Padding targetPadding = view.getPadding();
- final Padding containerPadding = view.getView().getPadding();
- offset.add(containerPadding.getLeft() - targetPadding.getLeft(), containerPadding.getTop() - targetPadding.getTop());
-
- this.location.subtract(offset);
- }
-
- @Override
- public void cancel(final Viewer viewer) {
- view.dragCancel(this);
- }
-
- @Override
- public void drag(final View target, final Location location, final int mods) {
- this.location.setX(location.getX());
- this.location.setY(location.getY());
- this.location.subtract(offset);
- view.drag(this);
- }
-
- @Override
- public void end(final Viewer viewer) {
- view.dragTo(this);
- }
-
- /**
- * Gets the location of the pointer relative to the view.
- */
- @Override
- public Location getLocation() {
- return new Location(location);
- }
-
- @Override
- public View getOverlay() {
- return null;
- }
-
- @Override
- public String toString() {
- final ToString s = new ToString(this, super.toString());
- s.append("location", location);
- s.append("relative", getLocation());
- return s.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ViewDragImpl.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ViewDragImpl.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ViewDragImpl.java
deleted file mode 100644
index 9bf31e8..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/interaction/ViewDragImpl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.interaction;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Offset;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewDrag;
-import org.apache.isis.viewer.dnd.view.Viewer;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class ViewDragImpl extends DragImpl implements ViewDrag {
- private Location location;
- /**
- * Offset from the view's top-left corner to the pointer (relative to the
- * view).
- */
- private final Offset overlayOffset;
- private final View sourceView;
- private final View overlayView;
- private View targetView;
- private final Workspace viewsWorkspace;
-
- /**
- * Creates a new drag event. The source view has its pickup(), and then,
- * exited() methods called on it. The view returned by the pickup method
- * becomes this event overlay view, which is moved continuously so that it
- * tracks the pointer.
- *
- * @param view
- * the view over which the pointer was when this event started
- */
- public ViewDragImpl(final View view, final Offset offset, final View dragView) {
- this.sourceView = view;
- this.overlayView = dragView;
- this.overlayOffset = offset;
-
- viewsWorkspace = view.getWorkspace();
- }
-
- /**
- * getView().getAbsoluteLocation().getX(),
- * -getView().getAbsoluteLocation().getY() Cancel drag by changing cursor
- * back to pointer.
- */
- @Override
- public void cancel(final Viewer viewer) {
- getSourceView().getFeedbackManager().showDefaultCursor();
- }
-
- /**
- * Moves the overlay view so it follows the pointer
- */
- protected void drag(final Viewer viewer) {
- if (overlayView != null) {
- overlayView.markDamaged();
- updateDraggingLocation();
- overlayView.markDamaged();
- }
- }
-
- @Override
- public void drag(final View target, final Location location, final int mods) {
- this.location = location;
- if (overlayView != null) {
- overlayView.markDamaged();
- updateDraggingLocation();
- // this.location.subtract(target.getAbsoluteLocation());
- viewsWorkspace.getViewManager().getSpy().addTrace(target, " over", getLocation());
- targetView = target;
- target.drag(this);
- overlayView.markDamaged();
- }
- }
-
- /**
- * Ends the drag by calling drop() on the workspace.
- */
- @Override
- public void end(final Viewer viewer) {
- viewer.clearAction();
- targetView.drop(this);
- }
-
- @Override
- public View getOverlay() {
- return overlayView;
- }
-
- @Override
- public Location getLocation() {
- return location;
- }
-
- @Override
- public View getSourceView() {
- return sourceView;
- }
-
- @Override
- public Location getViewDropLocation() {
- final Location viewLocation = new Location(location);
- viewLocation.subtract(overlayOffset);
- return viewLocation;
- }
-
- public void subtract(final Location location) {
- location.subtract(location);
- }
-
- @Override
- public String toString() {
- return "ViewDrag [" + super.toString() + "]";
- }
-
- private void updateDraggingLocation() {
- final Location viewLocation = new Location(location);
- viewLocation.subtract(overlayOffset);
- overlayView.setLocation(viewLocation);
- overlayView.limitBoundsWithin(viewsWorkspace.getSize());
- }
-
- @Override
- public void subtract(final int x, final int y) {
- location.subtract(x, y);
- }
-
-}