changeset 78:4ac9946b9fb5

Forms work with first test
author Frank Benoit <benoit@tionex.de>
date Sat, 24 May 2008 08:33:56 +0200
parents 26c6c9dfd13c
children 0953c252a764
files dwtx/jface/fieldassist/FieldDecorationRegistry.d dwtx/jface/resource/ColorRegistry.d dwtx/jface/resource/JFaceResources.d dwtx/ui/forms/FormColors.d dwtx/ui/forms/widgets/SharedScrolledComposite.d dwtx/ui/internal/forms/MessageManager.d dwtx/ui/internal/forms/widgets/FormTextModel.d dwtx/ui/internal/forms/widgets/FormUtil.d
diffstat 8 files changed, 86 insertions(+), 81 deletions(-) [+]
line wrap: on
line diff
--- a/dwtx/jface/fieldassist/FieldDecorationRegistry.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/jface/fieldassist/FieldDecorationRegistry.d	Sat May 24 08:33:56 2008 +0200
@@ -105,7 +105,7 @@
     /*
      * Declare images and decorations immediately.
      */
-    static this() {
+    private static void static_this(FieldDecorationRegistry reg) {
         ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
 
         // Define the images used in the standard decorations.
@@ -128,32 +128,32 @@
 
         // Define the standard decorations. Some do not have standard
         // descriptions. Use null in these cases.
-        getDefault()
+        reg
                 .registerFieldDecoration(
                         DEC_CONTENT_PROPOSAL,
                         JFaceResources
                                 .getString("FieldDecorationRegistry.contentAssistMessage"), //$NON-NLS-1$
                         IMG_DEC_FIELD_CONTENT_PROPOSAL, imageRegistry);
 
-        getDefault().registerFieldDecoration(
+        reg.registerFieldDecoration(
                 DEC_ERROR,
                 JFaceResources
                         .getString("FieldDecorationRegistry.errorMessage"), //$NON-NLS-1$
                 IMG_DEC_FIELD_ERROR, imageRegistry);
 
-        getDefault().registerFieldDecoration(
+        reg.registerFieldDecoration(
                 DEC_ERROR_QUICKFIX,
                 JFaceResources
                         .getString("FieldDecorationRegistry.errorQuickFixMessage"), //$NON-NLS-1$
                 IMG_DEC_FIELD_ERROR_QUICKFIX, imageRegistry);
 
-        getDefault().registerFieldDecoration(DEC_WARNING, null,
+        reg.registerFieldDecoration(DEC_WARNING, null,
                 IMG_DEC_FIELD_WARNING, imageRegistry);
 
-        getDefault().registerFieldDecoration(DEC_INFORMATION, null,
+        reg.registerFieldDecoration(DEC_INFORMATION, null,
                 IMG_DEC_FIELD_INFO, imageRegistry);
 
-        getDefault()
+        reg
                 .registerFieldDecoration(
                         DEC_REQUIRED,
                         JFaceResources
@@ -232,7 +232,12 @@
      */
     public static FieldDecorationRegistry getDefault() {
         if (defaultInstance is null) {
-            defaultInstance = new FieldDecorationRegistry();
+            synchronized(FieldDecorationRegistry.classinfo){
+                if (defaultInstance is null) {
+                    defaultInstance = new FieldDecorationRegistry();
+                    static_this(defaultInstance);
+                }
+            }
         }
         return defaultInstance;
     }
--- a/dwtx/jface/resource/ColorRegistry.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/jface/resource/ColorRegistry.d	Sat May 24 08:33:56 2008 +0200
@@ -182,14 +182,14 @@
     public Color get(String symbolicName) {
 
         Assert.isNotNull(symbolicName);
-        auto result1 = stringToColor.get(symbolicName);
+        auto result1 = ( stringToColor.containsKey(symbolicName) ? stringToColor.get(symbolicName) : null );
         if (result1 !is null) {
             return result1;
         }
 
         Color color = null;
 
-        auto result = stringToRGB.get(symbolicName);
+        auto result = ( stringToRGB.containsKey(symbolicName) ? stringToRGB.get(symbolicName) : null );
         if (result is null) {
             return null;
         }
--- a/dwtx/jface/resource/JFaceResources.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/jface/resource/JFaceResources.d	Sat May 24 08:33:56 2008 +0200
@@ -37,6 +37,7 @@
 import dwt.dwthelper.Runnable;
 import dwt.dwthelper.ResourceBundle;
 import tango.text.convert.Format;
+import tango.util.log.Trace;
 /**
  * Utility methods to access JFace-specific resources.
  * <p>
@@ -227,6 +228,7 @@
                     mgr = new DeviceResourceManager(d);
                     reg = mgr;
                     toQuery_ = d;
+                    Trace.formatln( " {} {}", d, reg );
                     registries.add(d, reg);
                 }
                 /*
--- a/dwtx/ui/forms/FormColors.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/ui/forms/FormColors.d	Sat May 24 08:33:56 2008 +0200
@@ -258,7 +258,7 @@
      */
     public Color createColor(String key, int r, int g, int b) {
         Color c = new Color(display, r, g, b);
-        Color prevC = cast(Color) colorRegistry.get(key);
+        Color prevC = cast(Color) (colorRegistry.containsKey(key) ? colorRegistry.get(key) : null );
         if (prevC !is null)
             prevC.dispose();
         colorRegistry.add(key, c);
--- a/dwtx/ui/forms/widgets/SharedScrolledComposite.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/ui/forms/widgets/SharedScrolledComposite.d	Sat May 24 08:33:56 2008 +0200
@@ -230,17 +230,18 @@
         setMinSize(area.width, c.getSize().y);
     }
 
+    private void handleScheduleReflow(bool flushCache) {
+        if (!isDisposed())
+            reflow(flushCache);
+        reflowPending = false;
+    }
     private void scheduleReflow(bool flushCache) {
         if (delayedReflow) {
             if (reflowPending) {
                 updateSizeWhilePending();
                 return;
             }
-            getDisplay().asyncExec( dgRunnable( (bool flushCache) {
-                if (!isDisposed())
-                    reflow(flushCache);
-                reflowPending = false;
-            }, flushCache));
+            getDisplay().asyncExec( dgRunnable( &handleScheduleReflow, flushCache));
             reflowPending = true;
         } else
             reflow(flushCache);
--- a/dwtx/ui/internal/forms/MessageManager.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/ui/internal/forms/MessageManager.d	Sat May 24 08:33:56 2008 +0200
@@ -100,21 +100,36 @@
         return standardInformation_;
     }
 
-    private static String[] SINGLE_MESSAGE_SUMMARY_KEYS;
-    private static String[] MULTIPLE_MESSAGE_SUMMARY_KEYS;
+    private static String[] SINGLE_MESSAGE_SUMMARY_KEYS_;
+    private static String[] SINGLE_MESSAGE_SUMMARY_KEYS(){
+        if( SINGLE_MESSAGE_SUMMARY_KEYS_ is null ){
+            synchronized(MessageManager.classinfo){
+                if( SINGLE_MESSAGE_SUMMARY_KEYS_ is null ){
+                    SINGLE_MESSAGE_SUMMARY_KEYS_ = [
+                        Messages.MessageManager_sMessageSummary,
+                        Messages.MessageManager_sMessageSummary,
+                        Messages.MessageManager_sWarningSummary,
+                        Messages.MessageManager_sErrorSummary ];
+                }
+            }
+        }
+        return SINGLE_MESSAGE_SUMMARY_KEYS_;
+    }
 
-    static this(){
-        SINGLE_MESSAGE_SUMMARY_KEYS = [
-            Messages.MessageManager_sMessageSummary,
-            Messages.MessageManager_sMessageSummary,
-            Messages.MessageManager_sWarningSummary,
-            Messages.MessageManager_sErrorSummary ];
-
-        MULTIPLE_MESSAGE_SUMMARY_KEYS = [
-            Messages.MessageManager_pMessageSummary,
-            Messages.MessageManager_pMessageSummary,
-            Messages.MessageManager_pWarningSummary,
-            Messages.MessageManager_pErrorSummary ];
+    private static String[] MULTIPLE_MESSAGE_SUMMARY_KEYS_;
+    private static String[] MULTIPLE_MESSAGE_SUMMARY_KEYS(){
+        if( MULTIPLE_MESSAGE_SUMMARY_KEYS_ is null ){
+            synchronized(MessageManager.classinfo){
+                if( MULTIPLE_MESSAGE_SUMMARY_KEYS_ is null ){
+                    MULTIPLE_MESSAGE_SUMMARY_KEYS_ = [
+                        Messages.MessageManager_pMessageSummary,
+                        Messages.MessageManager_pMessageSummary,
+                        Messages.MessageManager_pWarningSummary,
+                        Messages.MessageManager_pErrorSummary ];
+                }
+            }
+        }
+        return MULTIPLE_MESSAGE_SUMMARY_KEYS_;
     }
 
     static class Message : IMessage {
--- a/dwtx/ui/internal/forms/widgets/FormTextModel.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/ui/internal/forms/widgets/FormTextModel.d	Sat May 24 08:33:56 2008 +0200
@@ -19,45 +19,14 @@
 import dwtx.ui.internal.forms.widgets.ControlSegment;
 import dwtx.ui.internal.forms.widgets.ImageSegment;
 import dwtx.ui.internal.forms.widgets.ObjectSegment;
+import dwtx.ui.internal.forms.widgets.SWTUtil;
 
 import dwt.DWT;
 import dwtx.ui.forms.HyperlinkSettings;
 
 import dwt.dwthelper.utils;
 import dwt.dwthelper.InputStream;
-pragma(msg,"FIXME temp type "~__FILE__);
-public class FormTextModel {
-    public static const String BOLD_FONT_ID = "f.____bold"; //$NON-NLS-1$
-    public this() ;
-    public Paragraph[] getParagraphs() ;
-    public String getAccessibleText() ;
-    public void parseTaggedText(String taggedText, bool expandURLs) ;
-    public void parseInputStream(InputStream is_, bool expandURLs) ;
-    public void parseRegularText(String regularText, bool convertURLs) ;
-    public HyperlinkSettings getHyperlinkSettings() ;
-    public void setHyperlinkSettings(HyperlinkSettings settings) ;
-    IFocusSelectable[] getFocusSelectableSegments() ;
-    public IHyperlinkSegment getHyperlink(int index) ;
-    public IHyperlinkSegment findHyperlinkAt(int x, int y) ;
-    public int getHyperlinkCount() ;
-    public int indexOf(IHyperlinkSegment link) ;
-    public ParagraphSegment findSegmentAt(int x, int y) ;
-    public void clearCache(String fontId) ;
-    public IFocusSelectable getSelectedSegment() ;
-    public int getSelectedSegmentIndex() ;
-    public bool linkExists(IHyperlinkSegment link) ;
-    public bool traverseFocusSelectableObjects(bool next) ;
-    public IFocusSelectable getNextFocusSegment(bool next) ;
-    public bool restoreSavedLink() ;
-    public void selectLink(IHyperlinkSegment link) ;
-    public void select(IFocusSelectable selectable) ;
-    public bool hasFocusSegments() ;
-    public void dispose() ;
-    public bool isWhitespaceNormalized() ;
-    public void setWhitespaceNormalized(bool whitespaceNormalized) ;
-}
 
-/++
 static import tango.text.xml.Document;
 import tango.util.collection.ArraySeq;
 public class FormTextModel {
@@ -113,7 +82,13 @@
         }
         return sbuf.toString();
     }
-
+    public void parseTaggedText(String taggedText, bool expandURLs) {
+        implMissing(__FILE__,__LINE__);
+    }
+    public void parseInputStream(InputStream is_, bool expandURLs) {
+        implMissing(__FILE__,__LINE__);
+    }
+/++
     /*
      * @see ITextModel#parse(String)
      */
@@ -366,12 +341,12 @@
                 segment.setVerticalAlignment(ImageSegment.BOTTOM);
         }
     }
-
+++/
     private void appendText(String value, StringBuffer buf, int[] spaceCounter) {
         if (!whitespaceNormalized)
             buf.append(value);
         else {
-            for (int j = 0; j < value.length(); j++) {
+            for (int j = 0; j < value.length; j++) {
                 char c = value.charAt(j);
                 if (c is ' ' || c is '\t') {
                     // space
@@ -401,7 +376,7 @@
         appendText(text, buf, spaceCounter);
         return buf.toString();
     }
-
+/++
     private String getSingleNodeText(Node node) {
         return getNormalizedText(node.getNodeValue());
     }
@@ -545,7 +520,7 @@
         p.parseRegularText(text, expandURLs, wrapAllowed, getHyperlinkSettings(), fontId,
                 colorId);
     }
-
+++/
     public void parseRegularText(String regularText, bool convertURLs) {
         reset();
 
@@ -558,7 +533,7 @@
         paragraphs.append(p);
         int pstart = 0;
 
-        for (int i = 0; i < regularText.length(); i++) {
+        for (int i = 0; i < regularText.length; i++) {
             char c = regularText.charAt(i);
             if (p is null) {
                 p = new Paragraph(true);
@@ -581,7 +556,7 @@
 
     public HyperlinkSettings getHyperlinkSettings() {
         // #132723 cannot have null settings
-        if (hyperlinkSettingsisnull)
+        if (hyperlinkSettings is null)
             hyperlinkSettings = new HyperlinkSettings(SWTUtil.getStandardDisplay());
         return hyperlinkSettings;
     }
@@ -608,7 +583,7 @@
             ParagraphSegment[] segments = p.getSegments();
             for (int j = 0; j < segments.length; j++) {
                 if (null !is cast(IFocusSelectable)segments[j] )
-                    result ~= segments[j];
+                    result ~= cast(IFocusSelectable)segments[j];
             }
         }
         selectableSegments = result;
@@ -681,7 +656,7 @@
     }
 
     public bool linkExists(IHyperlinkSegment link) {
-        if (selectableSegmentsisnull)
+        if (selectableSegments is null)
             return false;
         for (int i=0; i<selectableSegments.length; i++) {
             if (selectableSegments[i] is link)
@@ -743,7 +718,7 @@
         if (selectables is null)
             return;
         for (int i = 0; i < selectables.length; i++) {
-            if (selectables[i].equals(selectable)) {
+            if ((cast(Object)selectables[i]).opEquals(cast(Object)selectable)) {
                 selectedSegmentIndex = i;
                 break;
             }
@@ -779,4 +754,3 @@
         this.whitespaceNormalized = whitespaceNormalized;
     }
 }
-++/
\ No newline at end of file
--- a/dwtx/ui/internal/forms/widgets/FormUtil.d	Sat May 24 06:59:31 2008 +0200
+++ b/dwtx/ui/internal/forms/widgets/FormUtil.d	Sat May 24 08:33:56 2008 +0200
@@ -47,25 +47,32 @@
     static class BreakIterator{
 
         public static const int DONE = 0;
-
+        char[] text;
+        static BreakIterator inst;
         public static BreakIterator getWordInstance() {
-            // TODO Auto-generated method stub
-            return null;
+            if( inst is null ){
+                inst = new BreakIterator;
+            }
+            return inst;
         }
+        uint last = 0;
 
         public void setText(String text) {
-            // TODO Auto-generated method stub
-
+            this.text = text;
+            last = 0;
         }
-
         public int first() {
             // TODO Auto-generated method stub
-            return 0;
+            return text.length > 0 ? 1 : 0;
         }
 
         public int next() {
             // TODO Auto-generated method stub
-            return 0;
+            last++;
+            if( last >= text.length ){
+                return DONE;
+            }
+            return last;
         }
 
     }
@@ -430,6 +437,7 @@
             case DWT.PAGE_DOWN:
                 FormUtil.scrollPage(scomp, false);
                 break;
+            default:
             }
         }
     }