import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import javazoom.jl.player.*;
import java.text.NumberFormat;
import javax.net.ssl.*;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.awt.datatransfer.StringSelection;
import javax.swing.border.*;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;
import javax.swing.undo.UndoManager;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import java.text.*;
class main {
static boolean _moduleClass_PlaySoundOnNewVisitor;
static class PlaySoundOnNewVisitor extends DynPrintLogAndEnabled {
void start() { super.start();
dm_vmBus_onMessage_q("newHomePageVisitors", new Runnable() { public void run() { try { if (enabled) doSound() ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "if (enabled) doSound()"; }});
dm_requireModule("#1016183/HomePageVisitors");
}
JComponent visualize() {
return withCenteredButtons(super.visualize(), "Test the sound", runnableThread(new Runnable() { public void run() { try { doSound();
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "doSound();"; }}));
}
void doSound() { AutoCloseable __0 = enter(); try { playWAVSnippetAndWait("#1400163"); } finally { _close(__0); }}
}
// TODO: more argument versions
static AutoCloseable dm_vmBus_onMessage_q(final String msg, final VF1 onMessage) {
final DynModule m = dm_current_mandatory();
return dm_vmBus_onMessage(msg, new VF1() { public void get(final A a) { try {
m.q().add(new Runnable() { public void run() { try {
callF(onMessage, a);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "callF(onMessage, a);"; }}); } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "switch to m.q();\r\n callF(onMessage, a);"; }});
}
static AutoCloseable dm_vmBus_onMessage_q(final String msg, final Runnable onMessage) {
final DynModule m = dm_current_mandatory();
return dm_vmBus_onMessage(msg, new VF1() { public void get(final A a) { try {
m.q().add(new Runnable() { public void run() { try {
callF(onMessage);
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "callF(onMessage);"; }}); } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "switch to m.q();\r\n callF(onMessage);"; }});
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
// makes dynamic & static modules
static String dm_requireModule(String moduleLibID) {
return dm_makeModule(moduleLibID);
}
static JPanel withCenteredButtons(JComponent center, Object... params) {
return centerAndSouth(center, withMargin(jcenteredbuttons(params)));
}
static Runnable runnableThread(final Runnable r) {
return new Runnable() { public void run() { try { startThread(r) ;
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "startThread(r)"; }};
}
static void playWAVSnippetAndWait(String snippetID) {
playWAVSnippet(snippetID);
}
static void _close(AutoCloseable c) {
if (c != null) try {
c.close();
} catch (Throwable e) {
// Some classes stupidly throw an exception on double-closing
if (c instanceof javax.imageio.stream.ImageOutputStream)
return;
else throw rethrow(e);
}
}
static DynModule dm_current_mandatory() {
return assertNotNull("No module set!", dm_currentModule());
}
static AutoCloseable dm_vmBus_onMessage(final String msg, final VF1 onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
static AutoCloseable dm_vmBus_onMessage(String msg, final VF2 onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
static AutoCloseable dm_vmBus_onMessage(String msg, Runnable onMessage) {
return dm_ownResource(vmBus_onMessage(msg, onMessage));
}
static Map> callF_cache = newDangerousWeakHashMap();
static A callF(F0 f) {
return f == null ? null : f.get();
}
static B callF(F1 f, A a) {
return f == null ? null : f.get(a);
}
static C callF(F2 f, A a, B b) {
return f == null ? null : f.get(a, b);
}
static void callF(VF1 f, A a) {
if (f != null) f.get(a);
}
static Object callF(Object f, Object... args) { try {
if (f instanceof String)
return callMC((String) f, args);
if (f instanceof Runnable) {
((Runnable) f).run();
return null;
}
if (f == null) return null;
Class c = f.getClass();
ArrayList methods;
synchronized(callF_cache) {
methods = callF_cache.get(c);
if (methods == null)
methods = callF_makeCache(c);
}
int n = l(methods);
if (n == 0) {
throw fail("No get method in " + getClassName(c));
}
if (n == 1) return invokeMethod(methods.get(0), f, args);
for (int i = 0; i < n; i++) {
Method m = methods.get(i);
if (call_checkArgs(m, args, false))
return invokeMethod(m, f, args);
}
throw fail("No matching get method in " + getClassName(c));
} catch (Exception __e) { throw rethrow(__e); } }
// used internally
static ArrayList callF_makeCache(Class c) {
ArrayList l = new ArrayList();
Class _c = c;
do {
for (Method m : _c.getDeclaredMethods())
if (m.getName().equals("get")) {
m.setAccessible(true);
l.add(m);
}
if (!l.isEmpty()) break;
_c = _c.getSuperclass();
} while (_c != null);
callF_cache.put(c, l);
return l;
}
static void _handleError(Error e) {
call(javax(), "_handleError", e);
}
// makes dynamic & static modules - returns module ID
static String dm_makeModule(String moduleLibID) {
return (String) callCreator("makeModule", moduleLibID);
}
static JPanel centerAndSouth(final Component c, final Component s) {
return swing(new F0() { JPanel get() { try {
JPanel panel = new JPanel(new BorderLayout());
panel.add(BorderLayout.CENTER, wrap(c));
if (s != null) panel.add(BorderLayout.SOUTH, wrap(s));
return panel;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "JPanel panel = new JPanel(new BorderLayout);\r\n panel.add(BorderLayout.CENT..."; }});
}
static int withMargin_defaultWidth = 6;
static JPanel withMargin(Component c) {
return withMargin(withMargin_defaultWidth, c);
}
static JPanel withMargin(int w, Component c) {
return withMargin(w, w, c);
}
static JPanel withMargin(int w, int h, Component c) {
return withMargin(w, h, w, h, c);
}
static JPanel withMargin(final int top, final int left, final int bottom, final int right, final Component c) {
return swing(new F0() { JPanel get() { try {
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right));
p.add(c);
return p;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "JPanel p = new JPanel(new BorderLayout);\r\n p.setBorder(BorderFactory.creat..."; }});
}
static JPanel jcenteredbuttons(Object... params) {
List l = new ArrayList();
for (int i = 0; i < l(params); i += 2)
if (params[i] != null)
if (params[i] instanceof JComponent)
l.add((JComponent) params[i--]);
else
l.add(jbutton((String) params[i], params[i+1]));
return jcenteredline(l);
}
static Thread startThread(Object runnable) {
return startThread(defaultThreadName(), runnable);
}
static Thread startThread(String name, Object runnable) {
runnable = wrapAsActivity(runnable);
return startThread(newThread(toRunnable(runnable), name));
}
static Thread startThread(Thread t) {
_registerThread(t);
t.start();
return t;
}
static void playWAVSnippet(String snippetID) {
playWAVAndWait(loadWAVSnippet(snippetID));
}
static A assertNotNull(A a) {
assertTrue(a != null);
return a;
}
static A assertNotNull(String msg, A a) {
assertTrue(msg, a != null);
return a;
}
static InheritableThreadLocal < WeakReference < DynModule > > dm_currentModule_value = new InheritableThreadLocal();
static DynModule dm_currentModule() {
return getWeakRef(dm_currentModule_value.get());
}
static void _onLoad_dm_currentModule() {
setOptMC("dm_currentModule_generic", dm_currentModule_value);
}
// prevent memory leak
static void cleanMeUp_dm_currentModule() {
dm_currentModule_value = new InheritableThreadLocal();
}
static AutoCloseable dm_ownResource(AutoCloseable resource) {
dm_currentModuleMandatory().ownResource(resource);
return resource;
}
static AutoCloseable vmBus_onMessage(final String msg, final VF1 onMessage) {
Map map = vm_busListenersByMessage_live();
synchronized(map) {
Set listeners = map.get(msg);
if (listeners == null) map.put(msg, listeners = syncIdentityHashSet());
// We're technically violating the one-synchronized-object-per-thread rule,
// but it should be OK here.
// TODO: remove empty sets from map
return tempAdd(listeners, new VF2() { public void get(String _msg, Object arg) { try {
callF(onMessage, arg)
; } catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "callF(onMessage, arg)"; }});
}
}
static AutoCloseable vmBus_onMessage(String msg, final VF2 onMessage) {
return vmBus_onMessage(msg, new VF1