Search in sources :

Example 1 with ProgressCallback

use of com.biglybt.core.CoreOperationTask.ProgressCallback in project BiglyBT by BiglySoftware.

the class DiskManagerOperationScheduler method operationAdded.

public void operationAdded(CoreOperation operation) {
    CoreOperationTask task = operation.getTask();
    ProgressCallback cb = task.getProgressCallback();
    if (cb != null) {
        if ((cb.getSupportedTaskStates() & ProgressCallback.ST_PAUSE) != 0) {
            String[] fs = task.getAffectedFileSystems();
            if (fs != null && fs.length > 0) {
                synchronized (this) {
                    operations.add(new Operation(operation, cb, fs));
                    Collections.sort(operations);
                    schedule();
                }
            }
        }
    }
}
Also used : ProgressCallback(com.biglybt.core.CoreOperationTask.ProgressCallback) CoreOperationTask(com.biglybt.core.CoreOperationTask) CoreOperation(com.biglybt.core.CoreOperation)

Example 2 with ProgressCallback

use of com.biglybt.core.CoreOperationTask.ProgressCallback in project BiglyBT by BiglySoftware.

the class ColumnFO_Order method refresh.

@Override
public void refresh(TableCell cell) {
    CoreOperation op = (CoreOperation) cell.getDataSource();
    int order = -1;
    if (op != null) {
        ProgressCallback cb = op.getTask().getProgressCallback();
        if (cb != null) {
            if (cb.isAutoPause()) {
                order = cb.getOrder();
            }
        }
    }
    if (!cell.setSortValue(order) && cell.isValid()) {
        return;
    }
    cell.setText(order <= 0 ? "" : String.valueOf(order));
}
Also used : CoreOperation(com.biglybt.core.CoreOperation) ProgressCallback(com.biglybt.core.CoreOperationTask.ProgressCallback)

Example 3 with ProgressCallback

use of com.biglybt.core.CoreOperationTask.ProgressCallback in project BiglyBT by BiglySoftware.

the class ColumnFO_Status method refresh.

@Override
public void refresh(TableCell cell) {
    CoreOperation op = (CoreOperation) cell.getDataSource();
    if (op == null) {
        return;
    }
    ProgressCallback cb = op.getTask().getProgressCallback();
    if (cb == null) {
        return;
    }
    int state = cb.getTaskState();
    String text;
    int sort;
    if (state == ProgressCallback.ST_CANCEL) {
        text = MessageText.getString("Progress.reporting.status.canceled");
        sort = 4;
    } else if (state == ProgressCallback.ST_PAUSE) {
        if (cb.isAutoPause()) {
            text = MessageText.getString("TrackerActivityView.scheduled");
            sort = 3;
        } else {
            text = MessageText.getString("ManagerItem.paused");
            sort = 2;
        }
    } else if (state == ProgressCallback.ST_QUEUED) {
        text = MessageText.getString("ManagerItem.queued");
        sort = 1;
    } else {
        text = "";
        sort = 0;
    }
    if (cell.setSortValue(sort)) {
        cell.setText(text);
    }
}
Also used : CoreOperation(com.biglybt.core.CoreOperation) ProgressCallback(com.biglybt.core.CoreOperationTask.ProgressCallback)

Example 4 with ProgressCallback

use of com.biglybt.core.CoreOperationTask.ProgressCallback in project BiglyBT by BiglySoftware.

the class SBC_DiskOpsView method fillMenu.

protected void fillMenu(Menu menu) {
    Object[] selectedDS;
    synchronized (this) {
        if (tvDiskOps == null) {
            return;
        }
        selectedDS = tvDiskOps.getSelectedDataSources().toArray();
    }
    if (selectedDS.length == 0) {
        return;
    }
    List<ProgressCallback> can_start = new ArrayList<>();
    List<ProgressCallback> can_stop = new ArrayList<>();
    List<ProgressCallback> can_remove = new ArrayList<>();
    for (Object ds : selectedDS) {
        CoreOperation op = (CoreOperation) ds;
        ProgressCallback prog = op.getTask().getProgressCallback();
        if (prog != null) {
            int states = prog.getSupportedTaskStates();
            int state = prog.getTaskState();
            if ((states & ProgressCallback.ST_PAUSE) != 0) {
                if (state == ProgressCallback.ST_NONE || state == ProgressCallback.ST_QUEUED || (state == ProgressCallback.ST_PAUSE && prog.isAutoPause())) {
                    can_stop.add(prog);
                }
            }
            if ((states & ProgressCallback.ST_RESUME) != 0) {
                if (state == ProgressCallback.ST_PAUSE) {
                    can_start.add(prog);
                }
            }
            if ((states & ProgressCallback.ST_CANCEL) != 0) {
                if (state != ProgressCallback.ST_CANCEL) {
                    can_remove.add(prog);
                }
            }
        }
    }
    MenuItem mi = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(mi, "v3.MainWindow.button.resume");
    mi.addListener(SWT.Selection, (ev) -> {
        for (ProgressCallback cb : can_start) {
            cb.setTaskState(ProgressCallback.ST_RESUME);
        }
        refreshToolbar();
    });
    mi.setEnabled(!can_start.isEmpty());
    mi = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(mi, "v3.MainWindow.button.pause");
    mi.addListener(SWT.Selection, (ev) -> {
        for (ProgressCallback cb : can_stop) {
            if (cb.getTaskState() == ProgressCallback.ST_PAUSE) {
                cb.setAutoPause(false);
            } else {
                cb.setTaskState(ProgressCallback.ST_PAUSE);
            }
        }
        refreshToolbar();
    });
    mi.setEnabled(!can_stop.isEmpty());
    mi = new MenuItem(menu, SWT.PUSH);
    Messages.setLanguageText(mi, "UpdateWindow.cancel");
    mi.addListener(SWT.Selection, (ev) -> {
        for (ProgressCallback cb : can_remove) {
            cb.setTaskState(ProgressCallback.ST_CANCEL);
        }
        refreshToolbar();
    });
    mi.setEnabled(!can_remove.isEmpty());
    new MenuItem(menu, SWT.SEPARATOR);
}
Also used : ProgressCallback(com.biglybt.core.CoreOperationTask.ProgressCallback) CoreOperation(com.biglybt.core.CoreOperation) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 5 with ProgressCallback

use of com.biglybt.core.CoreOperationTask.ProgressCallback in project BiglyBT by BiglySoftware.

the class ColumnFO_Percent method refresh.

@Override
public void refresh(TableCell cell) {
    CoreOperation op = (CoreOperation) cell.getDataSource();
    int progress = -1;
    if (op != null) {
        ProgressCallback cb = op.getTask().getProgressCallback();
        if (cb != null) {
            progress = cb.getProgress();
        }
    }
    if (!cell.setSortValue(progress) && cell.isValid()) {
        return;
    }
    cell.setText(progress < 0 ? "" : DisplayFormatters.formatPercentFromThousands(progress));
}
Also used : CoreOperation(com.biglybt.core.CoreOperation) ProgressCallback(com.biglybt.core.CoreOperationTask.ProgressCallback)

Aggregations

ProgressCallback (com.biglybt.core.CoreOperationTask.ProgressCallback)15 CoreOperation (com.biglybt.core.CoreOperation)13 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)4 CoreOperationTask (com.biglybt.core.CoreOperationTask)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 CoreOperationListener (com.biglybt.core.CoreOperationListener)1 ProgressCallbackAdapter (com.biglybt.core.CoreOperationTask.ProgressCallbackAdapter)1 DownloadManager (com.biglybt.core.download.DownloadManager)1 AERunnable (com.biglybt.core.util.AERunnable)1 DelayedEvent (com.biglybt.core.util.DelayedEvent)1 UIExitUtilsSWT.canCloseListener (com.biglybt.ui.swt.UIExitUtilsSWT.canCloseListener)1 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)1 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)1 ArrayList (java.util.ArrayList)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1 GridData (org.eclipse.swt.layout.GridData)1