Search in sources :

Example 46 with AERunnable

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

the class SWTSkinObjectSlider method mouseDown.

// @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
@Override
public void mouseDown(MouseEvent e) {
    if (disabled) {
        return;
    }
    mouseDown = true;
    int offset = imageThumbBounds.width / 2;
    int sizeX = maxSize.x;
    if (maxSize.x == 0) {
        sizeX = canvas.getClientArea().width;
    }
    float newPercent = (e.x - offset) / (float) (sizeX - imageThumbBounds.width);
    if (mouseMoveAdjusts) {
        setPercent(newPercent, true);
    } else {
        draggingPercent = validatePercent(newPercent, true);
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                if (canvas != null && !canvas.isDisposed()) {
                    canvas.redraw();
                    canvas.update();
                }
            }
        });
    }
}
Also used : AERunnable(com.biglybt.core.util.AERunnable)

Example 47 with AERunnable

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

the class SWTSkinObjectSlider method mouseMove.

// @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
@Override
public void mouseMove(MouseEvent e) {
    if (disabled) {
        return;
    }
    if (mouseDown) {
        int offset = imageThumbBounds.width / 2;
        int sizeX = maxSize.x;
        if (maxSize.x == 0) {
            sizeX = canvas.getClientArea().width;
        }
        float newPercent = (e.x - offset) / (float) (sizeX - imageThumbBounds.width);
        if (mouseMoveAdjusts) {
            setPercent(newPercent, true);
        } else {
            draggingPercent = validatePercent(newPercent, true);
            Utils.execSWTThread(new AERunnable() {

                @Override
                public void runSupport() {
                    if (canvas != null && !canvas.isDisposed()) {
                        canvas.redraw();
                        canvas.update();
                    }
                }
            });
        }
    }
}
Also used : AERunnable(com.biglybt.core.util.AERunnable)

Example 48 with AERunnable

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

the class SWTSkinObjectText1 method setTextID.

@Override
public void setTextID(final String key) {
    if (key == null) {
        setText("");
    } else if (key.equals(sKey)) {
        return;
    }
    this.sText = MessageText.getString(key);
    this.sKey = key;
    bIsTextDefault = false;
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            if (label != null && !label.isDisposed()) {
                Messages.setLanguageText(label, key);
                Utils.relayout(label);
            }
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable)

Example 49 with AERunnable

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

the class TaggingView method dataSourceChanged.

private void dataSourceChanged(Object ds) {
    boolean wasNull = taggables == null;
    if (ds instanceof Taggable) {
        taggables = new ArrayList<>();
        taggables.add((Taggable) ds);
    } else if (ds instanceof Taggable[]) {
        taggables = new ArrayList<>();
        taggables.addAll(Arrays.asList((Taggable[]) ds));
    } else if (ds instanceof Object[]) {
        taggables = new ArrayList<>();
        Object[] objects = (Object[]) ds;
        for (Object o : objects) {
            if (o instanceof Taggable) {
                Taggable taggable = (Taggable) o;
                if (!taggables.contains(taggable)) {
                    taggables.add(taggable);
                }
            } else if (o instanceof DiskManagerFileInfo) {
                DownloadManager temp = ((DiskManagerFileInfo) o).getDownloadManager();
                if (temp != null) {
                    if (!taggables.contains(temp)) {
                        taggables.add(temp);
                    }
                }
            }
        }
        if (taggables.size() == 0) {
            taggables = null;
        }
    } else {
        taggables = null;
    }
    boolean isNull = taggables == null;
    if (isNull != wasNull) {
        TagManager tm = TagManagerFactory.getTagManager();
        TagType tagType;
        /*
			tagType = tm.getTagType(TagType.TT_DOWNLOAD_CATEGORY);
			if (isNull) {
				tagType.removeTagTypeListener(this);
			} else {
				tagType.addTagTypeListener(this, false);
			}
			*/
        tagType = tm.getTagType(TagType.TT_DOWNLOAD_MANUAL);
        if (isNull) {
            tagType.removeTagTypeListener(this);
        } else {
            tagType.addTagTypeListener(this, false);
        }
    }
    Utils.execSWTThread(new AERunnable() {

        @Override
        public void runSupport() {
            swt_updateFields();
        }
    });
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) ArrayList(java.util.ArrayList) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 50 with AERunnable

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

the class TorrentOptionsView method dataSourceChanged.

private void dataSourceChanged(Object newDataSource) {
    DownloadManagerOptionsHandler[] old_managers = managers;
    if (old_managers != null) {
        for (int i = 0; i < old_managers.length; i++) {
            old_managers[i].removeListener(this);
        }
    }
    if (newDataSource instanceof DownloadManager) {
        multi_view = false;
        managers = new DownloadManagerOptionsHandler[] { new DMWrapper((DownloadManager) newDataSource) };
    } else if (newDataSource instanceof DownloadManagerOptionsHandler) {
        multi_view = false;
        managers = new DownloadManagerOptionsHandler[] { (DownloadManagerOptionsHandler) newDataSource };
    } else if (newDataSource instanceof DownloadManager[]) {
        multi_view = true;
        Object[] objs = (Object[]) newDataSource;
        managers = new DownloadManagerOptionsHandler[objs.length];
        for (int i = 0; i < objs.length; i++) {
            managers[i] = new DMWrapper((DownloadManager) objs[i]);
        }
    } else if (newDataSource instanceof Object[]) {
        Object[] objs = (Object[]) newDataSource;
        if (objs.length > 0) {
            if (objs[0] instanceof DownloadManager) {
                managers = new DownloadManagerOptionsHandler[objs.length];
                for (int i = 0; i < objs.length; i++) {
                    managers[i] = new DMWrapper((DownloadManager) objs[i]);
                }
                multi_view = true;
            }
        }
    }
    if (parent != null && !parent.isDisposed()) {
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                if (!parent.isDisposed()) {
                    initialize(parent);
                }
            }
        });
    }
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) DownloadManagerOptionsHandler(com.biglybt.core.download.DownloadManagerOptionsHandler) DownloadManager(com.biglybt.core.download.DownloadManager)

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