📄 messageboxwindow.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: MessageBoxWindow.java
package org.gudy.azureus2.ui.swt;
import com.aelitis.azureus.ui.common.RememberedDecisionsManager;
import com.aelitis.azureus.ui.swt.imageloader.ImageLoader;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.util.AESemaphore;
import org.gudy.azureus2.ui.swt.components.BufferedLabel;
// Referenced classes of package org.gudy.azureus2.ui.swt:
// Utils
public class MessageBoxWindow
{
public static final String ICON_ERROR = "error";
public static final String ICON_WARNING = "warning";
public static final String ICON_INFO = "info";
private Shell shell;
private AESemaphore result_sem;
private volatile int result;
private volatile boolean result_set;
public static int open(String id, int options, int remember_map, boolean default_is_yes, Display display, String icon, String title, String message)
{
int remembered = RememberedDecisionsManager.getRememberedDecision(id, remember_map);
if (remembered > 0)
return remembered;
else
return (new MessageBoxWindow(id, options, remember_map != 0, default_is_yes, display, icon, title, message)).getResult();
}
protected MessageBoxWindow(final String id, int options, boolean remember_decision, boolean default_is_yes, Display display, String icon, String title,
String message)
{
result_sem = new AESemaphore("MessageBoxWindow");
shell = new Shell(display, 0x10060);
shell.setText(title);
Utils.setShellIcon(shell);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
shell.setLayout(layout);
Label label = new Label(shell, 0);
ImageLoader.getInstance().setLabelImage(label, icon);
BufferedLabel msg_label = new BufferedLabel(shell, 64);
msg_label.setText(message);
GridData gridData = new GridData(768);
gridData.horizontalSpan = 2;
msg_label.setLayoutData(gridData);
final Button checkBox;
if (remember_decision)
{
checkBox = new Button(shell, 32);
checkBox.setSelection(false);
checkBox.setText(MessageText.getString("MessageBoxWindow.rememberdecision"));
gridData = new GridData(768);
gridData.horizontalSpan = 3;
checkBox.setLayoutData(gridData);
} else
{
checkBox = null;
Label pad = new Label(shell, 0);
gridData = new GridData(768);
gridData.horizontalSpan = 3;
pad.setLayoutData(gridData);
}
Label labelSeparator = new Label(shell, 258);
gridData = new GridData(768);
gridData.horizontalSpan = 3;
labelSeparator.setLayoutData(gridData);
label = new Label(shell, 0);
final int yes_option = options & 0x60;
Button bYes = new Button(shell, 8);
bYes.setText(MessageText.getString(yes_option != 64 ? "Button.ok" : "Button.yes"));
gridData = new GridData(896);
gridData.grabExcessHorizontalSpace = true;
gridData.widthHint = 70;
bYes.setLayoutData(gridData);
bYes.addListener(13, new Listener() {
final String val$id;
final int val$yes_option;
final Button val$checkBox;
final MessageBoxWindow this$0;
public void handleEvent(Event e)
{
setResult(id, yes_option, checkBox != null ? checkBox.getSelection() : false);
}
{
this$0 = MessageBoxWindow.this;
id = s;
yes_option = i;
checkBox = button;
super();
}
});
final int no_option = options & 0x180;
Button bNo = new Button(shell, 8);
bNo.setText(MessageText.getString(no_option != 128 ? "Button.cancel" : "Button.no"));
gridData = new GridData(128);
gridData.grabExcessHorizontalSpace = false;
gridData.widthHint = 70;
bNo.setLayoutData(gridData);
bNo.addListener(13, new Listener() {
final String val$id;
final int val$no_option;
final Button val$checkBox;
final MessageBoxWindow this$0;
public void handleEvent(Event e)
{
setResult(id, no_option, checkBox != null ? checkBox.getSelection() : false);
}
{
this$0 = MessageBoxWindow.this;
id = s;
no_option = i;
checkBox = button;
super();
}
});
shell.setDefaultButton(default_is_yes ? bYes : bNo);
shell.addListener(31, new Listener() {
final String val$id;
final MessageBoxWindow this$0;
public void handleEvent(Event e)
{
if (e.character == '\033')
setResult(id, 0, false);
}
{
this$0 = MessageBoxWindow.this;
id = s;
super();
}
});
shell.addListener(21, new Listener() {
final String val$id;
final MessageBoxWindow this$0;
public void handleEvent(Event arg0)
{
setResult(id, 0, false);
}
{
this$0 = MessageBoxWindow.this;
id = s;
super();
}
});
shell.pack();
Utils.centreWindow(shell);
shell.open();
(default_is_yes ? bYes : bNo).setFocus();
do
{
if (shell.isDisposed())
break;
if (!display.readAndDispatch())
display.sleep();
} while (true);
}
protected void setResult(String id, int option, boolean remember)
{
if (!result_set)
{
result = option;
result_set = true;
if (remember)
RememberedDecisionsManager.setRemembered(id, result);
result_sem.release();
close();
}
}
protected void close()
{
if (!shell.isDisposed())
shell.dispose();
}
protected int getResult()
{
result_sem.reserve();
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -