use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class SplashWindow method update.
/**
* @since 3.0.0.7
*/
private void update() {
if (updating && !Utils.isThisThreadSWT()) {
return;
}
updating = true;
// Post runnable to SWTThread
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
updating = false;
if (splash == null || splash.isDisposed()) {
return;
}
canvas.redraw(0, height - 50, width, height, true);
canvas.update();
}
});
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class SearchUtils method exportAll.
private static void exportAll() {
final Shell shell = Utils.findAnyShell();
shell.getDisplay().asyncExec(new AERunnable() {
@Override
public void runSupport() {
FileDialog dialog = new FileDialog(shell, SWT.SYSTEM_MODAL | SWT.SAVE);
dialog.setFilterPath(TorrentOpener.getFilterPathData());
dialog.setText(MessageText.getString("metasearch.export.select.template.file"));
dialog.setFilterExtensions(VuzeFileHandler.getVuzeFileFilterExtensions());
dialog.setFilterNames(VuzeFileHandler.getVuzeFileFilterExtensions());
String path = TorrentOpener.setFilterPathData(dialog.open());
if (path != null) {
if (!VuzeFileHandler.isAcceptedVuzeFileName(path)) {
path = VuzeFileHandler.getVuzeFileName(path);
}
try {
MetaSearchManagerFactory.getSingleton().getMetaSearch().exportEngines(new File(path));
} catch (Throwable e) {
Debug.out(e);
}
}
}
});
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class CoreWaiterSWT method waitForCore.
public static void waitForCore(final TriggerInThread triggerInThread, final CoreRunningListener l) {
CoreFactory.addCoreRunningListener(new CoreRunningListener() {
@Override
public void coreRunning(final Core core) {
if (triggerInThread == TriggerInThread.ANY_THREAD) {
l.coreRunning(core);
} else if (triggerInThread == TriggerInThread.NEW_THREAD) {
new AEThread2("CoreWaiterInvoke", true) {
@Override
public void run() {
l.coreRunning(core);
}
}.start();
}
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
// TODO: Need to detect cancel (can't rely on shell status since it may never open)
if (shell != null && !shell.isDisposed()) {
shell.dispose();
shell = null;
}
if (triggerInThread == TriggerInThread.SWT_THREAD) {
l.coreRunning(core);
}
}
});
}
});
if (!CoreFactory.isCoreRunning()) {
if (DEBUG) {
System.out.println("NOT AVAIL FOR " + Debug.getCompressedStackTrace());
}
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
showWaitWindow();
}
});
} else if (DEBUG) {
System.out.println("NO NEED TO WAIT.. CORE AVAIL! " + Debug.getCompressedStackTrace());
}
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class AboutWindow method _show.
private static void _show() {
if (instance != null) {
instance.open();
return;
}
paintColorTo = 0;
final Shell window = ShellFactory.createMainShell(SWT.DIALOG_TRIM);
Utils.setShellIcon(window);
final Display display = window.getDisplay();
window.setText(MessageText.getString("MainWindow.about.title") + " " + Constants.getCurrentVersion());
GridData gridData;
window.setLayout(new GridLayout(2, false));
ImageLoader imageLoader = ImageLoader.getInstance();
imgSrc = imageLoader.getImage(IMG_SPLASH);
if (imgSrc != null) {
int w = imgSrc.getBounds().width;
int h = imgSrc.getBounds().height;
Image imgGray = new Image(display, imageLoader.getImage(IMG_SPLASH), SWT.IMAGE_GRAY);
imageLoader.releaseImage(IMG_SPLASH);
Image image2 = new Image(display, w, h);
GC gc = new GC(image2);
gc.setBackground(window.getBackground());
gc.fillRectangle(image2.getBounds());
gc.dispose();
imageToDispose = image = Utils.renderTransparency(display, image2, imgGray, new Point(0, 0), 180);
image2.dispose();
imgGray.dispose();
}
final Canvas labelImage = new Canvas(window, SWT.DOUBLE_BUFFERED);
// labelImage.setImage(image);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
gridData.horizontalSpan = 2;
gridData.horizontalIndent = gridData.verticalIndent = 0;
final Rectangle imgBounds = image.getBounds();
final Rectangle boundsColor = imgSrc.getBounds();
gridData.widthHint = 300;
gridData.heightHint = imgBounds.height + imgBounds.y + 20;
labelImage.setLayoutData(gridData);
labelImage.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
try {
Rectangle clipping = e.gc.getClipping();
int ofs = (labelImage.getSize().x - boundsColor.width) / 2;
if (paintColorTo > 0) {
e.gc.drawImage(imgSrc, 0, 0, paintColorTo, boundsColor.height, ofs, 10, paintColorTo, boundsColor.height);
}
if (clipping.x + clipping.width > ofs + paintColorTo && imgBounds.width - paintColorTo - 1 > 0) {
e.gc.drawImage(image, paintColorTo + 1, 0, imgBounds.width - paintColorTo - 1, imgBounds.height, paintColorTo + 1 + ofs, 10, imgBounds.width - paintColorTo - 1, imgBounds.height);
}
} catch (Throwable f) {
// seen some 'argument not valid errors spewed here, couldn't track down
// the cause though :( parg.
}
}
});
Group gInternet = new Group(window, SWT.NULL);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = true;
gInternet.setLayout(gridLayout);
// $NON-NLS-1$
Messages.setLanguageText(gInternet, "MainWindow.about.section.internet");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gInternet.setLayoutData(gridData);
Group gSys = new Group(window, SWT.NULL);
gSys.setLayout(new GridLayout());
// $NON-NLS-1$
Messages.setLanguageText(gSys, "MainWindow.about.section.system");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.verticalSpan = 1;
gSys.setLayoutData(gridData);
String swt = "";
if (Utils.isGTK) {
try {
swt = "/" + System.getProperty("org.eclipse.swt.internal.gtk.version");
} catch (Throwable e1) {
// TODO Auto-generated catch block
}
}
Point dpi = Utils.getDisplay().getDPI();
swt += ", zoom=" + Utils.getDeviceZoom() + ", dpi=" + (dpi.x == dpi.y ? dpi.x : dpi.x + "x" + dpi.y);
Text txtSysInfo = new Text(gSys, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
txtSysInfo.setBackground(Colors.getSystemColor(display, SWT.COLOR_WIDGET_BACKGROUND));
String about_text = "Java " + System.getProperty("java.version") + " (" + (Constants.is64Bit ? 64 : 32) + " bit)\n " + System.getProperty("java.vendor") + "\n" + System.getProperty("java.home") + "\n\n" + "SWT v" + Utils.getSWTVersionAndRevision() + ", " + SWT.getPlatform() + swt + "\n" + System.getProperty("os.name") + " v" + System.getProperty("os.version") + ", " + System.getProperty("os.arch") + " (" + (Constants.isOS64Bit ? 64 : 32) + " bit)\n" + Constants.APP_NAME.charAt(0) + Constants.getCurrentVersion() + (Constants.SUBVERSION.length() == 0 ? "" : ("-" + Constants.SUBVERSION)) + "/" + CorePatchLevel.getCurrentPatchLevel() + " " + COConfigurationManager.getStringParameter("ui");
txtSysInfo.setText(about_text);
gridData = new GridData(GridData.FILL_BOTH);
txtSysInfo.setLayoutData(gridData);
if (window.getCaret() != null)
window.getCaret().setVisible(false);
final String[][] link = { { "homepage", "bugreports", "forumdiscussion", "wiki", "!" + MessageText.getString("ConfigView.section.plugins"), "!" + MessageText.getString("ConfigView.section.plugins") + " (Tor)" }, { Constants.URL_CLIENT_HOME, Constants.URL_BUG_REPORTS, Constants.URL_FORUMS, Constants.URL_WIKI, Constants.PLUGINS_WEB_SITE, "http://ezhdqq3jjpsqg65l.onion" } };
Button copy = new Button(gSys, SWT.PUSH);
copy.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
copy.setText(MessageText.getString("label.copy"));
copy.addListener(SWT.Selection, (ev) -> {
ClipboardCopy.copyToClipBoard(about_text);
});
for (int i = 0; i < link[0].length; i++) {
final CLabel linkLabel = new CLabel(gInternet, SWT.NONE);
if (link[0][i].startsWith("!")) {
linkLabel.setText(link[0][i].substring(1));
} else {
linkLabel.setText(MessageText.getString("MainWindow.about.internet." + link[0][i]));
}
linkLabel.setData(link[1][i]);
linkLabel.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(display.getSystemColor(SWT.COLOR_LINK_FOREGROUND));
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 1;
linkLabel.setLayoutData(gridData);
linkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((CLabel) arg0.widget).getData());
}
@Override
public void mouseUp(MouseEvent arg0) {
Utils.launch((String) ((CLabel) arg0.widget).getData());
}
});
ClipboardCopy.addCopyToClipMenu(linkLabel);
}
Listener keyListener = new Listener() {
@Override
public void handleEvent(Event e) {
if (e.character == SWT.ESC) {
window.dispose();
}
}
};
window.addListener(SWT.KeyUp, keyListener);
window.pack();
txtSysInfo.setFocus();
Utils.centreWindow(window);
window.open();
instance = window;
window.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
instance = null;
disposeImage();
}
});
final int maxX = image.getBounds().width;
final int maxY = image.getBounds().height;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (image == null || image.isDisposed() || labelImage.isDisposed()) {
return;
}
if (display.isDisposed()) {
return;
}
paintColorTo += paintColorDir;
Utils.execSWTThreadLater(7 * paintColorDir, this);
int ofs = (labelImage.getSize().x - boundsColor.width) / 2;
labelImage.redraw(paintColorTo - paintColorDir + ofs, 10, paintColorDir, maxY, true);
if (paintColorTo >= maxX || paintColorTo <= 0) {
paintColorTo = 0;
// paintColorDir = (int) (Math.random() * 5) + 2;
Image tmp = image;
image = imgSrc;
imgSrc = tmp;
}
}
});
}
use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.
the class PiecesItem method dispose.
@Override
public void dispose(TableCell cell) {
synchronized (this) {
row_count--;
}
// Named infoObj so code can be copied easily to the other PiecesItem
final List<Image> to_dispose = new ArrayList<>();
PEPeer infoObj = (PEPeer) cell.getDataSource();
if (infoObj != null) {
Image img = (Image) infoObj.getData("PiecesImage");
if (img != null) {
to_dispose.add(img);
}
infoObj.setData("PiecesImageBuffer", null);
infoObj.setData("PiecesImage", null);
}
Graphic graphic = cell.getGraphic();
if (graphic instanceof UISWTGraphic) {
Image img = ((UISWTGraphic) graphic).getImage();
if (img != null && to_dispose.contains(img)) {
to_dispose.add(img);
}
}
if (to_dispose.size() > 0) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
for (Image img : to_dispose) {
if (!img.isDisposed()) {
img.dispose();
}
}
}
});
}
}
Aggregations