diff dwtx/jface/resource/JFaceResources.d @ 9:6c14e54dfc11

completed /jface/resource/
author Frank Benoit <benoit@tionex.de>
date Sat, 29 Mar 2008 02:25:12 +0100
parents a3ff22a98bef
children 6886832e1ed8
line wrap: on
line diff
--- a/dwtx/jface/resource/JFaceResources.d	Sat Mar 29 01:25:27 2008 +0100
+++ b/dwtx/jface/resource/JFaceResources.d	Sat Mar 29 02:25:12 2008 +0100
@@ -15,26 +15,13 @@
 import dwtx.jface.resource.FontRegistry;
 import dwtx.jface.resource.ImageRegistry;
 import dwtx.jface.resource.ResourceManager;
-
-import dwt.graphics.Font;
-import dwt.widgets.Display;
+import dwtx.jface.resource.ColorRegistry;
+import dwtx.jface.resource.FontDescriptor;
+import dwtx.jface.resource.DeviceResourceManager;
+import dwtx.jface.resource.ImageDescriptor;
 
-import dwt.dwthelper.utils;
-public class JFaceResources {
-    public static const String DEFAULT_FONT = "dwtx.jface.defaultfont"; //$NON-NLS-1$
-    public static final String DIALOG_FONT = "dwtx.jface.dialogfont"; //$NON-NLS-1$
-    public static FontRegistry getFontRegistry() ;
-    public static String getString(String key) ;
-    public static Font getDialogFont() ;
-    public static ImageRegistry getImageRegistry() ;
-    public static ResourceManager getResources(Display toQuery) ;
-}
-/++
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import tango.util.collection.HashMap;
+import tango.util.collection.model.Map;
 
 import dwt.graphics.Font;
 import dwt.graphics.Image;
@@ -45,6 +32,10 @@
 import dwtx.jface.preference.PreferenceDialog;
 import dwtx.jface.wizard.Wizard;
 
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.ResourceBundle;
+import tango.text.convert.Format;
 /**
  * Utility methods to access JFace-specific resources.
  * <p>
@@ -66,25 +57,30 @@
     /**
      * The path to the icons in the resources.
      */
-    private final static String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
+    private const static String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
 
     /**
      * Map of Display onto DeviceResourceManager. Holds all the resources for
      * the associated display.
      */
-    private static final Map registries = new HashMap();
+    private static Map!(Display,ResourceManager) registries;
+    static this(){
+        registries = new HashMap!(Display,ResourceManager);
+    }
 
     /**
      * The symbolic font name for the banner font (value
      * <code>"dwtx.jface.bannerfont"</code>).
      */
-    public static final String BANNER_FONT = "dwtx.jface.bannerfont"; //$NON-NLS-1$
+    public static const String BANNER_FONT = "dwtx.jface.bannerfont"; //$NON-NLS-1$
 
     /**
      * The JFace resource bundle; eagerly initialized.
      */
-    private static final ResourceBundle bundle = ResourceBundle
-            .getBundle("dwtx.jface.messages"); //$NON-NLS-1$
+    private static /+final+/ ResourceBundle bundle;
+    static this(){
+        bundle = ResourceBundle.getBundle("dwtx.jface.messages"); //$NON-NLS-1$
+    }
 
     /**
      * The JFace color registry; <code>null</code> until lazily initialized or
@@ -96,13 +92,13 @@
      * The symbolic font name for the standard font (value
      * <code>"dwtx.jface.defaultfont"</code>).
      */
-    public static final String DEFAULT_FONT = "dwtx.jface.defaultfont"; //$NON-NLS-1$
+    public static const String DEFAULT_FONT = "dwtx.jface.defaultfont"; //$NON-NLS-1$
 
     /**
      * The symbolic font name for the dialog font (value
      * <code>"dwtx.jface.dialogfont"</code>).
      */
-    public static final String DIALOG_FONT = "dwtx.jface.dialogfont"; //$NON-NLS-1$
+    public static const String DIALOG_FONT = "dwtx.jface.dialogfont"; //$NON-NLS-1$
 
     /**
      * The JFace font registry; <code>null</code> until lazily initialized or
@@ -114,7 +110,7 @@
      * The symbolic font name for the header font (value
      * <code>"dwtx.jface.headerfont"</code>).
      */
-    public static final String HEADER_FONT = "dwtx.jface.headerfont"; //$NON-NLS-1$
+    public static const String HEADER_FONT = "dwtx.jface.headerfont"; //$NON-NLS-1$
 
     /**
      * The JFace image registry; <code>null</code> until lazily initialized.
@@ -125,7 +121,7 @@
      * The symbolic font name for the text font (value
      * <code>"dwtx.jface.textfont"</code>).
      */
-    public static final String TEXT_FONT = "dwtx.jface.textfont"; //$NON-NLS-1$
+    public static const String TEXT_FONT = "dwtx.jface.textfont"; //$NON-NLS-1$
 
     /**
      * The symbolic font name for the viewer font (value
@@ -133,7 +129,7 @@
      *
      * @deprecated This font is not in use
      */
-    public static final String VIEWER_FONT = "dwtx.jface.viewerfont"; //$NON-NLS-1$
+    public static const String VIEWER_FONT = "dwtx.jface.viewerfont"; //$NON-NLS-1$
 
     /**
      * The symbolic font name for the window font (value
@@ -141,7 +137,7 @@
      *
      * @deprecated This font is not in use
      */
-    public static final String WINDOW_FONT = "dwtx.jface.windowfont"; //$NON-NLS-1$
+    public static const String WINDOW_FONT = "dwtx.jface.windowfont"; //$NON-NLS-1$
 
     /**
      * Returns the formatted message for the given key in JFace's resource
@@ -154,7 +150,7 @@
      * @return the string
      */
     public static String format(String key, Object[] args) {
-        return MessageFormat.format(getString(key), args);
+        return Format(getString(key), args);
     }
 
     /**
@@ -208,14 +204,17 @@
      *            display to query
      * @return the global resource manager for the given display
      */
-    public static ResourceManager getResources(final Display toQuery) {
-        ResourceManager reg = (ResourceManager) registries.get(toQuery);
+    public static ResourceManager getResources(Display toQuery) {
+        ResourceManager reg = cast(ResourceManager) registries.get(toQuery);
 
         if (reg is null) {
-            final DeviceResourceManager mgr = new DeviceResourceManager(toQuery);
-            reg = mgr;
-            registries.put(toQuery, reg);
-            toQuery.disposeExec(new Runnable() {
+            toQuery.disposeExec(new class Runnable {
+                DeviceResourceManager mgr;
+                this(){
+                    mgr = new DeviceResourceManager(toQuery);
+                    reg = mgr;
+                    registries.add(toQuery, reg);
+                }
                 /*
                  * (non-Javadoc)
                  *
@@ -223,7 +222,7 @@
                  */
                 public void run() {
                     mgr.dispose();
-                    registries.remove(toQuery);
+                    registries.removeKey(toQuery);
                 }
             });
         }
@@ -425,33 +424,33 @@
     private static void initializeDefaultImages() {
 
         Object bundle = null;
-        try {
-//FIXME
+// DWT-Note: deactivated
+//         try {
 //          bundle = JFaceActivator.getBundle();
-        } catch (NoClassDefFoundError exception) {
-            // Test to see if OSGI is present
-        }
-        declareImage(bundle, Wizard.DEFAULT_IMAGE, ICONS_PATH + "page.gif", //$NON-NLS-1$
-                Wizard.class, "images/page.gif"); //$NON-NLS-1$
+//         } catch (NoClassDefFoundError exception) {
+//             // Test to see if OSGI is present
+//         }
+        declareImage(bundle, Wizard.DEFAULT_IMAGE, ICONS_PATH ~ "page.gif", //$NON-NLS-1$
+                Wizard.classinfo, "images/page.gif"); //$NON-NLS-1$
 
         // register default images for dialogs
         declareImage(bundle, Dialog.DLG_IMG_MESSAGE_INFO, ICONS_PATH
-                + "message_info.gif", Dialog.class, "images/message_info.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+                ~ "message_info.gif", Dialog.classinfo, "images/message_info.gif"); //$NON-NLS-1$ //$NON-NLS-2$
         declareImage(bundle, Dialog.DLG_IMG_MESSAGE_WARNING, ICONS_PATH
-                + "message_warning.gif", Dialog.class, //$NON-NLS-1$
+                ~ "message_warning.gif", Dialog.classinfo, //$NON-NLS-1$
                 "images/message_warning.gif"); //$NON-NLS-1$
         declareImage(bundle, Dialog.DLG_IMG_MESSAGE_ERROR, ICONS_PATH
-                + "message_error.gif", Dialog.class, "images/message_error.gif");//$NON-NLS-1$ //$NON-NLS-2$
+                ~ "message_error.gif", Dialog.classinfo, "images/message_error.gif");//$NON-NLS-1$ //$NON-NLS-2$
         declareImage(bundle, Dialog.DLG_IMG_HELP, ICONS_PATH
-                + "help.gif", Dialog.class, "images/help.gif");//$NON-NLS-1$ //$NON-NLS-2$
+                ~ "help.gif", Dialog.classinfo, "images/help.gif");//$NON-NLS-1$ //$NON-NLS-2$
         declareImage(
                 bundle,
                 TitleAreaDialog.DLG_IMG_TITLE_BANNER,
-                ICONS_PATH + "title_banner.png", TitleAreaDialog.class, "images/title_banner.gif");//$NON-NLS-1$ //$NON-NLS-2$
+                ICONS_PATH ~ "title_banner.png", TitleAreaDialog.classinfo, "images/title_banner.gif");//$NON-NLS-1$ //$NON-NLS-2$
         declareImage(
                 bundle,
                 PreferenceDialog.PREF_DLG_TITLE_IMG,
-                ICONS_PATH + "pref_dialog_title.gif", PreferenceDialog.class, "images/pref_dialog_title.gif");//$NON-NLS-1$ //$NON-NLS-2$
+                ICONS_PATH ~ "pref_dialog_title.gif", PreferenceDialog.classinfo, "images/pref_dialog_title.gif");//$NON-NLS-1$ //$NON-NLS-2$
 
     }
 
@@ -476,7 +475,7 @@
      *
      */
     private static final void declareImage(Object bundle, String key,
-            String path, Class fallback, String fallbackPath) {
+            String path, ClassInfo fallback, String fallbackPath) {
 
 
         ImageDescriptor descriptor = null;
@@ -522,10 +521,10 @@
      * @return a list of corresponding string values
      */
     public static String[] getStrings(String[] keys) {
-        Assert.isNotNull(keys);
-        int length = keys.length;
-        String[] result = new String[length];
-        for (int i = 0; i < length; i++) {
+        Assert.isTrue(keys.length > 0 );
+        int length_ = keys.length;
+        String[] result = new String[](length_);
+        for (int i = 0; i < length_; i++) {
             result[i] = getString(keys[i]);
         }
         return result;
@@ -591,8 +590,7 @@
     /*
      * (non-Javadoc) Declare a private constructor to block instantiation.
      */
-    private JFaceResources() {
+    private this() {
         // no-op
     }
 }
-++/
\ No newline at end of file