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:10 UTC
[09/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/debug/DebugDumpSnapshotOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugDumpSnapshotOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugDumpSnapshotOption.java
deleted file mode 100644
index b6a867e..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugDumpSnapshotOption.java
+++ /dev/null
@@ -1,74 +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.debug;
-
-import static org.apache.isis.core.commons.lang.ObjectExtensions.asEnumerationT;
-
-import java.util.Enumeration;
-
-import org.slf4j.Logger;
-
-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.logging.SnapshotAppender;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-/**
- * Display debug window
- */
-public class DebugDumpSnapshotOption extends UserActionAbstract {
- public DebugDumpSnapshotOption() {
- super("Dump log snapshot", ActionType.DEBUG);
- }
-
- @Override
- public Consent disabled(final View component) {
- final Enumeration<Logger> enumeration = asEnumerationT(org.apache.log4j.Logger.getRootLogger().getAllAppenders(), Logger.class);
- while (enumeration.hasMoreElements()) {
- final org.apache.log4j.Appender appender = (org.apache.log4j.Appender) enumeration.nextElement();
- if (appender instanceof SnapshotAppender) {
- return Allow.DEFAULT;
- }
- }
- // TODO: move logic into Facet
- return new Veto("No available snapshot appender");
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final Enumeration<Logger> enumeration = asEnumerationT(org.apache.log4j.Logger.getRootLogger().getAllAppenders(), Logger.class);
- while (enumeration.hasMoreElements()) {
- final org.apache.log4j.Appender appender = (org.apache.log4j.Appender) enumeration.nextElement();
- if (appender instanceof SnapshotAppender) {
- ((SnapshotAppender) appender).forceSnapshot();
- }
- }
- }
-
- @Override
- public String getDescription(final View view) {
- return "Force a snapshot of the log";
- }
-}
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/debug/DebugObjectGraph.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectGraph.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectGraph.java
deleted file mode 100644
index 77401fa..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectGraph.java
+++ /dev/null
@@ -1,50 +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.debug;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.util.Dump;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-
-public class DebugObjectGraph implements DebuggableWithTitle {
- private final ObjectAdapter object;
-
- public DebugObjectGraph(final ObjectAdapter object) {
- this.object = object;
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- dumpGraph(object, debug);
- }
-
- @Override
- public String debugTitle() {
- return "Object Graph";
- }
-
- private void dumpGraph(final ObjectAdapter object, final DebugBuilder info) {
- if (object != null) {
- Dump.graph(object, IsisContext.getAuthenticationSession(), info);
- }
- }
-}
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/debug/DebugObjectSpecification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectSpecification.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectSpecification.java
deleted file mode 100644
index 6e433e6..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugObjectSpecification.java
+++ /dev/null
@@ -1,53 +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.debug;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.util.Dump;
-
-public class DebugObjectSpecification implements DebuggableWithTitle {
- private final ObjectSpecification specification;
-
- public DebugObjectSpecification(final ObjectAdapter object) {
- this.specification = object.getSpecification();
- }
-
- public DebugObjectSpecification(final ObjectSpecification object) {
- this.specification = object;
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- if (specification == null) {
- debug.appendln("no specfication");
- } else {
- Dump.specification(specification, debug);
- }
- }
-
- @Override
- public String debugTitle() {
- return "Object Specification";
- }
-
-}
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/debug/DebugOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOption.java
deleted file mode 100644
index deb0d69..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOption.java
+++ /dev/null
@@ -1,79 +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.debug;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.runtime.userprofile.PerspectiveEntry;
-import org.apache.isis.core.runtime.userprofile.UserProfilesDebugUtil;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.service.PerspectiveContent;
-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.Workspace;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-/**
- * Display debug window
- */
-public class DebugOption extends UserActionAbstract {
- public DebugOption() {
- super("Debug...", ActionType.DEBUG);
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final Content content = view.getContent();
- final ObjectAdapter object = content == null ? null : content.getAdapter();
-
- final List<DebuggableWithTitle> debug = Lists.newArrayList();
- if (content instanceof PerspectiveContent) {
- final PerspectiveEntry perspectiveEntry = ((PerspectiveContent) content).getPerspective();
- debug.add(UserProfilesDebugUtil.asDebuggableWithTitle(perspectiveEntry));
- } else {
- debug.add(new DebugObjectSpecification(content.getSpecification()));
- }
- if (object != null) {
- debug.add(new DebugAdapter(object));
- debug.add(new DebugObjectGraph(object));
- }
-
- debug.add(new DebugViewStructure(view));
- debug.add(new DebugContent(view));
- debug.add(new DebugDrawing(view));
- debug.add(new DebugDrawingAbsolute(view));
-
- final DebuggableWithTitle[] info = debug.toArray(new DebuggableWithTitle[debug.size()]);
- at.add(50, 6);
- // at.getX() + 50, at.getY() + 6
- Toolkit.getViewer().showDebugFrame(info, at);
- }
-
- @Override
- public String getDescription(final View view) {
- return "Open debug window about " + view;
- }
-}
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/debug/DebugOutput.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOutput.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOutput.java
deleted file mode 100644
index c58a96f..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugOutput.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.view.debug;
-
-import java.awt.FileDialog;
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.PrintJob;
-import java.awt.Toolkit;
-import java.awt.datatransfer.Clipboard;
-import java.awt.datatransfer.StringSelection;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.commons.exceptions.IsisException;
-
-public class DebugOutput {
- private static final DateFormat FORMAT = new SimpleDateFormat("yyyyMMdd-HHmmss-SSS");
- private static final Font TEXT_FONT = new Font("SansSerif", Font.PLAIN, 10);
- private static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 12);
-
- public static void print(final String title, final String text) {
- final Frame parent = new Frame();
- final PrintJob job = Toolkit.getDefaultToolkit().getPrintJob(parent, "Print " + title, new Properties());
-
- if (job != null) {
- final Graphics graphic = job.getGraphics();
- // Dimension pageSize = job.getPageDimension();
-
- if (graphic != null) {
- graphic.translate(10, 10);
- final int x = 50;
- int y = 50;
-
- graphic.setFont(TITLE_FONT);
-
- final int height = graphic.getFontMetrics().getAscent();
- final int width = graphic.getFontMetrics().stringWidth(title);
- graphic.drawRect(x - 10, y - 10 - height, width + 20, height + 20);
-
- graphic.drawString(title, x, y);
-
- y += graphic.getFontMetrics().getHeight();
- y += 20;
-
- graphic.setFont(TEXT_FONT);
- final StringTokenizer tk = new StringTokenizer(text, "\n\r");
- while (tk.hasMoreTokens()) {
- final String line = tk.nextToken();
- graphic.drawString(line, x, y);
- y += graphic.getFontMetrics().getHeight();
- }
-
- graphic.dispose();
- }
-
- job.end();
- }
- parent.dispose();
- }
-
- /*
- *
- *
- * Frame frame = new Frame(); PrintJob job =
- * Toolkit.getDefaultToolkit().getPrintJob(frame, "Print object", null);
- *
- * if (job != null) { Graphics pg = job.getGraphics(); Dimension pageSize =
- * job.getPageDimension();
- *
- * if (pg != null) { pg.translate(LEFT, HEIGHT); pg.drawRect(0, 0,
- * pageSize.width - LEFT - 1, pageSize.height - HEIGHT - 1); view.print(new
- * PrintCanvas(pg, view)); pg.dispose(); }
- *
- * job.end(); } frame.dispose();
- */
-
- public static void saveToClipboard(final String text) {
- final Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
- final StringSelection ss = new StringSelection(text);
- cb.setContents(ss, ss);
- }
-
- public static void saveToFile(final DebuggableWithTitle object) {
- final String dateStamp = FORMAT.format(new Date());
- final String fileName = object.getClass().getName() + "-" + dateStamp + ".txt";
- final DebugString text = new DebugString();
- object.debugData(text);
- final String title = object.debugTitle();
-
- saveToFile(new File(fileName), title, text.toString());
- }
-
- public static void saveToFile(final File file, final String title, final String text) {
- try {
- final PrintWriter writer = new PrintWriter(new FileWriter(file));
- writer.println(title);
- writer.println();
- writer.println(text.toString());
- writer.close();
- } catch (final IOException e) {
- throw new IsisException(e);
- }
- }
-
- public static void saveToFile(final String saveDialogTitle, final String title, final String text) {
- final Frame parent = new Frame();
-
- final FileDialog dialog = new FileDialog(parent, saveDialogTitle, FileDialog.SAVE);
- dialog.setVisible(true);
- final String file = dialog.getFile();
- final String dir = dialog.getDirectory();
-
- parent.dispose();
-
- saveToFile(new File(dir, file), title, 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/debug/DebugView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugView.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugView.java
deleted file mode 100644
index e8db480..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugView.java
+++ /dev/null
@@ -1,124 +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.debug;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.util.Dump;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Bounds;
-import org.apache.isis.viewer.dnd.drawing.DebugCanvas;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-
-public class DebugView implements DebuggableWithTitle {
- private final View view;
-
- public DebugView(final View display) {
- this.view = display;
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- debug.append(view.getView());
- debug.blankLine();
- debug.blankLine();
-
- // display details
- debug.appendTitle("VIEW");
-
- view.debug(debug);
- debug.appendln();
-
- // content
- final Content content = view.getContent();
- debug.appendTitle("CONTENT");
- if (content != null) {
- String type = content.getClass().getName();
- type = type.substring(type.lastIndexOf('.') + 1);
- debug.appendln("Content", type);
- content.debugDetails(debug);
-
- debug.indent();
- debug.appendln("Icon name", content.getIconName());
- debug.appendln("Icon ", content.getIconPicture(32));
- debug.appendln("Window title", content.windowTitle());
- debug.appendln("Persistable", content.isPersistable());
- debug.appendln("Object", content.isObject());
- debug.appendln("Collection", content.isCollection());
-
- debug.appendln("Parseable", content.isTextParseable());
- debug.unindent();
- } else {
- debug.appendln("Content", "none");
- }
- debug.blankLine();
-
- if (content instanceof ObjectContent) {
- final ObjectAdapter object = ((ObjectContent) content).getObject();
- dumpObject(object, debug);
- debug.blankLine();
- dumpSpecification(object, debug);
- debug.blankLine();
- dumpGraph(object, debug);
-
- } else if (content instanceof CollectionContent) {
- final ObjectAdapter collection = ((CollectionContent) content).getCollection();
- debug.blankLine();
- dumpObject(collection, debug);
- dumpSpecification(collection, debug);
- debug.blankLine();
- dumpGraph(collection, debug);
- }
-
- debug.append("\n\nDRAWING\n");
- debug.append("------\n");
- view.draw(new DebugCanvas(debug, new Bounds(view.getBounds())));
- }
-
- @Override
- public String debugTitle() {
- return "Debug: " + view + view == null ? "" : ("/" + view.getContent());
- }
-
- public void dumpGraph(final ObjectAdapter object, final DebugBuilder info) {
- if (object != null) {
- info.appendTitle("GRAPH");
- Dump.graph(object, IsisContext.getAuthenticationSession(), info);
- }
- }
-
- public void dumpObject(final ObjectAdapter object, final DebugBuilder info) {
- if (object != null) {
- info.appendTitle("OBJECT");
- Dump.adapter(object, info);
- }
- }
-
- private void dumpSpecification(final ObjectAdapter object, final DebugBuilder info) {
- if (object != null) {
- info.appendTitle("SPECIFICATION");
- Dump.specification(object, info);
- }
- }
-}
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/debug/DebugViewStructure.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugViewStructure.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugViewStructure.java
deleted file mode 100644
index dd7ea75..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/DebugViewStructure.java
+++ /dev/null
@@ -1,42 +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.debug;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.viewer.dnd.view.View;
-
-public class DebugViewStructure implements DebuggableWithTitle {
- private final View view;
-
- public DebugViewStructure(final View display) {
- this.view = display;
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- view.debug(debug);
- }
-
- @Override
- public String debugTitle() {
- return "View Structure";
- }
-}
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/debug/LoggingOptions.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/LoggingOptions.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/LoggingOptions.java
deleted file mode 100644
index 63178f5..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/debug/LoggingOptions.java
+++ /dev/null
@@ -1,59 +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.debug;
-
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.core.metamodel.consent.ConsentAbstract;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.MenuOptions;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-public class LoggingOptions implements MenuOptions {
-
- @Override
- public void menuOptions(final UserActionSet options) {
- options.add(loggingOption("Off", org.apache.log4j.Level.OFF));
- options.add(loggingOption("Error", org.apache.log4j.Level.ERROR));
- options.add(loggingOption("Warn", org.apache.log4j.Level.WARN));
- options.add(loggingOption("Info", org.apache.log4j.Level.INFO));
- options.add(loggingOption("Debug", org.apache.log4j.Level.DEBUG));
-
- options.add(new DebugDumpSnapshotOption());
- }
-
- private UserActionAbstract loggingOption(final String name, final org.apache.log4j.Level level) {
- return new UserActionAbstract("Log level " + level, ActionType.DEBUG) {
- @Override
- public Consent disabled(final View component) {
- return ConsentAbstract.allowIf(org.apache.log4j.LogManager.getRootLogger().getLevel() != level);
- }
-
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- org.apache.log4j.LogManager.getRootLogger().setLevel(level);
- }
- };
- }
-
-}
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/field/ClearOneToManyAssociationOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToManyAssociationOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToManyAssociationOption.java
deleted file mode 100644
index 530e19d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToManyAssociationOption.java
+++ /dev/null
@@ -1,45 +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.field;
-
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-public class ClearOneToManyAssociationOption extends UserActionAbstract {
-
- public ClearOneToManyAssociationOption() {
- super("Clear association");
- }
-
- @Override
- public Consent disabled(final View view) {
- final OneToManyFieldElement content = (OneToManyFieldElement) view.getContent();
- return content.canClear();
- }
-
- @Override
- public void execute(final Workspace frame, final View view, final Location at) {
- final OneToManyFieldElement content = (OneToManyFieldElement) view.getContent();
- content.clear();
- }
-}
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/field/ClearOneToOneAssociationOption.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToOneAssociationOption.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToOneAssociationOption.java
deleted file mode 100644
index 44f0009..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ClearOneToOneAssociationOption.java
+++ /dev/null
@@ -1,45 +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.field;
-
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.Workspace;
-import org.apache.isis.viewer.dnd.view.option.UserActionAbstract;
-
-public class ClearOneToOneAssociationOption extends UserActionAbstract {
- public ClearOneToOneAssociationOption() {
- super("Clear association");
- }
-
- @Override
- public Consent disabled(final View view) {
- final OneToOneField content = ((OneToOneField) view.getContent());
- return content.canClear();
- }
-
- @Override
- public void execute(final Workspace frame, final View view, final Location at) {
- final OneToOneField content = ((OneToOneField) view.getContent());
- content.clear();
- view.getParent().invalidateContent();
- }
-}
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/field/ObjectField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ObjectField.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ObjectField.java
deleted file mode 100644
index f1ddb42..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/ObjectField.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.field;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-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;
-
-final class ObjectField {
- private final ObjectAssociation field;
- private final ObjectAdapter parent;
-
- ObjectField(final ObjectAdapter parent, final ObjectAssociation field) {
- this.parent = parent;
- this.field = field;
- }
-
- public void debugDetails(final DebugBuilder debug) {
- debug.appendln("field", getObjectAssociation());
- debug.appendln("name", getName());
- debug.appendln("specification", getSpecification());
- debug.appendln("parent", parent);
- }
-
- public String getDescription() {
- return field.getDescription();
- }
-
- public String getHelp() {
- return field.getHelp();
- }
-
- public ObjectAssociation getObjectAssociation() {
- return field;
- }
-
- public final String getName() {
- return field.getName();
- }
-
- public ObjectAdapter getParent() {
- return parent;
- }
-
- public ObjectSpecification getSpecification() {
- return field.getSpecification();
- }
-}
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/field/OneToManyField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyField.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyField.java
deleted file mode 100644
index b49375b..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyField.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.field;
-
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.viewer.dnd.view.collection.CollectionContent;
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-
-public interface OneToManyField extends FieldContent, CollectionContent {
- OneToManyAssociation getOneToManyAssociation();
-}
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/field/OneToManyFieldElement.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElement.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElement.java
deleted file mode 100644
index 15db170..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElement.java
+++ /dev/null
@@ -1,27 +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.field;
-
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-
-public interface OneToManyFieldElement extends FieldContent, ObjectContent {
-
-}
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/field/OneToManyFieldElementImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElementImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElementImpl.java
deleted file mode 100644
index 6e56e89..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldElementImpl.java
+++ /dev/null
@@ -1,196 +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.field;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.content.AbstractObjectContent;
-
-public class OneToManyFieldElementImpl extends AbstractObjectContent implements OneToManyFieldElement {
- private static final Logger LOG = LoggerFactory.getLogger(OneToManyFieldElementImpl.class);
- private final ObjectAdapter element;
- private final ObjectField field;
-
- public OneToManyFieldElementImpl(final ObjectAdapter parent, final ObjectAdapter element, final OneToManyAssociation association) {
- field = new ObjectField(parent, association);
- this.element = element;
- }
-
- @Override
- public Consent canClear() {
- final ObjectAdapter parentObject = getParent();
- final OneToManyAssociation association = getOneToManyAssociation();
- final ObjectAdapter associatedObject = getObject();
-
- final Consent isEditable = isEditable();
- if (isEditable.isVetoed()) {
- return isEditable;
- }
-
- final Consent consent = association.isValidToRemove(parentObject, associatedObject);
- if (consent.isAllowed()) {
- consent.setDescription("Clear the association to this object from '" + parentObject.titleString() + "'");
- }
- return consent;
- }
-
- @Override
- public Consent isEditable() {
- return getField().isUsable(IsisContext.getAuthenticationSession(), getParent(), where);
- }
-
- @Override
- public Consent canSet(final ObjectAdapter dragSource) {
- return Veto.DEFAULT;
- }
-
- @Override
- public void clear() {
- final ObjectAdapter parentObject = getParent();
- final OneToManyAssociation association = getOneToManyAssociation();
- LOG.debug("remove " + element + " from " + parentObject);
- association.removeElement(parentObject, element);
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- field.debugDetails(debug);
- debug.appendln("element", element);
- }
-
- @Override
- public String getFieldName() {
- return field.getName();
- }
-
- @Override
- public ObjectAssociation getField() {
- return field.getObjectAssociation();
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return element;
- }
-
- @Override
- public ObjectAdapter getObject() {
- return element;
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return null;
- }
-
- private OneToManyAssociation getOneToManyAssociation() {
- return (OneToManyAssociation) field.getObjectAssociation();
- }
-
- @Override
- public ObjectAdapter getParent() {
- return field.getParent();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return field.getSpecification();
- }
-
- @Override
- public boolean isMandatory() {
- return false;
- }
-
- @Override
- public boolean isObject() {
- return true;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return false;
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- // ObjectOption.menuOptions(element, options);
- super.contentMenuOptions(options);
- options.add(new ClearOneToManyAssociationOption());
- }
-
- @Override
- public void setObject(final ObjectAdapter object) {
- /*
- * ObjectAdapter parentObject = getParent();
- * OneToManyAssociationSpecification association =
- * getOneToManyAssociation(); ObjectAdapter associatedObject =
- * getObject(); LOG.debug("remove " + associatedObject + " from " +
- * parentObject); association.clearAssociation(parentObject,
- * associatedObject);
- */
-
- }
-
- @Override
- public String title() {
- return element.titleString();
- }
-
- @Override
- public String toString() {
- return getObject() + "/" + field.getObjectAssociation();
- }
-
- @Override
- public String windowTitle() {
- return field.getName() + " element" + " for " + field.getParent().titleString();
- }
-
- @Override
- public String getId() {
- return getOneToManyAssociation().getName();
- }
-
- @Override
- public String getDescription() {
- return field.getName() + ": " + getOneToManyAssociation().getDescription();
- }
-
- @Override
- public String getHelp() {
- return getOneToManyAssociation().getHelp();
- }
-}
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/field/OneToManyFieldImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldImpl.java
deleted file mode 100644
index d005ea8..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToManyFieldImpl.java
+++ /dev/null
@@ -1,221 +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.field;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.exceptions.IsisException;
-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.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.collection.AbstractCollectionContent;
-
-public class OneToManyFieldImpl extends AbstractCollectionContent implements OneToManyField {
-
- // REVIEW: should provide this rendering context, rather than hardcoding.
- // the net effect currently is that class members annotated with
- // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
- // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
- // for any other value for Where
- private final Where where = Where.ANYWHERE;
-
- private final ObjectAdapter collection;
- private final ObjectField field;
-
- public OneToManyFieldImpl(final ObjectAdapter parent, final ObjectAdapter object, final OneToManyAssociation association) {
- field = new ObjectField(parent, association);
- this.collection = object;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- if (sourceContent.getAdapter() instanceof ObjectAdapter) {
- final ObjectAdapter sourceAdapter = sourceContent.getAdapter();
- final ObjectAdapter parentAdapter = field.getParent();
-
- final ObjectAdapter collection = getAdapter();
- if (collection == null) {
- // TODO: move logic into Facet
- return new Veto("Collection not set up; can't add elements to a non-existant collection");
- }
-
- final Consent usableInState = getOneToManyAssociation().isUsable(IsisContext.getAuthenticationSession(), parentAdapter, where);
- if (usableInState.isVetoed()) {
- return usableInState;
- }
-
- final ObjectSpecification specification = sourceAdapter.getSpecification();
- final ObjectSpecification elementSpecification = getElementSpecification();
- if (!specification.isOfType(elementSpecification)) {
- // TODO: move logic into Facet
- return new Veto(String.format("Only objects of type %s are allowed in this collection", elementSpecification.getSingularName()));
- }
- if (parentAdapter.representsPersistent() && sourceAdapter.isTransient()) {
- // TODO: move logic into Facet
- return new Veto("Can't set field in persistent object with reference to non-persistent object");
- }
- return getOneToManyAssociation().isValidToAdd(parentAdapter, sourceAdapter);
- } else {
- return Veto.DEFAULT;
- }
- }
-
- public Consent canSet(final ObjectAdapter dragSource) {
- return Veto.DEFAULT;
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- super.contentMenuOptions(options);
- // OptionFactory.addCreateOptions(getOneToManyAssociation().getSpecification(),
- // options);
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- field.debugDetails(debug);
- debug.appendln("collection", collection);
- super.debugDetails(debug);
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- final ObjectAdapter object = sourceContent.getAdapter();
- final ObjectAdapter parent = field.getParent();
- final Consent perm = canDrop(sourceContent);
- if (perm.isAllowed()) {
- getOneToManyAssociation().addElement(parent, object);
- }
- return null;
- }
-
- @Override
- public ObjectAdapter getCollection() {
- return collection;
- }
-
- @Override
- public String getDescription() {
- final String name = getFieldName();
- String type = getField().getSpecification().getSingularName();
- type = name.indexOf(type) == -1 ? " (" + type + ")" : "";
- final String description = getOneToManyAssociation().getDescription();
- return name + type + " " + description;
- }
-
- @Override
- public ObjectAssociation getField() {
- return field.getObjectAssociation();
- }
-
- @Override
- public String getFieldName() {
- return field.getName();
- }
-
- @Override
- public String getHelp() {
- return getOneToManyAssociation().getHelp();
- }
-
- @Override
- public String getIconName() {
- return null;
- // return "internal-collection";
- }
-
- @Override
- public Image getIconPicture(final int iconHeight) {
- final ObjectSpecification specification = getOneToManyAssociation().getSpecification();
- Image icon = ImageFactory.getInstance().loadIcon(specification, iconHeight, null);
- if (icon == null) {
- icon = ImageFactory.getInstance().loadDefaultIcon(iconHeight, null);
- }
- return icon;
- }
-
- @Override
- public String getId() {
- return getOneToManyAssociation().getId();
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return collection;
- }
-
- @Override
- public OneToManyAssociation getOneToManyAssociation() {
- return (OneToManyAssociation) field.getObjectAssociation();
- }
-
- @Override
- public ObjectAdapter getParent() {
- return field.getParent();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return field.getSpecification();
- }
-
- @Override
- public Consent isEditable() {
- return getField().isUsable(IsisContext.getAuthenticationSession(), getParent(), where);
- }
-
- @Override
- public boolean isMandatory() {
- return getOneToManyAssociation().isMandatory();
- }
-
- @Override
- public boolean isTransient() {
- return false;
- }
-
- public void setObject(final ObjectAdapter object) {
- throw new IsisException("Invalid call");
- }
-
- @Override
- public final String title() {
- return field.getName();
- }
-
- @Override
- public String toString() {
- return collection + "/" + field.getObjectAssociation();
- }
-
- @Override
- public String windowTitle() {
- return title() + " for " + field.getParent().titleString();
- }
-
-}
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/field/OneToOneField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java
deleted file mode 100644
index c00440a..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneField.java
+++ /dev/null
@@ -1,29 +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.field;
-
-import org.apache.isis.core.metamodel.consent.Consent;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-
-public interface OneToOneField extends FieldContent, ObjectContent {
- @Override
- Consent isEditable();
-}
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/field/OneToOneFieldImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java
deleted file mode 100644
index 693d468..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/OneToOneFieldImpl.java
+++ /dev/null
@@ -1,211 +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.field;
-
-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.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.view.UserAction;
-import org.apache.isis.viewer.dnd.view.UserActionSet;
-import org.apache.isis.viewer.dnd.view.content.AbstractObjectContent;
-
-public class OneToOneFieldImpl extends AbstractObjectContent implements OneToOneField {
- private static final UserAction CLEAR_ASSOCIATION = new ClearOneToOneAssociationOption();
- private final ObjectField field;
- private final ObjectAdapter adapter;
-
- public OneToOneFieldImpl(final ObjectAdapter parentAdapter, final ObjectAdapter adapter, final OneToOneAssociation association) {
- field = new ObjectField(parentAdapter, association);
- this.adapter = adapter;
- }
-
- @Override
- public Consent canClear() {
- final ObjectAdapter parentAdapter = getParent();
- final OneToOneAssociation association = getOneToOneAssociation();
- // ObjectAdapter associatedObject = getObject();
-
- final Consent isEditable = isEditable();
- if (isEditable.isVetoed()) {
- return isEditable;
- }
-
- final Consent consent = association.isAssociationValid(parentAdapter, null);
- if (consent.isAllowed()) {
- consent.setDescription("Clear the association to this object from '" + parentAdapter.titleString() + "'");
- }
- return consent;
- }
-
- @Override
- public Consent canSet(final ObjectAdapter adapter) {
- final ObjectSpecification targetType = getOneToOneAssociation().getSpecification();
- final ObjectSpecification spec = adapter.getSpecification();
-
- if (isEditable().isVetoed()) {
- return isEditable();
- }
-
- if (!spec.isOfType(targetType)) {
- // TODO: move logic into Facet
- return new Veto(String.format("Can only drop objects of type %s", targetType.getSingularName()));
- }
-
- if (getParent().representsPersistent() && adapter.isTransient()) {
- // TODO: move logic into Facet
- return new Veto("Can't drop a non-persistent into this persistent object");
- }
-
- final Consent perm = getOneToOneAssociation().isAssociationValid(getParent(), adapter);
- return perm;
- }
-
- @Override
- public void clear() {
- getOneToOneAssociation().clearAssociation(getParent());
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- field.debugDetails(debug);
- debug.appendln("object", adapter);
- }
-
- @Override
- public String getFieldName() {
- return field.getName();
- }
-
- @Override
- public ObjectAssociation getField() {
- return field.getObjectAssociation();
- }
-
- @Override
- public Consent isEditable() {
- return getField().isUsable(IsisContext.getAuthenticationSession(), getParent(), where);
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return adapter;
- }
-
- @Override
- public ObjectAdapter getObject() {
- return adapter;
- }
-
- private OneToOneAssociation getOneToOneAssociation() {
- return (OneToOneAssociation) getField();
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return getOneToOneAssociation().getChoices(getParent());
- }
-
- @Override
- public ObjectAdapter getParent() {
- return field.getParent();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return getOneToOneAssociation().getSpecification();
- }
-
- @Override
- public boolean isMandatory() {
- return getOneToOneAssociation().isMandatory();
- }
-
- @Override
- public boolean isPersistable() {
- return getObject() != null && super.isPersistable();
- }
-
- @Override
- public boolean isObject() {
- return true;
- }
-
- @Override
- public boolean isOptionEnabled() {
- return getOneToOneAssociation().hasChoices();
- }
-
- @Override
- public boolean isTransient() {
- return adapter != null && adapter.isTransient();
- }
-
- @Override
- public void contentMenuOptions(final UserActionSet options) {
- super.contentMenuOptions(options);
- if (getObject() != null && !getOneToOneAssociation().isMandatory()) {
- options.add(CLEAR_ASSOCIATION);
- }
- }
-
- @Override
- public void setObject(final ObjectAdapter object) {
- getOneToOneAssociation().setAssociation(getParent(), object);
- }
-
- @Override
- public String title() {
- return adapter == null ? "" : adapter.titleString();
- }
-
- @Override
- public String toString() {
- return getObject() + "/" + getField();
- }
-
- @Override
- public String windowTitle() {
- return field.getName() + " for " + field.getParent().titleString();
- }
-
- @Override
- public String getId() {
- return getOneToOneAssociation().getName();
- }
-
- @Override
- public String getDescription() {
- final String name = getFieldName();
- String type = getField().getSpecification().getSingularName();
- type = name.indexOf(type) == -1 ? " (" + type + ")" : "";
- final String description = getOneToOneAssociation().getDescription();
- return name + type + " " + description;
- }
-
- @Override
- public String getHelp() {
- return getOneToOneAssociation().getHelp();
- }
-}
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/field/TextParseableField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java
deleted file mode 100644
index 5cf5ae2..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableField.java
+++ /dev/null
@@ -1,27 +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.field;
-
-import org.apache.isis.viewer.dnd.view.content.FieldContent;
-import org.apache.isis.viewer.dnd.view.content.TextParseableContent;
-
-public interface TextParseableField extends TextParseableContent, FieldContent {
-
-}
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/field/TextParseableFieldImpl.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.java
deleted file mode 100644
index fca3475..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/field/TextParseableFieldImpl.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.field;
-
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.profiles.Localization;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-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.facets.maxlen.MaxLengthFacet;
-import org.apache.isis.core.metamodel.facets.multiline.MultiLineFacet;
-import org.apache.isis.core.metamodel.facets.object.parseable.InvalidEntryException;
-import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
-import org.apache.isis.core.metamodel.facets.typicallen.TypicalLengthFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.view.Content;
-import org.apache.isis.viewer.dnd.view.ObjectContent;
-import org.apache.isis.viewer.dnd.view.content.AbstractTextParsableContent;
-
-public class TextParseableFieldImpl extends AbstractTextParsableContent implements TextParseableField, ObjectContent {
- private final ObjectField field;
- private final ObjectAdapter parent;
- private ObjectAdapter object;
-
- public TextParseableFieldImpl(final ObjectAdapter parent, final ObjectAdapter object, final OneToOneAssociation association) {
- field = new ObjectField(parent, association);
- this.parent = parent;
- this.object = object;
- }
-
- @Override
- public Consent canDrop(final Content sourceContent) {
- return Veto.DEFAULT;
- }
-
- @Override
- public Consent canClear() {
- return Allow.DEFAULT; // TODO is this flagged anywhere -
- // getValueAssociation().canClear();
- }
-
- @Override
- public boolean canWrap() {
- return getValueAssociation().containsFacet(MultiLineFacet.class);
- }
-
- @Override
- public void clear() {
- }
-
- @Override
- public void debugDetails(final DebugBuilder debug) {
- field.debugDetails(debug);
- debug.appendln("object", object);
- }
-
- @Override
- public ObjectAdapter drop(final Content sourceContent) {
- return null;
- }
-
- @Override
- public void entryComplete() {
- getValueAssociation().setAssociation(getParent(), object);
- }
-
- @Override
- public String getDescription() {
- final String title = object == null ? "" : ": " + object.titleString();
- final String name = field.getName();
- final ObjectSpecification specification = getSpecification();
- final String type = name.indexOf(specification.getShortIdentifier()) == -1 ? "" : " (" + specification.getShortIdentifier() + ")";
- final String description = getValueAssociation().getDescription();
- return name + type + title + " " + description;
- }
-
- @Override
- public String getHelp() {
- return field.getHelp();
- }
-
- @Override
- public String getFieldName() {
- return field.getName();
- }
-
- @Override
- public ObjectAssociation getField() {
- return field.getObjectAssociation();
- }
-
- @Override
- public String getIconName() {
- return object == null ? "" : object.getIconName();
- }
-
- @Override
- public ObjectAdapter getAdapter() {
- return object;
- }
-
- @Override
- public String getId() {
- return field.getName();
- }
-
- @Override
- public ObjectAdapter[] getOptions() {
- return getValueAssociation().getChoices(getParent());
- }
-
- private OneToOneAssociation getValueAssociation() {
- return (OneToOneAssociation) getField();
- }
-
- @Override
- public int getMaximumLength() {
- return maxLengthFacet().value();
- }
-
- @Override
- public int getTypicalLineLength() {
- final TypicalLengthFacet facet = field.getObjectAssociation().getFacet(TypicalLengthFacet.class);
- return facet.value();
- }
-
- @Override
- public int getNoLines() {
- return multilineFacet().numberOfLines();
- }
-
- @Override
- public ObjectAdapter getParent() {
- return field.getParent();
- }
-
- @Override
- public ObjectSpecification getSpecification() {
- return getValueAssociation().getSpecification();
- }
-
- @Override
- public Consent isEditable() {
- return getValueAssociation().isUsable(IsisContext.getAuthenticationSession(), getParent(), Where.ANYWHERE);
- }
-
- @Override
- public boolean isEmpty() {
- return getField().isEmpty(getParent());
- }
-
- @Override
- public boolean isMandatory() {
- return getValueAssociation().isMandatory();
- }
-
- @Override
- public boolean isOptionEnabled() {
- return getValueAssociation().hasChoices();
- }
-
- @Override
- public String titleString(final ObjectAdapter value) {
- return titleString(value, field.getObjectAssociation(), field.getSpecification());
- }
-
- private ObjectAdapter validateAndParse(final String entryText) {
- final ObjectAdapter newValue = parse(entryText);
- final OneToOneAssociation objectAssociation = (OneToOneAssociation) field.getObjectAssociation();
- final Consent valid = objectAssociation.isAssociationValid(parent, newValue);
- if (valid.isVetoed()) {
- throw new InvalidEntryException(valid.getReason());
- }
- return newValue;
- }
-
- private ObjectAdapter parse(final String entryText) {
- final ObjectSpecification fieldSpecification = field.getSpecification();
- final ParseableFacet p = fieldSpecification.getFacet(ParseableFacet.class);
- try {
- Localization localization = IsisContext.getLocalization();
- return p.parseTextEntry(object, entryText, localization);
- } catch (final IllegalArgumentException ex) {
- throw new InvalidEntryException(ex.getMessage(), ex);
- }
- }
-
- @Override
- public void parseTextEntry(final String entryText) {
- object = validateAndParse(entryText);
- final Consent valid = ((OneToOneAssociation) getField()).isAssociationValid(getParent(), object);
- if (valid.isVetoed()) {
- throw new InvalidEntryException(valid.getReason());
- }
- if (getValueAssociation().isMandatory() && object == null) {
- throw new InvalidEntryException("Mandatory field cannot be empty");
- }
- }
-
- @Override
- public String title() {
- return field.getName();
- }
-
- @Override
- public String toString() {
- return (object == null ? "null" : object.titleString()) + "/" + getField();
- }
-
- @Override
- public String windowTitle() {
- return title();
- }
-
- private MaxLengthFacet maxLengthFacet() {
- return getValueAssociation().getFacet(MaxLengthFacet.class);
- }
-
- private MultiLineFacet multilineFacet() {
- return getValueAssociation().getFacet(MultiLineFacet.class);
- }
-
- @Override
- public Consent canSet(final ObjectAdapter dragSource) {
- return Veto.DEFAULT;
- }
-
- @Override
- public ObjectAdapter getObject() {
- return object;
- }
-
- @Override
- public void setObject(final ObjectAdapter object) {
- this.object = object;
- ((OneToOneAssociation) field.getObjectAssociation()).setAssociation(getParent(), object);
- }
-
-}
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/look/LookFactory.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.java
deleted file mode 100644
index b1dfd03..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/LookFactory.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.view.look;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.viewer.dnd.util.Properties;
-import org.apache.isis.viewer.dnd.view.Look;
-import org.apache.isis.viewer.dnd.view.look.line.LineLook;
-import org.apache.isis.viewer.dnd.view.look.linux.LinuxLook;
-import org.apache.isis.viewer.dnd.view.look.simple.SimpleLook;
-import org.apache.isis.viewer.dnd.view.look.swing.SwingLook;
-
-public class LookFactory {
- private static final Look SIMPLE_LOOK = new SimpleLook();
- private static final LineLook LINE_LOOK = new LineLook();
- private static final Look SWING_LOOK = new SwingLook();
- private static final Look LINUX_LOOK = new LinuxLook();
- private static final Look defaultLook = SIMPLE_LOOK;
- private static List<Look> looks = new ArrayList<Look>();
- private static Look installedLook;
-
- public static void init() {
- looks.add(SIMPLE_LOOK);
- looks.add(LINE_LOOK);
- looks.add(SWING_LOOK);
- looks.add(LINUX_LOOK);
-
- final String className = Properties.getString("look");
- if (className != null) {
- for (final Look look : looks) {
- if (look.getClass().getName().equals(className)) {
- setLook(look);
- return;
- }
- }
- }
- setLook(defaultLook);
- }
-
- public static void setLook(final Look look) {
- defaultLook.install();
- look.install();
- installedLook = look;
-
- Properties.setStringOption("look", installedLook.getClass().getName());
- }
-
- public static Look getInstalledLook() {
- return installedLook;
- }
-
- public static Iterable<Look> getAvailableLooks() {
- return looks;
- }
-
-}
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/look/line/ButtonLineStyleRender.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java
deleted file mode 100644
index 43be41d..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/ButtonLineStyleRender.java
+++ /dev/null
@@ -1,63 +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.look.line;
-
-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.Toolkit;
-import org.apache.isis.viewer.dnd.view.control.ButtonRender;
-
-public class ButtonLineStyleRender implements ButtonRender {
- private static final int TEXT_PADDING = 12;
- private static final Text style = Toolkit.getText(ColorsAndFonts.TEXT_CONTROL);
- private final int buttonHeight;
-
- public ButtonLineStyleRender() {
- this.buttonHeight = 2 + style.getTextHeight() + 2;
- }
-
- @Override
- public void draw(final Canvas canvas, final Size size, final boolean isDisabled, final boolean isDefault, final boolean hasFocus, final boolean isOver, final boolean isPressed, final String text) {
- final int buttonWidth = TEXT_PADDING + style.stringWidth(text) + TEXT_PADDING;
-
- final Color borderColor;
- Color textColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- if (isDisabled) {
- borderColor = textColor = Toolkit.getColor(ColorsAndFonts.COLOR_MENU_DISABLED);
- } else if (isDefault) {
- borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_PRIMARY1);
- } else if (isOver || hasFocus) {
- borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- } else {
- borderColor = Toolkit.getColor(ColorsAndFonts.COLOR_BLACK);
- }
- canvas.drawRoundedRectangle(0, 0, buttonWidth, buttonHeight, 0, 0, borderColor);
- canvas.drawText(text, TEXT_PADDING, buttonHeight / 2 + style.getMidPoint(), textColor, style);
- }
-
- @Override
- public Size getMaximumSize(final String text) {
- final int buttonWidth = TEXT_PADDING + Toolkit.getText(ColorsAndFonts.TEXT_CONTROL).stringWidth(text) + TEXT_PADDING;
- return new Size(buttonWidth, buttonHeight);
- }
-}
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/look/line/LineLook.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java b/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java
deleted file mode 100644
index b3e8123..0000000
--- a/mothballed/component/viewer/dnd/impl/src/main/java/org/apache/isis/viewer/dnd/view/look/line/LineLook.java
+++ /dev/null
@@ -1,39 +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.look.line;
-
-import org.apache.isis.viewer.dnd.view.Look;
-import org.apache.isis.viewer.dnd.view.control.Button;
-import org.apache.isis.viewer.dnd.view.window.AbstractWindowBorder;
-
-public class LineLook implements Look {
-
- @Override
- public void install() {
- AbstractWindowBorder.setBorderRenderer(new LineStyleWindowBorder());
- Button.setButtonRender(new ButtonLineStyleRender());
- }
-
- @Override
- public String getName() {
- return "Line";
- }
-
-}