You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2016/05/21 07:10:07 UTC
[06/56] [abbrv] [partial] isis git commit: ISIS-1335: deleting the
mothballed directory.
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/DetailedMessageViewSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/DetailedMessageViewSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/DetailedMessageViewSpecification.java
deleted file mode 100644
index 0acae98..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/DetailedMessageViewSpecification.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.message;
-
-import java.util.StringTokenizer;
-
-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.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.ButtonAction;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAreaType;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.border.ButtonBorder;
-import org.apache.isis.viewer.dnd.view.border.ScrollBorder;
-import org.apache.isis.viewer.dnd.view.control.AbstractButtonAction;
-import org.apache.isis.viewer.dnd.view.control.CancelAction;
-import org.apache.isis.viewer.dnd.view.debug.DebugOutput;
-
-public class DetailedMessageViewSpecification implements ViewSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- final Content content = requirement.getContent();
- return content instanceof MessageContent && ((MessageContent) content).getDetail() != null;
- }
-
- @Override
- public String getName() {
- return "Detailed Message";
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final ButtonAction actions[] = new ButtonAction[] { new AbstractButtonAction("Print...") {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- DebugOutput.print("Print exception", extract(view));
- }
- }, new AbstractButtonAction("Save...") {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- DebugOutput.saveToFile("Save exception", "Exception", extract(view));
- }
- }, new AbstractButtonAction("Copy") {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- DebugOutput.saveToClipboard(extract(view));
- }
- }, new CancelAction(),
-
- };
-
- final DetailedMessageView messageView = new DetailedMessageView(content, this);
- return new ButtonBorder(actions, new ScrollBorder(messageView));
- }
-
- private String extract(final View view) {
- final Content content = view.getContent();
- final String message = ((MessageContent) content).getMessage();
- final String heading = ((MessageContent) content).title();
- final String detail = ((MessageContent) content).getDetail();
-
- final StringBuffer text = new StringBuffer();
- text.append(heading);
- text.append("\n\n");
- text.append(message);
- text.append("\n\n");
- text.append(detail);
- text.append("\n\n");
- return text.toString();
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return true;
- }
-}
-
-class DetailedMessageView extends AbstractView {
- protected DetailedMessageView(final Content content, final ViewSpecification specification) {
- super(content, specification);
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final Size size = new Size();
- size.extendHeight(Toolkit.getText(ColorsAndFonts.TEXT_TITLE).getTextHeight());
- size.extendHeight(30);
-
- final String message = ((MessageContent) getContent()).getMessage();
- size.ensureWidth(500);
- size.extendHeight(Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).stringHeight(message, 500));
- size.extendHeight(30);
-
- final String detail = ((MessageContent) getContent()).getDetail();
- final StringTokenizer st = new StringTokenizer(detail, "\n\r");
- while (st.hasMoreTokens()) {
- final String line = st.nextToken();
- final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- size.ensureWidth((line.startsWith("\t") ? 20 : 0) + text.stringWidth(line));
- size.extendHeight(text.getTextHeight());
- }
-
- size.extend(40, 20);
- return size;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- final int left = 10;
- final Text title = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- int y = 10 + title.getAscent();
- final String message = ((MessageContent) getContent()).getMessage();
- final String heading = ((MessageContent) getContent()).title();
- final String detail = ((MessageContent) getContent()).getDetail();
-
- final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- canvas.drawText(heading, left, y, black, title);
- y += title.getTextHeight();
- final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- canvas.drawText(message, left, y, 500, black, text);
-
- y += text.stringHeight(message, 500);
- canvas.drawText(detail, left, y, 1000, Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1), text);
- }
-
- @Override
- public ViewAreaType viewAreaType(final Location mouseLocation) {
- return ViewAreaType.VIEW;
- }
-
- @Override
- public void setFocusManager(final FocusManager focusManager) {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/ExceptionMessageContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/ExceptionMessageContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/ExceptionMessageContent.java
deleted file mode 100644
index c8b5518..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/ExceptionMessageContent.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.message;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.IsisApplicationException;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.commons.lang.ThrowableExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
-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 ExceptionMessageContent implements MessageContent {
-
- protected String message;
- protected String name;
- protected String trace;
- protected String title;
- private final String icon;
-
- public ExceptionMessageContent(final Throwable error) {
- String fullName = error.getClass().getName();
- fullName = fullName.substring(fullName.lastIndexOf('.') + 1);
- name = StringExtensions.asNaturalName2(fullName);
- message = error.getMessage();
- trace = ThrowableExtensions.stackTraceFor(error);
- if (trace.indexOf("\tat") != -1) {
- trace = trace.substring(trace.indexOf("\tat"));
- }
-
- if (name == null) {
- name = "";
- }
- if (message == null) {
- message = "";
- }
- if (trace == null) {
- trace = "";
- }
-
- if (error instanceof IsisApplicationException) {
- title = "Application Error";
- icon = "application-error";
- } else if (error instanceof ConcurrencyException) {
- title = "Concurrency Error";
- icon = "concurrency-error";
- } else {
- title = "System Error";
- icon = "system-error";
- }
-
- }
-
- @Override
- public String getMessage() {
- return message;
- }
-
- @Override
- public String getDetail() {
- return trace;
- }
-
- @Override
- public String getIconName() {
- return icon;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- return null;
- }
-
- @Override
- public String getDescription() {
- return name;
- }
-
- @Override
- public String getHelp() {
- return "";
- }
-
- @Override
- public Image getIconPicture(final int iconHeight) {
- return null;
- }
-
- @Override
- public String getId() {
- return "message-exception";
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return null;
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return null;
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return null;
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public boolean isObject() {
- return false;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return false;
- }
-
- @Override
- public boolean isPersistable() {
- return false;
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- @Override
- public boolean isTextParseable() {
- return false;
- }
-
- public void parseTextEntry(final String entryText) {
- }
-
- @Override
- public String title() {
- return name;
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet options) {
- }
-
- @Override
- public String windowTitle() {
- return title;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageContent.java
deleted file mode 100644
index b8e6c33..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageContent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.message;
-
-import org.apache.isis.viewer.dnd.view.Content;
-
-public interface MessageContent extends Content {
- String getMessage();
-
- String getDetail();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageDialogSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageDialogSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageDialogSpecification.java
deleted file mode 100644
index d7ec4d33..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/MessageDialogSpecification.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.message;
-
-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.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.ButtonAction;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.FocusManager;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewAreaType;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.base.AbstractView;
-import org.apache.isis.viewer.dnd.view.border.ButtonBorder;
-import org.apache.isis.viewer.dnd.view.border.ScrollBorder;
-import org.apache.isis.viewer.dnd.view.control.AbstractButtonAction;
-import org.apache.isis.viewer.dnd.view.window.SubviewFocusManager;
-
-public class MessageDialogSpecification implements ViewSpecification {
-
- @Override
- public boolean canDisplay(final ViewRequirement requirement) {
- return requirement.getContent() instanceof MessageContent;
- }
-
- @Override
- public String getName() {
- return "Message Dialog";
- }
-
- @Override
- public View createView(final Content content, final Axes axes, final int sequence) {
- final ButtonAction actions[] = new ButtonAction[] { new CloseViewAction() };
- final MessageView messageView = new MessageView((MessageContent) content, this);
- final View dialogView = new ButtonBorder(actions, new ScrollBorder(messageView));
- dialogView.setFocusManager(new SubviewFocusManager(dialogView));
- return dialogView;
- }
-
- @Override
- public boolean isAligned() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public boolean isReplaceable() {
- return false;
- }
-
- @Override
- public boolean isResizeable() {
- return true;
- }
-
- @Override
- public boolean isSubView() {
- return false;
- }
-
- public static class CloseViewAction extends AbstractButtonAction {
- public CloseViewAction() {
- super("Close");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- view.dispose();
- }
- }
-}
-
-class MessageView extends AbstractView {
- private static final int MAX_TEXT_WIDTH = 400;
- private static final int LEFT = 20;
- private static final int RIGHT = 20;
- private static final int TOP = 15;
- private static final int PADDING = 10;
- private Image errorIcon;
- private FocusManager focusManager;
-
- protected MessageView(final MessageContent content, final ViewSpecification specification) {
- super(content, specification);
- final String iconName = ((MessageContent) getContent()).getIconName();
- errorIcon = ImageFactory.getInstance().loadIcon(iconName, 32, null);
- if (errorIcon == null) {
- errorIcon = ImageFactory.getInstance().loadDefaultIcon(32, null);
- }
- }
-
- @Override
- public Size getRequiredSize(final Size availableSpace) {
- final Size size = new Size();
-
- final String message = ((MessageContent) getContent()).getMessage();
- final String heading = ((MessageContent) getContent()).title();
-
- size.ensureHeight(errorIcon.getHeight());
- final Text text = Toolkit.getText(ColorsAndFonts.TEXT_NORMAL);
- final Text titleText = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- size.extendWidth(text.stringWidth(message, MAX_TEXT_WIDTH));
- int textHeight = titleText.getLineHeight();
- textHeight += text.stringHeight(message, MAX_TEXT_WIDTH);
- size.ensureHeight(textHeight);
-
- size.ensureWidth(titleText.stringWidth(heading));
-
- size.extendWidth(errorIcon.getWidth());
- size.extendWidth(PADDING);
-
- size.extend(LEFT + RIGHT, TOP * 2);
- return size;
- }
-
- @Override
- public void draw(final Canvas canvas) {
- super.draw(canvas);
-
- final String message = ((MessageContent) getContent()).getMessage();
- final String heading = ((MessageContent) getContent()).title();
-
- clearBackground(canvas, Toolkit.getColor(ColorsAndFonts.COLOR_WHITE));
-
- canvas.drawImage(errorIcon, LEFT, TOP);
-
- final int x = LEFT + errorIcon.getWidth() + PADDING;
- int y = TOP + 3 + Toolkit.getText(ColorsAndFonts.TEXT_NORMAL).getAscent();
- final Color black = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- if (!heading.equals("")) {
- final Text title = Toolkit.getText(ColorsAndFonts.TEXT_TITLE);
- canvas.drawText(heading, x, y, black, title);
- y += title.getLineHeight();
- }
- canvas.drawText(message, x, y, MAX_TEXT_WIDTH, black, Toolkit.getText(ColorsAndFonts.TEXT_NORMAL));
- }
-
- @Override
- public ViewAreaType viewAreaType(final Location mouseLocation) {
- return ViewAreaType.VIEW;
- }
-
- @Override
- public FocusManager getFocusManager() {
- return focusManager == null ? super.getFocusManager() : focusManager;
- }
-
- @Override
- public void setFocusManager(final FocusManager focusManager) {
- this.focusManager = focusManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/TextMessageContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/TextMessageContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/TextMessageContent.java
deleted file mode 100644
index 189fa9d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/message/TextMessageContent.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.view.message;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-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 TextMessageContent implements MessageContent {
- protected final String message;
- protected final String heading;
- protected final String detail;
- protected final String title;
-
- public TextMessageContent(final String title, final String message) {
- final int pos = message.indexOf(':');
- if (pos > 2) {
- this.heading = message.substring(0, pos).trim();
- this.message = message.substring(pos + 1).trim();
- } else {
- this.heading = "";
- this.message = message;
- }
- this.title = title;
- this.detail = null;
- }
-
- @Override
- public String getMessage() {
- return message;
- }
-
- @Override
- public String getDetail() {
- return detail;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- return null;
- }
-
- @Override
- public String getDescription() {
- return title;
- }
-
- @Override
- public String getHelp() {
- return "";
- }
-
- @Override
- public String getIconName() {
- return "message";
- }
-
- @Override
- public Image getIconPicture(final int iconHeight) {
- return null;
- }
-
- @Override
- public String getId() {
- return "message-exception";
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return null;
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- 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 isOptionEnabled() {
- return false;
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- @Override
- public boolean isTextParseable() {
- return false;
- }
-
- public void parseTextEntry(final String entryText) {
- }
-
- @Override
- public String title() {
- return heading;
- }
-
- @Override
- public void viewMenuOptions(final UserActionSet options) {
- }
-
- @Override
- public String windowTitle() {
- return title;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsForObjectOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsForObjectOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsForObjectOption.java
deleted file mode 100644
index 3e76ba3..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsForObjectOption.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class CloseAllViewsForObjectOption extends UserActionAbstract {
- public CloseAllViewsForObjectOption() {
- super("Close all views for this object");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final ObjectAdapter object = view.getContent().getAdapter();
- final View views[] = workspace.getSubviews();
- for (final View v : views) {
- if (v.getContent().getAdapter() == object) {
- v.dispose();
- }
- }
- }
-
- @Override
- public String getDescription(final View view) {
- final String title = view.getContent().title();
- return "Close all views for '" + title + "'";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsOption.java
deleted file mode 100644
index 6d14efb..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseAllViewsOption.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class CloseAllViewsOption extends UserActionAbstract {
- public CloseAllViewsOption() {
- super("Close all others");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final View views[] = view.getWorkspace().getSubviews();
-
- for (final View otherView : views) {
- if (otherView.getSpecification().isOpen() && otherView != view) {
- otherView.dispose();
- }
- }
- }
-
- @Override
- public String getDescription(final View view) {
- return "Close all views except " + view.getSpecification().getName().toLowerCase();
- }
-
- @Override
- public String toString() {
- return new ToString(this).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseOtherViewsForObjectOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseOtherViewsForObjectOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseOtherViewsForObjectOption.java
deleted file mode 100644
index 44d254d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseOtherViewsForObjectOption.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class CloseOtherViewsForObjectOption extends UserActionAbstract {
- public CloseOtherViewsForObjectOption() {
- super("Close other views for this object");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final ObjectAdapter object = view.getContent().getAdapter();
- final View views[] = workspace.getSubviews();
- for (final View v : views) {
- if (view != v && v.getContent().getAdapter() == object) {
- v.dispose();
- }
- }
- }
-
- @Override
- public String getDescription(final View view) {
- final String title = view.getContent().title();
- return "Close other views for '" + title + "'";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseViewOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseViewOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseViewOption.java
deleted file mode 100644
index 751b5ce..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/CloseViewOption.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class CloseViewOption extends UserActionAbstract {
- public CloseViewOption() {
- super("Close");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- view.dispose();
- }
-
- @Override
- public String getDescription(final View view) {
- return "Close this " + view.getSpecification().getName();
- }
-
- @Override
- public String toString() {
- return new ToString(this).toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/DisposeObjectOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/DisposeObjectOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/DisposeObjectOption.java
deleted file mode 100644
index 6432ce5..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/DisposeObjectOption.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.consent.Allow;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.Veto;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.Persistor;
-import org.apache.isis.core.runtime.system.transaction.UpdateNotifier;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-/**
- * Destroy this object
- */
-public class DisposeObjectOption extends UserActionAbstract {
- public DisposeObjectOption() {
- super("Dispose Object", ActionType.EXPLORATION);
- }
-
- @Override
- public Consent disabled(final View view) {
- final ObjectAdapter adapter = view.getContent().getAdapter();
- if (adapter.isDestroyed()) {
- // TODO: move logic into Facet
- return new Veto("Can't do anything with a destroyed object");
- }
- if (isObjectInRootView(view)) {
- return Allow.DEFAULT;
- } else {
- // TODO: move logic into Facet
- return new Veto("Can't dispose an object from within another view.");
- }
- }
-
- private boolean isObjectInRootView(final View view) {
- final View rootView = rootView(view);
- return view.getContent() == rootView.getContent();
- }
-
- private View rootView(final View view) {
- final View parent = view.getParent();
- if (view.getWorkspace() == parent) {
- return view;
- } else {
- return rootView(parent);
- }
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
-
- final ObjectAdapter object = ((ObjectContent) view.getContent()).getObject();
-
- // xactn mgmt now done by PersistenceSession#destroyObject()
- // getTransactionManager().startTransaction();
-
- getPersistenceSession().destroyObject(object);
-
- // getTransactionManager().endTransaction();
-
- getUpdateNotifier().addDisposedObject(object);
- view.getViewManager().disposeUnneededViews();
- view.getFeedbackManager().showMessagesAndWarnings();
- }
-
- // /////////////////////////////////////////////////////
- // Dependencies (from context)
- // /////////////////////////////////////////////////////
-
- private static Persistor getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- private static UpdateNotifier getUpdateNotifier() {
- return IsisContext.getUpdateNotifier();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/IconizeViewOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/IconizeViewOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/IconizeViewOption.java
deleted file mode 100644
index 7581211..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/IconizeViewOption.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.metamodel.consent.Allow;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class IconizeViewOption extends UserActionAbstract {
- public IconizeViewOption() {
- super("Iconize");
- }
-
- @Override
- public Consent disabled(final View view) {
- return Allow.DEFAULT;
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final View minimizedView = Toolkit.getViewFactory().createMinimizedView(view);
- minimizedView.setLocation(view.getLocation());
- final View[] views = workspace.getSubviews();
- for (final View view2 : views) {
- if (view2 == view) {
- workspace.removeView(view);
- workspace.addView(minimizedView);
- workspace.invalidateLayout();
- return;
- }
- }
-
- /*
- * // TODO change so that an iconized version of the window is created
- * and displayed, which holds the original view. View iconView = new
- * RootIconSpecification().createView(view.getContent(), null);
- * iconView.setLocation(view.getLocation()); workspace.replaceView(view,
- * iconView);
- */
- }
-
- @Override
- public String getDescription(final View view) {
- return "Show this object as an icon on the workspace";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/OpenViewOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/OpenViewOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/OpenViewOption.java
deleted file mode 100644
index c61f156..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/OpenViewOption.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.Placement;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-
-public class OpenViewOption extends UserActionAbstract {
- private static final Logger LOG = LoggerFactory.getLogger(OpenViewOption.class);
- private final ViewSpecification specification;
-
- public OpenViewOption(final ViewSpecification builder) {
- super(builder.getName());
- this.specification = builder;
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- Content content = view.getContent();
- if (content.getAdapter() != null && !(content instanceof FieldContent)) {
- content = Toolkit.getContentFactory().createRootContent(content.getAdapter());
- }
- final View newView = specification.createView(content, view.getViewAxes(), -1);
- LOG.debug("open view " + newView);
- workspace.addWindow(newView, new Placement(view));
- workspace.markDamaged();
- }
-
- @Override
- public String getDescription(final View view) {
- final String title = view.getContent().title();
- return "Open '" + title + "' in a " + specification.getName() + " window";
- }
-
- @Override
- public String toString() {
- return super.toString() + " [prototype=" + specification.getName() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/ReplaceViewOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/ReplaceViewOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/ReplaceViewOption.java
deleted file mode 100644
index fda4361..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/ReplaceViewOption.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.view.option;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-public class ReplaceViewOption extends UserActionAbstract {
- private static final Logger LOG = LoggerFactory.getLogger(ReplaceViewOption.class);
- private final ViewSpecification specification;
-
- public ReplaceViewOption(final ViewSpecification specification) {
- super(specification.getName());
- this.specification = specification;
- }
-
- @Override
- public String getDescription(final View view) {
- return "Replace this " + view.getSpecification().getName() + " view with a " + specification.getName() + " view";
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final View replacement = specification.createView(view.getContent(), new Axes(), -1);
- LOG.debug("replacement view " + replacement);
- replace(view, replacement);
- }
-
- protected void replace(final View view, final View withReplacement) {
- final View existingView = view.getView();
- view.getParent().replaceView(existingView, withReplacement);
- }
-
- @Override
- public String toString() {
- return super.toString() + " [prototype=" + specification.getName() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/UserActionAbstract.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/UserActionAbstract.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/UserActionAbstract.java
deleted file mode 100644
index 372dd22..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/option/UserActionAbstract.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.option;
-
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.core.metamodel.consent.Allow;
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.UserAction;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-
-/**
- * Each option that a user is shown in an objects popup menu a MenuOption. A
- * MenuOption details: the name of an option (in the users language);
- * <ul>
- * the type of object that might result when requesting this option
- * </ul>
- * ; a way to determine whether a user can select this option on the current
- * object.
- */
-public abstract class UserActionAbstract implements UserAction {
- private String description;
- private String name;
- private final ActionType type;
-
- public UserActionAbstract(final String name) {
- this(name, ActionType.USER);
- }
-
- public UserActionAbstract(final String name, final ActionType type) {
- this.name = name;
- this.type = type;
- }
-
- @Override
- public Consent disabled(final View view) {
- return Allow.DEFAULT;
- }
-
- @Override
- public abstract void execute(final Workspace workspace, final View view, final Location at);
-
- @Override
- public String getDescription(final View view) {
- return description;
- }
-
- @Override
- public String getHelp(final View view) {
- return "No help available for user action";
- }
-
- /**
- * Returns the stored name of the menu option.
- */
- @Override
- public String getName(final View view) {
- return name;
- }
-
- @Override
- public ActionType getType() {
- return type;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- final ToString str = new ToString(this);
- str.append("name", name);
- str.append("type", type);
- return str.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/CursorPosition.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/CursorPosition.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/CursorPosition.java
deleted file mode 100644
index d5d9d2a..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/CursorPosition.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.text;
-
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-/**
- * Represents the position of a line cursor within a TextContent. The character
- * position for a line extends from zero to text.length + 1. Where 0 means the
- * cursor is to the left of the first character, and 1 is to right of the first
- * character and to the left of the second character.
- */
-public class CursorPosition {
- private int character;
- private int line;
- private final TextContent textContent;
-
- public CursorPosition(final TextContent content, final CursorPosition pos) {
- this(content, pos.line, pos.character);
- }
-
- public CursorPosition(final TextContent content, final int line, final int afterCharacter) {
- this.textContent = content;
- this.line = line;
- this.character = afterCharacter;
- }
-
- public void asFor(final CursorPosition pos) {
- line = pos.line;
- character = pos.character;
- }
-
- /**
- * Move the cursor to the bottom-right of the field
- */
- public void bottom() {
- line = textContent.getNoLinesOfContent() - 1;
- textContent.alignDisplay(line);
- end();
- }
-
- public void cursorAt(final Location atLocation) {
- line = textContent.cursorAtLine(atLocation);
- character = textContent.cursorAtCharacter(atLocation, line);
-
- if (line >= textContent.getNoLinesOfContent()) {
- line = textContent.getNoLinesOfContent() - 1;
- end();
- }
- }
-
- /**
- * Move the cursor to the end of the line
- */
- public void end() {
- final String text = textContent.getText(line);
- character = text == null ? 0 : text.length();
- }
-
- /**
- * @return the character within this line.
- */
- public int getCharacter() {
- return character;
- }
-
- /**
- * @return the line within the field
- */
- public int getLine() {
- return line;
- }
-
- /**
- * Move the cursor to the left end of the field
- */
- public void home() {
- character = 0;
- }
-
- /**
- * Movet the cursor left by one character.
- */
- public void left() {
- if (!((line == 0) && (character == 0))) {
- character--;
-
- if (character < 0) {
- line--;
- textContent.alignDisplay(line);
- end();
- }
- }
- }
-
- /**
- * Move down one line.
- */
- public void lineDown() {
- moveDown(1);
- }
-
- /**
- * Move up one line.
- */
- public void lineUp() {
- moveUp(1);
- }
-
- private void moveDown(final int byLines) {
- final int size = textContent.getNoLinesOfContent();
-
- if (line < (size - 1)) {
- line += byLines;
- line = Math.min(size - 1, line);
-
- character = Math.min(character, textContent.getText(line).length());
-
- textContent.alignDisplay(line);
- }
- }
-
- private void moveUp(final int byLines) {
- if (line > 0) {
- line -= byLines;
- line = Math.max(0, line);
- textContent.alignDisplay(line);
- }
- }
-
- /**
- * Move down one page.
- */
- public void pageDown() {
- moveDown(textContent.getNoDisplayLines() - 1);
- }
-
- /**
- * Move cursor up by a page
- */
- public void pageUp() {
- moveUp(textContent.getNoDisplayLines() - 1);
- }
-
- /**
- * Move the cursor right by one character.
- */
- public void right() {
- right(1);
- }
-
- /**
- * Move the cursor right by one character.
- */
- public void right(final int characters) {
- final int length = textContent.getText(line).length();
-
- if ((character + characters) > length) {
- if ((line + 1) < textContent.getNoLinesOfContent()) {
- line++;
- textContent.alignDisplay(line);
-
- final int remainder = (character + characters) - length;
- character = 0;
- right(remainder);
- }
- } else {
- character += characters;
- }
- }
-
- /**
- * Move the cursor to the top-left of the field
- */
- public void top() {
- line = 0;
- character = 0;
- textContent.alignDisplay(line);
- }
-
- @Override
- public String toString() {
- return "CursorPosition [line=" + line + ",character=" + character + "]";
- }
-
- /**
- * Move the cursor left to the beginning of the previous word.
- */
- public void wordLeft() {
- if (!((line == 0) && (character == 0))) {
- if (character == 0) {
- line--;
- end();
- }
-
- final String text = textContent.getText(line);
-
- do {
- character--;
- } while ((character >= 0) && (text.charAt(character) == ' '));
-
- while ((character >= 0) && (text.charAt(character) != ' ')) {
- character--;
- }
-
- character++;
- }
- }
-
- /**
- * Move the cursor right to the end of the current word.
- */
- public void wordRight() {
- final String text = textContent.getText(line);
- final int lineLength = text.length();
- if (!(line == textContent.getNoLinesOfContent() - 1 && character == lineLength - 1)) {
- // skip spaces before
- while (character < lineLength && text.charAt(character) == ' ') {
- character++;
- }
- // skip characters (until next space)
- while (character < lineLength && text.charAt(character) != ' ') {
- character++;
- }
- // skip spaces after word
- while (character < lineLength && text.charAt(character) == ' ') {
- character++;
- }
- // wrap to nexrt line if at end
- if (character >= lineLength && line + 1 < textContent.getNoLinesOfContent()) {
- line++;
- character = 0;
- }
- }
- }
-
- public boolean samePosition(final CursorPosition positionToCompare) {
- return line == positionToCompare.line && character == positionToCompare.character;
- }
-
- public boolean isBefore(final CursorPosition positionToCompare) {
- return line < positionToCompare.line || (line == positionToCompare.line && character < positionToCompare.character);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/ObjectTitleText.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/ObjectTitleText.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/ObjectTitleText.java
deleted file mode 100644
index 1bb723c..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/ObjectTitleText.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.text;
-
-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.View;
-
-public class ObjectTitleText extends TitleText {
- private final Content content;
-
- public ObjectTitleText(final View view, final Text style) {
- super(view, style, Toolkit.getColor(ColorsAndFonts.COLOR_BLACK));
- content = view.getContent();
- }
-
- @Override
- protected String title() {
- return content.title();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlock.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlock.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlock.java
deleted file mode 100644
index 05b20e9..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlock.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.text;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-class TextBlock {
- private static final Logger LOG = LoggerFactory.getLogger(TextBlock.class);
- private static final Logger UI_LOG = LoggerFactory.getLogger("ui." + TextBlock.class.getName());
- private final TextBlockTarget forField;
- private String text;
- private int[] lineBreaks;
- private boolean isFormatted;
- private int lineCount;
- private boolean canWrap;
-
- TextBlock(final TextBlockTarget forField, final String text, final boolean canWrap) {
- this.forField = forField;
- this.text = text;
- isFormatted = false;
- this.canWrap = canWrap;
- }
-
- public String getLine(final int line) {
- if (line < 0 || line > lineCount) {
- throw new IllegalArgumentException("line outside of block " + line);
- }
-
- format();
-
- final int from = lineStart(line);
- final int to = lineEnd(line);
-
- return text.substring(from, to);
- }
-
- public String getText() {
- return text;
- }
-
- public void deleteLeft(final int line, final int character) {
- final int pos = pos(line, character);
- if (pos > 0) {
- text = text.substring(0, pos - 1) + text.substring(pos);
- isFormatted = false;
- }
- }
-
- public void delete(final int fromLine, final int fromCharacter, final int toLine, final int toCharacter) {
- format();
- final int from = pos(fromLine, fromCharacter);
- final int to = pos(toLine, toCharacter);
- text = text.substring(0, from) + text.substring(to);
- isFormatted = false;
- }
-
- public void deleteTo(final int toLine, final int toCharacter) {
- format();
- final int from = 0;
- final int to = pos(toLine, toCharacter);
- text = text.substring(0, from) + text.substring(to);
- isFormatted = false;
- }
-
- public void deleteFrom(final int fromLine, final int fromCharacter) {
- format();
- final int from = pos(fromLine, fromCharacter);
- final int to = text.length();
- text = text.substring(0, from) + text.substring(to);
- isFormatted = false;
- }
-
- public void deleteRight(final int line, final int character) {
- final int pos = pos(line, character);
- if (pos < text.length()) {
- text = text.substring(0, pos) + text.substring(pos + 1);
- isFormatted = false;
- }
- }
-
- public int noLines() {
- format();
- return lineCount + 1;
- }
-
- private void breakAt(final int breakAt) {
- // TODO deal with growing array
- lineBreaks[lineCount] = breakAt;
- lineCount++;
- }
-
- private void format() {
- if (canWrap && !isFormatted) {
- lineBreaks = new int[100];
- lineCount = 0;
-
- final int length = text.length();
-
- int lineWidth = 0;
- int breakAt = -1;
-
- for (int pos = 0; pos < length; pos++) {
- final char ch = text.charAt(pos);
-
- if (ch == '\n') {
- throw new IllegalStateException("Block must not contain newline characters");
- }
-
- lineWidth += forField.getText().charWidth(ch);
-
- if (lineWidth > forField.getMaxFieldWidth()) {
- breakAt = (breakAt == -1) ? pos - 1 : breakAt;
- // ensures that a string without spaces doesn't loop forever
- breakAt(breakAt);
-
- // include the remaining chars in the starting width.
- lineWidth = forField.getText().stringWidth(text.substring(breakAt - 1, pos + 1));
-
- // reset for next line
- // start = breakAt;
- breakAt = -1;
-
- continue;
- }
-
- if (ch == ' ') {
- breakAt = pos + 1; // break at the character after the space
- }
- }
-
- isFormatted = true;
- }
- }
-
- public void insert(final int line, final int character, final String characters) {
- if (characters.indexOf('\n') >= 0) {
- throw new IllegalArgumentException("Insert characters cannot contain newline");
- }
- final int pos = pos(line, character);
- text = text.substring(0, pos) + characters + text.substring(pos);
- isFormatted = false;
- }
-
- private int pos(final int line, final int character) {
- int pos = lineStart(line);
- pos += character;
- LOG.debug("position " + pos);
- return pos;
- }
-
- private int lineStart(final int line) {
- final int pos = line == 0 ? 0 : lineBreaks[line - 1];
- UI_LOG.debug("line " + line + " starts at " + pos);
- return pos;
- }
-
- private int lineEnd(final int line) {
- final int pos = line >= lineCount ? text.length() : lineBreaks[line];
- UI_LOG.debug("line " + line + " ends at " + pos);
- return pos;
- }
-
- /**
- * breaks a block at the cursor position by truncating this block and
- * creating a new block and adding the removed text.
- */
- public TextBlock splitAt(final int line, final int character) {
- format();
- final int pos = pos(line, character);
- final TextBlock newBlock = new TextBlock(forField, text.substring(pos), canWrap);
- text = text.substring(0, pos);
- isFormatted = false;
- return newBlock;
- }
-
- public void setCanWrap(final boolean canWrap) {
- this.canWrap = canWrap;
- }
-
- @Override
- public String toString() {
- final StringBuffer content = new StringBuffer();
- content.append("TextBlock [");
- content.append("formatted=");
- content.append(isFormatted);
- content.append(",lines=");
- content.append(lineCount);
- content.append(",text=");
- content.append(text);
- content.append(",breaks=");
- if (lineBreaks == null) {
- content.append("none");
- } else {
- for (int i = 0; i < lineBreaks.length; i++) {
- content.append(i == 0 ? "" : ",");
- content.append(lineBreaks[i]);
- }
- }
- content.append("]");
- return content.toString();
- }
-
- public void join(final TextBlock textBlock) {
- text += textBlock.text;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlockTarget.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlockTarget.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlockTarget.java
deleted file mode 100644
index 309e5c7..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextBlockTarget.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.text;
-
-import org.apache.isis.viewer.dnd.drawing.Text;
-
-public interface TextBlockTarget {
-
- /**
- * Maximum text entry width.
- */
- int getMaxFieldWidth();
-
- Text getText();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a43dbdd9/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextContent.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextContent.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextContent.java
deleted file mode 100644
index 1ce881f..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/text/TextContent.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.view.text;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.ensure.Assert;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.util.ToString;
-import org.apache.isis.viewer.dnd.drawing.Location;
-
-public class TextContent {
- private static final Logger LOG = LoggerFactory.getLogger(TextContent.class);
- private static final Logger UI_LOG = LoggerFactory.getLogger("ui." + TextContent.class.getName());
- public static final int NO_WRAPPING = 1;
- public static final int WRAPPING = 0;
- private final Vector blocks;
- private final TextBlockTarget target;
- private int displayFromLine;
- private int availableDisplayLines;
- private final boolean useEmptyLines;
- private final int wrap;
-
- public TextContent(final TextBlockTarget target, final int noLines, final int wrapStyle) {
- this(target, noLines, wrapStyle, false);
- }
-
- public TextContent(final TextBlockTarget target, final int noLines, final int wrapStyle, final boolean useEmptyLines) {
- this.target = target;
- this.wrap = wrapStyle;
- this.blocks = new Vector();
- this.useEmptyLines = useEmptyLines;
- availableDisplayLines = noLines;
- displayFromLine = 0;
- addBlock("");
- alignDisplay(0);
- }
-
- private void addBlock(final String text) {
- final TextBlock block = new TextBlock(target, text, wrap == TextContent.WRAPPING);
- LOG.debug("add block " + block);
- blocks.addElement(block);
- }
-
- /**
- * Returns the number of lines that this field will display the content.
- * This can be smaller than the actual number of lines of content, but will
- * be at least one.
- */
- public int getNoDisplayLines() {
- return availableDisplayLines;
- }
-
- /**
- * Aligns the lines of content so that the specified line is within the
- * array of lines returned by getDisplayLines().
- *
- * @see #getDisplayLines()
- */
- public void alignDisplay(final int line) {
- final int noContentLines = getNoLinesOfContent();
- final int lastLine = noContentLines - 1;
-
- int displayToLine = Math.min(displayFromLine + availableDisplayLines, noContentLines);
- if (noContentLines <= availableDisplayLines) {
- displayFromLine = 0;
- } else {
- if (line >= displayToLine) {
- displayToLine = line + 3;
- displayToLine = Math.min(displayToLine, lastLine);
-
- displayFromLine = displayToLine - availableDisplayLines + 1;
- displayFromLine = Math.max(displayFromLine, 0);
- }
-
- if (line < displayFromLine) {
- displayFromLine = line;
- displayToLine = (displayFromLine + availableDisplayLines) - 1;
-
- if (displayToLine >= noContentLines) {
- displayToLine = lastLine;
- displayFromLine = Math.max(0, displayToLine - availableDisplayLines);
- }
- }
- }
-
- LOG.debug("display line " + line + " " + displayFromLine + "~" + displayToLine);
- }
-
- public void breakBlock(final CursorPosition cursorAt) {
- final BlockToLineMapping mapping = findBlockFor(cursorAt.getLine());
- final TextBlock newBlock = mapping.textBlock.splitAt(mapping.line, cursorAt.getCharacter());
- blocks.insertElementAt(newBlock, mapping.index + 1);
- }
-
- /**
- * deletes the selected text
- */
- public void delete(final TextSelection selection) {
- final CursorPosition from = selection.from();
- final CursorPosition to = selection.to();
-
- final BlockToLineMapping fromMapping = findBlockFor(from.getLine());
- final int fromBlock = fromMapping.index;
- final int fromLine = fromMapping.line;
- final int fromCharacter = from.getCharacter();
-
- final BlockToLineMapping toMapping = findBlockFor(to.getLine());
- final int toBlock = toMapping.index;
- final int toLine = toMapping.line;
- final int toCharacter = to.getCharacter();
-
- if (fromBlock == toBlock) {
- final TextBlock block = (TextBlock) blocks.elementAt(fromBlock);
- block.delete(fromLine, fromCharacter, toLine, toCharacter);
- } else {
- TextBlock block = (TextBlock) blocks.elementAt(toBlock);
- block.deleteTo(toLine, toCharacter);
-
- block = (TextBlock) blocks.elementAt(fromBlock);
- block.deleteFrom(fromLine, fromCharacter);
-
- fromMapping.textBlock.join(toMapping.textBlock);
- blocks.removeElementAt(toMapping.index);
-
- for (int i = fromBlock + 1; i < toBlock; i++) {
- blocks.removeElementAt(i);
- }
- }
- }
-
- public void deleteLeft(final CursorPosition cursorAt) {
- final BlockToLineMapping mapping = findBlockFor(cursorAt.getLine());
- if (mapping == null || mapping.textBlock == null) {
- throw new IsisException("invalid block " + mapping + " for line " + cursorAt.getLine());
- }
- mapping.textBlock.deleteLeft(mapping.line, cursorAt.getCharacter());
- }
-
- public void deleteRight(final CursorPosition cursorAt) {
- final BlockToLineMapping mapping = findBlockFor(cursorAt.getLine());
- mapping.textBlock.deleteRight(mapping.line, cursorAt.getCharacter());
- }
-
- private BlockToLineMapping findBlockFor(final int line) {
- if (line < 0) {
- throw new IllegalArgumentException("Line must be greater than, or equal to, zero: " + line);
- }
-
- int lineWithinBlock = line;
- for (int i = 0; i < blocks.size(); i++) {
- final TextBlock block = (TextBlock) blocks.elementAt(i);
- final int noLines = block.noLines();
- if (lineWithinBlock < noLines) {
- UI_LOG.debug("block " + i + ", line " + lineWithinBlock);
- return new BlockToLineMapping(i, block, lineWithinBlock);
- }
- lineWithinBlock -= noLines;
- }
- return null;
- // throw new IllegalArgumentException("line number not valid " + line);
-
- }
-
- /**
- * returns the entire text of the content, with a newline between each block
- * (but not after the final block.
- */
- public String getText() {
- final StringBuffer content = new StringBuffer();
- final Enumeration e = blocks.elements();
- while (e.hasMoreElements()) {
- final TextBlock block = (TextBlock) e.nextElement();
- if (content.length() > 0) {
- content.append("\n");
- }
- content.append(block.getText());
- }
- return content.toString();
- }
-
- /**
- * returns the text on the specified line
- */
- public String getText(final int forLine) {
- final BlockToLineMapping block = findBlockFor(forLine);
- if (block == null) {
- return null;
- }
- return block.textBlock.getLine(block.line);
- }
-
- /**
- * returns only the text that is selected
- */
- public String getText(final TextSelection selection) {
- final CursorPosition from = selection.from();
- final CursorPosition to = selection.to();
-
- final int line = from.getLine();
- String text = getText(line);
- if (from.getLine() == to.getLine()) {
- return text.substring(from.getCharacter(), to.getCharacter());
-
- } else {
- final StringBuffer str = new StringBuffer();
- str.append(text.substring(from.getCharacter()));
- for (int i = line + 1; i < line + (to.getLine() - from.getLine()); i++) {
- text = getText(i);
- str.append(text);
- }
- text = getText(line + (to.getLine() - from.getLine()));
- str.append(text.substring(0, to.getCharacter()));
- return str.toString();
- }
- }
-
- public void insert(final CursorPosition cursorAt, final String characters) {
- Assert.assertNotNull(cursorAt);
-
- final BlockToLineMapping block = findBlockFor(cursorAt.getLine());
-
- Assert.assertNotNull("failed to get block for line " + cursorAt.getLine(), block);
-
- block.textBlock.insert(block.line, cursorAt.getCharacter(), characters);
- }
-
- /**
- * Returns the number of lines required to display the content text in it
- * entirety.
- */
- public int getNoLinesOfContent() {
- int lineCount = 0;
- final Enumeration e = blocks.elements();
- while (e.hasMoreElements()) {
- lineCount += ((TextBlock) e.nextElement()).noLines();
- }
- return lineCount;
- }
-
- public void setText(final String text) {
- blocks.removeAllElements();
-
- if (text == null || text.equals("")) {
- addBlock("");
- } else {
- final String[] tokens = text.split("\\n");
- for (final String token : tokens) {
- if (useEmptyLines || token.length() > 0) {
- addBlock(token);
- }
- }
- }
- }
-
- @Override
- public String toString() {
- final ToString content = new ToString(this);
- content.append("field", target);
- content.append("lines", availableDisplayLines);
- content.append("blocks=", blocks.size());
- /*
- * for (int i = 0; i < blocks.size(); i++) { content.append(i == 0 ? " "
- * : "\n "); content.append(blocks.elementAt(i)); }
- */
- return content.toString();
- }
-
- public String[] getDisplayLines() {
- final String[] lines = new String[availableDisplayLines];
- for (int i = 0, j = displayFromLine; i < lines.length; i++, j++) {
- final String line = getText(j);
- lines[i] = line == null ? "" : line;
- }
- return lines;
- }
-
- public int getDisplayFromLine() {
- return displayFromLine;
- }
-
- public void setNoDisplayLines(final int noDisplayLines) {
- this.availableDisplayLines = noDisplayLines;
- }
-
- public void increaseDepth() {
- availableDisplayLines++;
- }
-
- public boolean decreaseDepth() {
- if (availableDisplayLines > 1) {
- availableDisplayLines--;
- return true;
- } else {
- return false;
- }
- }
-
- private static class BlockToLineMapping {
- TextBlock textBlock;
- int index;
- int line;
-
- public BlockToLineMapping(final int blockIndex, final TextBlock block, final int line) {
- this.index = blockIndex;
- this.textBlock = block;
- this.line = line;
- }
- }
-
- int cursorAtLine(final Location atLocation) {
- LOG.debug("pointer at " + atLocation);
- final int y = atLocation.getY();
- int lineIndex = displayFromLine + (y / target.getText().getLineHeight());
- lineIndex = Math.max(lineIndex, 0);
- return lineIndex;
- }
-
- int cursorAtCharacter(final Location atLocation, final int lineOffset) {
- final String text = getText(lineOffset);
- if (text == null) {
- for (int i = lineOffset; i >= 0; i--) {
- final String text2 = getText(i);
- if (text2 != null) {
- final int at = text2.length();
- LOG.debug("character at " + at + " line " + lineOffset);
- return at;
- }
- }
- }
-
- /*
- * slightly offsetting mouse helps the user position the cursor between
- * characters near the pointer rather than always after the pointer
- */
- final int x = atLocation.getX() - 3;
-
- int at = 0;
- final int endAt = text.length();
-
- int width = 0;
-
- while (at < endAt && x > width) {
- width += target.getText().charWidth(text.charAt(at));
- at++;
- }
-
- LOG.debug("character at " + at + " line " + lineOffset);
- return at;
- }
-
-}