dwt-win Path bug with tango 0.99.7

yidabu yidabu.spam at gmail.com
Wed Jul 30 20:24:52 PDT 2008



runtime exception:

Exception occurred
Exception of type tango.core.Exception.IOException in (0): unexpected '\' character in path: C:\Documents and Settings\Owner\My Documents

ddbg captured:

(tango.core.Exception.IOException
 "<console> :: The handle is invalid.") at KERNEL32.dll (0x7c812a5b) thread(2276)
->us
#0 ?? () from KERNEL32.dll
->


Example code (based on ShowFieldPrefs.d):


import dwtx.jface.preference.DirectoryFieldEditor;
import dwtx.jface.preference.FileFieldEditor;
import dwtx.jface.preference.FieldEditorPreferencePage;
import dwtx.jface.preference.PathEditor;
import dwtx.jface.preference.StringFieldEditor;
import dwtx.jface.preference.IPreferenceStore;
import dwtx.jface.preference.PreferenceManager;
import dwtx.jface.preference.PreferencePage;
import dwtx.jface.preference.PreferenceNode;
import dwtx.jface.preference.PreferenceStore;
import dwtx.jface.preference.PreferenceDialog;
import dwtx.jface.resource.ImageDescriptor;

import dwt.widgets.Display;
import dwt.widgets.Composite;
import dwt.widgets.Label;
import dwt.widgets.Button;
import dwt.widgets.Text;
import dwt.widgets.Control;
import dwt.events.SelectionAdapter;
import dwt.events.SelectionEvent;
import dwt.layout.RowLayout;
import dwt.layout.GridLayout;
import dwt.layout.GridData;
import dwt.DWT;
import dwt.dwthelper.utils;

import tango.io.File;
import Path = tango.io.Path;

version(JIVE) import jive.stacktrace;

const char[] FILENAME = "showfieldprefs";

/**
 * This class demonstrates field editors
 */
public class FieldEditorPageOne : FieldEditorPreferencePage {
    public this() {
        // Use the "flat" layout
        super(FLAT);
    }

    /**
     * Creates the field editors
     */
    protected void createFieldEditors() {

        // Add a directory field
        DirectoryFieldEditor dfe = new DirectoryFieldEditor("myDirectory",
            "Directory:", getFieldEditorParent());
        addField(dfe);

        // Add a file field
        FileFieldEditor ffe = new FileFieldEditor("myFile", "File:",
            getFieldEditorParent());
        addField(ffe);

        // Add a path field
        PathEditor pe = new PathEditor("myPath", "Path:", "Choose a Path",
            getFieldEditorParent());
        addField(pe);
    }
}





/**
 * This class demonstrates JFace preferences and field editors
 */
public class ShowFieldPrefs {
    /**
    * Runs the application
    */
    public void run() {
//         Display display = new Display();

        // Create the preference manager
        PreferenceManager mgr = new PreferenceManager();

        // Create the nodes
        PreferenceNode one = new PreferenceNode("one", "One", null,
            FieldEditorPageOne.classinfo.name );


        // Add the nodes
        mgr.addToRoot(one);

        // Create the preferences dialog
        PreferenceDialog dlg = new PreferenceDialog(null, mgr);

        // Set the preference store
        PreferenceStore ps = new PreferenceStore(FILENAME);
        try {
            ps.load();
        } catch (IOException e) {
            // Ignore
        }
        dlg.setPreferenceStore(ps);

        // Open the dialog
        dlg.open();

        try {
            // Save the preferences
            ps.save();
        } catch (IOException e) {
            ExceptionPrintStackTrace(e);
        }
//         display.dispose();
    }

    /**
     * The application entry point
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        (new ShowFieldPrefs()).run();
    }
}


void main(){
    if( !Path.exists( FILENAME ) ){
        scope prefs = new File( FILENAME );
        version(linux){
            prefs.write( import("jface.showfieldprefs.properties.linux" ));
        }
        version(Windows){
            prefs.write( import("jface.showfieldprefs.properties.win" ));
        }
    }
    ShowFieldPrefs.main( null );
}










-- 
yidabu <yidabu.spam at gmail.com>
http://www.dsource.org/projects/dwin

D 语言-中文(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/




More information about the Digitalmars-d-dwt mailing list