You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/08 15:56:02 UTC
[36/53] [partial] ISIS-188: making structure of component viewers
consistent
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewer.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewer.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewer.java
deleted file mode 100644
index d13e837..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewer.java
+++ /dev/null
@@ -1,474 +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;
-
-import java.awt.Dimension;
-import java.util.StringTokenizer;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfigurationException;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.factory.InstanceCreationException;
-import org.apache.isis.core.commons.factory.InstanceUtil;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.userprofile.UserProfile;
-import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.AuthenticationRequestExploration;
-import org.apache.isis.runtimes.dflt.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewerAbstract;
-import org.apache.isis.viewer.dnd.awt.AwtImageFactory;
-import org.apache.isis.viewer.dnd.awt.AwtToolkit;
-import org.apache.isis.viewer.dnd.awt.LoginDialog;
-import org.apache.isis.viewer.dnd.awt.ViewerFrame;
-import org.apache.isis.viewer.dnd.awt.XViewer;
-import org.apache.isis.viewer.dnd.calendar.CalendarSpecification;
-import org.apache.isis.viewer.dnd.combined.ExpandableListSpecification;
-import org.apache.isis.viewer.dnd.combined.FormWithTableSpecification;
-import org.apache.isis.viewer.dnd.combined.TwoPartViewSpecification;
-import org.apache.isis.viewer.dnd.configurable.ConfigurableObjectViewSpecification;
-import org.apache.isis.viewer.dnd.configurable.GridListSpecification;
-import org.apache.isis.viewer.dnd.configurable.NewViewSpecification;
-import org.apache.isis.viewer.dnd.configurable.PanelViewSpecification;
-import org.apache.isis.viewer.dnd.drawing.Bounds;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Size;
-import org.apache.isis.viewer.dnd.field.CheckboxField;
-import org.apache.isis.viewer.dnd.field.ColorField;
-import org.apache.isis.viewer.dnd.field.DateFieldSpecification;
-import org.apache.isis.viewer.dnd.field.EmptyField;
-import org.apache.isis.viewer.dnd.field.FieldOfSpecification;
-import org.apache.isis.viewer.dnd.field.ImageField;
-import org.apache.isis.viewer.dnd.field.PasswordFieldSpecification;
-import org.apache.isis.viewer.dnd.field.TextFieldSpecification;
-import org.apache.isis.viewer.dnd.form.ExpandableFormSpecification;
-import org.apache.isis.viewer.dnd.form.FormSpecification;
-import org.apache.isis.viewer.dnd.form.FormWithDetailSpecification;
-import org.apache.isis.viewer.dnd.form.InternalFormSpecification;
-import org.apache.isis.viewer.dnd.form.SummaryFormSpecification;
-import org.apache.isis.viewer.dnd.grid.GridSpecification;
-import org.apache.isis.viewer.dnd.help.HelpViewer;
-import org.apache.isis.viewer.dnd.help.InternalHelpViewer;
-import org.apache.isis.viewer.dnd.histogram.HistogramSpecification;
-import org.apache.isis.viewer.dnd.icon.LargeIconSpecification;
-import org.apache.isis.viewer.dnd.icon.RootIconSpecification;
-import org.apache.isis.viewer.dnd.icon.SubviewIconSpecification;
-import org.apache.isis.viewer.dnd.list.InternalListSpecification;
-import org.apache.isis.viewer.dnd.list.SimpleListSpecification;
-import org.apache.isis.viewer.dnd.service.PerspectiveContent;
-import org.apache.isis.viewer.dnd.service.ServiceIconSpecification;
-import org.apache.isis.viewer.dnd.table.WindowTableSpecification;
-import org.apache.isis.viewer.dnd.tree.ListWithDetailSpecification;
-import org.apache.isis.viewer.dnd.tree.TreeSpecification;
-import org.apache.isis.viewer.dnd.tree.TreeWithDetailSpecification;
-import org.apache.isis.viewer.dnd.tree2.CollectionTreeNodeSpecification;
-import org.apache.isis.viewer.dnd.tree2.TreeNodeSpecification;
-import org.apache.isis.viewer.dnd.util.Properties;
-import org.apache.isis.viewer.dnd.view.Axes;
-import org.apache.isis.viewer.dnd.view.ShutdownListener;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.View;
-import org.apache.isis.viewer.dnd.view.ViewRequirement;
-import org.apache.isis.viewer.dnd.view.ViewSpecification;
-import org.apache.isis.viewer.dnd.view.ViewUpdateNotifier;
-import org.apache.isis.viewer.dnd.view.base.ViewUpdateNotifierImpl;
-import org.apache.isis.viewer.dnd.view.message.DetailedMessageViewSpecification;
-import org.apache.isis.viewer.dnd.view.message.MessageDialogSpecification;
-import org.apache.isis.viewer.dnd.viewer.SkylarkViewFactory;
-import org.apache.isis.viewer.dnd.viewer.basic.DragContentSpecification;
-import org.apache.isis.viewer.dnd.viewer.basic.InnerWorkspaceSpecification;
-import org.apache.isis.viewer.dnd.viewer.basic.RootWorkspaceSpecification;
-import org.apache.isis.viewer.dnd.viewer.basic.WrappedTextFieldSpecification;
-
-public class DndViewer extends IsisViewerAbstract {
-
- private static final Logger LOG = Logger.getLogger(DndViewer.class);
- private static final String SPECIFICATION_BASE = Properties.PROPERTY_BASE + "specification.";
- private ViewUpdateNotifier updateNotifier;
- private ViewerFrame frame;
- private XViewer viewer;
- private ShutdownListener shutdownListener;
- private Bounds bounds;
- private HelpViewer helpViewer;
- private boolean acceptingLogIns = true;
-
- // ////////////////////////////////////
- // shutdown
- // ////////////////////////////////////
-
- @Override
- public void shutdown() {
- System.exit(0);
- }
-
- private Bounds calculateInitialWindowSize(final Dimension screenSize) {
- int maxWidth = screenSize.width;
- final int maxHeight = screenSize.height;
-
- if ((screenSize.width / screenSize.height) >= 2) {
- final int f = screenSize.width / screenSize.height;
- maxWidth = screenSize.width / f;
- }
-
- final int width = maxWidth - 80;
- final int height = maxHeight - 80;
- final int x = 100;
- final int y = 100;
-
- final Size defaultWindowSize = new Size(width, height);
- defaultWindowSize.limitWidth(800);
- defaultWindowSize.limitHeight(600);
-
- final Size size = Properties.getSize(Properties.PROPERTY_BASE + "initial.size", defaultWindowSize);
- final Location location = Properties.getLocation(Properties.PROPERTY_BASE + "initial.location", new Location(x, y));
- return new Bounds(location, size);
- }
-
- private ViewSpecification loadSpecification(final String name, final Class<?> cls) {
- final String factoryName = IsisContext.getConfiguration().getString(SPECIFICATION_BASE + name);
- ViewSpecification spec;
- if (factoryName != null) {
- spec = InstanceUtil.createInstance(factoryName, ViewSpecification.class);
- } else {
- spec = InstanceUtil.createInstance(cls.getName(), ViewSpecification.class);
- }
- return spec;
- }
-
- private synchronized void logOut() {
- LOG.info("user log out");
- saveDesktop();
- final AuthenticationSession session = IsisContext.getAuthenticationSession();
- getAuthenticationManager().closeSession(session);
- viewer.close();
- notify();
- }
-
- private void saveDesktop() {
- if (!IsisContext.inSession()) {
- // can't do anything
- return;
- }
- viewer.saveOpenObjects();
- }
-
- protected void quit() {
- LOG.info("user quit");
- saveDesktop();
- acceptingLogIns = false;
- shutdown();
- }
-
- @Override
- public synchronized void init() {
- super.init();
-
- new AwtImageFactory(IsisContext.getTemplateImageLoader());
- new AwtToolkit();
-
- setShutdownListener(new ShutdownListener() {
- @Override
- public void logOut() {
- DndViewer.this.logOut();
- }
-
- @Override
- public void quit() {
- DndViewer.this.quit();
- }
- });
-
- updateNotifier = new ViewUpdateNotifierImpl();
-
- if (updateNotifier == null) {
- throw new NullPointerException("No update notifier set for " + this);
- }
- if (shutdownListener == null) {
- throw new NullPointerException("No shutdown listener set for " + this);
- }
-
- while (acceptingLogIns) {
- if (login()) {
- openViewer();
- try {
- wait();
- } catch (final InterruptedException e) {
- }
- } else {
- quit();
- }
- }
- }
-
- // ////////////////////////////////////
- // login
- // ////////////////////////////////////
-
- // TODO: nasty
- private boolean loggedInUsingLogonFixture = false;
-
- /**
- * TODO: there is similar code in
- * <tt>AuthenticationSessionLookupStrategyDefault</tt>; should try to
- * combine somehow...
- */
- private boolean login() {
- final AuthenticationRequest request = determineRequestIfPossible();
-
- // we may have enough to get a session
- AuthenticationSession session = getAuthenticationManager().authenticate(request);
- clearAuthenticationRequestViaArgs();
-
- if (session == null) {
- session = loginDialogPrompt(request);
- }
- if (session == null) {
- return false;
- } else {
- IsisContext.openSession(session);
- return true;
- }
- }
-
- private AuthenticationSession loginDialogPrompt(final AuthenticationRequest request) {
- AuthenticationSession session;
- final LoginDialog dialog = new LoginDialog(getAuthenticationManager());
- if (request != null) {
- dialog.setUserName(request.getName());
- }
- dialog.setVisible(true);
- dialog.toFront();
- dialog.login();
- dialog.setVisible(false);
- dialog.dispose();
- session = dialog.getSession();
- return session;
- }
-
- private AuthenticationRequest determineRequestIfPossible() {
-
- // command line args
- AuthenticationRequest request = getAuthenticationRequestViaArgs();
- ;
-
- // exploration & (optionally) logon fixture provided
- if (request == null) {
- if (getDeploymentType().isExploring()) {
- request = new AuthenticationRequestExploration(getLogonFixture());
- }
- }
-
- // logon fixture provided
- if (request == null) {
- if (getLogonFixture() != null && !loggedInUsingLogonFixture) {
- loggedInUsingLogonFixture = true;
- request = new AuthenticationRequestLogonFixture(getLogonFixture());
- }
- }
- return request;
- }
-
- private void openViewer() {
- frame = new ViewerFrame();
-
- if (bounds == null) {
- bounds = calculateInitialWindowSize(frame.getToolkit().getScreenSize());
- }
-
- frame.pack(); // forces insets to be calculated, hence need to then set
- // bounds
- frame.setBounds(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
-
- viewer = (XViewer) Toolkit.getViewer();
- viewer.setRenderingArea(frame);
- viewer.setUpdateNotifier(updateNotifier);
- viewer.setListener(shutdownListener);
- viewer.setExploration(isInExplorationMode());
- viewer.setPrototype(isInPrototypeMode());
-
- if (helpViewer == null) {
- helpViewer = new InternalHelpViewer(viewer);
- }
- viewer.setHelpViewer(helpViewer);
-
- frame.setViewer(viewer);
-
- final AuthenticationSession currentSession = IsisContext.getAuthenticationSession();
- if (currentSession == null) {
- throw new NullPointerException("No session for " + this);
- }
-
- setupViewFactory();
-
- final UserProfile userProfiler = IsisContext.getUserProfile();
-
- // TODO viewer should be shown during init() (so login can take place on
- // main window, and can quit
- // before
- // logging in), and should be updated during start to show context.
-
- // TODO resolving should be done by the views?
- // resolveApplicationContextCollection(rootObject, "services");
- // resolveApplicationContextCollection(rootObject, "objects");
- final RootWorkspaceSpecification spec = new RootWorkspaceSpecification();
- final PerspectiveContent content = new PerspectiveContent(userProfiler.getPerspective());
- if (spec.canDisplay(new ViewRequirement(content, ViewRequirement.CLOSED))) {
- // View view = spec.createView(new RootObject(rootObject), null);
- final View view = spec.createView(content, new Axes(), -1);
- viewer.setRootView(view);
- } else {
- throw new IsisException();
- }
-
- viewer.init();
-
- final String name = userProfiler.getPerspective().getName();
- frame.setTitle(name);
- frame.init();
-
- viewer.initSize();
- viewer.scheduleRepaint();
-
- frame.setVisible(true);
- frame.toFront();
- }
-
- private boolean isInExplorationMode() {
- return getDeploymentType().isExploring();
- }
-
- private boolean isInPrototypeMode() {
- return getDeploymentType().isPrototyping();
- }
-
- public void setBounds(final Bounds bounds) {
- this.bounds = bounds;
- }
-
- public void setHelpViewer(final HelpViewer helpViewer) {
- this.helpViewer = helpViewer;
- }
-
- public void setShutdownListener(final ShutdownListener shutdownListener) {
- this.shutdownListener = shutdownListener;
- }
-
- private void setupViewFactory() throws IsisConfigurationException, InstanceCreationException {
- final SkylarkViewFactory viewFactory = (SkylarkViewFactory) Toolkit.getViewFactory();
-
- LOG.debug("setting up default views (provided by the framework)");
-
- /*
- * viewFactory.addValueFieldSpecification(loadSpecification("field.option"
- * , OptionSelectionField.Specification.class));
- * viewFactory.addValueFieldSpecification
- * (loadSpecification("field.percentage",
- * PercentageBarField.Specification.class));
- * viewFactory.addValueFieldSpecification
- * (loadSpecification("field.timeperiod",
- * TimePeriodBarField.Specification.class));
- */
- viewFactory.addSpecification(loadSpecification("field.image", ImageField.Specification.class));
- viewFactory.addSpecification(loadSpecification("field.color", ColorField.Specification.class));
- viewFactory.addSpecification(loadSpecification("field.password", PasswordFieldSpecification.class));
- viewFactory.addSpecification(loadSpecification("field.wrappedtext", WrappedTextFieldSpecification.class));
- viewFactory.addSpecification(loadSpecification("field.checkbox", CheckboxField.Specification.class));
- viewFactory.addSpecification(loadSpecification("field.date", DateFieldSpecification.class));
- viewFactory.addSpecification(loadSpecification("field.text", TextFieldSpecification.class));
- viewFactory.addSpecification(new RootWorkspaceSpecification());
- viewFactory.addSpecification(new InnerWorkspaceSpecification());
-
- if (IsisContext.getConfiguration().getBoolean(SPECIFICATION_BASE + "defaults", true)) {
- viewFactory.addSpecification(new FieldOfSpecification());
-
- viewFactory.addSpecification(new InternalListSpecification());
- viewFactory.addSpecification(new SimpleListSpecification());
- viewFactory.addSpecification(new GridSpecification());
- // TBA viewFactory.addSpecification(new
- // ListWithExpandableElementsSpecification());
- // TBA
- viewFactory.addSpecification(new CalendarSpecification());
- viewFactory.addSpecification(new ListWithDetailSpecification());
- viewFactory.addSpecification(new HistogramSpecification());
-
- viewFactory.addSpecification(new TreeWithDetailSpecification());
- viewFactory.addSpecification(new FormSpecification());
- viewFactory.addSpecification(new FormWithTableSpecification());
- viewFactory.addSpecification(new WindowTableSpecification());
- // TBA
- viewFactory.addSpecification(new ExpandableFormSpecification());
- viewFactory.addSpecification(new InternalFormSpecification());
- viewFactory.addSpecification(new TwoPartViewSpecification());
- // TBA
- viewFactory.addSpecification(new FormWithDetailSpecification());
-
- viewFactory.addSpecification(new SummaryFormSpecification());
-
- viewFactory.addSpecification(new TreeSpecification());
- // TODO allow window form to be used for objects with limited number
- // of collections
- // viewFactory.addSpecification(new TreeWithDetailSpecification(0,
- // 3));
-
- viewFactory.addDesignSpecification(new GridListSpecification());
- viewFactory.addDesignSpecification(new ConfigurableObjectViewSpecification());
- viewFactory.addDesignSpecification(new PanelViewSpecification());
- viewFactory.addDesignSpecification(new NewViewSpecification());
- }
-
- viewFactory.addSpecification(new MessageDialogSpecification());
- viewFactory.addSpecification(new DetailedMessageViewSpecification());
-
- viewFactory.addEmptyFieldSpecification(loadSpecification("field.empty", EmptyField.Specification.class));
-
- viewFactory.addSpecification(loadSpecification("icon.object", RootIconSpecification.class));
- viewFactory.addSpecification(loadSpecification("icon.subview", SubviewIconSpecification.class));
- viewFactory.addSpecification(loadSpecification("icon.collection", ExpandableListSpecification.class));
- viewFactory.addSpecification(new LargeIconSpecification());
-
- viewFactory.addSpecification(loadSpecification("icon.service", ServiceIconSpecification.class));
- viewFactory.setDragContentSpecification(loadSpecification("drag-content", DragContentSpecification.class));
-
- // TODO remove or move to better position
- final ViewSpecification[] specifications = CollectionTreeNodeSpecification.create();
- viewFactory.addSpecification(specifications[0]);
- viewFactory.addSpecification(specifications[1]);
- viewFactory.addSpecification(new TreeNodeSpecification());
-
- installSpecsFromConfiguration(viewFactory);
-
- viewFactory.loadUserViewSpecifications();
- }
-
- private void installSpecsFromConfiguration(final SkylarkViewFactory viewFactory) {
- final String viewParams = IsisContext.getConfiguration().getString(SPECIFICATION_BASE + "view");
- if (viewParams != null) {
- final StringTokenizer st = new StringTokenizer(viewParams, ",");
- while (st.hasMoreTokens()) {
- final String specName = st.nextToken().trim();
- if (specName != null && !specName.trim().equals("")) {
- viewFactory.addSpecification(specName);
- }
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewerInstaller.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewerInstaller.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewerInstaller.java
deleted file mode 100644
index 5f4a52a..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/DndViewerInstaller.java
+++ /dev/null
@@ -1,36 +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;
-
-import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstallerAbstract;
-import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
-
-public class DndViewerInstaller extends IsisViewerInstallerAbstract {
-
- public DndViewerInstaller() {
- super("dnd");
- }
-
- @Override
- public IsisViewer doCreateViewer() {
- return new DndViewer();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AWTUtilities.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AWTUtilities.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AWTUtilities.java
deleted file mode 100644
index 64c33a3..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AWTUtilities.java
+++ /dev/null
@@ -1,37 +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.awt;
-
-import java.awt.Frame;
-import java.awt.Image;
-import java.net.URL;
-
-public class AWTUtilities {
-
- public static void addWindowIcon(final Frame window, final String file) {
- final URL url = ViewerFrame.class.getResource("/" + "images/" + file);
- if (url != null) {
- final Image image = java.awt.Toolkit.getDefaultToolkit().getImage(url);
- if (image != null) {
- window.setIconImage(image);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtCanvas.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtCanvas.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtCanvas.java
deleted file mode 100644
index 48e7790..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtCanvas.java
+++ /dev/null
@@ -1,263 +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.awt;
-
-import java.awt.Font;
-import java.awt.Graphics;
-import java.awt.Polygon;
-import java.awt.Rectangle;
-import java.awt.image.ImageObserver;
-import java.util.StringTokenizer;
-
-import org.apache.isis.viewer.dnd.drawing.Bounds;
-import org.apache.isis.viewer.dnd.drawing.Canvas;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.drawing.Shape;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.view.base.AwtImage;
-
-public class AwtCanvas implements Canvas {
- private java.awt.Color color;
- private Font font;
- private final Graphics graphics;
- private final RenderingArea renderingArea;
-
- private AwtCanvas(final Graphics graphics, final RenderingArea renderingArea) {
- this.graphics = graphics;
- this.renderingArea = renderingArea;
- }
-
- public AwtCanvas(final Graphics bufferGraphic, final RenderingArea renderingArea, final int x, final int y, final int width, final int height) {
- graphics = bufferGraphic;
- this.renderingArea = renderingArea;
- graphics.clipRect(x, y, width, height);
- }
-
- private Polygon createOval(final int x, final int y, final int width, final int height) {
- final int points = 40;
- final int xPoints[] = new int[points];
- final int yPoints[] = new int[points];
- double radians = 0.0;
- for (int i = 0; i < points; i++) {
- xPoints[i] = x + (int) (width / 2.0) + (int) (width / 2.0 * Math.cos(radians));
- yPoints[i] = y + (int) (height / 2.0) + (int) (height / 2.0 * Math.sin(radians));
- radians += (2.0 * Math.PI) / points;
- }
- final Polygon p = new Polygon(xPoints, yPoints, points);
- return p;
- }
-
- @Override
- public Canvas createSubcanvas() {
- return new AwtCanvas(graphics.create(), renderingArea);
- }
-
- @Override
- public Canvas createSubcanvas(final Bounds bounds) {
- return createSubcanvas(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight());
- }
-
- @Override
- public Canvas createSubcanvas(final int x, final int y, final int width, final int height) {
- final Graphics g = graphics.create();
- // this form of clipping must go here!
- g.translate(x, y);
- return new AwtCanvas(g, renderingArea, 0, 0, width, height);
- }
-
- @Override
- public void draw3DRectangle(final int x, final int y, final int width, final int height, final Color color, final boolean raised) {
- useColor(color);
- graphics.draw3DRect(x, y, width - 1, height - 1, raised);
- }
-
- @Override
- public void drawDebugOutline(final Bounds bounds, final int baseline, final Color color) {
- final int width = bounds.getWidth();
- final int height = bounds.getHeight();
- drawRectangle(bounds.getX(), bounds.getY(), width, height, color);
- final int midpoint = bounds.getY() + height / 2;
- drawLine(bounds.getX(), midpoint, width - 2, midpoint, color);
- if (baseline > 0) {
- drawLine(bounds.getX(), baseline, width - 1, baseline, Toolkit.getColor(ColorsAndFonts.COLOR_DEBUG_BASELINE));
- }
- }
-
- @Override
- public void drawImage(final Image image, final int x, final int y) {
- graphics.drawImage(((AwtImage) image).getAwtImage(), x, y, (ImageObserver) renderingArea);
- }
-
- @Override
- public void drawImage(final Image image, final int x, final int y, final int width, final int height) {
- graphics.drawImage(((AwtImage) image).getAwtImage(), x, y, width - 1, height - 1, (ImageObserver) renderingArea);
- }
-
- @Override
- public void drawLine(final int x, final int y, final int x2, final int y2, final Color color) {
- useColor(color);
- graphics.drawLine(x, y, x2, y2);
- }
-
- @Override
- public void drawLine(final Location start, final int xExtent, final int yExtent, final Color color) {
- drawLine(start.getX(), start.getY(), start.getX() + xExtent, start.getY() + yExtent, color);
- }
-
- @Override
- public void drawOval(final int x, final int y, final int width, final int height, final Color color) {
- useColor(color);
- final Polygon p = createOval(x, y, width - 1, height - 1);
- graphics.drawPolygon(p);
- }
-
- @Override
- public void drawRectangle(final int x, final int y, final int width, final int height, final Color color) {
- useColor(color);
- graphics.drawRect(x, y, width - 1, height - 1);
- }
-
- @Override
- public void drawRectangleAround(final Bounds bounds, final Color color) {
- drawRectangle(0, 0, bounds.getWidth(), bounds.getHeight(), color);
- }
-
- @Override
- public void drawRoundedRectangle(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight, final Color color) {
- useColor(color);
- graphics.drawRoundRect(x, y, width - 1, height - 1, arcWidth, arcHeight);
- }
-
- @Override
- public void drawShape(final Shape shape, final Color color) {
- useColor(color);
- graphics.drawPolygon(shape.getX(), shape.getY(), shape.count());
- }
-
- @Override
- public void drawShape(final Shape shape, final int x, final int y, final Color color) {
- final Shape copy = new Shape(shape);
- copy.translate(x, y);
- drawShape(copy, color);
- }
-
- @Override
- public void drawSolidOval(final int x, final int y, final int width, final int height, final Color color) {
- useColor(color);
- final Polygon p = createOval(x, y, width, height);
- graphics.fillPolygon(p);
- }
-
- @Override
- public void drawSolidRectangle(final int x, final int y, final int width, final int height, final Color color) {
- useColor(color);
- graphics.fillRect(x, y, width, height);
- }
-
- @Override
- public void drawSolidShape(final Shape shape, final Color color) {
- useColor(color);
- graphics.fillPolygon(shape.getX(), shape.getY(), shape.count());
- }
-
- @Override
- public void drawSolidShape(final Shape shape, final int x, final int y, final Color color) {
- final Shape copy = new Shape(shape);
- copy.translate(x, y);
- drawSolidShape(copy, color);
- }
-
- @Override
- public void drawText(final String text, final int x, final int y, final Color color, final Text style) {
- useColor(color);
- useFont(style);
- graphics.drawString(text, x, y);
- }
-
- @Override
- public void drawText(final String text, final int x, final int y, final int maxWidth, final Color color, final Text style) {
- useColor(color);
- useFont(style);
-
- int top = y;
- final StringTokenizer lines = new StringTokenizer(text, "\n\r");
- while (lines.hasMoreTokens()) {
- final String line = lines.nextToken();
- final StringTokenizer words = new StringTokenizer(line, " ");
- final StringBuffer l = new StringBuffer();
- int width = 0;
- while (words.hasMoreTokens()) {
- final String nextWord = words.nextToken();
- final int wordWidth = style.stringWidth(nextWord);
- width += wordWidth;
- if (width >= maxWidth) {
- graphics.drawString(l.toString(), x + (line.startsWith("\t") ? 20 : 00), top);
- top += style.getLineHeight();
- l.setLength(0);
- width = wordWidth;
- }
- l.append(nextWord);
- l.append(" ");
- width += style.stringWidth(" ");
- }
- graphics.drawString(l.toString(), x + (line.startsWith("\t") ? 20 : 00), top);
- top += style.getLineHeight();
- }
- }
-
- @Override
- public void offset(final int x, final int y) {
- graphics.translate(x, y);
- }
-
- @Override
- public boolean overlaps(final Bounds bounds) {
- final Rectangle clip = graphics.getClipBounds();
- final Bounds activeArea = new Bounds(clip.x, clip.y, clip.width, clip.height);
- return bounds.intersects(activeArea);
- }
-
- @Override
- public String toString() {
- final Rectangle cb = graphics.getClipBounds();
- return "Canvas [area=" + cb.x + "," + cb.y + " " + cb.width + "x" + cb.height + ",color=" + color + ",font=" + font + "]";
- }
-
- private void useColor(final Color color) {
- final java.awt.Color awtColor = ((AwtColor) color).getAwtColor();
-
- if (this.color != awtColor) {
- this.color = awtColor;
- graphics.setColor(awtColor);
- }
- }
-
- private void useFont(final Text style) {
- final Font font = ((AwtText) style).getAwtFont();
- if (this.font != font) {
- this.font = font;
- graphics.setFont(font);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColor.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColor.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColor.java
deleted file mode 100644
index 5bd5ceb..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColor.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.viewer.dnd.awt;
-
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.util.Properties;
-
-public class AwtColor implements Color {
- public static final AwtColor DEBUG_BASELINE = new AwtColor(java.awt.Color.magenta);
- public static final AwtColor DEBUG_DRAW_BOUNDS = new AwtColor(java.awt.Color.cyan);
- public static final AwtColor DEBUG_VIEW_BOUNDS = new AwtColor(java.awt.Color.orange);
- public static final AwtColor DEBUG_REPAINT_BOUNDS = new AwtColor(java.awt.Color.green);
- public static final AwtColor DEBUG_BORDER_BOUNDS = new AwtColor(java.awt.Color.pink);
-
- public static final AwtColor RED = new AwtColor(java.awt.Color.red);
- public static final AwtColor GREEN = new AwtColor(java.awt.Color.green);
- public static final AwtColor BLUE = new AwtColor(java.awt.Color.blue);
- public static final AwtColor BLACK = new AwtColor(java.awt.Color.black);
- public static final AwtColor WHITE = new AwtColor(java.awt.Color.white);
- public static final AwtColor GRAY = new AwtColor(java.awt.Color.gray);
- public static final AwtColor LIGHT_GRAY = new AwtColor(java.awt.Color.lightGray);
- public static final AwtColor ORANGE = new AwtColor(java.awt.Color.orange);
- public static final AwtColor YELLOW = new AwtColor(java.awt.Color.yellow);
-
- static public final AwtColor NULL = new AwtColor(0);
-
- private static final String PROPERTY_STEM = Properties.PROPERTY_BASE + "color.";
- private final java.awt.Color color;
- private String name;
-
- public AwtColor(final int rgbColor) {
- this(new java.awt.Color(rgbColor));
- }
-
- private AwtColor(final java.awt.Color color) {
- this.color = color;
- }
-
- public AwtColor(final String propertyName, final String defaultColor) {
- this.name = propertyName;
- color = IsisContext.getConfiguration().getColor(PROPERTY_STEM + propertyName, java.awt.Color.decode(defaultColor));
- }
-
- public AwtColor(final String propertyName, final AwtColor defaultColor) {
- this.name = propertyName;
- color = IsisContext.getConfiguration().getColor(PROPERTY_STEM + propertyName, defaultColor.getAwtColor());
- }
-
- @Override
- public Color brighter() {
- return new AwtColor(color.brighter());
- }
-
- @Override
- public Color darker() {
- return new AwtColor(color.darker());
- }
-
- public java.awt.Color getAwtColor() {
- return color;
- }
-
- @Override
- public String toString() {
- return name + " (" + "#" + Integer.toHexString(color.getRGB()) + ")";
- }
-
- @Override
- public String getName() {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColorsAndFonts.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColorsAndFonts.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColorsAndFonts.java
deleted file mode 100644
index cc05daa..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtColorsAndFonts.java
+++ /dev/null
@@ -1,168 +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.awt;
-
-import java.util.Hashtable;
-
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.view.ViewConstants;
-
-public class AwtColorsAndFonts implements ColorsAndFonts {
- private final Hashtable colors = new Hashtable();
- private int defaultBaseline;
- private int defaultFieldHeight;
- private final Hashtable fonts = new Hashtable();
-
- @Override
- public int defaultBaseline() {
- if (defaultBaseline == 0) {
- final int iconSize = getText(TEXT_NORMAL).getAscent();
- defaultBaseline = ViewConstants.VPADDING + iconSize;
- }
- return defaultBaseline;
- }
-
- @Override
- public int defaultFieldHeight() {
- if (defaultFieldHeight == 0) {
- defaultFieldHeight = getText(TEXT_NORMAL).getTextHeight();
- }
- return defaultFieldHeight;
- }
-
- @Override
- public Color getColor(final String name) {
- Color color = (Color) colors.get(name);
- if (color == null && name.startsWith(COLOR_WINDOW + ".")) {
- color = new AwtColor(name, (AwtColor) getColor(COLOR_WINDOW));
- colors.put(name, color);
- }
- return color;
-
- }
-
- @Override
- public Color getColor(final int rgbColor) {
- return new AwtColor(rgbColor);
- }
-
- @Override
- public Text getText(final String name) {
- return (Text) fonts.get(name);
- }
-
- @Override
- public void init() {
- // core color scheme
- setColor(COLOR_BLACK, "#000000");
- setColor(COLOR_WHITE, "#ffffff");
- setColor(COLOR_PRIMARY1, "#666699");
- setColor(COLOR_PRIMARY2, "#9999cc");
- setColor(COLOR_PRIMARY3, "#ccccff");
- setColor(COLOR_SECONDARY1, "#666666");
- setColor(COLOR_SECONDARY2, "#999999");
- setColor(COLOR_SECONDARY3, "#cccccc");
-
- // background colors
- setColor(COLOR_APPLICATION, "#e0e0e0");
- setColor(COLOR_WINDOW, getColor(COLOR_WHITE));
- setColor(COLOR_MENU_VALUE, getColor(COLOR_PRIMARY3)); // "#ccffcc");
- setColor(COLOR_MENU_CONTENT, getColor(COLOR_PRIMARY3)); // "#ffcccc");
- setColor(COLOR_MENU_VIEW, getColor(COLOR_SECONDARY3)); // "#ffccff");
- setColor(COLOR_MENU_WORKSPACE, getColor(COLOR_SECONDARY3)); // "#cccccc");
-
- // menu colors
- setColor(COLOR_MENU, getColor(COLOR_BLACK));
- setColor(COLOR_MENU_DISABLED, getColor(COLOR_SECONDARY1));
- setColor(COLOR_MENU_REVERSED, getColor(COLOR_WHITE));
-
- // label colors
- setColor(COLOR_LABEL_MANDATORY, getColor(COLOR_BLACK));
- setColor(COLOR_LABEL, getColor(COLOR_SECONDARY1));
- setColor(COLOR_LABEL_DISABLED, getColor(COLOR_SECONDARY2));
-
- // state colors
- setColor(COLOR_IDENTIFIED, getColor(COLOR_PRIMARY1)); // "#0099ff");
- setColor(COLOR_VALID, "#32CD32");
- setColor(COLOR_INVALID, "#ee1919");
- setColor(COLOR_ERROR, "#ee1919");
- setColor(COLOR_ACTIVE, "#ff0000");
- setColor(COLOR_OUT_OF_SYNC, "#662200");
-
- // text colors
- setColor(COLOR_TEXT_SAVED, getColor(COLOR_SECONDARY1));
- setColor(COLOR_TEXT_EDIT, getColor(COLOR_PRIMARY1)); // "#009933");
- setColor(COLOR_TEXT_CURSOR, getColor(COLOR_PRIMARY1));
- setColor(COLOR_TEXT_HIGHLIGHT, getColor(COLOR_PRIMARY3));
-
- // debug outline colors
- setColor(COLOR_DEBUG_BASELINE, AwtColor.DEBUG_BASELINE);
- setColor(COLOR_DEBUG_BOUNDS_BORDER, AwtColor.DEBUG_BORDER_BOUNDS);
- setColor(COLOR_DEBUG_BOUNDS_DRAW, AwtColor.DEBUG_DRAW_BOUNDS);
- setColor(COLOR_DEBUG_BOUNDS_REPAINT, AwtColor.DEBUG_REPAINT_BOUNDS);
- setColor(COLOR_DEBUG_BOUNDS_VIEW, AwtColor.DEBUG_VIEW_BOUNDS);
-
- // fonts
- final String defaultFontFamily = AwtText.defaultFontFamily();
- final int defaultFontSizeSmall = AwtText.defaultFontSizeSmall();
- final int defaultFontSizeMedium = AwtText.defaultFontSizeMedium();
- final int defaultFontSizeLarge = AwtText.defaultFontSizeLarge();
-
- setText(TEXT_TITLE, defaultFontFamily + "-bold-" + defaultFontSizeLarge);
-
- setText(TEXT_TITLE_SMALL, defaultFontFamily + "-bold-" + defaultFontSizeMedium);
- setText(TEXT_NORMAL, defaultFontFamily + "-plain-" + defaultFontSizeMedium);
- setText(TEXT_CONTROL, defaultFontFamily + "-bold-" + defaultFontSizeMedium);
- setText(TEXT_STATUS, defaultFontFamily + "--" + defaultFontSizeMedium);
- setText(TEXT_ICON, defaultFontFamily + "-bold-" + defaultFontSizeMedium);
- setText(TEXT_MENU, defaultFontFamily + "--" + defaultFontSizeMedium);
-
- setText(TEXT_LABEL_MANDATORY, defaultFontFamily + "--" + defaultFontSizeSmall);
- setText(TEXT_LABEL_DISABLED, defaultFontFamily + "--" + defaultFontSizeSmall);
- setText(TEXT_LABEL, defaultFontFamily + "--" + defaultFontSizeSmall);
- }
-
- private void setColor(final String name, final Color defaultColor) {
- setColor(name, (AwtColor) defaultColor);
- }
-
- private void setColor(final String name, final AwtColor defaultColor) {
- if (getColor(name) == null) {
- final AwtColor color = new AwtColor(name, defaultColor);
- colors.put(name, color);
- }
- }
-
- private void setColor(final String name, final String defaultColor) {
- if (getColor(name) == null) {
- final AwtColor color = new AwtColor(name, defaultColor);
- colors.put(name, color);
- }
- }
-
- private void setText(final String name, final String defaultFont) {
- if (getText(name) == null) {
- final AwtText font = new AwtText(name, defaultFont);
- fonts.put(name, font);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtImageFactory.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtImageFactory.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtImageFactory.java
deleted file mode 100644
index 27d8c18..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtImageFactory.java
+++ /dev/null
@@ -1,83 +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.awt;
-
-import java.awt.Toolkit;
-import java.awt.image.FilteredImageSource;
-import java.awt.image.RGBImageFilter;
-
-import org.apache.isis.core.runtime.imageloader.TemplateImage;
-import org.apache.isis.core.runtime.imageloader.TemplateImageLoader;
-import org.apache.isis.viewer.dnd.drawing.Color;
-import org.apache.isis.viewer.dnd.drawing.Image;
-import org.apache.isis.viewer.dnd.drawing.ImageFactory;
-import org.apache.isis.viewer.dnd.view.base.AwtImage;
-
-public class AwtImageFactory extends ImageFactory {
-
- private static class Filter extends RGBImageFilter {
- @Override
- public int filterRGB(final int x, final int y, final int rgb) {
- return 0xFFFFFF - rgb;
- }
- }
-
- private final TemplateImageLoader loader;
-
- public AwtImageFactory(final TemplateImageLoader imageLoader) {
- loader = imageLoader;
- }
-
- /**
- * Load an image with the given name.
- */
- @Override
- public Image loadImage(final String path) {
- final TemplateImage template = templateImage(path);
- if (template == null) {
- return null;
- }
- return new AwtImage(template.getImage());
- }
-
- @Override
- protected Image loadImage(final String name, final int height, final Color tint) {
- final TemplateImage template = templateImage(name);
- if (template == null) {
- return null;
- }
- final java.awt.Image iconImage = template.getIcon(height);
- if (tint != null) {
- Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(iconImage.getSource(), new Filter()));
- }
- final Image icon = new AwtImage(iconImage);
- return icon;
- }
-
- // ////////////////////////////////////////////////////////////////////
- // Helpers
- // ////////////////////////////////////////////////////////////////////
-
- private TemplateImage templateImage(final String name) {
- final TemplateImage template = loader.getTemplateImage(name);
- return template;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtText.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtText.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtText.java
deleted file mode 100644
index e44d913..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtText.java
+++ /dev/null
@@ -1,242 +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.awt;
-
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Frame;
-import java.util.StringTokenizer;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.ColorsAndFonts;
-import org.apache.isis.viewer.dnd.drawing.Text;
-import org.apache.isis.viewer.dnd.util.Properties;
-
-public class AwtText implements Text {
- private static final String ASCENT_ADJUST = Properties.PROPERTY_BASE + "ascent-adjust";
- private static final String FONT_PROPERTY_STEM = Properties.PROPERTY_BASE + "font.";
- private static final Logger LOG = Logger.getLogger(AwtText.class);
- private static final String SPACING_PROPERTYSTEM = Properties.PROPERTY_BASE + "spacing.";
- private final boolean ascentAdjust;
- private Font font;
- private final Frame fontMetricsComponent = new Frame();
- private final int lineSpacing;
- private int maxCharWidth;
- private final FontMetrics metrics;
- private final String propertyName;
-
- protected AwtText(final String propertyName, final String defaultFont) {
- final IsisConfiguration cfg = IsisContext.getConfiguration();
- font = cfg.getFont(FONT_PROPERTY_STEM + propertyName, Font.decode(defaultFont));
- LOG.info("font " + propertyName + " loaded as " + font);
-
- this.propertyName = propertyName;
-
- if (font == null) {
- font = cfg.getFont(FONT_PROPERTY_STEM + ColorsAndFonts.TEXT_DEFAULT, new Font("SansSerif", Font.PLAIN, 12));
- }
-
- metrics = fontMetricsComponent.getFontMetrics(font);
-
- maxCharWidth = metrics.getMaxAdvance() + 1;
- if (maxCharWidth == 0) {
- maxCharWidth = (charWidth('X') + 3);
- }
-
- lineSpacing = cfg.getInteger(SPACING_PROPERTYSTEM + propertyName, 0);
-
- ascentAdjust = cfg.getBoolean(ASCENT_ADJUST, false);
-
- LOG.debug("font " + propertyName + " height=" + metrics.getHeight() + ", leading=" + metrics.getLeading() + ", ascent=" + metrics.getAscent() + ", descent=" + metrics.getDescent() + ", line spacing=" + lineSpacing);
- }
-
- @Override
- public int charWidth(final char c) {
- return metrics.charWidth(c);
- }
-
- @Override
- public int getAscent() {
- return metrics.getAscent() - (ascentAdjust ? metrics.getDescent() : 0);
- }
-
- /**
- * Returns the Font from the AWT used for drawing within the AWT.
- *
- * @see Font
- */
- public Font getAwtFont() {
- return font;
- }
-
- @Override
- public int getDescent() {
- return metrics.getDescent();
- }
-
- @Override
- public int getLineHeight() {
- return metrics.getHeight() + getLineSpacing();
- }
-
- @Override
- public int getLineSpacing() {
- return lineSpacing;
- }
-
- @Override
- public String getName() {
- return propertyName;
- }
-
- @Override
- public int getMidPoint() {
- return getAscent() / 2;
- }
-
- @Override
- public int getTextHeight() {
- return metrics.getHeight() - (ascentAdjust ? metrics.getDescent() : 0);
- }
-
- @Override
- public int stringHeight(final String text, final int maxWidth) {
- int noLines = 0;
- final StringTokenizer lines = new StringTokenizer(text, "\n\r");
- while (lines.hasMoreTokens()) {
- final String line = lines.nextToken();
- final StringTokenizer words = new StringTokenizer(line, " ");
- final StringBuffer l = new StringBuffer();
- int width = 0;
- while (words.hasMoreTokens()) {
- final String nextWord = words.nextToken();
- final int wordWidth = stringWidth(nextWord);
- width += wordWidth;
- if (width >= maxWidth) {
- noLines++;
- l.setLength(0);
- width = wordWidth;
- }
- l.append(nextWord);
- l.append(" ");
- width += stringWidth(" ");
- }
- noLines++;
- }
- return noLines * getLineHeight();
- }
-
- @Override
- public int stringWidth(final String text, final int maxWidth) {
- int width = 0;
- final StringTokenizer lines = new StringTokenizer(text, "\n\r");
- while (lines.hasMoreTokens()) {
- final String line = lines.nextToken();
- final StringTokenizer words = new StringTokenizer(line, " ");
- final StringBuffer l = new StringBuffer();
- int lineWidth = 0;
- while (words.hasMoreTokens()) {
- final String nextWord = words.nextToken();
- final int wordWidth = stringWidth(nextWord);
- lineWidth += wordWidth;
- if (lineWidth >= maxWidth) {
- return maxWidth;
- }
- if (lineWidth > width) {
- width = lineWidth;
- }
- l.append(nextWord);
- l.append(" ");
- lineWidth += stringWidth(" ");
- }
- }
- return width;
- }
-
- // DKH: 20060404... yes, this will grow over time, but only used client-side
- // RCM this is only a temporary solutions to help deal with titles, TODO
- // move the caching up to the
- // views/components that use this method
- private final java.util.Hashtable stringWidthByString = new java.util.Hashtable();
-
- // DKH 20060404: new implementation that caches
- @Override
- public int stringWidth(final String text) {
- int[] cachedStringWidth = (int[]) stringWidthByString.get(text);
- if (cachedStringWidth == null) {
- cachedStringWidth = new int[] { stringWidthInternal(text) };
- stringWidthByString.put(text, cachedStringWidth);
- }
- return cachedStringWidth[0];
- }
-
- // DKH 20060404: previously was stringWidth, now cached, see above.
- private int stringWidthInternal(final String text) {
- int stringWidth = metrics.stringWidth(text);
- if (stringWidth > text.length() * maxCharWidth) {
- LOG.debug("spurious width of string; calculating manually: " + stringWidth + " for " + this + ": " + text);
- /*
- * This fixes an intermittent bug in .NET where stringWidth()
- * returns a ridiculous number is returned for the width.
- *
- * TODO don't do this when running Java
- */
- stringWidth = 0;
- for (int i = 0; i < text.length(); i++) {
- int charWidth = charWidth(text.charAt(i));
- if (charWidth > maxCharWidth) {
- LOG.debug("spurious width of character; using max width: " + charWidth + " for " + text.charAt(i));
- charWidth = maxCharWidth;
- }
- stringWidth += charWidth;
- LOG.debug(i + " " + stringWidth);
- }
- }
- return stringWidth;
- }
-
- @Override
- public String toString() {
- return font.toString();
- }
-
- public static String defaultFontFamily() {
- final IsisConfiguration cfg = IsisContext.getConfiguration();
- return cfg.getString(FONT_PROPERTY_STEM + "family", "SansSerif");
- }
-
- public static int defaultFontSizeSmall() {
- final IsisConfiguration cfg = IsisContext.getConfiguration();
- return cfg.getInteger(FONT_PROPERTY_STEM + "size.small", 10);
- }
-
- public static int defaultFontSizeMedium() {
- final IsisConfiguration cfg = IsisContext.getConfiguration();
- return cfg.getInteger(FONT_PROPERTY_STEM + "size.medium", 11);
- }
-
- public static int defaultFontSizeLarge() {
- final IsisConfiguration cfg = IsisContext.getConfiguration();
- return cfg.getInteger(FONT_PROPERTY_STEM + "size.large", 12);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtToolkit.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtToolkit.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtToolkit.java
deleted file mode 100644
index 5d45d27..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/AwtToolkit.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.awt;
-
-import org.apache.isis.viewer.dnd.view.Toolkit;
-import org.apache.isis.viewer.dnd.viewer.DefaultContentFactory;
-import org.apache.isis.viewer.dnd.viewer.SkylarkViewFactory;
-import org.apache.isis.viewer.dnd.viewer.basic.LogoBackground;
-
-public class AwtToolkit extends Toolkit {
- @Override
- protected void init() {
- final XViewer v = new XViewer();
- final XFeedbackManager f = new XFeedbackManager(v);
- v.setFeedbackManager(f);
- feedbackManager = f;
- viewer = v;
- viewer.setBackground(new LogoBackground());
- contentFactory = new DefaultContentFactory();
- viewFactory = new SkylarkViewFactory();
- colorsAndFonts = new AwtColorsAndFonts();
-
- colorsAndFonts.init();
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugFrame.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugFrame.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugFrame.java
deleted file mode 100644
index 5e87138..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugFrame.java
+++ /dev/null
@@ -1,353 +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.awt;
-
-import java.awt.BorderLayout;
-import java.awt.Button;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Panel;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.TextArea;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.URL;
-import java.util.Vector;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.viewer.dnd.view.debug.DebugOutput;
-
-/**
- * A specialised frame for displaying the details of an object and its display
- * mechanisms.
- */
-public abstract class DebugFrame extends Frame {
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = Logger.getLogger(DebugFrame.class);
- private static Vector<Frame> frames = new Vector<Frame>();
- private int panel = 0;
-
- /**
- * Calls dispose on all the open debug frames
- *
- */
- public static void disposeAll() {
- final Frame[] f = new Frame[frames.size()];
-
- for (int i = 0; i < f.length; i++) {
- f[i] = frames.elementAt(i);
- }
-
- for (final Frame element : f) {
- element.dispose();
- }
- }
-
- private TextArea field;
- private TabPane tabPane;
-
- public DebugFrame() {
- frames.addElement(this);
-
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(final WindowEvent e) {
- closeDialog();
- }
- });
-
- final URL url = DebugFrame.class.getResource("/" + "images/debug-log.gif");
- if (url != null) {
- final Image image = Toolkit.getDefaultToolkit().getImage(url);
- if (image != null) {
- setIconImage(image);
- }
- }
-
- setLayout(new BorderLayout(7, 7));
- final Panel tabPane = createTabPane();
- add(tabPane);
- }
-
- private Panel createTabPane() {
- tabPane = new TabPane();
- tabPane.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(final MouseEvent e) {
- final Point point = e.getPoint();
- panel = tabPane.select(point);
-
- showDebugForPane();
- }
- });
-
- tabPane.setLayout(new BorderLayout(7, 7));
-
- final TextArea textArea = new TextArea("", 60, 110, TextArea.SCROLLBARS_BOTH);
- textArea.setForeground(Color.black);
- textArea.setEditable(false);
- // Font font = Isis.getConfiguration().getFont("isis.debug.font", new
- // Font("Monospaced", Font.PLAIN, 10));
- final Font font = new Font("Monospaced", Font.PLAIN, 11);
- textArea.setFont(font);
- tabPane.add("Center", textArea);
- field = textArea;
-
- final Panel buttons = new Panel();
- buttons.setLayout(new FlowLayout());
- tabPane.add(buttons, BorderLayout.SOUTH);
-
- // add buttons
- Button b = new java.awt.Button("Refresh");
- b.setFont(font);
-
- buttons.add(b);
- b.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- showDebugForPane();
- }
- });
-
- b = new java.awt.Button("Print...");
- b.setFont(font);
-
- buttons.add(b);
- b.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DebugOutput.print("Debug " + tabPane.getName(), field.getText());
- }
- });
-
- b = new java.awt.Button("Save...");
- b.setFont(font);
-
- buttons.add(b);
- b.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DebugOutput.saveToFile("Save details", "Debug " + tabPane.getName(), field.getText());
- }
- });
-
- b = new java.awt.Button("Copy");
- b.setFont(font);
-
- buttons.add(b);
- b.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- DebugOutput.saveToClipboard(field.getText());
- }
- });
-
- b = new java.awt.Button("Close");
- b.setFont(font);
-
- buttons.add(b);
- b.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(final ActionEvent e) {
- closeDialog();
- }
- });
-
- return tabPane;
- }
-
- @Override
- public Insets getInsets() {
- final Insets insets = super.getInsets();
- insets.left += 10;
- insets.right += 10;
- insets.top += 10;
- insets.bottom += 10;
- return insets;
- }
-
- private void closeDialog() {
- dialogClosing();
- // hide();
- dispose();
- }
-
- public void dialogClosing() {
- }
-
- @Override
- public void dispose() {
- LOG.debug("dispose...");
- tabPane.removeAll();
- frames.removeElement(this);
- super.dispose();
- LOG.debug("...disposed");
- }
-
- protected abstract DebuggableWithTitle[] getInfo();
-
- /**
- * show the frame at the specified coordinates
- */
- public void show(final int x, final int y) {
- /*
- * WARNING - When refresh button is pressed it is in the AWT thread; if
- * the repository is thread based then the wrong set of components will
- * be used giving strange results, particularly in the object persistor.
- */
- // TODO run in correct thread
- refresh();
-
- pack();
- limitBounds(x, y);
- setVisible(true);
- }
-
- private void refresh() {
- final DebuggableWithTitle[] infos = getInfo();
- final DebuggableWithTitle info = infos[panel];
- if (info != null) {
- setTitle(info.debugTitle());
- final DebugString str = new DebugString();
- info.debugData(str);
- field.setText(str.toString());
- field.setCaretPosition(0);
- }
- }
-
- public void showDebugForPane() {
- refresh();
- }
-
- private void limitBounds(final int xLimit, final int yLimit) {
- final Dimension screenSize = getToolkit().getScreenSize();
- final int maxWidth = screenSize.width - 50;
- final int maxHeight = screenSize.height - 50;
-
- int width = getSize().width;
- int height = getSize().height;
-
- int x = xLimit;
- if (x + width > maxWidth) {
- x = 0;
- if (x + width > maxWidth) {
- width = maxWidth;
- }
- }
-
- int y = yLimit;
- if (y + height > maxHeight) {
- y = 0;
- if (y + height > maxHeight) {
- height = maxHeight;
- }
- }
-
- setSize(width, height);
- setLocation(x, y);
- }
-
- private class TabPane extends Panel {
- private static final long serialVersionUID = 1L;
- private Rectangle[] tabs;
- private int panel = 0;
-
- public int select(final Point point) {
- for (int i = 0; i < tabs.length; i++) {
- if (tabs[i] != null && tabs[i].contains(point)) {
- panel = i;
- repaint();
- break;
- }
- }
- return panel;
- }
-
- @Override
- public Insets getInsets() {
- final Insets insets = super.getInsets();
- insets.left += 10;
- insets.right += 10;
- insets.top += 30;
- insets.bottom += 10;
- return insets;
- }
-
- @Override
- public void paint(final Graphics g) {
- final DebuggableWithTitle[] info = getInfo();
-
- if (info != null) {
- if (tabs == null) {
- tabs = new Rectangle[getInfo().length];
- }
- final Dimension size = getSize();
- g.setColor(Color.gray);
- g.drawRect(0, 20, size.width - 1, size.height - 21);
-
- FontMetrics fm;
- fm = g.getFontMetrics();
- int offset = 0;
- final int maxWidth = info.length == 0 ? size.width : size.width / info.length - 1;
- for (int i = 0; i < info.length; i++) {
- String title = info[i].debugTitle();
- title = title == null ? info[i].getClass().getName() : title;
- final int width = Math.min(maxWidth, fm.stringWidth(title) + 20);
-
- tabs[i] = new Rectangle(offset, 0, width, 20);
- g.setColor(Color.gray);
- g.drawRect(offset + 0, 0, width, 20);
- if (i == panel) {
- g.setColor(Color.white);
- g.fillRect(offset + 1, 1, width - 1, 20);
- // g.drawLine(offset + 1, 20, offset + width, 20);
- g.setColor(Color.black);
- } else {
- g.setColor(Color.lightGray);
- g.fillRect(offset + 1, 1, width - 1, 20 - 1);
- g.setColor(Color.gray);
- }
-
- g.drawString(title, offset + 9, 20 - 5);
-
- offset += width;
- }
- g.setColor(Color.white);
- g.fillRect(offset + 1, 1, size.width - offset, 20 - 1);
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugOptions.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugOptions.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugOptions.java
deleted file mode 100644
index 56df754..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/DebugOptions.java
+++ /dev/null
@@ -1,158 +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.awt;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.spec.ActionType;
-import org.apache.isis.core.runtime.sysout.SystemPrinter;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.viewer.dnd.drawing.Location;
-import org.apache.isis.viewer.dnd.view.MenuOptions;
-import org.apache.isis.viewer.dnd.view.Toolkit;
-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 DebugOptions implements MenuOptions {
- private final XViewer viewer;
-
- public DebugOptions(final XViewer viewer) {
- this.viewer = viewer;
- }
-
- @Override
- public void menuOptions(final UserActionSet options) {
- final String showExplorationMenu = "Always show exploration menu " + (viewer.showExplorationMenuByDefault ? "off" : "on");
- options.add(new UserActionAbstract(showExplorationMenu, ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- viewer.showExplorationMenuByDefault = !viewer.showExplorationMenuByDefault;
- view.markDamaged();
- }
- });
-
- final String repaint = "Show painting area " + (viewer.showRepaintArea ? "off" : "on");
- options.add(new UserActionAbstract(repaint, ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- viewer.showRepaintArea = !viewer.showRepaintArea;
- view.markDamaged();
- }
- });
-
- final String debug = "Debug graphics " + (Toolkit.debug ? "off" : "on");
- options.add(new UserActionAbstract(debug, ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- Toolkit.debug = !Toolkit.debug;
- view.markDamaged();
- }
- });
-
- final String action = viewer.isShowingMouseSpy() ? "Hide" : "Show";
- options.add(new UserActionAbstract(action + " mouse spy", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- viewer.setShowMouseSpy(!viewer.isShowingMouseSpy());
- }
- });
-
- // I've commented this out because in the new design we should close the
- // ExecutionContext
- // and then re-login.
- // options.add(new AbstractUserAction("Restart object loader/persistor",
- // UserAction.DEBUG) {
- // @Override
- // public void execute(final Workspace workspace, final View view, final
- // Location at) {
- // IsisContext.getObjectPersistor().reset();
- // }
- // });
-
- options.add(new UserActionAbstract("Diagnostics...", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final InfoDebugFrame f = new InfoDebugFrame();
- final DebuggableWithTitle info = new DebuggableWithTitle() {
-
- @Override
- public void debugData(final DebugBuilder debug) {
- final ByteArrayOutputStream out2 = new ByteArrayOutputStream();
- final PrintStream out = new PrintStream(out2);
- new SystemPrinter(out).printDiagnostics();
- debug.append(out2.toString());
- }
-
- @Override
- public String debugTitle() {
- return "Diagnostics";
- }
-
- };
- f.setInfo(info);
- f.show(at.getX() + 50, workspace.getBounds().getY() + 6);
- }
- });
-
- options.add(new UserActionAbstract("Debug system...", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final InfoDebugFrame f = new InfoDebugFrame();
- final DebuggableWithTitle[] contextInfo = IsisContext.debugSystem();
- f.setInfo(contextInfo);
- f.show(at.getX() + 50, workspace.getBounds().getY() + 6);
- }
- });
-
- options.add(new UserActionAbstract("Debug session...", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final InfoDebugFrame f = new InfoDebugFrame();
- final DebuggableWithTitle[] contextInfo = IsisContext.debugSession();
- f.setInfo(contextInfo);
- f.show(at.getX() + 50, workspace.getBounds().getY() + 6);
- }
- });
-
- options.add(new UserActionAbstract("Debug viewer...", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final InfoDebugFrame f = new InfoDebugFrame();
- f.setInfo(new DebuggableWithTitle[] { Toolkit.getViewFactory(), viewer.updateNotifier });
- f.show(at.getX() + 50, workspace.getBounds().getY() + 6);
- }
- });
-
- options.add(new UserActionAbstract("Debug overlay...", ActionType.DEBUG) {
- @Override
- public void execute(final Workspace workspace, final View view, final Location at) {
- final DebugFrame f = new OverlayDebugFrame(viewer);
- f.show(at.getX() + 50, workspace.getBounds().getY() + 6);
- }
- });
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/eb613703/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/InfoDebugFrame.java
----------------------------------------------------------------------
diff --git a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/InfoDebugFrame.java b/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/InfoDebugFrame.java
deleted file mode 100644
index bfc55fd..0000000
--- a/component/viewer/dnd/src/main/java/org/apache/isis/viewer/dnd/awt/InfoDebugFrame.java
+++ /dev/null
@@ -1,47 +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.awt;
-
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-
-public class InfoDebugFrame extends DebugFrame {
- private static final long serialVersionUID = 1L;
- private DebuggableWithTitle[] info;
-
- @Override
- protected DebuggableWithTitle[] getInfo() {
- return info;
- }
-
- /**
- * set the display strategy to use to display the information.
- */
- public void setInfo(final DebuggableWithTitle info) {
- this.info = new DebuggableWithTitle[] { info };
- }
-
- /**
- * set the display strategies to use to display the information.
- */
- public void setInfo(final DebuggableWithTitle[] info) {
- this.info = info;
- }
-
-}