<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    DANCE WITH JAVA

    開發出高質量的系統

    常用鏈接

    統計

    積分與排名

    好友之家

    最新評論

    給自定義Dialog加入保留對話框值的功能

    有的時候我們需要這樣的功能,記下Dialog中的值,當再次打開這個Dialog的時候,還原這些值。這就需要把這些Dialog的值保存起來。Dialog的IDialogSettings類提供了這個功能。下邊是使用方法:
    在上例"自定義Dialog"的代碼上加入三個函數:
    public void saveState(){
            
    if (text.getText() == null || text.getText().equals("")){
                
    return ;
            }

            IDialogSettings topSettings 
    = getTopSettings();
            IDialogSettings settings 
    =  topSettings.getSection("TestDialog");
            
    if(settings == null)settings = topSettings.addNewSection("TestDialog");
            settings.put(
    "value", text.getText());
            
    try{
                topSettings.save(
    "content/system.xml");
            }
    catch(IOException e){
                System.out.println(e.getMessage());
            }

        }

        
    public void restoreState(){
            IDialogSettings topSettings 
    = getTopSettings();
            IDialogSettings settings 
    =  topSettings.getSection("TestDialog");
            
    if(settings == nullreturn;
            
    if (text.getText() == null || text.getText().equals("")){
                text.setText(settings.get(
    "value"));
            }

        }

        
    public IDialogSettings getTopSettings(){
            IDialogSettings topSettings 
    = new DialogSettings("system");
            
    try{
                topSettings.load(
    "content/system.xml");
            }
    catch(IOException e){
                System.out.println(e.getMessage());
            }

            
    return topSettings;
        }

    然后在覆寫的buttonPressed函數中調用save
    protected void buttonPressed(int button){
            saveState();
        }
    在createDialogArea函數中加入取出數據
    protected Control createDialogArea(Composite parent) {
            Composite container 
    = (Composite) super.createDialogArea(parent);
            container.setLayout(
    new RowLayout());
            text 
    = new Text(container, SWT.BORDER);
            text.setLayoutData(
    new RowData(100,-1));
            
    //加入這一句
            if (text.getText() == null || text.getText().equals("")){
                restoreState();
            }

            
    return container;
        }
    最后,記得建立需要的文件,在當前workspace下建立文件夾content,然后在文件夾下建立system.xml文件。當然你也可以利用程序來實現。
    運行一下看看吧,是不是記住了上次填入的內容.
    source下載:http://www.tkk7.com/Files/dreamstone/jface-record.rar

    posted on 2007-08-09 18:13 dreamstone 閱讀(2541) 評論(1)  編輯  收藏 所屬分類: SWT和插件開發

    評論

    # re: 給自定義Dialog加入保留對話框值的功能 2007-10-25 06:34 QuandeLiu

    謝謝你,寫的非常好 .

    簡單易懂,又很實用  回復  更多評論   

    主站蜘蛛池模板: 一级特级aaaa毛片免费观看| 亚洲AV无码资源在线观看| 精品免费久久久久国产一区| 国产精品国产午夜免费福利看| 亚洲国产系列一区二区三区| 国产成人精品免费视频大全麻豆| 亚洲人成影院在线| 99re免费视频| 亚洲国产精品xo在线观看| 中文字幕无码不卡免费视频| 狠狠色伊人亚洲综合网站色| 免费看片A级毛片免费看| 麻豆亚洲AV成人无码久久精品 | 色欲国产麻豆一精品一AV一免费| 亚洲国产精品国自产拍AV| 91香蕉国产线观看免费全集| 亚洲天堂中文字幕在线观看| 成人免费视频观看无遮挡| 国产精品亚洲综合网站| 国产精品亚洲高清一区二区 | 两个人的视频www免费| 亚洲av无码国产精品色午夜字幕 | 亚洲小视频在线观看| 18禁美女黄网站色大片免费观看| 亚洲激情视频图片| 又粗又大又长又爽免费视频| 国产免费区在线观看十分钟| 91亚洲一区二区在线观看不卡| 成人免费无码大片a毛片| 高潮毛片无遮挡高清免费| 亚洲av无码国产精品色午夜字幕| 国产在线观看免费观看不卡| 曰批全过程免费视频观看免费软件| 国产成人精品日本亚洲| 最近免费中文字幕大全视频| 中国性猛交xxxxx免费看| 亚洲国产成人久久精品app| 亚洲精品成人区在线观看| 亚洲日本在线免费观看| 麻豆91免费视频| 亚洲人成777在线播放|