Search in sources :

Example 1 with AERunnableObject

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

the class ClipboardCopy method copyFromClipboard.

public static String copyFromClipboard() {
    if (Utils.isSWTThread()) {
        Clipboard clipboard = new Clipboard(Display.getDefault());
        String text = (String) clipboard.getContents(TextTransfer.getInstance());
        clipboard.dispose();
        return (text);
    } else {
        return ((String) Utils.execSWTThreadWithObject("copyFromClipboard", new AERunnableObject() {

            @Override
            public Object runSupport() {
                Clipboard clipboard = new Clipboard(Display.getDefault());
                String text = (String) clipboard.getContents(TextTransfer.getInstance());
                clipboard.dispose();
                return (text);
            }
        }, 10 * 1000));
    }
}
Also used : AERunnableObject(com.biglybt.core.util.AERunnableObject) AERunnableObject(com.biglybt.core.util.AERunnableObject) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 2 with AERunnableObject

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

the class SWTSkinObjectContainer method getChildren.

public SWTSkinObject[] getChildren() {
    if (isDisposed()) {
        return new SWTSkinObject[0];
    }
    SWTSkinObject[] so = (SWTSkinObject[]) Utils.execSWTThreadWithObject("getChildren", new AERunnableObject() {

        @Override
        public Object runSupport() {
            if (control.isDisposed()) {
                return new SWTSkinObject[0];
            }
            Control[] swtChildren = ((Composite) control).getChildren();
            ArrayList<SWTSkinObject> list = new ArrayList<>(swtChildren.length);
            for (int i = 0; i < swtChildren.length; i++) {
                Control childControl = swtChildren[i];
                SWTSkinObject so = (SWTSkinObject) childControl.getData("SkinObject");
                if (so != null) {
                    list.add(so);
                }
            }
            return list.toArray(new SWTSkinObject[list.size()]);
        }
    }, 2000);
    if (so == null) {
        System.err.println("Tell Tux to fix this " + Debug.getCompressedStackTrace());
        return oldgetChildren();
    }
    return so;
}
Also used : Control(org.eclipse.swt.widgets.Control) AERunnableObject(com.biglybt.core.util.AERunnableObject) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

Aggregations

AERunnableObject (com.biglybt.core.util.AERunnableObject)2 ArrayList (java.util.ArrayList)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1