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();
}
}
}
}
}
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));
}
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);
}
}
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);
}
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));
}
Aggregations