📄 alerts.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: Alerts.java
package org.gudy.azureus2.ui.swt;
import com.aelitis.azureus.core.util.GeneralUtils;
import com.aelitis.azureus.ui.*;
import java.util.*;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.ui.swt.mainwindow.SWTThread;
import org.gudy.azureus2.ui.swt.shells.MessageSlideShell;
// Referenced classes of package org.gudy.azureus2.ui.swt:
// Utils
public class Alerts
{
public static interface AlertListener
{
public abstract boolean allowPopup(Object aobj[], int i);
}
private static List alert_queue = new ArrayList();
private static AEMonitor alert_queue_mon = new AEMonitor("Alerts:Q");
private static List alert_history = new ArrayList();
private static AEMonitor alert_history_mon = new AEMonitor("Alerts:H");
private static boolean initialisation_complete = false;
private static boolean has_unshown_messages = false;
private static transient boolean stopping;
private static List listeners = new ArrayList();
private Alerts()
{
}
private static void showWarningMessageBox(Object relatedTo[], String message, int timeoutSecs)
{
showMessageBoxUsingResourceString(relatedTo, 8, "AlertMessageBox.warning", message, timeoutSecs);
}
private static void showMessageBoxUsingResourceString(Object relatedTo[], int type, String key, String message, int timeoutSecs)
{
showMessageBox(relatedTo, type, MessageText.getString(key), message, null, timeoutSecs);
}
private static void showMessageBox(Object relatedTo[], int type, String title, String message, String details, int timeoutSecs)
{
Display display;
display = SWTThread.getInstance().getDisplay();
if (!stopping && !display.isDisposed())
break MISSING_BLOCK_LABEL_165;
alert_queue_mon.enter();
List close_alerts = COConfigurationManager.getListParameter("Alerts.raised.at.close", new ArrayList());
Map alert_map = new HashMap();
alert_map.put("type", new Long(type));
alert_map.put("title", title);
alert_map.put("message", message);
alert_map.put("timeout", new Long(timeoutSecs));
if (details != null)
alert_map.put("details", details);
close_alerts.add(alert_map);
COConfigurationManager.setParameter("Alerts.raised.at.close", close_alerts);
alert_queue_mon.exit();
return;
Exception exception;
exception;
alert_queue_mon.exit();
throw exception;
String message2;
boolean use_message_box;
if (display.isDisposed())
return;
if (message != null && COConfigurationManager.getBooleanParameter("Show Timestamp For Alerts"))
message2 = (new StringBuilder()).append("[").append(DisplayFormatters.formatDateShort(SystemTime.getCurrentTime())).append("] ").append(message).toString();
else
message2 = message != null ? message : "";
boolean suppress_popups = COConfigurationManager.getBooleanParameter("Suppress Alerts");
use_message_box = COConfigurationManager.getBooleanParameter("Use Message Box For Popups");
MessageSlideShell.recordMessage(type, title, message2 != null ? message2 : "", details, relatedTo, timeoutSecs);
for (Iterator iter = listeners.iterator(); iter.hasNext();)
{
AlertListener l = (AlertListener)iter.next();
if (!l.allowPopup(relatedTo, type))
{
suppress_popups = true;
return;
}
}
if (!suppress_popups)
break MISSING_BLOCK_LABEL_396;
alert_queue_mon.enter();
if (!has_unshown_messages)
{
UIFunctions ui_functions = UIFunctionsManager.getUIFunctions();
if (ui_functions != null)
{
ui_functions.setStatusText(1, MessageText.getString("AlertMessageBox.unread"), new UIStatusTextClickListener(display, ui_functions) {
final Display val$display;
final UIFunctions val$ui_functions;
public void UIStatusTextClicked()
{
MessageSlideShell.displayLastMessage(display, true);
ui_functions.setStatusText("");
Alerts.has_unshown_messages = false;
}
{
display = display1;
ui_functions = uifunctions;
super();
}
});
has_unshown_messages = true;
}
}
alert_queue_mon.exit();
return;
Exception exception1;
exception1;
alert_queue_mon.exit();
throw exception1;
if (!use_message_box)
{
MessageSlideShell.displayLastMessage(display, true);
} else
{
String amb_key_suffix;
switch (type)
{
case 1: // '\001'
amb_key_suffix = "error";
break;
case 2: // '\002'
amb_key_suffix = "information";
break;
case 8: // '\b'
amb_key_suffix = "warning";
break;
default:
amb_key_suffix = null;
break;
}
String title2;
if (amb_key_suffix != null && title.equals(MessageText.getString((new StringBuilder()).append("AlertMessageBox.").append(amb_key_suffix).toString())))
title2 = Constants.APP_NAME;
else
title2 = title;
display.asyncExec(new AERunnable(type, title2, message2) {
final int val$type;
final String val$title2;
final String val$message2;
public void runSupport()
{
org.eclipse.swt.widgets.Shell s = Utils.findAnyShell();
if (s == null)
{
return;
} else
{
MessageBox mb = new MessageBox(s, type | 0x20);
mb.setText(title2);
mb.setMessage(GeneralUtils.stripOutHyperlinks(message2));
mb.open();
return;
}
}
{
type = i;
title2 = s;
message2 = s1;
super();
}
});
}
return;
}
public static void showErrorMessageBoxUsingResourceString(Object relatedTo[], String title_key, Throwable error, int timeoutSecs)
{
showErrorMessageBox(relatedTo, MessageText.getString(title_key), error, timeoutSecs);
}
private static void showErrorMessageBox(Object relatedTo[], String message, Throwable error, int timeoutSecs)
{
String error_message = Debug.getStackTrace(error);
showMessageBox(relatedTo, 1, MessageText.getString("AlertMessageBox.error"), (new StringBuilder()).append(message).append("\n").append(Debug.getExceptionMessage(error)).toString(), error_message, timeoutSecs);
}
private static void showErrorMessageBox(Object relatedTo[], String message, int timeoutSecs)
{
showMessageBoxUsingResourceString(relatedTo, 1, "AlertMessageBox.error", message, timeoutSecs);
}
private static void showCommentMessageBox(Object relatedTo[], String message, int timeoutSecs)
{
showMessageBoxUsingResourceString(relatedTo, 2, "AlertMessageBox.information", message, timeoutSecs);
}
protected static void showAlert(LogAlert alert)
{
String key = alert.err != null ? (new StringBuilder()).append(alert.text).append(":").append(alert.err.toString()).toString() : alert.text;
alert_history_mon.enter();
if (alert.repeatable)
break MISSING_BLOCK_LABEL_113;
if (alert_history.contains(key))
{
alert_history_mon.exit();
return;
}
alert_history.add(key);
if (alert_history.size() > 512)
alert_history.remove(0);
alert_history_mon.exit();
break MISSING_BLOCK_LABEL_131;
Exception exception;
exception;
alert_history_mon.exit();
throw exception;
if (alert.err == null)
{
if (alert.entryType == 0)
showCommentMessageBox(alert.relatedTo, alert.text, alert.timeoutSecs);
else
if (alert.entryType == 1)
showWarningMessageBox(alert.relatedTo, alert.text, alert.timeoutSecs);
else
showErrorMessageBox(alert.relatedTo, alert.text, alert.timeoutSecs);
} else
{
showErrorMessageBox(alert.relatedTo, alert.text, alert.err, alert.timeoutSecs);
}
return;
}
public static void initComplete()
{
(new AEThread2("Init Complete", true) {
public void run()
{
Alerts.alert_queue_mon.enter();
Alerts.initialisation_complete = true;
for (int i = 0; i < Alerts.alert_queue.size(); i++)
{
LogAlert alert = (LogAlert)Alerts.alert_queue.get(i);
Alerts.showAlert(alert);
}
List close_alerts = COConfigurationManager.getListParameter("Alerts.raised.at.close", new ArrayList());
if (close_alerts.size() > 0)
{
COConfigurationManager.setParameter("Alerts.raised.at.close", new ArrayList());
String intro = (new StringBuilder()).append(MessageText.getString("alert.raised.at.close")).append("\n").toString();
for (int i = 0; i < close_alerts.size(); i++)
try
{
Map alert_map = (Map)close_alerts.get(i);
byte details[] = (byte[])(byte[])alert_map.get("details");
Long l_timeout = (Long)alert_map.get("timeout");
int timeout = l_timeout != null ? l_timeout.intValue() : -1;
Alerts.showMessageBox(null, ((Long)alert_map.get("type")).intValue(), new String((byte[])(byte[])alert_map.get("title")), (new StringBuilder()).append(intro).append(new String((byte[])(byte[])alert_map.get("message"))).toString(), details != null ? new String(details) : null, timeout);
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
Alerts.alert_queue.clear();
Alerts.alert_queue_mon.exit();
break MISSING_BLOCK_LABEL_322;
Exception exception;
exception;
Alerts.alert_queue_mon.exit();
throw exception;
}
}).start();
}
public static void stopInitiated()
{
stopping = true;
}
public static void init()
{
Logger.addListener(new ILogAlertListener() {
public void alertRaised(LogAlert alert)
{
if (Alerts.initialisation_complete)
break MISSING_BLOCK_LABEL_41;
Alerts.alert_queue_mon.enter();
Alerts.alert_queue.add(alert);
Alerts.alert_queue_mon.exit();
break MISSING_BLOCK_LABEL_40;
Exception exception;
exception;
Alerts.alert_queue_mon.exit();
throw exception;
return;
Alerts.showAlert(alert);
return;
}
});
}
public static void addListener(AlertListener l)
{
listeners.add(l);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -