Eclipse/プラグイン開発のTIPS集/RCPで終了するときに、終了してよいかをたずねるようにする
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
WorkbenchWindowAdvisorのサブクラスでpreWindowShellCloseを...
public boolean preWindowShellClose() {
// 複数上がってる場合はダイアログ出さないで閉じちゃう。
if (getWorkbench().getWorkbenchWindowCount() > 1) {
return true;
}
// the user has asked to close the last window, while ...
// workbench to close in due course - prompt the user ...
IPreferenceStore store = ApplicationsPlugin.getDefault()
.getPreferenceStore();
// この設定値("EXIT_PROMPT_ON_CLOSE_LAST_WINDOW")をみ...
boolean promptOnExit = store
.getBoolean("EXIT_PROMPT_ON_CLOSE_LAST_WINDOW");
// storeの設定がtrueだったら
if (promptOnExit) {
String message;
String productName = null;
IProduct product = Platform.getProduct();
if (product != null) {
productName = product.getName();
}
if (productName == null) {
message = "Exit application?";
} else {
message = NLS.bind("Exit {0}?", productName);
}
MessageDialogWithToggle dlg = MessageDialogWithTog...
.openOkCancelConfirm(getWindowConfigurer()...
.getShell(), "終了の確認", message...
false, null, null);
if (dlg.getReturnCode() != IDialogConstants.OK_ID) {
return false;
}
if (dlg.getToggleState()) {
// チェックボックスを付けた(はずした?)とき、f...
store.setValue("EXIT_PROMPT_ON_CLOSE_LAST_WIND...
ApplicationsPlugin.getDefault().savePluginPref...
}
}
return true;
}
*** 上で、チェックボックスなしのダイアログを使う [#t1258a...
上のやり方は、Eclipse3.1のIDEをパクリました。「常にプロン...
return MessageDialog.openConfirm(getWindowConfigurer().g...
.getShell(), "終了の確認", message);
ちなみに、http://www.eclipsecon.org/2005/tutorials.php に...
#ref(pic.png)
----
この記事は
#vote(おもしろかった[3],そうでもない[0])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
終了行:
// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。
WorkbenchWindowAdvisorのサブクラスでpreWindowShellCloseを...
public boolean preWindowShellClose() {
// 複数上がってる場合はダイアログ出さないで閉じちゃう。
if (getWorkbench().getWorkbenchWindowCount() > 1) {
return true;
}
// the user has asked to close the last window, while ...
// workbench to close in due course - prompt the user ...
IPreferenceStore store = ApplicationsPlugin.getDefault()
.getPreferenceStore();
// この設定値("EXIT_PROMPT_ON_CLOSE_LAST_WINDOW")をみ...
boolean promptOnExit = store
.getBoolean("EXIT_PROMPT_ON_CLOSE_LAST_WINDOW");
// storeの設定がtrueだったら
if (promptOnExit) {
String message;
String productName = null;
IProduct product = Platform.getProduct();
if (product != null) {
productName = product.getName();
}
if (productName == null) {
message = "Exit application?";
} else {
message = NLS.bind("Exit {0}?", productName);
}
MessageDialogWithToggle dlg = MessageDialogWithTog...
.openOkCancelConfirm(getWindowConfigurer()...
.getShell(), "終了の確認", message...
false, null, null);
if (dlg.getReturnCode() != IDialogConstants.OK_ID) {
return false;
}
if (dlg.getToggleState()) {
// チェックボックスを付けた(はずした?)とき、f...
store.setValue("EXIT_PROMPT_ON_CLOSE_LAST_WIND...
ApplicationsPlugin.getDefault().savePluginPref...
}
}
return true;
}
*** 上で、チェックボックスなしのダイアログを使う [#t1258a...
上のやり方は、Eclipse3.1のIDEをパクリました。「常にプロン...
return MessageDialog.openConfirm(getWindowConfigurer().g...
.getShell(), "終了の確認", message);
ちなみに、http://www.eclipsecon.org/2005/tutorials.php に...
#ref(pic.png)
----
この記事は
#vote(おもしろかった[3],そうでもない[0])
#comment
#topicpath
SIZE(10){現在のアクセス:&counter;}
ページ名: