changeset 12:8ec40848221b

TitleAreaDialog
author Frank Benoit <benoit@tionex.de>
date Mon, 31 Mar 2008 01:07:26 +0200
parents 11bd25f93332
children 6886832e1ed8
files dwtx/jface/dialogs/IMessageProvider.d dwtx/jface/dialogs/TitleAreaDialog.d
diffstat 2 files changed, 86 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwtx/jface/dialogs/IMessageProvider.d	Mon Mar 31 01:07:26 2008 +0200
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.IMessageProvider;
+
+import dwt.dwthelper.utils;
+
+/**
+ * Minimal interface to a message provider. Used for dialog pages which can
+ * provide a message with an icon.
+ *
+ * @since 2.0
+ */
+public interface IMessageProvider {
+    /**
+     * Constant for a regular message (value 0).
+     * <p>
+     * Typically this indicates that the message should be shown without an
+     * icon.
+     * </p>
+     */
+    public const static int NONE = 0;
+
+    /**
+     * Constant for an info message (value 1).
+     */
+    public const static int INFORMATION = 1;
+
+    /**
+     * Constant for a warning message (value 2).
+     */
+    public const static int WARNING = 2;
+
+    /**
+     * Constant for an error message (value 3).
+     */
+    public const static int ERROR = 3;
+
+    /**
+     * Returns the current message for this message provider.
+     * <p>
+     * A message provides instruction or information to the user.
+     * </p>
+     *
+     * @return the message, or <code>null</code> if none
+     */
+    public String getMessage();
+
+    /**
+     * Returns a value indicating if the message is a an information message, a
+     * warning message, or an error message.
+     * <p>
+     * Returns one of <code>NONE</code>,<code>INFORMATION</code>,
+     * <code>WARNING</code>, or <code>ERROR</code>.
+     * </p>
+     *
+     * @return the message type
+     */
+    public int getMessageType();
+}
--- a/dwtx/jface/dialogs/TitleAreaDialog.d	Mon Mar 31 01:03:07 2008 +0200
+++ b/dwtx/jface/dialogs/TitleAreaDialog.d	Mon Mar 31 01:07:26 2008 +0200
@@ -16,14 +16,10 @@
  *******************************************************************************/
 module dwtx.jface.dialogs.TitleAreaDialog;
 
-import dwt.dwthelper.utils;
-pragma( msg, "FIXME dwtx.jface.dialogs.TitleAreaDialog" );
-class TitleAreaDialog{
-    public static const String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$
-}
+import dwtx.jface.dialogs.IDialogConstants;
+import dwtx.jface.dialogs.TrayDialog;
+import dwtx.jface.dialogs.IMessageProvider;
 
-
-/++
 import dwt.DWT;
 import dwt.events.DisposeEvent;
 import dwt.events.DisposeListener;
@@ -45,23 +41,25 @@
 import dwtx.jface.resource.JFaceColors;
 import dwtx.jface.resource.JFaceResources;
 
+import dwt.dwthelper.utils;
+
 /**
  * A dialog that has a title area for displaying a title and an image as well as
  * a common area for displaying a description, a message, or an error message.
  * <p>
  * This dialog class may be subclassed.
  */
-public class TitleAreaDialog extends TrayDialog {
+public class TitleAreaDialog : TrayDialog {
     /**
      * Image registry key for error message image.
      */
-    public static final String DLG_IMG_TITLE_ERROR = DLG_IMG_MESSAGE_ERROR;
+    public static const String DLG_IMG_TITLE_ERROR = DLG_IMG_MESSAGE_ERROR;
 
     /**
      * Image registry key for banner image (value
      * <code>"dialog_title_banner_image"</code>).
      */
-    public static final String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$
+    public static const String DLG_IMG_TITLE_BANNER = "dialog_title_banner_image";//$NON-NLS-1$
 
     /**
      * Message type constant used to display an info icon with the message.
@@ -69,7 +67,7 @@
      * @since 2.0
      * @deprecated
      */
-    public final static String INFO_MESSAGE = "INFO_MESSAGE"; //$NON-NLS-1$
+    public const static String INFO_MESSAGE = "INFO_MESSAGE"; //$NON-NLS-1$
 
     /**
      * Message type constant used to display a warning icon with the message.
@@ -77,16 +75,16 @@
      * @since 2.0
      * @deprecated
      */
-    public final static String WARNING_MESSAGE = "WARNING_MESSAGE"; //$NON-NLS-1$
+    public const static String WARNING_MESSAGE = "WARNING_MESSAGE"; //$NON-NLS-1$
 
     // Space between an image and a label
-    private static final int H_GAP_IMAGE = 5;
+    private static const int H_GAP_IMAGE = 5;
 
     // Minimum dialog width (in dialog units)
-    private static final int MIN_DIALOG_WIDTH = 350;
+    private static const int MIN_DIALOG_WIDTH = 350;
 
     // Minimum dialog height (in dialog units)
-    private static final int MIN_DIALOG_HEIGHT = 150;
+    private static const int MIN_DIALOG_HEIGHT = 150;
 
     private Label titleLabel;
 
@@ -126,7 +124,7 @@
      * @param parentShell
      *            the parent DWT shell
      */
-    public TitleAreaDialog(Shell parentShell) {
+    public this(Shell parentShell) {
         super(parentShell);
     }
 
@@ -200,7 +198,7 @@
     private Control createTitleArea(Composite parent) {
 
         // add a dispose listener
-        parent.addDisposeListener(new DisposeListener() {
+        parent.addDisposeListener(new class DisposeListener {
             public void widgetDisposed(DisposeEvent e) {
                 if (titleAreaColor !is null) {
                     titleAreaColor.dispose();
@@ -395,7 +393,7 @@
         } else {
             // Add in a space for layout purposes but do not
             // change the instance variable
-            String displayedErrorMessage = " " + errorMessage; //$NON-NLS-1$
+            String displayedErrorMessage = " " ~ errorMessage; //$NON-NLS-1$
             updateMessage(displayedErrorMessage);
             if (!showingError) {
                 // we were not previously showing an error
@@ -536,7 +534,7 @@
             message = "";//$NON-NLS-1$
         // Message string to be shown - if there is an image then add in
         // a space to the message for layout purposes
-        String shownMessage = (newImage is null) ? message : " " + message; //$NON-NLS-1$
+        String shownMessage = (newImage is null) ? message : " " ~ message; //$NON-NLS-1$
         messageImage = newImage;
         if (!showingError) {
             // we are not showing an error
@@ -635,4 +633,3 @@
         workArea.setLayoutData(childData);
     }
 }
-++/
\ No newline at end of file