Use JFXListView in place of custom components to accelerate rendering

This commit is contained in:
huanghongxun
2019-01-22 16:01:00 +08:00
parent 056a4eead2
commit 0813211c20
4 changed files with 56 additions and 49 deletions

View File

@@ -18,10 +18,7 @@
package org.jackhuang.hmcl.task;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyDoubleWrapper;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.beans.property.*;
import org.jackhuang.hmcl.event.EventManager;
import org.jackhuang.hmcl.util.AutoTypingMap;
import org.jackhuang.hmcl.util.InvocationDispatcher;
@@ -58,14 +55,18 @@ public abstract class Task {
this.significance = significance;
}
private TaskState state = TaskState.READY;
private ReadOnlyObjectWrapper<TaskState> state = new ReadOnlyObjectWrapper<>(this, "state", TaskState.READY);
public TaskState getState() {
return state;
return state.get();
}
void setState(TaskState state) {
this.state = state;
this.state.setValue(state);
}
public ReadOnlyObjectProperty<TaskState> stateProperty() {
return state.getReadOnlyProperty();
}
private Throwable lastException = null;

View File

@@ -211,6 +211,7 @@ public final class TaskExecutor {
task.onDone().fireEvent(new TaskEvent(this, task, false));
taskListeners.forEach(it -> it.onFinished(task));
} catch (InterruptedException e) {
task.setLastException(e);
if (task.getSignificance().shouldLog()) {
Logging.LOG.log(Level.FINE, "Task aborted: " + task.getName());
}

View File

@@ -38,6 +38,7 @@ public abstract class TaskListener implements EventListener {
}
public void onFailed(Task task, Throwable throwable) {
onFinished(task);
}
public void onStop(boolean success, TaskExecutor executor) {