Search in sources :

Example 31 with AERunnable

use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.

the class VuzeMessageBox method waitUntilClosed.

/* (non-Javadoc)
	 * @see UIFunctionsUserPrompter#waitUntilClosed()
	 */
@Override
public int waitUntilClosed() {
    if (opened) {
        final AESemaphore sem = new AESemaphore("waitUntilClosed");
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                if (dlg == null) {
                    sem.release();
                    return;
                }
                if (!opened) {
                    dlg.open();
                }
                Shell shell = dlg.getShell();
                if (shell == null || shell.isDisposed()) {
                    sem.release();
                    return;
                }
                shell.addDisposeListener(new DisposeListener() {

                    @Override
                    public void widgetDisposed(DisposeEvent e) {
                        sem.release();
                    }
                });
            }
        });
        if (Utils.isThisThreadSWT()) {
            // on swt thread, so execSWTThread just ran and we should have a shell
            if (dlg != null) {
                Shell shell = dlg.getShell();
                if (shell != null) {
                    Display d = shell.getDisplay();
                    while (!shell.isDisposed()) {
                        if (!d.readAndDispatch()) {
                            d.sleep();
                        }
                    }
                }
                skinDialogClosed(dlg);
                return buttonsArea.getButtonVal(result);
            }
        }
        sem.reserve();
    }
    skinDialogClosed(dlg);
    return buttonsArea.getButtonVal(result);
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DisposeListener(org.eclipse.swt.events.DisposeListener) Shell(org.eclipse.swt.widgets.Shell) AESemaphore(com.biglybt.core.util.AESemaphore) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Display(org.eclipse.swt.widgets.Display)

Example 32 with AERunnable

use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.

the class TransferStatsView method initialize.

private void initialize(Composite composite) {
    mainPanel = new Composite(composite, SWT.NULL);
    GridLayout mainLayout = new GridLayout();
    mainPanel.setLayout(mainLayout);
    CoreFactory.addCoreRunningListener(new CoreRunningListener() {

        @Override
        public void coreRunning(Core core) {
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    if (mainPanel == null || mainPanel.isDisposed()) {
                        return;
                    }
                    createGeneralPanel();
                    createConnectionPanel();
                    createCapacityPanel();
                    createAutoSpeedPanel();
                    initialised = true;
                }
            });
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) CoreRunningListener(com.biglybt.core.CoreRunningListener) Core(com.biglybt.core.Core)

Example 33 with AERunnable

use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.

the class StandardButtonsArea method setButtonEnabled.

public void setButtonEnabled(final int buttonVal, final boolean enable) {
    buttonsEnabled.put(buttonVal, enable);
    if (buttons == null) {
        return;
    }
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            if (buttons == null) {
                return;
            }
            int pos = getButtonPosFromVal(buttonVal);
            if (pos >= 0 && pos < buttons.length) {
                Button button = buttons[pos];
                if (button != null && !button.isDisposed()) {
                    button.setEnabled(enable);
                }
            }
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable)

Example 34 with AERunnable

use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.

the class UISWTStatusEntryImpl method created.

@Override
public void created(final MainStatusBar.CLabelPadding label) {
    final Listener click_listener = new Listener() {

        @Override
        public void handleEvent(Event e) {
            onClick();
        }
    };
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            label.addListener(SWT.MouseDoubleClick, click_listener);
        }
    }, true);
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) Listener(org.eclipse.swt.widgets.Listener) UISWTStatusEntryListener(com.biglybt.ui.swt.pif.UISWTStatusEntryListener) Event(org.eclipse.swt.widgets.Event) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 35 with AERunnable

use of com.biglybt.core.util.AERunnable in project BiglyBT by BiglySoftware.

the class SWTNetworkSelection method selectNetworks.

@Override
public String[] selectNetworks(final String description, final String[] tracker_networks) {
    final Display display = Utils.getDisplay();
    if (display.isDisposed()) {
        return (null);
    }
    final AESemaphore sem = new AESemaphore("NetworkClassifier");
    final classifierDialog[] dialog = new classifierDialog[1];
    try {
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                dialog[0] = new classifierDialog(sem, display, description, tracker_networks);
            }
        });
    } catch (Throwable e) {
        Debug.printStackTrace(e);
        return (null);
    }
    sem.reserve();
    return (dialog[0].getSelection());
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) AESemaphore(com.biglybt.core.util.AESemaphore)

Aggregations

AERunnable (com.biglybt.core.util.AERunnable)92 GridLayout (org.eclipse.swt.layout.GridLayout)12 DownloadManager (com.biglybt.core.download.DownloadManager)11 Image (org.eclipse.swt.graphics.Image)10 ArrayList (java.util.ArrayList)9 GridData (org.eclipse.swt.layout.GridData)9 CoreRunningListener (com.biglybt.core.CoreRunningListener)7 File (java.io.File)7 PEPeer (com.biglybt.core.peer.PEPeer)6 Shell (org.eclipse.swt.widgets.Shell)6 Core (com.biglybt.core.Core)5 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)5 Point (org.eclipse.swt.graphics.Point)5 PEPeerManager (com.biglybt.core.peer.PEPeerManager)4 Subscription (com.biglybt.core.subs.Subscription)3 TableColumnCore (com.biglybt.ui.common.table.TableColumnCore)3 UISWTViewEvent (com.biglybt.ui.swt.pif.UISWTViewEvent)3 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)3 MouseAdapter (org.eclipse.swt.events.MouseAdapter)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3