欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

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

系統 1661 0

有的時候我們需要這樣的功能,記下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? == ? null )? return ;
????????
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文件。當然你也可以利用程序來實現。
運行一下看看吧,是不是記住了上次填入的內容.

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


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 好看的一级毛片 | 99精品大香线蕉线伊人久久久 | 亚瑟天堂久久一区二区影院 | 91精品久久| 欧美一区视频 | 成年免费大片黄在线观看岛国 | 国产精品久久久久久久久久久新郎 | 久久亚洲精品国产精品777777 | 久久无码人妻中文国产 | 国产福利视频一区美女 | 国产精品久久久久久久久久久久 | 精品国产一区二区国模嫣然 | 成人精品一区二区三区 | 久久久久久久av | 国产精品色综合 | 一级毛片在线看在线播放 | 久久成人18免费网站 | 偷拍自拍网站 | 天天干天天碰 | 91日本在线观看亚洲精品 | 五月婷婷综合网 | 亚洲在线资源 | av在线视| 天天操天天操天天操天天操 | 成人午夜免费福利视频 | 99久久精品免费看国产免费 | 国产免费www | 国产黑丝在线播放 | 天天操综合网 | 久久精品无码一区二区日韩av | 亚洲成人福利在线 | 欧美午夜一区 | 免费在线亚洲视频 | 国产精品福利视频免费观看 | 青草悠悠视频在线观看 | 91精品国产乱码久久久久久久久 | 三级国产短视频在线观看 | 九九九热在线精品免费全部 | 亚洲一区二区三区中文字幕 | 免费99视频 | 欧美日韩在线一区 |