changeset 20:d1f4edab3f34

Page Change
author Frank Benoit <benoit@tionex.de>
date Thu, 03 Apr 2008 00:33:43 +0200
parents 2b36428a5ce4
children cb935a3f6e90
files dwtx/jface/dialogs/DialogPage.d dwtx/jface/dialogs/IDialogPage.d dwtx/jface/dialogs/IPageChangeProvider.d dwtx/jface/dialogs/IPageChangedListener.d dwtx/jface/dialogs/IPageChangingListener.d dwtx/jface/dialogs/PageChangedEvent.d dwtx/jface/dialogs/PageChangingEvent.d
diffstat 7 files changed, 916 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/DialogPage.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,479 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.DialogPage;
+
+import dwtx.jface.dialogs.Dialog;
+import dwtx.jface.dialogs.IDialogConstants;
+import dwtx.jface.dialogs.IDialogPage;
+import dwtx.jface.dialogs.IMessageProvider;
+
+import dwt.DWT;
+import dwt.graphics.Font;
+import dwt.graphics.FontMetrics;
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.graphics.Point;
+import dwt.layout.GridData;
+import dwt.widgets.Button;
+import dwt.widgets.Control;
+import dwt.widgets.Shell;
+import dwtx.jface.resource.ImageDescriptor;
+import dwtx.jface.resource.JFaceResources;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Abstract base implementation of a dialog page. All dialog pages are
+ * subclasses of this one.
+ */
+public abstract class DialogPage : IDialogPage, IMessageProvider {
+    /**
+     * The control for this dialog page.
+     */
+    private Control control;
+
+    /**
+     * Optional title; <code>null</code> if none.
+     *
+     * @see #setTitle
+     */
+    private String title = null;
+
+    /**
+     * Optional description; <code>null</code> if none.
+     *
+     * @see #setDescription
+     */
+    private String description = null;
+
+    /**
+     * Cached image; <code>null</code> if none.
+     *
+     * @see #setImageDescriptor(ImageDescriptor)
+     */
+    private Image image = null;
+
+    /**
+     * Optional image; <code>null</code> if none.
+     *
+     * @see #setImageDescriptor(ImageDescriptor)
+     */
+    private ImageDescriptor imageDescriptor = null;
+
+    /**
+     * The current message; <code>null</code> if none.
+     */
+    private String message = null;
+
+    /**
+     * The current message type; default value <code>NONE</code>.
+     */
+    private int messageType = NONE;
+
+    /**
+     * The current error message; <code>null</code> if none.
+     */
+    private String errorMessage = null;
+
+    /**
+     * Font metrics to use for determining pixel sizes.
+     */
+    private FontMetrics fontMetrics;
+
+    /**
+     * Creates a new empty dialog page.
+     */
+    protected this() {
+        //No initial behaviour
+    }
+
+    /**
+     * Creates a new dialog page with the given title.
+     *
+     * @param title
+     *            the title of this dialog page, or <code>null</code> if none
+     */
+    protected this(String title) {
+        this.title = title;
+    }
+
+    /**
+     * Creates a new dialog page with the given title and image.
+     *
+     * @param title
+     *            the title of this dialog page, or <code>null</code> if none
+     * @param image
+     *            the image for this dialog page, or <code>null</code> if none
+     */
+    protected this(String title, ImageDescriptor image) {
+        this(title);
+        imageDescriptor = image;
+    }
+
+    /**
+     * Returns the number of pixels corresponding to the height of the given
+     * number of characters.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     *
+     * @param chars
+     *            the number of characters
+     * @return the number of pixels
+     */
+    protected int convertHeightInCharsToPixels(int chars) {
+        // test for failure to initialize for backward compatibility
+        if (fontMetrics is null) {
+            return 0;
+        }
+        return Dialog.convertHeightInCharsToPixels(fontMetrics, chars);
+    }
+
+    /**
+     * Returns the number of pixels corresponding to the given number of
+     * horizontal dialog units.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     *
+     * @param dlus
+     *            the number of horizontal dialog units
+     * @return the number of pixels
+     */
+    protected int convertHorizontalDLUsToPixels(int dlus) {
+        // test for failure to initialize for backward compatibility
+        if (fontMetrics is null) {
+            return 0;
+        }
+        return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus);
+    }
+
+    /**
+     * Returns the number of pixels corresponding to the given number of
+     * vertical dialog units.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     *
+     * @param dlus
+     *            the number of vertical dialog units
+     * @return the number of pixels
+     */
+    protected int convertVerticalDLUsToPixels(int dlus) {
+        // test for failure to initialize for backward compatibility
+        if (fontMetrics is null) {
+            return 0;
+        }
+        return Dialog.convertVerticalDLUsToPixels(fontMetrics, dlus);
+    }
+
+    /**
+     * Returns the number of pixels corresponding to the width of the given
+     * number of characters.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     *
+     * @param chars
+     *            the number of characters
+     * @return the number of pixels
+     */
+    protected int convertWidthInCharsToPixels(int chars) {
+        // test for failure to initialize for backward compatibility
+        if (fontMetrics is null) {
+            return 0;
+        }
+        return Dialog.convertWidthInCharsToPixels(fontMetrics, chars);
+    }
+
+    /**
+     * The <code>DialogPage</code> implementation of an
+     * <code>IDialogPage</code> method does nothing. Subclasses may extend.
+     */
+    public void dispose() {
+        // deallocate DWT resources
+        if (image !is null) {
+            image.dispose();
+            image = null;
+        }
+    }
+
+    /**
+     * Returns the top level control for this dialog page.
+     *
+     * @return the top level control
+     */
+    public Control getControl() {
+        return control;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * Returns the symbolic font name used by dialog pages.
+     *
+     * @return the symbolic font name
+     */
+    protected String getDialogFontName() {
+        return JFaceResources.DIALOG_FONT;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    /**
+     * Returns the default font to use for this dialog page.
+     *
+     * @return the font
+     */
+    protected Font getFont() {
+        return JFaceResources.getFontRegistry().get(getDialogFontName());
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public Image getImage() {
+        if (image is null) {
+            if (imageDescriptor !is null) {
+                image = imageDescriptor.createImage();
+            }
+        }
+        return image;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public String getMessage() {
+        return message;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IMessageProvider.
+     */
+    public int getMessageType() {
+        return messageType;
+    }
+
+    /**
+     * Returns this dialog page's shell. Convenience method for
+     * <code>getControl().getShell()</code>. This method may only be called
+     * after the page's control has been created.
+     *
+     * @return the shell
+     */
+    public Shell getShell() {
+        return getControl().getShell();
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * Returns the tool tip text for the widget with the given id.
+     * <p>
+     * The default implementation of this framework method does nothing and
+     * returns <code>null</code>. Subclasses may override.
+     * </p>
+     *
+     * @param widgetId
+     *            the id of the widget for which hover help is requested
+     * @return the tool tip text, or <code>null</code> if none
+     * @deprecated
+     */
+    protected final String getToolTipText(int widgetId) {
+        // return nothing by default
+        return null;
+    }
+
+    /**
+     * Initializes the computation of horizontal and vertical dialog units based
+     * on the size of current font.
+     * <p>
+     * This method must be called before any of the dialog unit based conversion
+     * methods are called.
+     * </p>
+     *
+     * @param testControl
+     *            a control from which to obtain the current font
+     */
+    protected void initializeDialogUnits(Control testControl) {
+        // Compute and store a font metric
+        GC gc = new GC(testControl);
+        gc.setFont(JFaceResources.getDialogFont());
+        fontMetrics = gc.getFontMetrics();
+        gc.dispose();
+    }
+
+    /**
+     * Sets the <code>GridData</code> on the specified button to be one that
+     * is spaced for the current dialog page units. The method
+     * <code>initializeDialogUnits</code> must be called once before calling
+     * this method for the first time.
+     *
+     * @param button
+     *            the button to set the <code>GridData</code>
+     * @return the <code>GridData</code> set on the specified button
+     */
+    protected GridData setButtonLayoutData(Button button) {
+        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+        int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+        Point minSize = button.computeSize(DWT.DEFAULT, DWT.DEFAULT, true);
+        data.widthHint = Math.max(widthHint, minSize.x);
+        button.setLayoutData(data);
+        return data;
+    }
+
+    /**
+     * Tests whether this page's UI content has already been created.
+     *
+     * @return <code>true</code> if the control has been created, and
+     *         <code>false</code> if not
+     */
+    protected bool isControlCreated() {
+        return control !is null;
+    }
+
+    /**
+     * This default implementation of an <code>IDialogPage</code> method does
+     * nothing. Subclasses should override to take some action in response to a
+     * help request.
+     */
+    public void performHelp() {
+        //No default help
+    }
+
+    /**
+     * Set the control for the receiver.
+     * @param newControl
+     */
+    protected void setControl(Control newControl) {
+        control = newControl;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    /**
+     * Sets or clears the error message for this page.
+     *
+     * @param newMessage
+     *            the message, or <code>null</code> to clear the error message
+     */
+    public void setErrorMessage(String newMessage) {
+        errorMessage = newMessage;
+    }
+
+    /*
+     * (non-Javadoc) Method declared on IDialogPage.
+     */
+    public void setImageDescriptor(ImageDescriptor desc) {
+        imageDescriptor = desc;
+        if (image !is null) {
+            image.dispose();
+            image = null;
+        }
+    }
+
+    /**
+     * Sets or clears the message for this page.
+     * <p>
+     * This is a shortcut for <code>setMessage(newMesasge, NONE)</code>
+     * </p>
+     *
+     * @param newMessage
+     *            the message, or <code>null</code> to clear the message
+     */
+    public void setMessage(String newMessage) {
+        setMessage(newMessage, NONE);
+    }
+
+    /**
+     * Sets the message for this page with an indication of what type of message
+     * it is.
+     * <p>
+     * The valid message types are one of <code>NONE</code>,
+     * <code>INFORMATION</code>,<code>WARNING</code>, or
+     * <code>ERROR</code>.
+     * </p>
+     * <p>
+     * Note that for backward compatibility, a message of type
+     * <code>ERROR</code> is different than an error message (set using
+     * <code>setErrorMessage</code>). An error message overrides the current
+     * message until the error message is cleared. This method replaces the
+     * current message and does not affect the error message.
+     * </p>
+     *
+     * @param newMessage
+     *            the message, or <code>null</code> to clear the message
+     * @param newType
+     *            the message type
+     * @since 2.0
+     */
+    public void setMessage(String newMessage, int newType) {
+        message = newMessage;
+        messageType = newType;
+    }
+
+    /**
+     * The <code>DialogPage</code> implementation of this
+     * <code>IDialogPage</code> method remembers the title in an internal
+     * state variable. Subclasses may extend.
+     */
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    /**
+     * The <code>DialogPage</code> implementation of this
+     * <code>IDialogPage</code> method sets the control to the given
+     * visibility state. Subclasses may extend.
+     */
+    public void setVisible(bool visible) {
+        control.setVisible(visible);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/IDialogPage.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.IDialogPage;
+
+
+import dwt.graphics.Image;
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwtx.jface.resource.ImageDescriptor;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Interface for a page in a multi-page dialog.
+ */
+public interface IDialogPage {
+    /**
+     * Creates the top level control for this dialog
+     * page under the given parent composite.
+     * <p>
+     * Implementors are responsible for ensuring that
+     * the created control can be accessed via <code>getControl</code>
+     * </p>
+     *
+     * @param parent the parent composite
+     */
+    public void createControl(Composite parent);
+
+    /**
+     * Disposes the DWT resources allocated by this
+     * dialog page.
+     */
+    public void dispose();
+
+    /**
+     * Returns the top level control for this dialog page.
+     * <p>
+     * May return <code>null</code> if the control
+     * has not been created yet.
+     * </p>
+     *
+     * @return the top level control or <code>null</code>
+     */
+    public Control getControl();
+
+    /**
+     * Returns this dialog page's description text.
+     *
+     * @return the description text for this dialog page,
+     *  or <code>null</code> if none
+     */
+    public String getDescription();
+
+    /**
+     * Returns the current error message for this dialog page.
+     * May be <code>null</code> to indicate no error message.
+     * <p>
+     * An error message should describe some error state,
+     * as opposed to a message which may simply provide instruction
+     * or information to the user.
+     * </p>
+     *
+     * @return the error message, or <code>null</code> if none
+     */
+    public String getErrorMessage();
+
+    /**
+     * Returns this dialog page's image.
+     *
+     * @return the image for this dialog page, or <code>null</code>
+     *  if none
+     */
+    public Image getImage();
+
+    /**
+     * Returns the current message for this wizard page.
+     * <p>
+     * A message provides instruction or information to the
+     * user, as opposed to an error message which should
+     * describe some error state.
+     * </p>
+     *
+     * @return the message, or <code>null</code> if none
+     */
+    public String getMessage();
+
+    /**
+     * Returns this dialog page's title.
+     *
+     * @return the title of this dialog page,
+     *  or <code>null</code> if none
+     */
+    public String getTitle();
+
+    /**
+     * Notifies that help has been requested for this dialog page.
+     */
+    public void performHelp();
+
+    /**
+     * Sets this dialog page's description text.
+     *
+     * @param description the description text for this dialog
+     *  page, or <code>null</code> if none
+     */
+    public void setDescription(String description);
+
+    /**
+     * Sets this dialog page's image.
+     *
+     * @param image the image for this dialog page,
+     *  or <code>null</code> if none
+     */
+    public void setImageDescriptor(ImageDescriptor image);
+
+    /**
+     * Set this dialog page's title.
+     *
+     * @param title the title of this dialog page,
+     *  or <code>null</code> if none
+     */
+    public void setTitle(String title);
+
+    /**
+     * Sets the visibility of this dialog page.
+     *
+     * @param visible <code>true</code> to make this page visible,
+     *  and <code>false</code> to hide it
+     */
+    public void setVisible(bool visible);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/IPageChangeProvider.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.IPageChangeProvider;
+
+import dwtx.jface.dialogs.IPageChangedListener;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Minimal interface to a page change provider. Used for dialogs which can
+ * switch between multiple pages.
+ *
+ * @since 3.1
+ */
+public interface IPageChangeProvider {
+    /**
+     * Returns the currently selected page in the dialog.
+     *
+     * @return the selected page in the dialog or <code>null</code> if none is
+     *         selected. The type may be domain specific. In
+     *         the JFace provided dialogs this will be an instance of
+     *         <code>IDialogPage</code>.
+     */
+    Object getSelectedPage();
+
+    /**
+     * Adds a listener for page changes in this page change provider. Has no
+     * effect if an identical listener is already registered.
+     *
+     * @param listener
+     *            a page changed listener
+     */
+    void addPageChangedListener(IPageChangedListener listener);
+
+    /**
+     * Removes the given page change listener from this page change provider.
+     * Has no effect if an identical listener is not registered.
+     *
+     * @param listener
+     *            a page changed listener
+     */
+    void removePageChangedListener(IPageChangedListener listener);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/IPageChangedListener.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.IPageChangedListener;
+
+import dwtx.jface.dialogs.PageChangedEvent;
+
+import dwt.dwthelper.utils;
+
+/**
+ * A listener which is notified when the current page of the multi-page dialog
+ * is changed.
+ *
+ * @see IPageChangeProvider
+ * @see PageChangedEvent
+ *
+ * @since 3.1
+ */
+public interface IPageChangedListener {
+    /**
+     * Notifies that the selected page has changed.
+     *
+     * @param event
+     *            event object describing the change
+     */
+    public void pageChanged(PageChangedEvent event);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/IPageChangingListener.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Chris Gross (schtoo@schtoo.com) - initial API and implementation for bug 16179
+ *     IBM Corporation - revisions to initial contribution
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.IPageChangingListener;
+
+import dwtx.jface.dialogs.PageChangingEvent;
+
+import dwt.dwthelper.utils;
+
+/**
+ * A listener which is notified when the current page of a multi-page dialog is
+ * changing. Use this listener to perform long-running work that should only be
+ * executed once, when the page is in the process of changing, rather then
+ * during validation of page controls.
+ *
+ * @see PageChangingEvent
+ * @since 3.3
+ */
+public interface IPageChangingListener {
+
+    /**
+     * Handle the an <code>IDialogPage</code> changing.
+     *
+     * The <code>doit</code> field of the <code>PageChangingEvent</code>
+     * must be set to false to prevent the page from changing.
+     *
+     * @param event
+     *            event object describing the change
+     */
+    public void handlePageChanging(PageChangingEvent event);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/PageChangedEvent.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.PageChangedEvent;
+
+import dwtx.jface.dialogs.IPageChangeProvider;
+
+import dwtx.core.runtime.Assert;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Event object describing a page selection change. The source of these events
+ * is a page change provider.
+ *
+ * @see IPageChangeProvider
+ * @see IPageChangedListener
+ *
+ * @since 3.1
+ */
+public class PageChangedEvent : EventObject {
+
+    /**
+     * Generated serial version UID for this class.
+     *
+     * @since 3.1
+     */
+    private static const long serialVersionUID = 3835149545519723574L;
+
+    /**
+     * The selected page.
+     */
+    protected Object selectedPage;
+
+    /**
+     * Creates a new event for the given source and selected page.
+     *
+     * @param source
+     *            the page change provider
+     * @param selectedPage
+     *            the selected page. In the JFace provided dialogs this
+     *            will be an <code>IDialogPage</code>.
+     */
+    public this(IPageChangeProvider source,
+            Object selectedPage) {
+        super( cast(Object) source);
+        Assert.isNotNull(selectedPage);
+        this.selectedPage = selectedPage;
+    }
+
+    /**
+     * Returns the selected page.
+     *
+     * @return the selected page. In dialogs implemented by JFace,
+     *      this will be an <code>IDialogPage</code>.
+     */
+    public Object getSelectedPage() {
+        return selectedPage;
+    }
+
+    /**
+     * Returns the page change provider that is the source of this event.
+     *
+     * @return the originating page change provider
+     */
+    public IPageChangeProvider getPageChangeProvider() {
+        return cast(IPageChangeProvider) getSource();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/PageChangingEvent.d	Thu Apr 03 00:33:43 2008 +0200
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Chris Gross (schtoo@schtoo.com) - initial API and implementation for bug 16179
+ *     IBM Corporation - revisions to initial contribution
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwtx.jface.dialogs.PageChangingEvent;
+
+
+import dwtx.core.runtime.Assert;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Event object describing an <code>IDialogPage</code> in the midst of changing.
+ *
+ * @see IPageChangingListener
+ * @since 3.3
+ */
+public class PageChangingEvent : EventObject {
+
+
+    private static const long serialVersionUID = 1L;
+
+    private Object currentPage;
+
+    private Object targetPage;
+
+    /**
+     * Public field that dictates if the page change will successfully change.
+     *
+     * Set this field to <code>false</code> to prevent the page from changing.
+     *
+     * Default value is <code>true</code>.
+     */
+    public bool doit = true;
+
+    /**
+     * Creates a new event for the given source, selected (current) page and
+     * direction.
+     *
+     * @param source
+     *            the page changing provider (the source of this event)
+     * @param currentPage
+     *            the current page. In the JFace provided dialogs this will be
+     *            an <code>IDialogPage</code>.
+     * @param targetPage
+     *            the target page. In the JFace provided dialogs this will be an
+     *            <code>IDialogPage</code>.
+     */
+    public this(Object source, Object currentPage, Object targetPage) {
+        super(source);
+        Assert.isNotNull(currentPage);
+        Assert.isNotNull(targetPage);
+        this.currentPage = currentPage;
+        this.targetPage = targetPage;
+    }
+
+    /**
+     * Returns the current page from which the page change originates.
+     *
+     * @return the current page. In dialogs implemented by JFace,
+     *      this will be an <code>IDialogPage</code>.
+     */
+    public Object getCurrentPage() {
+        return currentPage;
+    }
+
+    /**
+     * Returns the target page to change to.
+     *
+     * @return the target page. In dialogs implemented by JFace,
+     *      this will be an <code>IDialogPage</code>.
+     */
+    public Object getTargetPage() {
+        return targetPage;
+    }
+
+}