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 java.util.function.*;
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 java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;
import javax.swing.border.TitledBorder;
import javax.swing.border.*;
import javax.swing.undo.UndoManager;
import java.awt.datatransfer.StringSelection;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.Timer;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.awt.geom.*;
import java.nio.charset.Charset;
import javax.imageio.metadata.*;
import javax.imageio.stream.*;
import static x30_pkg.x30_util.DynamicObject;
import javax.swing.Icon;
import java.nio.file.*;
import static java.nio.file.StandardWatchEventKinds.*;
import org.fife.ui.autocomplete.*;
import org.fife.rsta.ui.CollapsibleSectionPanel;
import org.fife.rsta.ui.GoToDialog;
import org.fife.rsta.ui.SizeGripIcon;
import org.fife.rsta.ui.search.FindDialog;
import org.fife.rsta.ui.search.ReplaceDialog;
import org.fife.rsta.ui.search.ReplaceToolBar;
import org.fife.rsta.ui.search.SearchEvent;
import org.fife.rsta.ui.search.SearchListener;
import org.fife.rsta.ui.search.FindToolBar;
import org.fife.ui.rsyntaxtextarea.ErrorStrip;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rtextarea.RTextScrollPane;
import org.fife.ui.rtextarea.SearchContext;
import org.fife.ui.rtextarea.SearchEngine;
import org.fife.ui.rtextarea.SearchResult;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
import org.fife.ui.rsyntaxtextarea.SyntaxScheme;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.Const;
import org.apache.bcel.generic.*;
import java.lang.reflect.Type;
import java.awt.datatransfer.*;
import java.awt.dnd.*;
import java.util.jar.*;
import java.nio.file.Path;
import java.text.*;
import org.fife.ui.rsyntaxtextarea.*;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import java.awt.geom.AffineTransform;
import java.util.TimeZone;
import java.awt.datatransfer.UnsupportedFlavorException;
public class main {
static public class G22GalleryPanel implements Swingable {
final public G22GalleryPanel setG22utils(G22Utils g22utils) {
return g22utils(g22utils);
}
public G22GalleryPanel g22utils(G22Utils g22utils) {
this.g22utils = g22utils;
return this;
}
final public G22Utils getG22utils() {
return g22utils();
}
public G22Utils g22utils() {
return g22utils;
}
transient public G22Utils g22utils;
transient public JGallery_v2 gallery = new JGallery_v2();
transient public ImageSurface selectedImageSurface;
transient public G22AnalysisPanel analysisPanel = new G22AnalysisPanel();
public void selectImage(G22GalleryImage img) {
if (img != null)
gallery.selectFile(img.path);
}
public transient JComponent visualize_cache;
public JComponent visualize() {
if (visualize_cache == null)
visualize_cache = visualize_load();
return visualize_cache;
}
public JComponent visualize_load() {
return markVisualizer(this, visualize_impl());
}
public JComponent visualize_impl() {
var selectedImageSurface = g22utils.stdImageSurface();
gallery.onAdaptingButton(button -> {
if (!g22utils.devMode())
return;
componentPopupMenuItem(button, "Upload image...", runnableThread(new Runnable() {
public void run() {
try {
uploadImageFileDialog(button.imageFile());
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "uploadImageFileDialog(button.imageFile())";
}
}));
});
new AWTOnConceptChangesByClass(g22utils.concepts(), G22GalleryImage.class, gallery.visualize(), () -> {
print("Updating gallery");
var files = sortFilesAlphaNumIC(map(list(g22utils.concepts(), G22GalleryImage.class), i -> i.path));
gallery.setImageFiles(files);
updateEnclosingTabTitleWithCount(gallery.visualize(), l(files));
}).install();
return withBottomMargin(jvsplit(0.75, jhsplit(0.25, jCenteredSection("All Images", gallery.visualize()), jRaisedCenteredSection("Selected Image", withRightAlignedButtons(selectedImageSurface.visualize(), "Gallery CRUD", new Runnable() {
public void run() {
try {
g22utils.showUIURL("Gallery CRUD");
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "g22utils.showUIURL(\"Gallery CRUD\")";
}
}))), analysisPanel.visualize()));
}
}
static public G22Utils g22utils(Concepts cc) {
return (G22Utils) cc.miscMapGet(G22Utils.class);
}
static public A markVisualizer(Object visualizer, A a) {
return setMetaSrc(a, visualizer);
}
static public A componentPopupMenuItem(A c, final String name, final Object action) {
componentPopupMenu(c, new VF1() {
public void get(JPopupMenu menu) {
try {
addMenuItem(menu, name, action);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "addMenuItem(menu, name, action);";
}
});
return c;
}
static public void componentPopupMenuItem(JComponent c, final JMenuItem menuItem) {
componentPopupMenu(c, new VF1() {
public void get(JPopupMenu menu) {
try {
addMenuItem(menu, menuItem);
} catch (Exception __e) {
throw rethrow(__e);
}
}
public String toString() {
return "addMenuItem(menu, menuItem);";
}
});
}
static public 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 public void uploadImageFileDialog(File imageFile) {
if (!isFile(imageFile))
return;
JTextField tf = jTextField();
showFormTitled("Upload Image", "Image file", new JFilePathLabel(imageFile), "Image title (optional)", focusOnShow(tf), new F0